2 * Copyright 2007-2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
6 #include "fssh_fcntl.h"
11 #include "fssh_errno.h"
12 #include "partition_support.h"
13 #include "stat_util.h"
16 using namespace FSShell
;
19 #if (!defined(__BEOS__) && !defined(__HAIKU__))
20 // The _kern_open() defined in libroot_build.so.
21 # define _kern_open _kernbuild_open
22 extern "C" int _kern_open(int fd
, const char *path
, int openMode
,
28 fssh_open(const char *pathname
, int oflags
, ...)
31 va_start(args
, oflags
);
33 // get the mode, if O_CREAT was specified
35 if (oflags
& FSSH_O_CREAT
)
36 mode
= va_arg(args
, fssh_mode_t
);
40 // Use the _kern_open() defined in libroot on BeOS incompatible systems.
41 // Required for proper attribute emulation support.
43 #if (defined(__BEOS__) || defined(__HAIKU__))
44 fd
= open(pathname
, to_platform_open_mode(oflags
),
45 to_platform_mode(mode
));
47 fd
= _kern_open(-1, pathname
, to_platform_open_mode(oflags
),
48 to_platform_mode(mode
));
56 restricted_file_opened(fd
);
63 fssh_creat(const char *path
, fssh_mode_t mode
)
65 return fssh_open(path
, FSSH_O_WRONLY
| FSSH_O_CREAT
| FSSH_O_TRUNC
, mode
);