diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-04-12 14:42:26 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-04-12 15:32:49 +0900 |
commit | a5688b5ce6e87a5b881a4d52d4e59b6fe807e807 (patch) | |
tree | ecd93ebe97fd601134c612042533dc4c4ab8a418 /file.c | |
parent | 799ea1d1540aca03542ee31647052343507a4b41 (diff) |
Support non-standard `struct stat` [Bug #17793]
On 32-bit Android:
* `st_dev`/`st_rdev` are not `dev_t`
* `st_mode` is not `mode_t`
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -577,7 +577,13 @@ rb_stat_cmp(VALUE self, VALUE other) static VALUE rb_stat_dev(VALUE self) { +#if SIZEOF_STRUCT_STAT_ST_DEV <= SIZEOF_DEV_T return DEVT2NUM(get_stat(self)->st_dev); +#elif SIZEOF_STRUCT_STAT_ST_DEV <= SIZEOF_LONG + return ULONG2NUM(get_stat(self)->st_dev); +#else + return ULL2NUM(get_stat(self)->st_dev); +#endif } /* @@ -747,7 +753,13 @@ static VALUE rb_stat_rdev(VALUE self) { #ifdef HAVE_STRUCT_STAT_ST_RDEV +# if SIZEOF_STRUCT_STAT_ST_RDEV <= SIZEOF_DEV_T return DEVT2NUM(get_stat(self)->st_rdev); +# elif SIZEOF_STRUCT_STAT_ST_RDEV <= SIZEOF_LONG + return ULONG2NUM(get_stat(self)->st_rdev); +# else + return ULL2NUM(get_stat(self)->st_rdev); +# endif #else return Qnil; #endif @@ -6254,7 +6266,11 @@ path_check_0(VALUE path) #endif && !access(p0, W_OK)) { rb_enc_warn(enc, "Insecure world writable dir %s in PATH, mode 0%" +#if SIZEOF_DEV_T > SIZEOF_INT PRI_MODET_PREFIX"o", +#else + "o", +#endif p0, st.st_mode); if (p) *p = '/'; RB_GC_GUARD(path); |