1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/-test/file/fs.c (get_atime_p): Updating of file access times

is enabled or not.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2016-11-05 08:23:57 +00:00
parent a2144bd72a
commit 0fe34211f2
3 changed files with 34 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Sat Nov 5 17:18:24 2016 NARUSE, Yui <naruse@ruby-lang.org>
* ext/-test/file/fs.c (get_atime_p): Updating of file access times
is enabled or not.
Sat Nov 5 16:28:07 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> Sat Nov 5 16:28:07 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (extract_getline_opts): extract chomp option. * io.c (extract_getline_opts): extract chomp option.

View file

@ -5,6 +5,7 @@ headers = %w[sys/param.h sys/mount.h sys/vfs.h].select {|h| have_header(h)}
if have_type("struct statfs", headers) if have_type("struct statfs", headers)
have_struct_member("struct statfs", "f_fstypename", headers) have_struct_member("struct statfs", "f_fstypename", headers)
have_struct_member("struct statfs", "f_type", headers) have_struct_member("struct statfs", "f_type", headers)
have_struct_member("struct statfs", "f_flags", headers)
end end
headers = %w[sys/statvfs.h].select {|h| have_header(h)} headers = %w[sys/statvfs.h].select {|h| have_header(h)}

View file

@ -36,6 +36,12 @@ typedef struct statvfs statfs_t;
# if defined HAVE_STRUCT_STATVFS_F_TYPE # if defined HAVE_STRUCT_STATVFS_F_TYPE
# define HAVE_STRUCT_STATFS_T_F_TYPE 1 # define HAVE_STRUCT_STATFS_T_F_TYPE 1
# endif # endif
#elif defined(HAVE_STRUCT_STATFS_F_TYPE) /* Linux */
typedef struct statfs statfs_t;
# define STATFS(f, s) statfs((f), (s))
# if defined HAVE_STRUCT_STATFS_F_TYPE
# define HAVE_STRUCT_STATFS_T_F_TYPE 1
# endif
#endif #endif
VALUE VALUE
@ -72,9 +78,31 @@ get_fsname(VALUE self, VALUE str)
return Qnil; return Qnil;
} }
VALUE
get_atime_p(VALUE self, VALUE str)
{
#ifdef STATFS
statfs_t st;
FilePathValue(str);
str = rb_str_encode_ospath(str);
if (STATFS(StringValueCStr(str), &st) == -1) {
rb_sys_fail_str(str);
}
# ifdef HAVE_STRUCT_STATFS_F_FLAGS
# ifdef MNT_NOATIME
return st.f_flags & MNT_NOATIME ? Qtrue : Qfalse;
# elif defined(ST_NOATIME)
return st.f_flags & ST_NOATIME ? Qtrue : Qfalse;
# endif
# endif
#endif
return Qnil;
}
void void
Init_fs(VALUE module) Init_fs(VALUE module)
{ {
VALUE fs = rb_define_module_under(module, "Fs"); VALUE fs = rb_define_module_under(module, "Fs");
rb_define_module_function(fs, "fsname", get_fsname, 1); rb_define_module_function(fs, "fsname", get_fsname, 1);
rb_define_module_function(fs, "atime?", get_atime_p, 1);
} }