Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fchmod to glibc #62

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions elf/Versions
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ ld {
__nacl_irt_shmctl;
__nacl_irt_rename;
__nacl_irt_chmod;
__nacl_irt_fchmod;

# Those are in the dynamic linker, but used by libc.so.
__libc_enable_secure;
Expand Down
7 changes: 7 additions & 0 deletions sysdeps/nacl/irt_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ int (*__nacl_irt_mkdir) (const char* pathname, mode_t mode);
int (*__nacl_irt_rmdir) (const char* pathname);
int (*__nacl_irt_chdir) (const char* pathname);
int (*__nacl_irt_chmod) (const char* pathname, mode_t mode);
int (*__nacl_irt_fchmod) (int fd, mode_t mode);
int (*__nacl_irt_getuid) (void);
int (*__nacl_irt_geteuid) (void);
int (*__nacl_irt_getgid) (void);
Expand Down Expand Up @@ -537,6 +538,11 @@ static int nacl_irt_chmod (const char *pathname, mode_t mode)
return NACL_SYSCALL (chmod) (pathname, mode);
}

static int nacl_irt_fchmod (int fd, mode_t mode)
{
return NACL_SYSCALL (fchmod) (fd, mode);
}

static int nacl_irt_getuid(void) {
return NACL_SYSCALL (getuid) ();
}
Expand Down Expand Up @@ -1055,6 +1061,7 @@ init_irt_table (void)
__nacl_irt_mkdir = nacl_irt_mkdir;
__nacl_irt_chdir = nacl_irt_chdir;
__nacl_irt_chmod = nacl_irt_chmod;
__nacl_irt_fchmod = nacl_irt_fchmod;
__nacl_irt_rmdir = nacl_irt_rmdir;
__nacl_irt_getuid = nacl_irt_getuid;
__nacl_irt_geteuid = nacl_irt_geteuid;
Expand Down
1 change: 1 addition & 0 deletions sysdeps/nacl/irt_syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extern int (*__nacl_irt_mkdir) (const char* pathname, mode_t mode);
extern int (*__nacl_irt_rmdir) (const char* pathname);
extern int (*__nacl_irt_chdir) (const char* pathname);
extern int (*__nacl_irt_chmod) (const char* pathname, mode_t mode);
extern int (*__nacl_irt_fchmod) (int fd, mode_t mode);

extern int (*__nacl_irt_getuid) (void);
extern int (*__nacl_irt_geteuid) (void);
Expand Down
2 changes: 2 additions & 0 deletions sysdeps/nacl/nacl_syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
#define NACL_sys_rmdir 132
#define NACL_sys_statfs 133
#define NACL_sys_fstatfs 134
#define NACL_sys_fchmod 135
#define NACL_sys_socket 136
#define NACL_sys_getsockopt 137
#define NACL_sys_setsockopt 138
Expand Down Expand Up @@ -205,6 +206,7 @@ typedef int (*TYPE_nacl_getgid) (void);
typedef int (*TYPE_nacl_getegid) (void);
typedef int (*TYPE_nacl_chdir) (const char* pathname);
typedef int (*TYPE_nacl_chmod) (const char* pathname, mode_t mode);
typedef int (*TYPE_nacl_fchmod) (int fd, mode_t mode);
typedef int (*TYPE_nacl_mkdir) (const char* pathname, mode_t mode);
typedef int (*TYPE_nacl_rmdir) (const char* pathname);

Expand Down
9 changes: 6 additions & 3 deletions sysdeps/nacl/sysdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,12 @@ INTERNAL_SYSCALL_fchdir_1 (int *err, int fd)
__extern_always_inline int
INTERNAL_SYSCALL_fchmod_2 (int *err, int fd, mode_t mode)
{
log_unimplemented("fchmod unimplemented");
*err = (38 /* ENOSYS */);
return 0;
int rv = __nacl_irt_fchmod (fd, mode);
if(rv < 0) {
*err = -rv;
return -1;
}
return rv;
}

__extern_always_inline int
Expand Down