etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / fcntl.c
blob8a243e5c19c29a4649a4290b0967a7f29722f2f0
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
5 #include <string.h>
6 #include <fcntl.h>
7 #include <stdarg.h>
9 int fcntl(int fd, int cmd, ...)
11 va_list argp;
12 message m;
14 va_start(argp, cmd);
16 /* Set up for the sensible case where there is no variable parameter. This
17 * covers F_GETFD, F_GETFL and invalid commands.
19 memset(&m, 0, sizeof(m));
21 /* Adjust for the stupid cases. */
22 switch(cmd) {
23 case F_DUPFD:
24 case F_DUPFD_CLOEXEC:
25 case F_SETFD:
26 case F_SETFL:
27 case F_SETNOSIGPIPE:
28 m.m_lc_vfs_fcntl.arg_int = va_arg(argp, int);
29 break;
30 case F_GETLK:
31 case F_SETLK:
32 case F_SETLKW:
33 case F_FREESP:
34 m.m_lc_vfs_fcntl.arg_ptr = (vir_bytes)va_arg(argp, struct flock *);
35 break;
38 /* Clean up and make the system call. */
39 va_end(argp);
40 m.m_lc_vfs_fcntl.fd = fd;
41 m.m_lc_vfs_fcntl.cmd = cmd;
42 return(_syscall(VFS_PROC_NR, VFS_FCNTL, &m));