summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 08:23:57 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 08:23:57 +0000
commit0fe34211f226115a50afb8df0cab3970eff25d62 (patch)
tree10e0cd3e0f536d85fad948fd33e39bb38f66f7bb
parenta2144bd72aad7c25e160cf283f957d59fe7c90b2 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--ext/-test-/file/extconf.rb1
-rw-r--r--ext/-test-/file/fs.c28
3 files changed, 34 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a0c58e74f9..bac0f2b71d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* io.c (extract_getline_opts): extract chomp option.
diff --git a/ext/-test-/file/extconf.rb b/ext/-test-/file/extconf.rb
index 321c173f4c..9027ed1c3e 100644
--- a/ext/-test-/file/extconf.rb
+++ b/ext/-test-/file/extconf.rb
@@ -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)
have_struct_member("struct statfs", "f_fstypename", headers)
have_struct_member("struct statfs", "f_type", headers)
+ have_struct_member("struct statfs", "f_flags", headers)
end
headers = %w[sys/statvfs.h].select {|h| have_header(h)}
diff --git a/ext/-test-/file/fs.c b/ext/-test-/file/fs.c
index d3fa5350e5..06f03756ad 100644
--- a/ext/-test-/file/fs.c
+++ b/ext/-test-/file/fs.c
@@ -36,6 +36,12 @@ typedef struct statvfs statfs_t;
# if defined HAVE_STRUCT_STATVFS_F_TYPE
# define HAVE_STRUCT_STATFS_T_F_TYPE 1
# 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
VALUE
@@ -72,9 +78,31 @@ get_fsname(VALUE self, VALUE str)
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
Init_fs(VALUE module)
{
VALUE fs = rb_define_module_under(module, "Fs");
rb_define_module_function(fs, "fsname", get_fsname, 1);
+ rb_define_module_function(fs, "atime?", get_atime_p, 1);
}