this repo has no description
1
fork

Configure Feed

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

Use `llistxattr` for symlinks in `flistxattr`

The last commit changed `openat` to use Linux O_PATH for BSD O_SYMLINK, which is necessary to open a file handle to the symlink itself rather than its target. Unfortunately, this means that some syscalls (like `flistxattr`) need to modified because Linux doesn't support O_PATH descriptors in them

`fgetxattr` and `fsetxattr` will also need fixing

+32 -1
+32 -1
src/kernel/emulation/linux/xattr/flistxattr.c
··· 2 2 #include "../base.h" 3 3 #include "../errno.h" 4 4 #include <linux-syscalls/linux.h> 5 + #include "../stat/common.h" 6 + #include "../fdpath.h" 7 + #include <sys/stat.h> 8 + #include "../simple.h" 9 + 10 + #ifdef __NR_fstat64 11 + #define STAT_CALL __NR_fstat64 12 + #else 13 + #define STAT_CALL __NR_fstat 14 + #endif 15 + #ifndef MAXPATHLEN 16 + # define MAXPATHLEN 1024 17 + #endif 5 18 6 19 long sys_flistxattr(int fd, char* namebuf, unsigned long size, int options) 7 20 { 8 21 int ret; 9 22 10 - ret = LINUX_SYSCALL(__NR_flistxattr, fd, namebuf, size); 23 + struct linux_stat st; 24 + ret = LINUX_SYSCALL(STAT_CALL, fd, &st); 25 + if (ret < 0) 26 + return errno_linux_to_bsd(ret); 27 + 28 + if (S_ISLNK(st.st_mode)) { 29 + // for links, we need to use `llistxattr` 30 + // so translate the fd to a Linux path 31 + char buf[64] = {0}; 32 + char path[4096] = {0}; 33 + __simple_sprintf(buf, "/proc/self/fd/%d", fd); 34 + ret = LINUX_SYSCALL(__NR_readlink, buf, path, sizeof(path) - 1); 35 + if (ret < 0) 36 + return errno_linux_to_bsd(ret); 37 + path[ret] = '\0'; 38 + ret = LINUX_SYSCALL(__NR_llistxattr, path, namebuf, size); 39 + } else { 40 + ret = LINUX_SYSCALL(__NR_flistxattr, fd, namebuf, size); 41 + } 11 42 12 43 if (ret < 0) 13 44 return errno_linux_to_bsd(ret);