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