minix/lib/libc/sys-minix/open.c
Lionel Sambuc cef3ce969a Message type for path related calls.
- Updated system calls VFS_ACCESS, VFS_CHDIR, VFS_CHMOD, VFS_CHROOT,
                        VFS_MKDIR, VFS_OPEN, VFS_RMDIR, VSF_UNLINK

 - Removed M3_STRING and M3_LONG_STRING, which are tied to a specific
   "generic" message, and replaced where needed with M_PATH_STRING_MAX,
   which is tied to the mess_lc_vfs_path message.

Change-Id: If287c74f5ece937b9431e5d95b5b58a3c83ebff1
2014-07-28 17:05:33 +02:00

34 lines
743 B
C

#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
#include <fcntl.h>
#include <stdarg.h>
#include <string.h>
int open(const char *name, int flags, ...)
{
va_list argp;
message m;
int call;
memset(&m, 0, sizeof(m));
va_start(argp, flags);
/* Depending on whether O_CREAT is set, a different message layout is used,
* and therefore a different call number as well.
*/
if (flags & O_CREAT) {
m.VFS_CREAT_LEN = strlen(name) + 1;
m.VFS_CREAT_FLAGS = flags;
m.VFS_CREAT_MODE = va_arg(argp, int);
m.VFS_CREAT_NAME = (char *) __UNCONST(name);
call = VFS_CREAT;
} else {
_loadname(name, &m);
m.m_lc_vfs_path.flags = flags;
call = VFS_OPEN;
}
va_end(argp);
return (_syscall(VFS_PROC_NR, call, &m));
}