tools/nolibc: Fix S_ISxxx macros
authorWarner Losh <imp@bsdimp.com>
Mon, 9 Jan 2023 07:54:38 +0000 (08:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:34:31 +0000 (08:34 +0100)
commit338ec07a14cd82d9962b9d5f8b7d599864747ccd
treebfa2247362a3bac32fd3633318d0b7b6234a0354
parent99dd3449279bcc15a69af734f7609bfce1ff1e1c
tools/nolibc: Fix S_ISxxx macros

[ Upstream commit 16f5cea74179b5795af7ce359971f5128d10f80e ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/include/nolibc/types.h