diff options
author | sin-ack <sin-ack@users.noreply.github.com> | 2022-02-06 17:54:15 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-14 11:44:09 +0100 |
commit | 37658e6fa6fbffa0b0a37ef23941095eaed4b37d (patch) | |
tree | 2e26314421519a353903c3570ccb8b016330ec72 /Userland/Libraries/LibCore | |
parent | 285b2fba96f1322f75169e0003a3045b907fab93 (diff) | |
download | serenity-37658e6fa6fbffa0b0a37ef23941095eaed4b37d.zip |
LibCore: Implement System::fchown
Diffstat (limited to 'Userland/Libraries/LibCore')
-rw-r--r-- | Userland/Libraries/LibCore/System.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/System.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 70c93e27ba..9c257f3fb2 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -529,6 +529,13 @@ ErrorOr<void> fchmod(int fd, mode_t mode) return {}; } +ErrorOr<void> fchown(int fd, uid_t uid, gid_t gid) +{ + if (::fchown(fd, uid, gid) < 0) + return Error::from_syscall("fchown"sv, -errno); + return {}; +} + ErrorOr<void> lchown(StringView pathname, uid_t uid, gid_t gid) { if (!pathname.characters_without_null_termination()) diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index eb429eb1d3..9fa4c43eed 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -114,6 +114,7 @@ ErrorOr<void> chdir(StringView path); ErrorOr<pid_t> fork(); ErrorOr<int> mkstemp(Span<char> pattern); ErrorOr<void> fchmod(int fd, mode_t mode); +ErrorOr<void> fchown(int fd, uid_t, gid_t); ErrorOr<void> rename(StringView old_path, StringView new_path); ErrorOr<void> unlink(StringView path); ErrorOr<void> utime(StringView path, Optional<struct utimbuf>); |