1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:47:44 +00:00

LibCore+chown: Return ErrorOr<Optional<...>> for getgrnam and getpwnam

This patch returns an empty Optional<...> instead of an Error for
Core::System::getgrname and Core::System::getpwnam if we can't find a
matching group or user entry.

It also updates the 'chown' utility to support this new behavior.
This commit is contained in:
Kenneth Myhra 2021-12-23 09:41:00 +01:00 committed by Andreas Kling
parent ab324c1dae
commit 7772309169
3 changed files with 16 additions and 8 deletions

View file

@ -68,8 +68,8 @@ ErrorOr<struct termios> tcgetattr(int fd);
ErrorOr<void> tcsetattr(int fd, int optional_actions, struct termios const&);
ErrorOr<void> chmod(StringView pathname, mode_t mode);
ErrorOr<void> chown(StringView pathname, uid_t uid, gid_t gid);
ErrorOr<struct passwd> getpwnam(StringView name);
ErrorOr<struct group> getgrnam(StringView name);
ErrorOr<Optional<struct passwd>> getpwnam(StringView name);
ErrorOr<Optional<struct group>> getgrnam(StringView name);
ErrorOr<void> clock_settime(clockid_t clock_id, struct timespec* ts);
ErrorOr<pid_t> posix_spawnp(StringView const path, posix_spawn_file_actions_t* const file_actions, posix_spawnattr_t* const attr, char* const arguments[], char* const envp[]);
ErrorOr<pid_t> waitpid(pid_t waitee, int* wstatus, int options);