diff --git a/Kernel/FileSystem/File.h b/Kernel/FileSystem/File.h index 0ba1fb239fe..02fc6143268 100644 --- a/Kernel/FileSystem/File.h +++ b/Kernel/FileSystem/File.h @@ -82,8 +82,8 @@ public: virtual String absolute_path(const FileDescription&) const = 0; virtual KResult truncate(u64) { return KResult(-EINVAL); } - virtual KResult chown(uid_t, gid_t) { return KResult(-EBADF); } - virtual KResult chmod(mode_t) { return KResult(-EBADF); } + virtual KResult chown(FileDescription&, uid_t, gid_t) { return KResult(-EBADF); } + virtual KResult chmod(FileDescription&, mode_t) { return KResult(-EBADF); } virtual const char* class_name() const = 0; diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp index 6b7e4a507a8..984eadfd50b 100644 --- a/Kernel/FileSystem/FileDescription.cpp +++ b/Kernel/FileSystem/FileDescription.cpp @@ -330,13 +330,13 @@ void FileDescription::set_file_flags(u32 flags) KResult FileDescription::chmod(mode_t mode) { LOCKER(m_lock); - return m_file->chmod(mode); + return m_file->chmod(*this, mode); } KResult FileDescription::chown(uid_t uid, gid_t gid) { LOCKER(m_lock); - return m_file->chown(uid, gid); + return m_file->chown(*this, uid, gid); } } diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp index a5f8550c3dd..3e244345060 100644 --- a/Kernel/FileSystem/InodeFile.cpp +++ b/Kernel/FileSystem/InodeFile.cpp @@ -97,13 +97,15 @@ KResult InodeFile::truncate(u64 size) return KSuccess; } -KResult InodeFile::chown(uid_t uid, gid_t gid) +KResult InodeFile::chown(FileDescription& description, uid_t uid, gid_t gid) { + ASSERT(description.inode() == m_inode); return VFS::the().chown(*m_inode, uid, gid); } -KResult InodeFile::chmod(mode_t mode) +KResult InodeFile::chmod(FileDescription& description, mode_t mode) { + ASSERT(description.inode() == m_inode); return VFS::the().chmod(*m_inode, mode); } diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h index 14e8f335ed1..46ddc9e86e9 100644 --- a/Kernel/FileSystem/InodeFile.h +++ b/Kernel/FileSystem/InodeFile.h @@ -54,8 +54,8 @@ public: virtual String absolute_path(const FileDescription&) const override; virtual KResult truncate(u64) override; - virtual KResult chown(uid_t, gid_t) override; - virtual KResult chmod(mode_t) override; + virtual KResult chown(FileDescription&, uid_t, gid_t) override; + virtual KResult chmod(FileDescription&, mode_t) override; virtual const char* class_name() const override { return "InodeFile"; } diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index da4f330794d..0b074813cea 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -375,7 +375,7 @@ KResult LocalSocket::getsockopt(FileDescription& description, int level, int opt } } -KResult LocalSocket::chmod(mode_t mode) +KResult LocalSocket::chmod(FileDescription&, mode_t mode) { if (m_file) return m_file->chmod(mode); @@ -384,7 +384,7 @@ KResult LocalSocket::chmod(mode_t mode) return KSuccess; } -KResult LocalSocket::chown(uid_t uid, gid_t gid) +KResult LocalSocket::chown(FileDescription&, uid_t uid, gid_t gid) { if (m_file) return m_file->chown(uid, gid); diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h index 6a64ededa88..8435480d535 100644 --- a/Kernel/Net/LocalSocket.h +++ b/Kernel/Net/LocalSocket.h @@ -60,8 +60,8 @@ public: virtual ssize_t sendto(FileDescription&, const void*, size_t, int, const sockaddr*, socklen_t) override; virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) override; virtual KResult getsockopt(FileDescription&, int level, int option, void*, socklen_t*) override; - virtual KResult chown(uid_t, gid_t) override; - virtual KResult chmod(mode_t) override; + virtual KResult chown(FileDescription&, uid_t, gid_t) override; + virtual KResult chmod(FileDescription&, mode_t) override; private: explicit LocalSocket(int type);