summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2025-06-11 23:29:41 +0900
committerNobuyoshi Nakada <[email protected]>2025-06-13 19:35:52 +0900
commitc7f5ae981a36405f4161c7ee7fe8cd0186c8d89f (patch)
tree6cbb4f9be3cdcd4900adb00257309682df1bb04c /file.c
parent071aa02a4ad989916feaf74cd14633ac0e7d0728 (diff)
The device numbers in `struct statx` may be larger than `dev_t`
`dev_t` is already 64-bit in glibc, but on some platforms like Alpine Linux and Android NDK, `makedev` is defined as more than 32-bit ( promoting to `unsigned long long` then left-shifting by 32bit), while `dev_t` is still 32-bit.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13607
Diffstat (limited to 'file.c')
-rw-r--r--file.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/file.c b/file.c
index 322df6dbec..936e0cdb95 100644
--- a/file.c
+++ b/file.c
@@ -662,7 +662,7 @@ rb_stat_dev(VALUE self)
#if RUBY_USE_STATX
unsigned int m = get_stat(self)->stx_dev_major;
unsigned int n = get_stat(self)->stx_dev_minor;
- return DEVT2NUM(makedev(m, n));
+ return ULL2NUM(makedev(m, n));
#elif SIZEOF_STRUCT_STAT_ST_DEV <= SIZEOF_DEV_T
return DEVT2NUM(get_stat(self)->st_dev);
#elif SIZEOF_STRUCT_STAT_ST_DEV <= SIZEOF_LONG
@@ -833,7 +833,7 @@ rb_stat_rdev(VALUE self)
#if RUBY_USE_STATX
unsigned int m = get_stat(self)->stx_rdev_major;
unsigned int n = get_stat(self)->stx_rdev_minor;
- return DEVT2NUM(makedev(m, n));
+ return ULL2NUM(makedev(m, n));
#elif !defined(HAVE_STRUCT_STAT_ST_RDEV)
return Qnil;
#elif SIZEOF_STRUCT_STAT_ST_RDEV <= SIZEOF_DEV_T