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>
|
|
|
|
|
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) {
|
2014-05-12 16:42:43 +02:00
|
|
|
m.m_lc_vfs_creat.len = strlen(name) + 1;
|
|
|
|
m.m_lc_vfs_creat.flags = flags;
|
|
|
|
m.m_lc_vfs_creat.mode = va_arg(argp, mode_t);
|
|
|
|
m.m_lc_vfs_creat.name = (vir_bytes)name;
|
2013-11-04 22:48:08 +01:00
|
|
|
call = VFS_CREAT;
|
2011-02-17 18:11:09 +01:00
|
|
|
} else {
|
|
|
|
_loadname(name, &m);
|
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-05-12 16:30:43 +02:00
|
|
|
m.m_lc_vfs_path.flags = flags;
|
2013-11-04 22:48:08 +01:00
|
|
|
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
|
|
|
}
|