summaryrefslogtreecommitdiff
path: root/src/sys/stat
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-09 13:14:01 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-09 13:14:01 -0500
commit253a32e2f9ff1cbb8edbe7c79834a678daebeb93 (patch)
tree599cf5baf01c6dae33a2f89989b08b7d553f7fd0 /src/sys/stat
parent88d0b5e7ffbf0554b236dc46225846061b5f4817 (diff)
merge POSIX.1-1988/1990
Diffstat (limited to 'src/sys/stat')
-rw-r--r--src/sys/stat/S_IRGRP.c6
-rw-r--r--src/sys/stat/S_IROTH.c6
-rw-r--r--src/sys/stat/S_IRUSR.c6
-rw-r--r--src/sys/stat/S_IRWXG.c6
-rw-r--r--src/sys/stat/S_IRWXO.c6
-rw-r--r--src/sys/stat/S_IRWXU.c6
-rw-r--r--src/sys/stat/S_ISBLK.C5
-rw-r--r--src/sys/stat/S_ISCHR.c5
-rw-r--r--src/sys/stat/S_ISDIR.c5
-rw-r--r--src/sys/stat/S_ISFIFO.c5
-rw-r--r--src/sys/stat/S_ISGID.c5
-rw-r--r--src/sys/stat/S_ISREG.c5
-rw-r--r--src/sys/stat/S_ISUID.c5
-rw-r--r--src/sys/stat/S_IWGRP.c5
-rw-r--r--src/sys/stat/S_IWOTH.c5
-rw-r--r--src/sys/stat/S_IWUSR.c5
-rw-r--r--src/sys/stat/S_IXGRP.c5
-rw-r--r--src/sys/stat/S_IXOTH.c5
-rw-r--r--src/sys/stat/S_IXUSR.c5
-rw-r--r--src/sys/stat/chmod.c17
-rw-r--r--src/sys/stat/fstat.c11
-rw-r--r--src/sys/stat/mkdir.c13
-rw-r--r--src/sys/stat/mkfifo.c11
-rw-r--r--src/sys/stat/stat.c32
-rw-r--r--src/sys/stat/struct_stat.c23
-rw-r--r--src/sys/stat/umask.c11
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)
+*/