summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-14 18:15:22 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-14 18:15:22 +0000
commit6b24178534c6c321134246d864c1bdde55800fa5 (patch)
treedf50e5396a900f6e0f8255e1b1c6bdca6406dd24
parent49b15b2161874e8c7cbb42a1d05619ce98fb4a92 (diff)
merge revision(s) 56559,56582,56584,56585: [Backport #12903]
* test/ruby/test_file.rb (TestFile#test_stat): fix noatime case. [ruby-core:77943] [Bug #12903] * 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/branches/ruby_2_3@56785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--ext/-test-/file/extconf.rb1
-rw-r--r--ext/-test-/file/fs.c28
-rw-r--r--test/ruby/test_file.rb4
-rw-r--r--version.h2
5 files changed, 43 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 1cde648e81..afde8df352 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Tue Nov 15 03:14:02 2016 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ext/-test/file/fs.c (get_atime_p): Updating of file access times
+ is enabled or not.
+
+Tue Nov 15 03:14:02 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * test/ruby/test_file.rb (TestFile#test_stat): fix noatime case.
+ [ruby-core:77943] [Bug #12903]
+
Tue Nov 15 03:09:39 2016 Shugo Maeda <shugo@ruby-lang.org>
* test/rinda/test_rinda.rb (test_make_socket_ipv6_multicast,
diff --git a/ext/-test-/file/extconf.rb b/ext/-test-/file/extconf.rb
index c4cfdadcaf..c1c26f215d 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..c9c3473257 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_noatime_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, "noatime?", get_noatime_p, 1);
}
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index f5a00f9e17..a4ddf1d74d 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -2,6 +2,7 @@
require 'test/unit'
require 'tempfile'
require "thread"
+require "-test-/file"
require_relative 'ut_eof'
class TestFile < Test::Unit::TestCase
@@ -358,6 +359,7 @@ class TestFile < Test::Unit::TestCase
sleep 2
File.write(path, "bar")
sleep 2
+ File.read(path)
File.chmod(0644, path)
sleep 2
File.read(path)
@@ -369,7 +371,7 @@ class TestFile < Test::Unit::TestCase
if stat.birthtime != stat.ctime
assert_in_delta t0+4, stat.ctime.to_f, delta
end
- unless /mswin|mingw/ =~ RUBY_PLATFORM
+ if /mswin|mingw/ !~ RUBY_PLATFORM && !Bug::File::Fs.noatime?(path)
# Windows delays updating atime
assert_in_delta t0+6, stat.atime.to_f, delta
end
diff --git a/version.h b/version.h
index 495c5da648..836779a41a 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.2"
#define RUBY_RELEASE_DATE "2016-11-15"
-#define RUBY_PATCHLEVEL 216
+#define RUBY_PATCHLEVEL 217
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 11