Add F_DUPFD, F_DUPFD_CLOEXEC, F_DUPFD_CLOFORK.
This commit is contained in:
parent
42f00f5d79
commit
defa74d7ec
|
@ -88,6 +88,12 @@ __BEGIN_DECLS
|
||||||
#define F_GETFL_NUM 3
|
#define F_GETFL_NUM 3
|
||||||
#define F_GETFL F_ENCODE_CMD(F_GETFL_NUM, F_TYPE_VOID)
|
#define F_GETFL F_ENCODE_CMD(F_GETFL_NUM, F_TYPE_VOID)
|
||||||
|
|
||||||
|
/* Duplicates the file descriptor with at least the given index. */
|
||||||
|
#define F_DUPFD_NUM 4
|
||||||
|
#define F_DUPFD F_ENCODE_CMD(F_ENCODE(F_DUPFD_NUM, 0), F_TYPE_INT)
|
||||||
|
#define F_DUPFD_CLOEXEC F_ENCODE_CMD(F_ENCODE(F_DUPFD_NUM, FD_CLOEXEC), F_TYPE_INT)
|
||||||
|
#define F_DUPFD_CLOFORK F_ENCODE_CMD(F_ENCODE(F_DUPFD_NUM, FD_CLOFORK), F_TYPE_INT)
|
||||||
|
|
||||||
#define AT_FDCWD (-100)
|
#define AT_FDCWD (-100)
|
||||||
#define AT_REMOVEDIR (1<<0)
|
#define AT_REMOVEDIR (1<<0)
|
||||||
#define AT_EACCESS (1<<1)
|
#define AT_EACCESS (1<<1)
|
||||||
|
|
|
@ -328,6 +328,11 @@ static int sys_fcntl(int fd, int cmd, uintptr_t arg)
|
||||||
return dtable->GetFlags(fd);
|
return dtable->GetFlags(fd);
|
||||||
|
|
||||||
// Operations on the file description.
|
// Operations on the file description.
|
||||||
|
if ( F_DECODE_CMD(F_DECODE_CMD_RAW(cmd)) == F_DUPFD_NUM )
|
||||||
|
{
|
||||||
|
int fd_flags = F_DECODE_FLAGS(F_DECODE_CMD_RAW(cmd));
|
||||||
|
return dtable->Allocate(fd, fd_flags, (int) arg);
|
||||||
|
}
|
||||||
Ref<Descriptor> desc = dtable->Get(fd);
|
Ref<Descriptor> desc = dtable->Get(fd);
|
||||||
if ( !desc )
|
if ( !desc )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue