mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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`
This commit is contained in:
parent
799ea1d154
commit
a5688b5ce6
2 changed files with 21 additions and 0 deletions
|
@ -1693,6 +1693,7 @@ RUBY_CHECK_SIGNEDNESS(size_t, [AC_MSG_ERROR(size_t is signed)], [],
|
|||
[@%:@include <sys/types.h>])
|
||||
RUBY_CHECK_SIZEOF(size_t, [int long void*], [], [@%:@include <sys/types.h>])
|
||||
RUBY_CHECK_SIZEOF(ptrdiff_t, size_t, [], [@%:@include <stddef.h>])
|
||||
RUBY_CHECK_SIZEOF(dev_t)
|
||||
RUBY_CHECK_PRINTF_PREFIX(size_t, z)
|
||||
RUBY_CHECK_PRINTF_PREFIX(ptrdiff_t, t)
|
||||
AC_CHECK_MEMBERS([struct stat.st_blksize])
|
||||
|
@ -1703,6 +1704,10 @@ AS_IF([test "$ac_cv_member_struct_stat_st_blocks" = yes], [
|
|||
RUBY_CHECK_SIZEOF([struct stat.st_blocks], [off_t int long "long long"], [], [@%:@include <sys/stat.h>])
|
||||
])
|
||||
RUBY_CHECK_SIZEOF([struct stat.st_ino], [long "long long"], [], [@%:@include <sys/stat.h>])
|
||||
RUBY_CHECK_SIZEOF([struct stat.st_dev], [dev_t int long "long long"], [], [@%:@include <sys/stat.h>])
|
||||
AS_IF([test "$ac_cv_member_struct_stat_st_rdev" = yes], [
|
||||
RUBY_CHECK_SIZEOF([struct stat.st_rdev], [dev_t int long "long long"], [], [@%:@include <sys/stat.h>])
|
||||
])
|
||||
AC_CHECK_MEMBERS([struct stat.st_atim])
|
||||
AC_CHECK_MEMBERS([struct stat.st_atimespec])
|
||||
AC_CHECK_MEMBERS([struct stat.st_atimensec])
|
||||
|
|
16
file.c
16
file.c
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue