mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 09:18:05 +03:00
LibCore: Add syscall wrapper for chmod()
This commit is contained in:
parent
294cb3cef4
commit
0d76d15f9d
Notes:
sideshowbarker
2024-07-17 23:11:10 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/0d76d15f9d1 Pull-request: https://github.com/SerenityOS/serenity/pull/11168 Reviewed-by: https://github.com/bgianfo ✅
@ -275,4 +275,20 @@ ErrorOr<void> tcsetattr(int fd, int optional_actions, struct termios const& ios)
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> chmod(StringView pathname, mode_t mode)
|
||||
{
|
||||
if (!pathname.characters_without_null_termination())
|
||||
return Error::from_syscall("chmod"sv, -EFAULT);
|
||||
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_chmod, pathname.characters_without_null_termination(), pathname.length(), mode);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chmod"sv, rc, {});
|
||||
#else
|
||||
String path = pathname;
|
||||
if (::chmod(path.characters(), mode) < 0)
|
||||
return Error::from_syscall("chmod"sv, -errno);
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,5 +41,6 @@ ErrorOr<String> gethostname();
|
||||
ErrorOr<void> ioctl(int fd, unsigned request, ...);
|
||||
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);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user