diff --git a/src/tests/add-ons/kernel/file_systems/fs_shell/stat_util.cpp b/src/tests/add-ons/kernel/file_systems/fs_shell/stat_util.cpp index 8aa77fed4c..21c9954601 100644 --- a/src/tests/add-ons/kernel/file_systems/fs_shell/stat_util.cpp +++ b/src/tests/add-ons/kernel/file_systems/fs_shell/stat_util.cpp @@ -43,6 +43,13 @@ to_platform_stat(const struct my_stat *myst, struct stat *st) } +int +to_platform_open_mode(int myMode) +{ + return myMode; +} + + #else // !__BEOS__ #ifndef S_ATTR_DIR @@ -236,4 +243,44 @@ to_platform_stat(const struct my_stat *myst, struct stat *st) // st->st_crtime = myst->crtime; } + +int +to_platform_open_mode(int myMode) +{ + #define SET_OPEN_MODE_FLAG(flag, myFlag) \ + if (myMode & myFlag) \ + mode |= flag; + + int mode = 0; + + // the r/w mode + switch (myMode & MY_O_RWMASK) { + case MY_O_RDONLY: + mode |= O_RDONLY; + break; + case MY_O_WRONLY: + mode |= O_WRONLY; + break; + case MY_O_RDWR: + mode |= O_RDWR; + break; + } + + // the flags + //SET_OPEN_MODE_FLAG(O_CLOEXEC, MY_O_CLOEXEC) + SET_OPEN_MODE_FLAG(O_NONBLOCK, MY_O_NONBLOCK) + SET_OPEN_MODE_FLAG(O_EXCL, MY_O_EXCL) + SET_OPEN_MODE_FLAG(O_CREAT, MY_O_CREAT) + SET_OPEN_MODE_FLAG(O_TRUNC, MY_O_TRUNC) + SET_OPEN_MODE_FLAG(O_APPEND, MY_O_APPEND) + SET_OPEN_MODE_FLAG(O_NOCTTY, MY_O_NOCTTY) + SET_OPEN_MODE_FLAG(O_NOTRAVERSE, MY_O_NOTRAVERSE) + //SET_OPEN_MODE_FLAG(O_TEXT, MY_O_TEXT) + //SET_OPEN_MODE_FLAG(O_BINARY, MY_O_BINARY) + + #undef SET_OPEN_MODE_FLAG + + return mode; +} + #endif // !__BEOS__ diff --git a/src/tests/add-ons/kernel/file_systems/fs_shell/stat_util.h b/src/tests/add-ons/kernel/file_systems/fs_shell/stat_util.h index 967d9c4de3..3ba44938e6 100644 --- a/src/tests/add-ons/kernel/file_systems/fs_shell/stat_util.h +++ b/src/tests/add-ons/kernel/file_systems/fs_shell/stat_util.h @@ -17,6 +17,8 @@ mode_t to_platform_mode(my_mode_t mode); void from_platform_stat(const struct stat *st, struct my_stat *myst); void to_platform_stat(const struct my_stat *myst, struct stat *st); +extern int to_platform_open_mode(int myMode); + #ifdef __cplusplus } #endif diff --git a/src/tests/add-ons/kernel/file_systems/fs_shell/sysdep.c b/src/tests/add-ons/kernel/file_systems/fs_shell/sysdep.c index 95512660ec..1e35c38858 100644 --- a/src/tests/add-ons/kernel/file_systems/fs_shell/sysdep.c +++ b/src/tests/add-ons/kernel/file_systems/fs_shell/sysdep.c @@ -265,46 +265,6 @@ writev_pos(int fd, fs_off_t _pos, struct iovec *iov, int count) } -static int -to_platform_open_mode(int myMode) -{ - #define SET_OPEN_MODE_FLAG(flag, myFlag) \ - if (myMode & myFlag) \ - mode |= flag; - - int mode = 0; - - // the r/w mode - switch (myMode & MY_O_RWMASK) { - case MY_O_RDONLY: - mode |= O_RDONLY; - break; - case MY_O_WRONLY: - mode |= O_WRONLY; - break; - case MY_O_RDWR: - mode |= O_RDWR; - break; - } - - // the flags - //SET_OPEN_MODE_FLAG(O_CLOEXEC, MY_O_CLOEXEC) - SET_OPEN_MODE_FLAG(O_NONBLOCK, MY_O_NONBLOCK) - SET_OPEN_MODE_FLAG(O_EXCL, MY_O_EXCL) - SET_OPEN_MODE_FLAG(O_CREAT, MY_O_CREAT) - SET_OPEN_MODE_FLAG(O_TRUNC, MY_O_TRUNC) - SET_OPEN_MODE_FLAG(O_APPEND, MY_O_APPEND) - SET_OPEN_MODE_FLAG(O_NOCTTY, MY_O_NOCTTY) - SET_OPEN_MODE_FLAG(O_NOTRAVERSE, MY_O_NOTRAVERSE) - //SET_OPEN_MODE_FLAG(O_TEXT, MY_O_TEXT) - //SET_OPEN_MODE_FLAG(O_BINARY, MY_O_BINARY) - - #undef SET_OPEN_MODE_FLAG - - return mode; -} - - int build_platform_open(const char *pathname, int oflags, my_mode_t mode); int