etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / open.c
blobbaafbd606c149ec20a07088c53230d5473b52030
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
5 #include <fcntl.h>
6 #include <stdarg.h>
7 #include <string.h>
9 int open(const char *name, int flags, ...)
11 va_list argp;
12 message m;
13 int call;
15 memset(&m, 0, sizeof(m));
16 va_start(argp, flags);
17 /* Depending on whether O_CREAT is set, a different message layout is used,
18 * and therefore a different call number as well.
20 if (flags & O_CREAT) {
21 m.m_lc_vfs_creat.len = strlen(name) + 1;
22 m.m_lc_vfs_creat.flags = flags;
23 m.m_lc_vfs_creat.mode = va_arg(argp, mode_t);
24 m.m_lc_vfs_creat.name = (vir_bytes)name;
25 call = VFS_CREAT;
26 } else {
27 _loadname(name, &m);
28 m.m_lc_vfs_path.flags = flags;
29 call = VFS_OPEN;
31 va_end(argp);
32 return (_syscall(VFS_PROC_NR, call, &m));