2011-02-17 18:11:09 +01:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include "namespace.h"
|
|
|
|
#include <lib.h>
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifdef __weak_alias
|
|
|
|
__weak_alias(open, _open)
|
|
|
|
#endif
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int open(const char *name, int flags, ...)
|
2011-02-17 18:11:09 +01:00
|
|
|
{
|
|
|
|
va_list argp;
|
|
|
|
message m;
|
2013-11-04 22:48:08 +01:00
|
|
|
int call;
|
2011-02-17 18:11:09 +01:00
|
|
|
|
2013-11-04 22:48:08 +01:00
|
|
|
memset(&m, 0, sizeof(m));
|
2011-02-17 18:11:09 +01:00
|
|
|
va_start(argp, flags);
|
2013-11-04 22:48:08 +01:00
|
|
|
/* Depending on whether O_CREAT is set, a different message layout is used,
|
|
|
|
* and therefore a different call number as well.
|
|
|
|
*/
|
2011-02-17 18:11:09 +01:00
|
|
|
if (flags & O_CREAT) {
|
2013-11-04 22:48:08 +01:00
|
|
|
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;
|
2011-02-17 18:11:09 +01:00
|
|
|
} else {
|
|
|
|
_loadname(name, &m);
|
2013-11-04 22:48:08 +01:00
|
|
|
m.VFS_PATH_FLAGS = flags;
|
|
|
|
call = VFS_OPEN;
|
2011-02-17 18:11:09 +01:00
|
|
|
}
|
|
|
|
va_end(argp);
|
2013-11-04 22:48:08 +01:00
|
|
|
return (_syscall(VFS_PROC_NR, call, &m));
|
2011-02-17 18:11:09 +01:00
|
|
|
}
|