mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
LibCore: Add Directory::chown() API and use it in Core::Account
Since we already have the directory open, let's have an API to fchown() the underlying file descriptor instead of forcing clients to do another path lookup.
This commit is contained in:
parent
3f14582b85
commit
c1af2f28e3
3 changed files with 12 additions and 2 deletions
|
@ -31,6 +31,14 @@ Directory::~Directory()
|
|||
MUST(System::close(m_directory_fd));
|
||||
}
|
||||
|
||||
ErrorOr<void> Directory::chown(uid_t uid, gid_t gid)
|
||||
{
|
||||
if (m_directory_fd == -1)
|
||||
return Error::from_syscall("fchown"sv, -EBADF);
|
||||
TRY(Core::System::fchown(m_directory_fd, uid, gid));
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<bool> Directory::is_valid_directory(int fd)
|
||||
{
|
||||
auto stat = TRY(System::fstat(fd));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue