diff options
Diffstat (limited to 'src/sys/stat')
| -rw-r--r-- | src/sys/stat/S_IRGRP.c | 6 | ||||
| -rw-r--r-- | src/sys/stat/S_IROTH.c | 6 | ||||
| -rw-r--r-- | src/sys/stat/S_IRUSR.c | 6 | ||||
| -rw-r--r-- | src/sys/stat/S_IRWXG.c | 6 | ||||
| -rw-r--r-- | src/sys/stat/S_IRWXO.c | 6 | ||||
| -rw-r--r-- | src/sys/stat/S_IRWXU.c | 6 | ||||
| -rw-r--r-- | src/sys/stat/S_ISBLK.C | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_ISCHR.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_ISDIR.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_ISFIFO.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_ISGID.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_ISREG.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_ISUID.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_IWGRP.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_IWOTH.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_IWUSR.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_IXGRP.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_IXOTH.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/S_IXUSR.c | 5 | ||||
| -rw-r--r-- | src/sys/stat/chmod.c | 17 | ||||
| -rw-r--r-- | src/sys/stat/fstat.c | 11 | ||||
| -rw-r--r-- | src/sys/stat/mkdir.c | 13 | ||||
| -rw-r--r-- | src/sys/stat/mkfifo.c | 11 | ||||
| -rw-r--r-- | src/sys/stat/stat.c | 32 | ||||
| -rw-r--r-- | src/sys/stat/struct_stat.c | 23 | ||||
| -rw-r--r-- | src/sys/stat/umask.c | 11 |
26 files changed, 219 insertions, 0 deletions
diff --git a/src/sys/stat/S_IRGRP.c b/src/sys/stat/S_IRGRP.c new file mode 100644 index 00000000..98cf739e --- /dev/null +++ b/src/sys/stat/S_IRGRP.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IRGRP (040) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IROTH.c b/src/sys/stat/S_IROTH.c new file mode 100644 index 00000000..006421ed --- /dev/null +++ b/src/sys/stat/S_IROTH.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IROTH (04) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IRUSR.c b/src/sys/stat/S_IRUSR.c new file mode 100644 index 00000000..2b62f4f1 --- /dev/null +++ b/src/sys/stat/S_IRUSR.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IRUSR (0400) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IRWXG.c b/src/sys/stat/S_IRWXG.c new file mode 100644 index 00000000..e051625e --- /dev/null +++ b/src/sys/stat/S_IRWXG.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IRWXG (070) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IRWXO.c b/src/sys/stat/S_IRWXO.c new file mode 100644 index 00000000..82bbadb3 --- /dev/null +++ b/src/sys/stat/S_IRWXO.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IRWXO (07) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IRWXU.c b/src/sys/stat/S_IRWXU.c new file mode 100644 index 00000000..a518680e --- /dev/null +++ b/src/sys/stat/S_IRWXU.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IRWXU (0700) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISBLK.C b/src/sys/stat/S_ISBLK.C new file mode 100644 index 00000000..1a1498ef --- /dev/null +++ b/src/sys/stat/S_ISBLK.C @@ -0,0 +1,5 @@ +#includ +#define S_ISBLK(s) /* FIXME */ +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISCHR.c b/src/sys/stat/S_ISCHR.c new file mode 100644 index 00000000..a393b84e --- /dev/null +++ b/src/sys/stat/S_ISCHR.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISCHR(s) /* fixme */ +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISDIR.c b/src/sys/stat/S_ISDIR.c new file mode 100644 index 00000000..5b5720c7 --- /dev/null +++ b/src/sys/stat/S_ISDIR.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISDIR(s) (s) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISFIFO.c b/src/sys/stat/S_ISFIFO.c new file mode 100644 index 00000000..a28a90e9 --- /dev/null +++ b/src/sys/stat/S_ISFIFO.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISFIFO(s) /* fixme */ +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISGID.c b/src/sys/stat/S_ISGID.c new file mode 100644 index 00000000..55ceb105 --- /dev/null +++ b/src/sys/stat/S_ISGID.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISGID (02000) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISREG.c b/src/sys/stat/S_ISREG.c new file mode 100644 index 00000000..7a09ffe5 --- /dev/null +++ b/src/sys/stat/S_ISREG.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISREG(s) /* fixme */ +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISUID.c b/src/sys/stat/S_ISUID.c new file mode 100644 index 00000000..85295ad3 --- /dev/null +++ b/src/sys/stat/S_ISUID.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISUID (04000) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IWGRP.c b/src/sys/stat/S_IWGRP.c new file mode 100644 index 00000000..c7a716e7 --- /dev/null +++ b/src/sys/stat/S_IWGRP.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IWGRP (020) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IWOTH.c b/src/sys/stat/S_IWOTH.c new file mode 100644 index 00000000..26e75066 --- /dev/null +++ b/src/sys/stat/S_IWOTH.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IWOTH (02) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IWUSR.c b/src/sys/stat/S_IWUSR.c new file mode 100644 index 00000000..e9af1829 --- /dev/null +++ b/src/sys/stat/S_IWUSR.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IWUSR (0200) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IXGRP.c b/src/sys/stat/S_IXGRP.c new file mode 100644 index 00000000..34f44729 --- /dev/null +++ b/src/sys/stat/S_IXGRP.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IXGRP (010) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IXOTH.c b/src/sys/stat/S_IXOTH.c new file mode 100644 index 00000000..10d51686 --- /dev/null +++ b/src/sys/stat/S_IXOTH.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IXOTH (01) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IXUSR.c b/src/sys/stat/S_IXUSR.c new file mode 100644 index 00000000..b4b8e494 --- /dev/null +++ b/src/sys/stat/S_IXUSR.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IXUSR (0100) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/chmod.c b/src/sys/stat/chmod.c new file mode 100644 index 00000000..f061e1a8 --- /dev/null +++ b/src/sys/stat/chmod.c @@ -0,0 +1,17 @@ +#include "sys/types.h" +#include <sys/stat.h> +#include "nonstd/syscall.h" + +int chmod(const char *path, mode_t mode) +{ + SCNO(scno, "chmod", -1); + int r = __libc.syscall(scno, path, mode); + if (r < 0) { + errno = -r; + return -1; + } + return 0; +} +/* +POSIX(1) +*/ diff --git a/src/sys/stat/fstat.c b/src/sys/stat/fstat.c new file mode 100644 index 00000000..bdd9f574 --- /dev/null +++ b/src/sys/stat/fstat.c @@ -0,0 +1,11 @@ +#include "sys/types.h" +#include <sys/stat.h> + +int fstat(int fildes, struct stat *buf) +{ + (void)fildes; (void)buf; + return 0; +} +/* +POSIX(1) +*/ diff --git a/src/sys/stat/mkdir.c b/src/sys/stat/mkdir.c new file mode 100644 index 00000000..7b3f510d --- /dev/null +++ b/src/sys/stat/mkdir.c @@ -0,0 +1,13 @@ +#include "sys/types.h" +#include <sys/stat.h> +#include "nonstd/syscall.h" + +int mkdir(const char *path, mode_t mode) +{ + (void)path; (void)mode; + return -1; +} + +/* +POSIX(1) +*/ diff --git a/src/sys/stat/mkfifo.c b/src/sys/stat/mkfifo.c new file mode 100644 index 00000000..2d475258 --- /dev/null +++ b/src/sys/stat/mkfifo.c @@ -0,0 +1,11 @@ +#include "sys/types.h" +#include <sys/stat.h> + +int mkfifo(const char *path, mode_t mode) +{ + (void)path; (void)mode; + return 0; +} +/* +POSIX(1) +*/ diff --git a/src/sys/stat/stat.c b/src/sys/stat/stat.c new file mode 100644 index 00000000..c5079295 --- /dev/null +++ b/src/sys/stat/stat.c @@ -0,0 +1,32 @@ +#include "sys/types.h" +#include <sys/stat.h> +#include "stdlib.h" +#include "nonstd/assert.h" + +int stat(const char * restrict path, struct stat * restrict buf) +{ + ASSERT_NONNULL(path); + ASSERT_NONNULL(buf); + + int ret = 0; + #if 0 + char *linkbuf = NULL; + + do { + ret = lstat(path, buf); + if (S_ISLNK(buf->st_mode)) { + linkbuf = realloc(linkbuf, buf->st_size + 1); + readlink(path, linkbuf, buf->st_size); + path = linkbuf; + } else { + path = NULL; + } + } while (path); + realloc(linkbuf, 0); + #endif + + return ret; +} +/* +POSIX(1) +*/ diff --git a/src/sys/stat/struct_stat.c b/src/sys/stat/struct_stat.c new file mode 100644 index 00000000..c825e561 --- /dev/null +++ b/src/sys/stat/struct_stat.c @@ -0,0 +1,23 @@ +#include <sys/stat.h> + +struct stat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + #if 0 + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + blksize_t st_blksize; + blkcnt_t st_blocks; + #endif +}; + +/* +POSIX(1) +*/ diff --git a/src/sys/stat/umask.c b/src/sys/stat/umask.c new file mode 100644 index 00000000..ca038bad --- /dev/null +++ b/src/sys/stat/umask.c @@ -0,0 +1,11 @@ +#include "sys/types.h" +#include <sys/stat.h> + +mode_t umask(mode_t cmask) +{ + return cmask; +} + +/* +POSIX(1) +*/ |
