mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
fcntl: bug fixes
This commit is contained in:
@@ -32,6 +32,7 @@ syscallret_t syscall_fcntl(context_t *, int fd, int cmd, uint64_t arg) {
|
||||
{
|
||||
int f;
|
||||
ret.errno = fd_dup(fd, arg, false, (cmd == F_DUPFD_CLOEXEC) ? O_CLOEXEC : 0, &f);
|
||||
if (ret.errno == 0)
|
||||
ret.ret = f;
|
||||
}
|
||||
break;
|
||||
@@ -49,11 +50,13 @@ syscallret_t syscall_fcntl(context_t *, int fd, int cmd, uint64_t arg) {
|
||||
break;
|
||||
case F_SETFD:
|
||||
ret.errno = fd_setflags(fd, (arg & FD_CLOEXEC) ? O_CLOEXEC : 0);
|
||||
if (ret.errno == 0)
|
||||
ret.ret = 0;
|
||||
break;
|
||||
case F_GETFD:
|
||||
int flg;
|
||||
ret.errno = fd_getflags(fd, &flg);
|
||||
if (ret.errno == 0)
|
||||
ret.ret = flg ? FD_CLOEXEC : 0;
|
||||
break;
|
||||
case F_SETLK64:
|
||||
@@ -65,7 +68,6 @@ syscallret_t syscall_fcntl(context_t *, int fd, int cmd, uint64_t arg) {
|
||||
ret.errno = EINVAL;
|
||||
goto cleanup;
|
||||
}
|
||||
ret.errno = 0;
|
||||
|
||||
cleanup:
|
||||
ret.ret = ret.errno ? -1 : ret.ret;
|
||||
|
||||
Reference in New Issue
Block a user