kernel: Allow performing extra actions when opening an inode
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
apio 2023-09-14 22:55:54 +02:00
parent 05a0d912fa
commit 69a0600d45
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 7 additions and 0 deletions

View File

@ -118,6 +118,11 @@ namespace VFS
return err(EACCES);
}
virtual Result<SharedPtr<Inode>> open()
{
return SharedPtr<Inode> { this };
}
// Directory-specific methods
virtual Result<SharedPtr<Inode>> find(const char* name) const = 0;

View File

@ -62,6 +62,8 @@ Result<u64> sys_openat(Registers*, SyscallArgs args)
if ((flags & O_WRONLY) && !VFS::can_write(inode, current->auth)) return err(EACCES);
}
inode = TRY(inode->open());
// This should only be possible if O_NOFOLLOW was in flags.
if (inode->type() == VFS::InodeType::Symlink) return err(ELOOP);