git: 3141164b2a88 - stable/13 - stand: Add macros for file types from stat
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Jan 2023 22:14:14 UTC
The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3141164b2a88423b83d04282dc828f2f85c05166 commit 3141164b2a88423b83d04282dc828f2f85c05166 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2023-01-07 20:23:05 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2023-01-24 21:49:45 +0000 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) --- stand/kboot/host_syscall.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 @@ -46,6 +46,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 *