diff options
author | midipix <writeonce@midipix.org> | 2019-08-25 22:53:42 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2019-08-25 23:02:27 +0000 |
commit | e1f10b268ae40cbc969934f8e57aa6d892f631e6 (patch) | |
tree | 3ec46e9d32ff95c7164a119694fd5f6fc66c2170 | |
parent | f068672c56fe16cb91563e135769710e7489cf5b (diff) | |
download | mmglue-e1f10b268ae40cbc969934f8e57aa6d892f631e6.tar.bz2 mmglue-e1f10b268ae40cbc969934f8e57aa6d892f631e6.tar.xz |
glue layer: introduced <sys/fs.h>, implemented associated interfaces.
-rw-r--r-- | include/sys/fs.h | 51 | ||||
-rw-r--r-- | project/arch.mk | 1 | ||||
-rw-r--r-- | src/arch/nt32/fs.c | 26 | ||||
-rw-r--r-- | src/arch/nt64/fs.c | 26 |
4 files changed, 104 insertions, 0 deletions
diff --git a/include/sys/fs.h b/include/sys/fs.h new file mode 100644 index 0000000..f0dd33b --- /dev/null +++ b/include/sys/fs.h @@ -0,0 +1,51 @@ +#ifndef _SYS_FS_H +#define _SYS_FS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define __NEED_size_t + +#include <bits/alltypes.h> + +/***************************************************************************/ +/* int (*__fs_path_fn)(int fdat, const char * path, int options, */ +/* char * buffer, size_t buflen); */ +/* */ +/* resolve and obtain the full path using one of four supported notations: */ +/* */ +/* __fs_rpath(): root-relative notation (e.g. /bar) */ +/* __fs_apath(): root-based absolute notation (e.g. /dev/fs/c/foo/bar) */ +/* __fs_npath(): native tool notation (e.g. C:\foo\bar) */ +/* __fs_dpath(): native driver notation (e.g. \Device\Harddisk0\foo\bar */ +/* */ +/* arguments: */ +/* fdat: open at file descriptor */ +/* path: path to resolve, absolute or relative */ +/* options: options to be passed to the internal path resolution */ +/* interface, for instance O_DIRECTORY|O_NOFOLLOW */ +/* buffer: buffer to receive the fully resolved path */ +/* buflen: size of buffer, including null termination. */ +/* */ +/* return value: */ +/* zero upon successful resolution and buffer initialization */ +/* negative value returned upon failure, which is the actual value */ +/* returned by the underlying system call; accordingly, errno */ +/* is _not_ set by any of the above interfaces. */ +/* */ +/* implementation: */ +/* the above interfaces are async-safe, thread-safe, and re-entrant. */ +/* */ +/***************************************************************************/ + +int __fs_rpath(int, const char *, int, char *, size_t); +int __fs_apath(int, const char *, int, char *, size_t); +int __fs_npath(int, const char *, int, char *, size_t); +int __fs_dpath(int, const char *, int, char *, size_t); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/project/arch.mk b/project/arch.mk index 858c1f0..5a5b967 100644 --- a/project/arch.mk +++ b/project/arch.mk @@ -24,6 +24,7 @@ LDFLAGS_CONFIG += -Wl,--exclude-symbols=___errno_location TARGET_SYS_HEADERS = \ $(PROJECT_DIR)/include/sys/debug.h \ + $(PROJECT_DIR)/include/sys/fs.h \ $(PROJECT_DIR)/include/sys/ldso.h \ $(PROJECT_DIR)/include/sys/unwind.h \ diff --git a/src/arch/nt32/fs.c b/src/arch/nt32/fs.c new file mode 100644 index 0000000..b198777 --- /dev/null +++ b/src/arch/nt32/fs.c @@ -0,0 +1,26 @@ +#include <sys/fs.h> +#include "syscall.h" + +int __fs_rpath(int fdat, const char * path, int options, + char * buffer, size_t buflen) +{ + return __syscall(SYS_fs_rpath,fdat,path,options,buffer,buflen); +} + +int __fs_apath(int fdat, const char * path, int options, + char * buffer, size_t buflen) +{ + return __syscall(SYS_fs_apath,fdat,path,options,buffer,buflen); +} + +int __fs_npath(int fdat, const char * path, int options, + char * buffer, size_t buflen) +{ + return __syscall(SYS_fs_npath,fdat,path,options,buffer,buflen); +} + +int __fs_dpath(int fdat, const char * path, int options, + char * buffer, size_t buflen) +{ + return __syscall(SYS_fs_dpath,fdat,path,options,buffer,buflen); +} diff --git a/src/arch/nt64/fs.c b/src/arch/nt64/fs.c new file mode 100644 index 0000000..b198777 --- /dev/null +++ b/src/arch/nt64/fs.c @@ -0,0 +1,26 @@ +#include <sys/fs.h> +#include "syscall.h" + +int __fs_rpath(int fdat, const char * path, int options, + char * buffer, size_t buflen) +{ + return __syscall(SYS_fs_rpath,fdat,path,options,buffer,buflen); +} + +int __fs_apath(int fdat, const char * path, int options, + char * buffer, size_t buflen) +{ + return __syscall(SYS_fs_apath,fdat,path,options,buffer,buflen); +} + +int __fs_npath(int fdat, const char * path, int options, + char * buffer, size_t buflen) +{ + return __syscall(SYS_fs_npath,fdat,path,options,buffer,buflen); +} + +int __fs_dpath(int fdat, const char * path, int options, + char * buffer, size_t buflen) +{ + return __syscall(SYS_fs_dpath,fdat,path,options,buffer,buflen); +} |