From: Thomas Weißschuh Date: Sat, 4 Apr 2026 08:08:23 +0000 (+0200) Subject: tools/nolibc: use makedev() in fstatat() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=867fb336a65ac59260674382168d2d93896ffa8d;p=thirdparty%2Flinux.git tools/nolibc: use makedev() in fstatat() fstatat() contains two open-coded copies of makedev() to handle minor numbers >= 256. Now that the regular makedev() handles both large minor and major numbers correctly use the common function. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau Link: https://patch.msgid.link/20260404-nolibc-makedev-v2-6-456a429bf60c@weissschuh.net --- diff --git a/tools/include/nolibc/sys/stat.h b/tools/include/nolibc/sys/stat.h index b2ef34a617ca1..07ae715ff2536 100644 --- a/tools/include/nolibc/sys/stat.h +++ b/tools/include/nolibc/sys/stat.h @@ -13,6 +13,7 @@ #include "../arch.h" #include "../types.h" #include "../sys.h" +#include "../sys/sysmacros.h" /* * int statx(int fd, const char *path, int flags, unsigned int mask, struct statx *buf); @@ -49,17 +50,13 @@ int fstatat(int fd, const char *path, struct stat *buf, int flag) if (ret == -1) return ret; - buf->st_dev = ((statx.stx_dev_minor & 0xff) - | (statx.stx_dev_major << 8) - | ((statx.stx_dev_minor & ~0xff) << 12)); + buf->st_dev = makedev(statx.stx_dev_major, statx.stx_dev_minor); buf->st_ino = statx.stx_ino; buf->st_mode = statx.stx_mode; buf->st_nlink = statx.stx_nlink; buf->st_uid = statx.stx_uid; buf->st_gid = statx.stx_gid; - buf->st_rdev = ((statx.stx_rdev_minor & 0xff) - | (statx.stx_rdev_major << 8) - | ((statx.stx_rdev_minor & ~0xff) << 12)); + buf->st_rdev = makedev(statx.stx_rdev_major, statx.stx_rdev_minor); buf->st_size = statx.stx_size; buf->st_blksize = statx.stx_blksize; buf->st_blocks = statx.stx_blocks;