mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 09:46:04 -05:00
Kernel: Pass a parameter struct to chown()
This commit is contained in:
parent
29b3d95004
commit
6536a80aa9
Notes:
sideshowbarker
2024-07-19 10:12:40 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6536a80aa9f
4 changed files with 21 additions and 6 deletions
|
@ -2640,12 +2640,16 @@ int Process::sys$fchown(int fd, uid_t uid, gid_t gid)
|
|||
return description->chown(uid, gid);
|
||||
}
|
||||
|
||||
int Process::sys$chown(const char* pathname, uid_t uid, gid_t gid)
|
||||
int Process::sys$chown(const Syscall::SC_chown_params* user_params)
|
||||
{
|
||||
SmapDisabler disabler;
|
||||
if (!validate_read_str(pathname))
|
||||
if (!validate_read_typed(user_params))
|
||||
return -EFAULT;
|
||||
return VFS::the().chown(StringView(pathname), uid, gid, current_directory());
|
||||
Syscall::SC_chown_params params;
|
||||
copy_from_user(¶ms, user_params, sizeof(params));
|
||||
auto path = get_syscall_path_argument(params.path.characters, params.path.length);
|
||||
if (path.is_error())
|
||||
return path.error();
|
||||
return VFS::the().chown(path.value(), params.uid, params.gid, current_directory());
|
||||
}
|
||||
|
||||
void Process::finalize()
|
||||
|
|
|
@ -183,7 +183,7 @@ public:
|
|||
int sys$umount(const char* mountpoint, size_t mountpoint_length);
|
||||
int sys$chmod(const char* pathname, size_t path_length, mode_t);
|
||||
int sys$fchmod(int fd, mode_t);
|
||||
int sys$chown(const char* pathname, uid_t, gid_t);
|
||||
int sys$chown(const Syscall::SC_chown_params*);
|
||||
int sys$fchown(int fd, uid_t, gid_t);
|
||||
int sys$socket(int domain, int type, int protocol);
|
||||
int sys$bind(int sockfd, const sockaddr* addr, socklen_t);
|
||||
|
|
|
@ -333,6 +333,12 @@ struct SC_link_params {
|
|||
StringArgument new_path;
|
||||
};
|
||||
|
||||
struct SC_chown_params {
|
||||
StringArgument path;
|
||||
u32 uid;
|
||||
u32 gid;
|
||||
};
|
||||
|
||||
void initialize();
|
||||
int sync();
|
||||
|
||||
|
|
|
@ -27,7 +27,12 @@ int systrace(pid_t pid)
|
|||
|
||||
int chown(const char* pathname, uid_t uid, gid_t gid)
|
||||
{
|
||||
int rc = syscall(SC_chown, pathname, uid, gid);
|
||||
if (!pathname) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
Syscall::SC_chown_params params { { pathname, strlen(pathname) }, uid, gid };
|
||||
int rc = syscall(SC_chown, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue