From 4a3a92e9d46e4fc66cb6802a45f63986483766c9 Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 11 May 2023 19:40:34 +0200 Subject: [PATCH] libc: Move chmod from unistd.h to sys/stat.h Apparently that's where it's supposed to be. --- apps/chmod.cpp | 2 +- libc/include/sys/stat.h | 3 +++ libc/include/unistd.h | 3 --- libc/src/sys/stat.cpp | 6 ++++++ libc/src/unistd.cpp | 6 ------ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/chmod.cpp b/apps/chmod.cpp index b1d22fcf..040c9e68 100644 --- a/apps/chmod.cpp +++ b/apps/chmod.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include int main(int argc, char** argv) { diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index 21aaebc3..7de93387 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -18,6 +18,9 @@ extern "C" /* Create a special file. */ int mknod(const char* path, mode_t mode, dev_t dev); + /* Change the mode bits of a file. */ + int chmod(const char* path, mode_t mode); + #pragma GCC push_options #pragma GCC diagnostic ignored "-Wshadow" diff --git a/libc/include/unistd.h b/libc/include/unistd.h index 904f7e61..e1045d96 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -52,9 +52,6 @@ extern "C" /* Set the current process' effective group ID. */ int setegid(gid_t gid); - /* Change the mode bits of a file. */ - int chmod(const char* path, mode_t mode); - /* Change the owner and group of a file. */ int chown(const char* path, uid_t uid, gid_t gid); diff --git a/libc/src/sys/stat.cpp b/libc/src/sys/stat.cpp index a33cacf9..6349bb5a 100644 --- a/libc/src/sys/stat.cpp +++ b/libc/src/sys/stat.cpp @@ -18,6 +18,12 @@ extern "C" __errno_return(rc, int); } + int chmod(const char* path, mode_t mode) + { + long rc = syscall(SYS_chmod, path, mode); + __errno_return(rc, int); + } + int stat(const char* path, struct stat* st) { long rc = syscall(SYS_fstatat, AT_FDCWD, path, st, 0); diff --git a/libc/src/unistd.cpp b/libc/src/unistd.cpp index ca9e008e..1f6c0c62 100644 --- a/libc/src/unistd.cpp +++ b/libc/src/unistd.cpp @@ -142,12 +142,6 @@ extern "C" __errno_return(rc, int); } - int chmod(const char* path, mode_t mode) - { - long rc = syscall(SYS_chmod, path, mode); - __errno_return(rc, int); - } - int chown(const char* path, uid_t uid, gid_t gid) { long rc = syscall(SYS_chown, path, uid, gid);