Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384#include "lstat.h"#include "common.h"#include "../base.h"#include "../errno.h"#include <linux-syscalls/linux.h>#include <lkm/api.h>#include <mach/lkm.h>#include "../vchroot_expand.h"#include "../bsdthread/per_thread_wd.h"#include <sys/errno.h>
long sys_lstat(const char* path, struct stat* stat){ int ret; struct linux_stat lstat; struct vchroot_expand_args vc;
if (!path) return -EFAULT;
vc.flags = 0; vc.dfd = get_perthread_wd(); strcpy(vc.path, path);
ret = vchroot_expand(&vc); if (ret < 0) return errno_linux_to_bsd(ret);
#if defined(__NR_lstat64) ret = LINUX_SYSCALL(__NR_lstat64, vc.path, &lstat); #elif defined(__NR_lstat) ret = LINUX_SYSCALL(__NR_lstat, vc.path, &lstat); #else #if defined(__NR_newfstatat) int status = LINUX_SYSCALL(__NR_newfstatat, LINUX_AT_FDCWD, vc.path, &lstat, LINUX_AT_SYMLINK_NOFOLLOW); #else int status = LINUX_SYSCALL(__NR_fstatat64, LINUX_AT_FDCWD, vc.path, &lstat, LINUX_AT_SYMLINK_NOFOLLOW); #endif #endif
if (ret < 0) return errno_linux_to_bsd(ret);
stat_linux_to_bsd(&lstat, stat);
return 0;}
long sys_lstat64(const char* path, struct stat64* stat){ int ret; struct linux_stat lstat; struct vchroot_expand_args vc;
vc.flags = 0; vc.dfd = get_perthread_wd(); strcpy(vc.path, path);
ret = vchroot_expand(&vc); if (ret < 0) return errno_linux_to_bsd(ret);
#if defined(__NR_lstat64) ret = LINUX_SYSCALL(__NR_lstat64, vc.path, &lstat); #elif defined(__NR_lstat) ret = LINUX_SYSCALL(__NR_lstat, vc.path, &lstat); #else #if defined(__NR_newfstatat) int status = LINUX_SYSCALL(__NR_newfstatat, LINUX_AT_FDCWD, vc.path, &lstat, LINUX_AT_SYMLINK_NOFOLLOW); #else int status = LINUX_SYSCALL(__NR_fstatat64, LINUX_AT_FDCWD, vc.path, &lstat, LINUX_AT_SYMLINK_NOFOLLOW); #endif #endif
if (ret < 0) return errno_linux_to_bsd(ret);
stat_linux_to_bsd64(&lstat, stat);
return 0;}