this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement sys_openat()

+60
+1
src/kernel/emulation/linux/CMakeLists.txt
··· 114 114 misc/getrusage.c 115 115 misc/getlogin.c 116 116 fcntl/open.c 117 + fcntl/openat.c 117 118 fcntl/fcntl.c 118 119 network/socket.c 119 120 network/socketpair.c
+2
src/kernel/emulation/linux/fcntl/open.h
··· 37 37 #define BSD_O_SYMLINK 0x200000 38 38 #define BSD_O_CLOEXEC 0x1000000 39 39 40 + int oflags_bsd_to_linux(int flags); 41 + 40 42 #endif 41 43
+46
src/kernel/emulation/linux/fcntl/openat.c
··· 1 + #include "openat.h" 2 + #include "open.h" 3 + #include "../base.h" 4 + #include "../errno.h" 5 + #include <linux-syscalls/linux.h> 6 + #include "../../../../libc/include/fcntl.h" 7 + #include "../common_at.h" 8 + 9 + #ifndef O_NOFOLLOW 10 + # define O_NOFOLLOW 0x0100 11 + #endif 12 + #ifndef O_CLOEXEC 13 + # define O_CLOEXEC 0x1000000 14 + #endif 15 + #ifndef O_DIRECTORY 16 + # define O_DIRECTORY 0x100000 17 + #endif 18 + 19 + extern int strcmp(const char *s1, const char *s2); 20 + 21 + long sys_openat(int fd, const char* filename, int flags, unsigned int mode) 22 + { 23 + return sys_openat_nocancel(fd, filename, flags, mode); 24 + } 25 + 26 + long sys_openat_nocancel(int fd, const char* filename, int flags, unsigned int mode) 27 + { 28 + int ret, linux_flags; 29 + 30 + linux_flags = oflags_bsd_to_linux(flags); 31 + 32 + if (sizeof(void*) == 4) 33 + { 34 + linux_flags |= LINUX_O_LARGEFILE; 35 + } 36 + 37 + // XNU /dev/random behaves like Linux /dev/urandom 38 + if (strcmp(filename, "/dev/random") == 0) 39 + filename = "/dev/urandom"; 40 + 41 + ret = LINUX_SYSCALL(__NR_openat, atfd(fd), filename, linux_flags, mode); 42 + if (ret < 0) 43 + ret = errno_linux_to_bsd(ret); 44 + 45 + return ret; 46 + }
+8
src/kernel/emulation/linux/fcntl/openat.h
··· 1 + #ifndef LINUX_OPENAT_H 2 + #define LINUX_OPENAT_H 3 + 4 + long sys_openat(int fd, const char* filename, int flags, unsigned int mode); 5 + long sys_openat_nocancel(int fd, const char* filename, int flags, unsigned int mode); 6 + 7 + #endif 8 +
+3
src/kernel/emulation/linux/syscalls.c
··· 82 82 #include "misc/syscall.h" 83 83 #include "synch/semwait_signal.h" 84 84 #include "fcntl/open.h" 85 + #include "fcntl/openat.h" 85 86 #include "fcntl/fcntl.h" 86 87 #include "network/socket.h" 87 88 #include "network/connect.h" ··· 335 336 [417] = sys_poll_nocancel, 336 337 [423] = sys_semwait_signal_nocancel, 337 338 [461] = sys_getattrlistbulk, 339 + [463] = sys_openat, 340 + [464] = sys_openat_nocancel, 338 341 [469] = sys_fstatat, 339 342 [470] = sys_fstatat64, 340 343 [500] = sys_getentropy,