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
This commit is contained in:
Warner Losh 2023-01-07 13:23:05 -07:00
parent 0386255bee
commit 2f5f17b80c

View file

@ -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
*