summaryrefslogtreecommitdiff
path: root/include/sys/stat.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sys/stat.h')
-rw-r--r--include/sys/stat.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/include/sys/stat.h b/include/sys/stat.h
index 42a2e95..9258ce7 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -4,13 +4,23 @@
#include <sys/types.h>
#include <time.h>
-#define STAT_REG (1 << 0)
-#define STAT_DIR (1 << 1)
-#define STAT_FIFO (1 << 2)
+#define S_IFMT 0170000
-#define S_ISREG(_v) (((_v) >> 0) & 1)
-#define S_ISDIR(_v) (((_v) >> 1) & 1)
-#define S_ISFIFO(_v) (((_v) >> 2) & 1)
+#define S_IFDIR 0040000
+#define S_IFCHR 0020000
+#define S_IFBLK 0060000
+#define S_IFREG 0100000
+#define S_IFIFO 0010000
+#define S_IFLNK 0120000
+#define S_IFSOCK 0140000
+
+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
+#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
+#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
+#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
struct stat {
dev_t st_dev; // Device ID of device containing file.