mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-30 16:28:48 +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: 6af2418de7
Pull-request: https://github.com/SerenityOS/serenity/pull/2430
Reviewed-by: https://github.com/alimpfard
3 changed files with 12 additions and 10 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue