From 37658e6fa6fbffa0b0a37ef23941095eaed4b37d Mon Sep 17 00:00:00 2001 From: sin-ack Date: Sun, 6 Feb 2022 17:54:15 +0000 Subject: [PATCH] LibCore: Implement System::fchown --- Userland/Libraries/LibCore/System.cpp | 7 +++++++ Userland/Libraries/LibCore/System.h | 1 + 2 files changed, 8 insertions(+) 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 fchmod(int fd, mode_t mode) return {}; } +ErrorOr fchown(int fd, uid_t uid, gid_t gid) +{ + if (::fchown(fd, uid, gid) < 0) + return Error::from_syscall("fchown"sv, -errno); + return {}; +} + ErrorOr 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 chdir(StringView path); ErrorOr fork(); ErrorOr mkstemp(Span pattern); ErrorOr fchmod(int fd, mode_t mode); +ErrorOr fchown(int fd, uid_t, gid_t); ErrorOr rename(StringView old_path, StringView new_path); ErrorOr unlink(StringView path); ErrorOr utime(StringView path, Optional);