aboutsummaryrefslogtreecommitdiff
path: root/lib/sys/stat.h
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2022-12-14 18:26:49 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2022-12-14 18:26:49 +0100
commitd179f1846f9372920ef02f08cfb4d3abe99b383f (patch)
tree4b6ddc71566be95a1ce520ef9d957f4cac1af6c9 /lib/sys/stat.h
first commit
Diffstat (limited to 'lib/sys/stat.h')
-rw-r--r--lib/sys/stat.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/sys/stat.h b/lib/sys/stat.h
new file mode 100644
index 0000000..02bdc48
--- /dev/null
+++ b/lib/sys/stat.h
@@ -0,0 +1,62 @@
+#ifndef STAT_H
+#define STAT_H
+
+#include "sizes.h"
+#include "time.h"
+#include "syscalls.h"
+
+#define S_IFMT 0170000
+#define S_IFSOCK 0140000
+#define S_IFLNK 0120000
+#define S_IFREG 0100000
+#define S_IFBLK 0060000
+#define S_IFDIR 0040000
+#define S_IFCHR 0020000
+#define S_IFIFO 0010000
+
+#define S_ISUID 04000
+#define S_ISGID 02000
+#define S_ISVTX 01000
+
+#define S_IRWXU 00700
+
+#define S_IRUSR 00400
+#define S_IWUSR 00200
+#define S_IXUSR 00100
+
+#define S_IRWXG 00070
+
+#define S_IRGRP 00040
+#define S_IWGRP 00020
+#define S_IXGRP 00010
+
+#define S_IRWXO 00007
+
+#define S_IROTH 00004
+#define S_IWOTH 00002
+#define S_IXOTH 00001
+
+struct stat {
+ i64 dev;
+ i64 ino;
+ u64 nlink;
+ u32 mode;
+ u32 uid;
+ u32 gid;
+ u64 rdev;
+ u64 size;
+ u64 blksize;
+ i64 blocks;
+
+ struct timespec atime;
+ struct timespec mtime;
+ struct timespec ctime;
+
+ u64 __[3];
+};
+
+static int stat(const char * filename, struct stat * statbuf) {
+ return syscall(STAT, filename, statbuf);
+}
+
+#endif