mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 23:38:31 +00:00
Make Windows fcntl() and lseek() fixes (#668)
* F_SETFD should always return 0 on success * F_SETFL is not implemented on nt * nt lseek, error with ESPIPE when attempting on socket
This commit is contained in:
parent
ef9776755e
commit
da8f5009fd
2 changed files with 4 additions and 3 deletions
|
@ -320,7 +320,7 @@ textwindows int sys_fcntl_nt(int fd, int cmd, uintptr_t arg) {
|
||||||
// O_DSYNC / O_RSYNC / O_SYNC maybe if we fsync() everything
|
// O_DSYNC / O_RSYNC / O_SYNC maybe if we fsync() everything
|
||||||
// O_DIRECT | O_RANDOM | O_SEQUENTIAL | O_NDELAY possible but
|
// O_DIRECT | O_RANDOM | O_SEQUENTIAL | O_NDELAY possible but
|
||||||
// not worth it.
|
// not worth it.
|
||||||
rc = einval();
|
rc = enosys();
|
||||||
} else if (cmd == F_GETFD) {
|
} else if (cmd == F_GETFD) {
|
||||||
if (g_fds.p[fd].flags & O_CLOEXEC) {
|
if (g_fds.p[fd].flags & O_CLOEXEC) {
|
||||||
rc = FD_CLOEXEC;
|
rc = FD_CLOEXEC;
|
||||||
|
@ -330,11 +330,10 @@ textwindows int sys_fcntl_nt(int fd, int cmd, uintptr_t arg) {
|
||||||
} else if (cmd == F_SETFD) {
|
} else if (cmd == F_SETFD) {
|
||||||
if (arg & FD_CLOEXEC) {
|
if (arg & FD_CLOEXEC) {
|
||||||
g_fds.p[fd].flags |= O_CLOEXEC;
|
g_fds.p[fd].flags |= O_CLOEXEC;
|
||||||
rc = FD_CLOEXEC;
|
|
||||||
} else {
|
} else {
|
||||||
g_fds.p[fd].flags &= ~O_CLOEXEC;
|
g_fds.p[fd].flags &= ~O_CLOEXEC;
|
||||||
rc = 0;
|
|
||||||
}
|
}
|
||||||
|
rc = 0;
|
||||||
} else if (cmd == F_SETLK || cmd == F_SETLKW || cmd == F_GETLK) {
|
} else if (cmd == F_SETLK || cmd == F_SETLKW || cmd == F_GETLK) {
|
||||||
pthread_mutex_lock(&g_locks.mu);
|
pthread_mutex_lock(&g_locks.mu);
|
||||||
rc = sys_fcntl_nt_lock(g_fds.p + fd, fd, cmd, arg);
|
rc = sys_fcntl_nt_lock(g_fds.p + fd, fd, cmd, arg);
|
||||||
|
|
|
@ -34,6 +34,8 @@ textwindows int64_t sys_lseek_nt(int fd, int64_t offset, int whence) {
|
||||||
} else {
|
} else {
|
||||||
return espipe();
|
return espipe();
|
||||||
}
|
}
|
||||||
|
} else if (__isfdkind(fd, kFdSocket)) {
|
||||||
|
return espipe();
|
||||||
} else {
|
} else {
|
||||||
return ebadf();
|
return ebadf();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue