]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/nolibc: use makedev() in fstatat()
authorThomas Weißschuh <linux@weissschuh.net>
Sat, 4 Apr 2026 08:08:23 +0000 (10:08 +0200)
committerThomas Weißschuh <linux@weissschuh.net>
Sat, 4 Apr 2026 08:29:07 +0000 (10:29 +0200)
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 <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260404-nolibc-makedev-v2-6-456a429bf60c@weissschuh.net
tools/include/nolibc/sys/stat.h

index b2ef34a617ca11119994a8cb19db405f3d267e28..07ae715ff2536ae0ea48ed7d149459dbb3b6bfb5 100644 (file)
@@ -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;