2 * SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
4 * For a successful call, the return value depends on the operation:
6 * F_DUPFD The new descriptor.
7 * F_GETFD Value of file descriptor flags.
8 * F_GETFL Value of file status flags.
9 * F_GETLEASE Type of lease held on file descriptor.
10 * F_GETOWN Value of descriptor owner.
11 * F_GETSIG Value of signal sent when read or write becomes possible, or zero for traditional SIGIO behavior.
12 * F_GETPIPE_SZ The pipe capacity.
17 * On error, -1 is returned, and errno is set appropriately.
27 #if F_GETLK64 != F_GETLK
31 static void sanitise_fcntl(int childno
)
33 switch (shm
->a2
[childno
]) {
38 shm
->a3
[childno
] = (unsigned long) get_random_fd();
51 case F_SETFD
: /* arg = flags */
52 shm
->a3
[childno
] = (unsigned int) rand32();
56 shm
->a3
[childno
] = 0L;
58 shm
->a3
[childno
] |= O_APPEND
;
60 shm
->a3
[childno
] |= O_ASYNC
;
62 shm
->a3
[childno
] |= O_DIRECT
;
64 shm
->a3
[childno
] |= O_NOATIME
;
66 shm
->a3
[childno
] |= O_NONBLOCK
;
69 /* arg = (struct flock *) */
84 shm
->a3
[childno
] = (unsigned long) get_pid();
87 /* arg = struct f_owner_ex *) */
93 shm
->a3
[childno
] = (unsigned long) rand32();
94 if (shm
->a3
[childno
] == SIGINT
)
95 shm
->a3
[childno
] = 0; /* restore default (SIGIO) */
99 shm
->a3
[childno
] = 0L;
101 shm
->a3
[childno
] |= DN_ACCESS
;
103 shm
->a3
[childno
] |= DN_MODIFY
;
105 shm
->a3
[childno
] |= DN_CREATE
;
107 shm
->a3
[childno
] |= DN_DELETE
;
109 shm
->a3
[childno
] |= DN_RENAME
;
111 shm
->a3
[childno
] |= DN_ATTRIB
;
115 shm
->a3
[childno
] = rand32();
124 struct syscallentry syscall_fcntl
= {
137 .values
= { F_DUPFD
, F_DUPFD_CLOEXEC
, F_GETFD
, F_SETFD
, F_GETFL
, F_SETFL
, F_GETLK
, F_SETLK
,
138 F_SETLKW
, F_GETOWN
, F_SETOWN
, F_GETOWN_EX
, F_SETOWN_EX
, F_GETSIG
, F_SETSIG
, F_GETLEASE
,
139 F_SETLEASE
, F_NOTIFY
, F_SETPIPE_SZ
, F_GETPIPE_SZ
, F_GETOWNER_UIDS
,
141 F_GETLK64
, F_SETLK64
, F_SETLKW64
,
146 .rettype
= RET_FD
, //FIXME: Needs to mutate somehow depending on 'cmd'
149 .sanitise
= sanitise_fcntl
,