add *chmod, and *chown syscalls
This commit is contained in:
@@ -33,6 +33,8 @@ add_library(
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/utsname.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/mman.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/ioctl.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/chmod.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/chown.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/creat.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getppid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getpid.c
|
||||
|
||||
@@ -288,3 +288,41 @@ int dup(int fd);
|
||||
/// previous request would have generated a SIGALRM signal. Otherwise, alarm()
|
||||
/// shall return 0.
|
||||
unsigned alarm(int seconds);
|
||||
|
||||
/// @brief Change the file's mode bits.
|
||||
/// @param pathname The pathname of the file to change mode.
|
||||
/// @param mode The mode bits to set.
|
||||
/// @return On success, 0 is returned.
|
||||
/// On error, -1 is returned, and errno is set appropriately.
|
||||
int chmod(const char *pathname, mode_t mode);
|
||||
|
||||
/// @brief Change the file's mode bits.
|
||||
/// @param fd The fd pointing to the opened file.
|
||||
/// @param mode The mode bits to set.
|
||||
/// @return On success, 0 is returned.
|
||||
/// On error, -1 is returned, and errno is set appropriately.
|
||||
int fchmod(int fd, mode_t mode);
|
||||
|
||||
/// @brief Change the owner and group of a file.
|
||||
/// @param pathname The pathname of the file to change.
|
||||
/// @param owner The new owner to set.
|
||||
/// @param owner The new group to set.
|
||||
/// @return On success, 0 is returned.
|
||||
/// On error, -1 is returned, and errno is set appropriately.
|
||||
int chown(const char *pathname, uid_t owner, gid_t group);
|
||||
|
||||
/// @brief Change the owner and group of a file.
|
||||
/// @param fd The fd pointing to the opened file.
|
||||
/// @param owner The new owner to set.
|
||||
/// @param owner The new group to set.
|
||||
/// @return On success, 0 is returned.
|
||||
/// On error, -1 is returned, and errno is set appropriately.
|
||||
int fchown(int fd, uid_t owner, gid_t group);
|
||||
|
||||
/// @brief Change the owner and group of a file.
|
||||
/// @param pathname The pathname of the file to change.
|
||||
/// @param owner The new owner to set.
|
||||
/// @param owner The new group to set.
|
||||
/// @return On success, 0 is returned.
|
||||
/// On error, -1 is returned, and errno is set appropriately.
|
||||
int lchown(const char *pathname, uid_t owner, gid_t group);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/// @file chmod.c
|
||||
/// @brief
|
||||
/// @copyright (c) 2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#include "sys/unistd.h"
|
||||
#include "sys/errno.h"
|
||||
#include "system/syscall_types.h"
|
||||
|
||||
_syscall2(int, chmod, const char *, pathname, mode_t, mode)
|
||||
|
||||
_syscall2(int, fchmod, int, fd, mode_t, mode)
|
||||
@@ -0,0 +1,14 @@
|
||||
/// @file chown.c
|
||||
/// @brief
|
||||
/// @copyright (c) 2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#include "sys/unistd.h"
|
||||
#include "sys/errno.h"
|
||||
#include "system/syscall_types.h"
|
||||
|
||||
_syscall3(int, chown, const char *, pathname, uid_t, owner, gid_t, group)
|
||||
|
||||
_syscall3(int, lchown, const char *, pathname, uid_t, owner, gid_t, group)
|
||||
|
||||
_syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group)
|
||||
Reference in New Issue
Block a user