aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2023-01-07 20:23:05 +0000
committerWarner Losh <imp@FreeBSD.org>2023-01-24 21:49:45 +0000
commit3141164b2a88423b83d04282dc828f2f85c05166 (patch)
tree721f7ac777d1a3651956f562b13507b2604410a6
parent85d8155e952613e03ab444947405ec0d9183e3b0 (diff)
downloadsrc-3141164b2a88423b83d04282dc828f2f85c05166.tar.gz
src-3141164b2a88423b83d04282dc828f2f85c05166.zip
stand: Add macros for file types from stat
Add the familiar macros for file types for stat's st_mode member. Prepend HOST_ to the start of these. Make sure all the values match the linux nolibc and uapi headers. These values are the same as native values since they appear to be required by POSIX. Define anyway to allow the reader of the code to know that they are in the 'host (eg Linux)' namespace rather than the 'loader' namespace. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37967 (cherry picked from commit 2f5f17b80c2d030196e05b12b15d544b363eb058)
-rw-r--r--stand/kboot/host_syscall.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/stand/kboot/host_syscall.h b/stand/kboot/host_syscall.h
index ea0745542a5b..38f0fb04aa95 100644
--- a/stand/kboot/host_syscall.h
+++ b/stand/kboot/host_syscall.h
@@ -47,6 +47,28 @@ typedef int64_t host_blkcnt_t;
#include "stat_arch.h"
/*
+ * stat flags
+ * These are arch independent and match the values in nolib and uapi headers
+ * with HOST_ prepended.
+ */
+#define HOST_S_IFMT 0170000
+#define HOST_S_IFIFO 0010000
+#define HOST_S_IFCHR 0020000
+#define HOST_S_IFDIR 0040000
+#define HOST_S_IFBLK 0060000
+#define HOST_S_IFREG 0100000
+#define HOST_S_IFLNK 0120000
+#define HOST_S_IFSOCK 0140000
+
+#define HOST_S_ISBLK(mode) (((mode) & HOST_S_IFMT) == HOST_S_IFBLK)
+#define HOST_S_ISCHR(mode) (((mode) & HOST_S_IFMT) == HOST_S_IFCHR)
+#define HOST_S_ISDIR(mode) (((mode) & HOST_S_IFMT) == HOST_S_IFDIR)
+#define HOST_S_ISFIFO(mode) (((mode) & HOST_S_IFMT) == HOST_S_IFIFO)
+#define HOST_S_ISLNK(mode) (((mode) & HOST_S_IFMT) == HOST_S_IFLNK)
+#define HOST_S_ISREG(mode) (((mode) & HOST_S_IFMT) == HOST_S_IFREG)
+#define HOST_S_ISSOCK(mode) (((mode) & HOST_S_IFMT) == HOST_S_IFSOCK)
+
+/*
* Constants for open, fcntl, etc
*
* Note: Some of these are arch dependent on Linux, but are the same for