diff --git a/elf/Versions b/elf/Versions index c5613942..8d7bac5d 100644 --- a/elf/Versions +++ b/elf/Versions @@ -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; diff --git a/sysdeps/nacl/irt_syscalls.c b/sysdeps/nacl/irt_syscalls.c index 4f8e2c85..02d3548e 100644 --- a/sysdeps/nacl/irt_syscalls.c +++ b/sysdeps/nacl/irt_syscalls.c @@ -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); @@ -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) (); } @@ -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; diff --git a/sysdeps/nacl/irt_syscalls.h b/sysdeps/nacl/irt_syscalls.h index 06c43990..4caf3434 100644 --- a/sysdeps/nacl/irt_syscalls.h +++ b/sysdeps/nacl/irt_syscalls.h @@ -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); diff --git a/sysdeps/nacl/nacl_syscalls.h b/sysdeps/nacl/nacl_syscalls.h index a2eab466..ea05c84d 100644 --- a/sysdeps/nacl/nacl_syscalls.h +++ b/sysdeps/nacl/nacl_syscalls.h @@ -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 @@ -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); diff --git a/sysdeps/nacl/sysdep.h b/sysdeps/nacl/sysdep.h index a5d376a7..43f7adf5 100644 --- a/sysdeps/nacl/sysdep.h +++ b/sysdeps/nacl/sysdep.h @@ -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