mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: Pass a Custody instead of Inode to VFS methods
VFS no longer deals with inodes in public API, only with custodies and file descriptions. Talk directly to the file system if you need to operate on a inode. In most cases you actually want to go though VFS, to get proper permission check and other niceties. For this to work, you have to provide a custody, which describes *how* you have opened the inode, not just what the inode is.
This commit is contained in:
parent
a9946a99f2
commit
6af2418de7
Notes:
sideshowbarker
2024-07-19 06:01:12 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/6af2418de71 Pull-request: https://github.com/SerenityOS/serenity/pull/2430 Reviewed-by: https://github.com/alimpfard
3 changed files with 12 additions and 10 deletions
|
@ -100,13 +100,15 @@ KResult InodeFile::truncate(u64 size)
|
|||
KResult InodeFile::chown(FileDescription& description, uid_t uid, gid_t gid)
|
||||
{
|
||||
ASSERT(description.inode() == m_inode);
|
||||
return VFS::the().chown(*m_inode, uid, gid);
|
||||
ASSERT(description.custody());
|
||||
return VFS::the().chown(*description.custody(), uid, gid);
|
||||
}
|
||||
|
||||
KResult InodeFile::chmod(FileDescription& description, mode_t mode)
|
||||
{
|
||||
ASSERT(description.inode() == m_inode);
|
||||
return VFS::the().chmod(*m_inode, mode);
|
||||
ASSERT(description.custody());
|
||||
return VFS::the().chmod(*description.custody(), mode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -393,8 +393,9 @@ KResultOr<NonnullRefPtr<Custody>> VFS::open_directory(StringView path, Custody&
|
|||
return custody;
|
||||
}
|
||||
|
||||
KResult VFS::chmod(Inode& inode, mode_t mode)
|
||||
KResult VFS::chmod(Custody& custody, mode_t mode)
|
||||
{
|
||||
auto& inode = custody.inode();
|
||||
if (inode.fs().is_readonly())
|
||||
return KResult(-EROFS);
|
||||
|
||||
|
@ -412,8 +413,7 @@ KResult VFS::chmod(StringView path, mode_t mode, Custody& base)
|
|||
if (custody_or_error.is_error())
|
||||
return custody_or_error.error();
|
||||
auto& custody = *custody_or_error.value();
|
||||
auto& inode = custody.inode();
|
||||
return chmod(inode, mode);
|
||||
return chmod(custody, mode);
|
||||
}
|
||||
|
||||
KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
|
||||
|
@ -479,8 +479,9 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult VFS::chown(Inode& inode, uid_t a_uid, gid_t a_gid)
|
||||
KResult VFS::chown(Custody& custody, uid_t a_uid, gid_t a_gid)
|
||||
{
|
||||
auto& inode = custody.inode();
|
||||
if (inode.fs().is_readonly())
|
||||
return KResult(-EROFS);
|
||||
|
||||
|
@ -521,8 +522,7 @@ KResult VFS::chown(StringView path, uid_t a_uid, gid_t a_gid, Custody& base)
|
|||
if (custody_or_error.is_error())
|
||||
return custody_or_error.error();
|
||||
auto& custody = *custody_or_error.value();
|
||||
auto& inode = custody.inode();
|
||||
return chown(inode, a_uid, a_gid);
|
||||
return chown(custody, a_uid, a_gid);
|
||||
}
|
||||
|
||||
KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
|
||||
|
|
|
@ -118,9 +118,9 @@ public:
|
|||
KResult symlink(StringView target, StringView linkpath, Custody& base);
|
||||
KResult rmdir(StringView path, Custody& base);
|
||||
KResult chmod(StringView path, mode_t, Custody& base);
|
||||
KResult chmod(Inode&, mode_t);
|
||||
KResult chmod(Custody&, mode_t);
|
||||
KResult chown(StringView path, uid_t, gid_t, Custody& base);
|
||||
KResult chown(Inode&, uid_t, gid_t);
|
||||
KResult chown(Custody&, uid_t, gid_t);
|
||||
KResult access(StringView path, int mode, Custody& base);
|
||||
KResultOr<InodeMetadata> lookup_metadata(StringView path, Custody& base, int options = 0);
|
||||
KResult utime(StringView path, Custody& base, time_t atime, time_t mtime);
|
||||
|
|
Loading…
Reference in a new issue