mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Add MODE=optlinux build mode (#141)
This commit is contained in:
parent
226aaf3547
commit
67b5200a0b
111 changed files with 934 additions and 854 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sysdebug.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
|
@ -43,24 +44,37 @@
|
|||
* @vforksafe
|
||||
*/
|
||||
int openat(int dirfd, const char *file, int flags, ...) {
|
||||
int rc;
|
||||
va_list va;
|
||||
unsigned mode;
|
||||
struct ZiposUri zipname;
|
||||
va_start(va, flags);
|
||||
mode = va_arg(va, unsigned);
|
||||
va_end(va);
|
||||
if (!file) return efault();
|
||||
if (IsAsan() && !__asan_is_valid(file, 1)) return efault();
|
||||
if (__isfdkind(dirfd, kFdZip)) return einval(); /* TODO(jart): implement me */
|
||||
if (weaken(__zipos_open) && weaken(__zipos_parseuri)(file, &zipname) != -1) {
|
||||
if (__vforked) return eopnotsupp();
|
||||
if (dirfd != AT_FDCWD) return eopnotsupp();
|
||||
return weaken(__zipos_open)(&zipname, flags, mode);
|
||||
} else if (!IsWindows() && !IsMetal()) {
|
||||
return sys_openat(dirfd, file, flags, mode);
|
||||
} else if (IsMetal()) {
|
||||
return sys_openat_metal(dirfd, file, flags, mode);
|
||||
if (file && (!IsAsan() || __asan_is_valid(file, 1))) {
|
||||
if (!__isfdkind(dirfd, kFdZip)) {
|
||||
if (weaken(__zipos_open) &&
|
||||
weaken(__zipos_parseuri)(file, &zipname) != -1) {
|
||||
if (!__vforked && dirfd == AT_FDCWD) {
|
||||
rc = weaken(__zipos_open)(&zipname, flags, mode);
|
||||
} else {
|
||||
rc = eopnotsupp(); /* TODO */
|
||||
}
|
||||
} else if (!IsWindows() && !IsMetal()) {
|
||||
rc = sys_openat(dirfd, file, flags, mode);
|
||||
} else if (IsMetal()) {
|
||||
rc = sys_openat_metal(dirfd, file, flags, mode);
|
||||
} else {
|
||||
rc = sys_open_nt(dirfd, file, flags, mode);
|
||||
}
|
||||
} else {
|
||||
rc = eopnotsupp(); /* TODO */
|
||||
}
|
||||
} else {
|
||||
return sys_open_nt(dirfd, file, flags, mode);
|
||||
rc = efault();
|
||||
}
|
||||
SYSDEBUG("openat(%d, %s, %d, %d) -> %d %s", (long)dirfd, file, flags,
|
||||
(flags & (O_CREAT | O_TMPFILE)) ? mode : 0, (long)rc,
|
||||
rc == -1 ? strerror(errno) : "");
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue