tools/nolibc: Fix S_ISxxx macros
authorWarner Losh <imp@bsdimp.com>
Mon, 9 Jan 2023 07:54:38 +0000 (08:54 +0100)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 9 Jan 2023 17:36:05 +0000 (09:36 -0800)
commit16f5cea74179b5795af7ce359971f5128d10f80e
treefcbe9190ccd04d0f2029289a4609b06e291f6d18
parentfeaf75658783a919410f8c2039dbc24b6a29603d
tools/nolibc: Fix S_ISxxx macros

The mode field has the type encoded as an value in a field, not as a bit
mask. Mask the mode with S_IFMT instead of each type to test. Otherwise,
false positives are possible: eg S_ISDIR will return true for block
devices because S_IFDIR = 0040000 and S_IFBLK = 0060000 since mode is
masked with S_IFDIR instead of S_IFMT. These macros now match the
similar definitions in tools/include/uapi/linux/stat.h.

Signed-off-by: Warner Losh <imp@bsdimp.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/include/nolibc/types.h