diff --git a/src/kernel/emulation/linux/fcntl/open.c b/src/kernel/emulation/linux/fcntl/open.c index 9e1ca76cb..1b562e9ad 100644 --- a/src/kernel/emulation/linux/fcntl/open.c +++ b/src/kernel/emulation/linux/fcntl/open.c @@ -52,30 +52,32 @@ int oflags_bsd_to_linux(int flags) { int linux_flags = 0; - if (flags & O_RDONLY) /* always false */ + if (flags & BSD_O_RDONLY) /* always false */ linux_flags |= LINUX_O_RDONLY; - if (flags & O_WRONLY) + if (flags & BSD_O_WRONLY) linux_flags |= LINUX_O_WRONLY; - if (flags & O_RDWR) + if (flags & BSD_O_RDWR) linux_flags |= LINUX_O_RDWR; - if (flags & O_NONBLOCK) + if (flags & BSD_O_NONBLOCK) linux_flags |= LINUX_O_NONBLOCK; - if (flags & O_APPEND) + if (flags & BSD_O_APPEND) linux_flags |= LINUX_O_APPEND; - if (flags & O_CREAT) + if (flags & BSD_O_CREAT) linux_flags |= LINUX_O_CREAT; - if (flags & O_TRUNC) + if (flags & BSD_O_TRUNC) linux_flags |= LINUX_O_TRUNC; - if (flags & O_EXCL) + if (flags & BSD_O_EXCL) linux_flags |= LINUX_O_EXCL; - if (flags & O_CLOEXEC) + if (flags & BSD_O_CLOEXEC) linux_flags |= LINUX_O_CLOEXEC; - if (flags & O_NOFOLLOW) + if (flags & BSD_O_NOFOLLOW) linux_flags |= LINUX_O_NOFOLLOW; - if (flags & O_DIRECTORY) + if (flags & BSD_O_DIRECTORY) linux_flags |= LINUX_O_DIRECTORY; - if (flags & O_CLOEXEC) + if (flags & BSD_O_CLOEXEC) linux_flags |= LINUX_O_CLOEXEC; + if (flags & BSD_O_NOCTTY) + linux_flags |= LINUX_O_NOCTTY; return linux_flags; } @@ -85,29 +87,31 @@ int oflags_linux_to_bsd(int flags) int bsd_flags = 0; if (flags & LINUX_O_RDONLY) /* always false */ - bsd_flags |= O_RDONLY; + bsd_flags |= BSD_O_RDONLY; if (flags & LINUX_O_WRONLY) - bsd_flags |= O_WRONLY; + bsd_flags |= BSD_O_WRONLY; if (flags & LINUX_O_RDWR) - bsd_flags |= O_RDWR; + bsd_flags |= BSD_O_RDWR; if (flags & LINUX_O_NONBLOCK) - bsd_flags |= O_NONBLOCK; + bsd_flags |= BSD_O_NONBLOCK; if (flags & LINUX_O_APPEND) - bsd_flags |= O_APPEND; + bsd_flags |= BSD_O_APPEND; if (flags & LINUX_O_CREAT) - bsd_flags |= O_CREAT; + bsd_flags |= BSD_O_CREAT; if (flags & LINUX_O_TRUNC) - bsd_flags |= O_TRUNC; + bsd_flags |= BSD_O_TRUNC; if (flags & LINUX_O_EXCL) - bsd_flags |= O_EXCL; + bsd_flags |= BSD_O_EXCL; if (flags & LINUX_O_CLOEXEC) - bsd_flags |= O_CLOEXEC; + bsd_flags |= BSD_O_CLOEXEC; if (flags & LINUX_O_NOFOLLOW) - bsd_flags |= O_NOFOLLOW; + bsd_flags |= BSD_O_NOFOLLOW; if (flags & LINUX_O_DIRECTORY) - bsd_flags |= O_DIRECTORY; + bsd_flags |= BSD_O_DIRECTORY; if (flags & LINUX_O_CLOEXEC) - bsd_flags |= O_CLOEXEC; + bsd_flags |= BSD_O_CLOEXEC; + if (flags & LINUX_O_NOCTTY) + bsd_flags |= BSD_O_NOCTTY; return bsd_flags; } diff --git a/src/kernel/emulation/linux/fcntl/open.h b/src/kernel/emulation/linux/fcntl/open.h index 3cda12a3a..0e6ab1cf2 100644 --- a/src/kernel/emulation/linux/fcntl/open.h +++ b/src/kernel/emulation/linux/fcntl/open.h @@ -20,5 +20,22 @@ long sys_open_nocancel(const char* filename, int flags, unsigned int mode); #define LINUX_O_NOFOLLOW 0400000 #define LINUX_O_DIRECTORY 0200000 +#define BSD_O_RDONLY 0 +#define BSD_O_WRONLY 1 +#define BSD_O_RDWR 2 +#define BSD_O_NONBLOCK 4 +#define BSD_O_APPEND 8 +#define BSD_O_SHLOCK 0x10 +#define BSD_O_EXLOCK 0x20 +#define BSD_O_ASYNC 0x40 +#define BSD_O_NOFOLLOW 0x100 +#define BSD_O_CREAT 0x200 +#define BSD_O_TRUNC 0x400 +#define BSD_O_EXCL 0x800 +#define BSD_O_NOCTTY 0x20000 +#define BSD_O_DIRECTORY 0x100000 +#define BSD_O_SYMLINK 0x200000 +#define BSD_O_CLOEXEC 0x1000000 + #endif diff --git a/src/kernel/emulation/linux/stat/getfsstat.c b/src/kernel/emulation/linux/stat/getfsstat.c index f3b5bcc8a..1ff6e6dbb 100644 --- a/src/kernel/emulation/linux/stat/getfsstat.c +++ b/src/kernel/emulation/linux/stat/getfsstat.c @@ -31,7 +31,7 @@ long sys_getfsstat64(struct bsd_statfs64* buf, int bufsize, int flags) fd = sys_open("/proc/self/mounts", O_RDONLY, 0); if (fd < 0) - return error_linux_to_bsd(fd); + return errno_linux_to_bsd(fd); __simple_readline_init(&rbuf); diff --git a/src/kernel/libsyscall/sys/SYS.h b/src/kernel/libsyscall/sys/SYS.h index 57e302aca..4771a642f 100644 --- a/src/kernel/libsyscall/sys/SYS.h +++ b/src/kernel/libsyscall/sys/SYS.h @@ -147,6 +147,7 @@ LEAF(name, 0) ;\ cmpq $-4095, %rax ;\ jb 2f ;\ movq %rax, %rdi ;\ + negq %rdi ;\ BRANCH_EXTERN(cerror) ;\ 2: @@ -157,6 +158,7 @@ LEAF(name, 0) ;\ cmpq $-4095, %rax ;\ jb 2f ;\ movq %rax, %rdi ;\ + negq %rdi ;\ BRANCH_EXTERN(cerror) ;\ 2: diff --git a/src/kernel/libsyscall/wrappers/ioctl.c b/src/kernel/libsyscall/wrappers/ioctl.c index eced7e7e1..69fe9ec08 100644 --- a/src/kernel/libsyscall/wrappers/ioctl.c +++ b/src/kernel/libsyscall/wrappers/ioctl.c @@ -1,3 +1,4 @@ +// Modified by Lubos Dolezel for Darling /* * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. * @@ -23,6 +24,10 @@ #if defined(__LP64__) || defined(__arm__) +#ifdef DARLING +# define ioctl __real_ioctl +#endif + #include #include