mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibCore: Add syscall wrapper for chown()
This commit is contained in:
parent
59d299955e
commit
52a451dcff
2 changed files with 19 additions and 0 deletions
|
@ -307,4 +307,21 @@ ErrorOr<void> chmod(StringView pathname, mode_t mode)
|
|||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<void> chown(StringView pathname, uid_t uid, gid_t gid)
|
||||
{
|
||||
if (!pathname.characters_without_null_termination())
|
||||
return Error::from_syscall("chown"sv, -EFAULT);
|
||||
|
||||
#ifdef __serenity__
|
||||
Syscall::SC_chown_params params = { { pathname.characters_without_null_termination(), pathname.length() }, uid, gid };
|
||||
int rc = syscall(SC_chown, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chown"sv, rc, {});
|
||||
#else
|
||||
String path = pathname;
|
||||
if (::chown(path.characters(), uid, gid) < 0)
|
||||
return Error::from_syscall("chown"sv, -errno);
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue