libc: Add fchown, fchmod, and some POSIX feature test macros
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3db0c4fed2
commit
dc169124cc
@ -18,6 +18,9 @@ extern "C"
|
|||||||
/* Change the mode bits of a file. */
|
/* Change the mode bits of a file. */
|
||||||
int chmod(const char* path, mode_t mode);
|
int chmod(const char* path, mode_t mode);
|
||||||
|
|
||||||
|
/* Change the mode bits of a file descriptor. */
|
||||||
|
int fchmod(int fd, mode_t mode);
|
||||||
|
|
||||||
#pragma GCC push_options
|
#pragma GCC push_options
|
||||||
#pragma GCC diagnostic ignored "-Wshadow"
|
#pragma GCC diagnostic ignored "-Wshadow"
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
#define STDOUT_FILENO 1
|
#define STDOUT_FILENO 1
|
||||||
#define STDERR_FILENO 2
|
#define STDERR_FILENO 2
|
||||||
|
|
||||||
|
#define _POSIX_CHOWN_RESTRICTED 200112L
|
||||||
|
#define _POSIX_SHELL 200112L
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -55,6 +58,9 @@ extern "C"
|
|||||||
/* Change the owner and group of a file. */
|
/* Change the owner and group of a file. */
|
||||||
int chown(const char* path, uid_t uid, gid_t gid);
|
int chown(const char* path, uid_t uid, gid_t gid);
|
||||||
|
|
||||||
|
/* Change the owner and group of a file descriptor. */
|
||||||
|
int fchown(int fd, uid_t uid, gid_t gid);
|
||||||
|
|
||||||
/* Replace the current process with another one. On success, does not return. */
|
/* Replace the current process with another one. On success, does not return. */
|
||||||
int execv(const char* path, char* const* argv);
|
int execv(const char* path, char* const* argv);
|
||||||
|
|
||||||
|
@ -18,6 +18,12 @@ extern "C"
|
|||||||
__errno_return(rc, int);
|
__errno_return(rc, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fchmod(int fd, mode_t mode)
|
||||||
|
{
|
||||||
|
long rc = syscall(SYS_fchmodat, fd, "", mode, AT_EMPTY_PATH);
|
||||||
|
__errno_return(rc, int);
|
||||||
|
}
|
||||||
|
|
||||||
int stat(const char* path, struct stat* st)
|
int stat(const char* path, struct stat* st)
|
||||||
{
|
{
|
||||||
long rc = syscall(SYS_fstatat, AT_FDCWD, path, st, 0);
|
long rc = syscall(SYS_fstatat, AT_FDCWD, path, st, 0);
|
||||||
|
@ -148,6 +148,12 @@ extern "C"
|
|||||||
__errno_return(rc, int);
|
__errno_return(rc, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fchown(int fd, uid_t uid, gid_t gid)
|
||||||
|
{
|
||||||
|
long rc = syscall(SYS_fchownat, fd, "", uid, gid, AT_EMPTY_PATH);
|
||||||
|
__errno_return(rc, int);
|
||||||
|
}
|
||||||
|
|
||||||
int execv(const char* path, char* const* argv)
|
int execv(const char* path, char* const* argv)
|
||||||
{
|
{
|
||||||
return execve(path, argv, environ);
|
return execve(path, argv, environ);
|
||||||
|
Loading…
Reference in New Issue
Block a user