1 #include <sys/cdefs.h> 2 #include "namespace.h" 3 #include <lib.h> 4 5 #include <fcntl.h> 6 #include <stdarg.h> 7 #include <string.h> 8 9 int open(const char *name, int flags, ...) 10 { 11 va_list argp; 12 message m; 13 int call; 14 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. 19 */ 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; 30 } 31 va_end(argp); 32 return (_syscall(VFS_PROC_NR, call, &m)); 33 } 34