diff options
author | Anton Kling <anton@kling.gg> | 2024-12-31 16:09:27 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-12-31 16:09:27 +0100 |
commit | 934d8d5ee4c2ce756fea79d74d8562ad597cc5e5 (patch) | |
tree | c1037b3fca239c31831c895f81369e48a03498b0 | |
parent | 3a7c500bbbcaac31dce72477e263359ae2230bf5 (diff) |
stat: Use the standard values for S_ISDIR/S_ISREG etc
-rw-r--r-- | include/sys/stat.h | 22 |
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. |