[#32986] [Ruby 1.9-Bug#4010][Open] YAML fails to roundtrip non ASCII String — Heesob Park <redmine@...>
Bug #4010: YAML fails to roundtrip non ASCII String
On Tue, Nov 02, 2010 at 09:58:27PM +0900, Heesob Park wrote:
[#33000] [Ruby 1.9-Bug#4014][Open] Case-Sensitivity of Property Names Depends on Regexp Encoding — Run Paint Run Run <redmine@...>
Bug #4014: Case-Sensitivity of Property Names Depends on Regexp Encoding
[#33021] Re: [Ruby 1.9-Feature#4015][Open] File::DIRECT Constant for O_DIRECT — Yukihiro Matsumoto <matz@...>
Hi,
Issue #4015 has been updated by Run Paint Run Run.
Issue #4015 has been updated by Motohiro KOSAKI.
[#33102] Re: Suggestion for MatchData#first and #last — Robert Klemme <shortcutter@...>
On Mon, Nov 8, 2010 at 9:34 AM, NARUSE, Yui <naruse@airemix.jp> wrote:
[#33120] Re: [Ruby 1.9-Feature#4038] IO#advise — KOSAKI Motohiro <kosaki.motohiro@...>
Hi
Issue #4038 has been updated by Motohiro KOSAKI.
[#33123] timer thread sleep interval (powertop abuses) — Chris Mason <chris.mason@...>
Hi everyone,
[#33139] [Ruby 1.9-Bug#4044][Open] Regex matching errors when using \W character class and /i option — Ben Hoskings <redmine@...>
Bug #4044: Regex matching errors when using \W character class and /i option
[#33162] Windows Unicode (chcp 65001) Generates incorrect output — Luis Lavena <luislavena@...>
Hello,
usa is having a fever now, so I reply though I don't remember the detail..
On Sun, Nov 21, 2010 at 10:26 AM, NARUSE, Yui <naruse@airemix.jp> wrote:
[#33209] Re: import racc parser generator to core — Ryan Davis <ryand-ruby@...>
[#33238] [Ruby 1.9-Feature#4065][Open] Rename or alias module#append_features to module#include_module — Chauk-Mean Proum <redmine@...>
Feature #4065: Rename or alias module#append_features to module#include_module
[#33246] [Ruby 1.9-Feature#4068][Open] Replace current standard Date/DateTime library with home_run — Jeremy Evans <redmine@...>
Feature #4068: Replace current standard Date/DateTime library with home_run
Issue #4068 has been updated by tadayoshi funaba.
Issue #4068 has been updated by tadayoshi funaba.
Hi,
[#33255] [Ruby 1.9-Feature#4071][Open] support basic auth for Net::HTTP.get requests — "coderrr ." <redmine@...>
Feature #4071: support basic auth for Net::HTTP.get requests
Issue #4071 has been updated by Yui NARUSE.
[#33314] [Ruby 1.9-Feature#4084][Open] pack should support 64bit network byte order longs — Aaron Patterson <redmine@...>
Feature #4084: pack should support 64bit network byte order longs
Issue #4084 has been updated by Yui NARUSE.
[#33322] [Ruby 1.9-Feature#4085][Open] Refinements and nested methods — Shugo Maeda <redmine@...>
Feature #4085: Refinements and nested methods
Hi,
Hi,
Hi,
Hi,
Hi,
Hi,
Hi,
Woah, this is very nice stuff! Some comments/questions:
Hi,
Hi,
This is a long response, and for that I apologize. I want to make sure
Hi,
Hello,
Hi,
Hello,
Hi,
Hi,
I think that, for this same reason, `using` should normally not apply
Hi,
Hello,
Hi,
Hi,
Hi,
Hi,
Hi,
Hi,
Hi,
On Sat, Dec 4, 2010 at 6:32 AM, Shugo Maeda <shugo@ruby-lang.org> wrote:
(2010/12/06 21:17), Charles Oliver Nutter wrote:
On Mon, Dec 6, 2010 at 8:48 AM, Urabe Shyouhei <shyouhei@ruby-lang.org> wrote:
Hi,
Hi,
Since I explained one use case I'd have for local rebinding: I think not having local rebinding is mostly what we want, local rebinding would mostly cause unwanted side effects and would be a pure horror to debug.
[#33338] [Ruby 1.9-Bug#4087][Open] String#scan(arg) taints results if arg is a Regexp but not if arg is a String — Brian Ford <redmine@...>
Bug #4087: String#scan(arg) taints results if arg is a Regexp but not if arg is a String
[#33367] Planning to release 1.8.7 fixes on 12/25 (Japanese timezone) — Urabe Shyouhei <shyouhei@...>
Hello,
2010/11/25 Urabe Shyouhei <shyouhei@ruby-lang.org>:
2010/11/25 Urabe Shyouhei <shyouhei@ruby-lang.org>:
(2010/11/28 5:55), Luis Lavena wrote:
On Sun, Nov 28, 2010 at 8:19 PM, Urabe Shyouhei <shyouhei@ruby-lang.org> wrote:
(2010/11/29 9:53), Luis Lavena wrote:
On Sun, Nov 28, 2010 at 17:19, Urabe Shyouhei <shyouhei@ruby-lang.org> wrote:
[#33456] [Request for Comment] avoid timer thread — SASADA Koichi <ko1@...>
Hi,
On Mon, Nov 29, 2010 at 11:53:03AM +0900, SASADA Koichi wrote:
On Tue, Feb 08, 2011 at 09:24:13PM +0900, Mark Somerville wrote:
Mark Somerville <mark@scottishclimbs.com> wrote:
On Sat, Jun 11, 2011 at 05:57:11AM +0900, Eric Wong wrote:
Mark Somerville <mark@scottishclimbs.com> wrote:
(2011/06/14 3:37), Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
Eric Wong <normalperson@yhbt.net> wrote:
Eric Wong <normalperson@yhbt.net> wrote:
On Sat, Jun 18, 2011 at 08:55:19AM +0900, Eric Wong wrote:
(2011/06/23 20:53), Mark Somerville wrote:
SASADA Koichi <ko1@atdot.net> wrote:
Eric Wong <normalperson@yhbt.net> wrote:
(2011/06/28 19:55), Eric Wong wrote:
[#33460] [Ruby 1.9-Bug#4097][Open] Unexpected result of STDIN.read on Windows — Heesob Park <redmine@...>
Bug #4097: Unexpected result of STDIN.read on Windows
[#33469] [Ruby 1.9-Feature#4100][Open] Improve Net::HTTP documentation — Eric Hodel <redmine@...>
Feature #4100: Improve Net::HTTP documentation
Issue #4100 has been updated by Yui NARUSE.
Issue #4100 has been updated by mathew murphy.
[#33491] [Ruby 1.9-Bug#4103][Open] String#hash not returning consistent values in different sessions — Ryan Ong <redmine@...>
Bug #4103: String#hash not returning consistent values in different sessions
[ruby-core:33163] [Ruby 1.9-Feature#4052][Open] File.lutime Patch
Feature #4052: File.lutime Patch http://redmine.ruby-lang.org/issues/show/4052 Author: Run Paint Run Run Status: Open, Priority: Normal Category: core This patch implements File.lutime, which behaves as File.utime except if given a symlink it acts upon the link itself rather than the referent. The naming convention follows that of the other singleton methods of File which treat symlinks specially. This functionality could be implemented by a gem, but given we already define File.lchmod, File.lchown, and File.lstat, it is inconsistent not to also define File.lutime. This functionality is provided by either lutimes(3), or utimensat(2) with the AT_SYMLINK_NOFOLLOW flag. The latter is standardised by POSIX <http://goo.gl/38pHx> Platform support is as follows: * FreeBSD - Has lutimes(2) since version 3. <http://goo.gl/9OWRF> * Mac OS - Has lutimes since at least version 10.5. <http://goo.gl/pSvM1> * OpenBSD - Appears to lack both APIs. * Linux - Supported lutimes(3) and utimensat(2) since version 2.6.22. (lutimes() is just a wrapper for utimensat()). <http://goo.gl/p29ja> * Windows - No support. For the status of esoteric platforms, consult http://goo.gl/Bf4Qm and http://goo.gl/7h6cj . On platforms that don't support either function, File.lutime raises a NotImplementedError. The portability logic is a bit hairy, so I'll summarise: 1 - File.lutime requires either lutimes() to be defined or both utimensat() and AT_SYMLINK_NOFOLLOW. I'm not aware of a practical case where utimensat() would be defined without AT_SYMLINK_NOFOLLOW. Further, File.lutime requires utimes(). This isn't strictly necessary, but simplifies the logic: it seems most unlikely that a platform would support either lutimes() or utimensat() without also supporting utimes(). 2 - Like File.utime, we prefer to use utimensat() as it provides better resolution than utimes(). 3 - If utimensat(..., AT_SYMLINK_NOFOLLOW) sets errno to ENOSYS, there are two possibilities: either the platform doesn't support the system call, or, like Linux 2.6.22 (<http://goo.gl/Bf4Qm>), utimensat() is defined but raises ENOSYS when given this flag. If utimensat() gives ENOSYS when it wasn't passed AT_SYMLINK_NOFOLLOW, we assume the syscall really doesn't exist, and bypass it for all future invocations of File.utime and File.lutime. If utimensat() gives ENOSYS when passed AT_SYMLINK_NOFOLLOW, or AT_SYMLINK_NOFOLLOW_ isn't defined, we bypass utimensat() for all future File.lutime invocations, but still consider it for future File.utime invocations. 4 - If we can't use utimensat() we fall back on lutimes(). 5 - If a platform defines utimensat() and AT_SYMLINK_NOFOLLOW, but the former gives ENOSYS when passed the latter, we also fall back on lutimes(). However, if the platform doesn't define lutimes(), we raise NotImplementedError. Tests are attached for File.utime when given a symlink and File.lutime. ---------------------------------------- http://redmine.ruby-lang.org
Attachments (1)
diff --git a/configure.in b/configure.in
index af5274d..d41d70b 100644
--- a/configure.in
+++ b/configure.in
@@ -1291,7 +1291,7 @@ else
fi
AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot getcwd eaccess\
truncate ftruncate chsize times utimes utimensat fcntl lockf lstat\
- link symlink readlink readdir_r fsync fdatasync fchown\
+ link lutimes symlink readlink readdir_r fsync fdatasync fchown\
setitimer setruid seteuid setreuid setresuid setproctitle socketpair\
setrgid setegid setregid setresgid issetugid pause lchown lchmod\
getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
diff --git a/file.c b/file.c
index dc9f830..0e80731 100644
--- a/file.c
+++ b/file.c
@@ -2195,6 +2195,7 @@ struct timespec rb_time_timespec(VALUE time);
struct utime_args {
const struct timespec* tsp;
VALUE atime, mtime;
+ int follow; /* Whether to act on symlinks (1) or their referent (0) */
};
#if defined DOSISH || defined __CYGWIN__
@@ -2246,11 +2247,24 @@ utime_internal(const char *path, void *arg)
#ifdef HAVE_UTIMENSAT
static int try_utimensat = 1;
+ static int try_utimensat_follow = 1;
+ int flags = 0;
- if (try_utimensat) {
- if (utimensat(AT_FDCWD, path, tsp, 0) < 0) {
+ if ((v->follow && try_utimensat_follow) || (!v->follow && try_utimensat)) {
+ if (v->follow) {
+#ifdef AT_SYMLINK_NOFOLLOW
+ flags = AT_SYMLINK_NOFOLLOW;
+#else
+ try_utimensat_follow = 0;
+ goto no_utimensat;
+#endif
+ }
+
+ if (utimensat(AT_FDCWD, path, tsp, flags) < 0) {
if (errno == ENOSYS) {
- try_utimensat = 0;
+ try_utimensat_follow = 0;
+ if (!v->follow)
+ try_utimensat = 0;
goto no_utimensat;
}
utime_failed(path, tsp, v->atime, v->mtime);
@@ -2267,7 +2281,16 @@ no_utimensat:
tvbuf[1].tv_usec = (int)(tsp[1].tv_nsec / 1000);
tvp = tvbuf;
}
- if (utimes(path, tvp) < 0)
+
+ if (v->follow) {
+#ifdef HAVE_LUTIMES
+ if (lutimes(path, tvp) < 0)
+ utime_failed(path, tsp, v->atime, v->mtime);
+#else
+ rb_notimplement();
+#endif
+ }
+ else if (utimes(path, tvp) < 0)
utime_failed(path, tsp, v->atime, v->mtime);
}
@@ -2297,17 +2320,8 @@ utime_internal(const char *path, void *arg)
#endif
-/*
- * call-seq:
- * File.utime(atime, mtime, file_name,...) -> integer
- *
- * Sets the access and modification times of each
- * named file to the first two arguments. Returns
- * the number of file names in the argument list.
- */
-
static VALUE
-rb_file_s_utime(int argc, VALUE *argv)
+utime_internal_i(int argc, VALUE *argv, int follow)
{
VALUE rest;
struct utime_args args;
@@ -2317,6 +2331,8 @@ rb_file_s_utime(int argc, VALUE *argv)
rb_secure(2);
rb_scan_args(argc, argv, "2*", &args.atime, &args.mtime, &rest);
+ args.follow = follow;
+
if (!NIL_P(args.atime) || !NIL_P(args.mtime)) {
tsp = tss;
tsp[0] = rb_time_timespec(args.atime);
@@ -2328,6 +2344,45 @@ rb_file_s_utime(int argc, VALUE *argv)
return LONG2FIX(n);
}
+/*
+ * call-seq:
+ * File.utime(atime, mtime, file_name,...) -> integer
+ *
+ * Sets the access and modification times of each named file to the
+ * first two arguments. If a file is a symlink, this method acts upon
+ * its referent rather than the link itself; for the inverse
+ * behavior see <code>File.lutime</code>. Returns the number of file
+ * names in the argument list.
+ */
+
+static VALUE
+rb_file_s_utime(int argc, VALUE *argv)
+{
+ return utime_internal_i(argc, argv, 0);
+}
+
+#if defined(HAVE_UTIMES) && (defined(HAVE_LUTIMES) || (defined(HAVE_UTIMENSAT) && defined(AT_SYMLINK_NOFOLLOW)))
+
+/*
+ * call-seq:
+ * File.lutime(atime, mtime, file_name,...) -> integer
+ *
+ * Sets the access and modification times of each named file to the
+ * first two arguments. If a file is a symlink, this method acts upon
+ * the link itself as opposed to its referent; for the inverse
+ * behavior, see <code>File.utime</code>. Returns the number of file
+ * names in the argument list.
+ */
+
+static VALUE
+rb_file_s_lutime(int argc, VALUE *argv)
+{
+ return utime_internal_i(argc, argv, 1);
+}
+#else
+#define rb_file_s_lutime rb_f_notimplement
+#endif
+
NORETURN(static void sys_fail2(VALUE,VALUE));
static void
sys_fail2(VALUE s1, VALUE s2)
@@ -5319,6 +5374,7 @@ Init_File(void)
rb_define_singleton_method(rb_cFile, "chown", rb_file_s_chown, -1);
rb_define_singleton_method(rb_cFile, "lchmod", rb_file_s_lchmod, -1);
rb_define_singleton_method(rb_cFile, "lchown", rb_file_s_lchown, -1);
+ rb_define_singleton_method(rb_cFile, "lutime", rb_file_s_lutime, -1);
rb_define_singleton_method(rb_cFile, "link", rb_file_s_link, 2);
rb_define_singleton_method(rb_cFile, "symlink", rb_file_s_symlink, 2);
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index 1d45b97..1d16c3d 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -346,6 +346,41 @@ class TestFileExhaustive < Test::Unit::TestCase
File.utime(t + 1, t + 2, @zerofile)
assert_equal(t + 1, File.atime(@zerofile))
assert_equal(t + 2, File.mtime(@zerofile))
+ skip("File.symlink not implemented") unless (File.respond_to?(:symlink) and @symlinkfile)
+ stat_ln = File.lstat(@symlinkfile)
+ assert_equal(File.utime(t, t, @symlinkfile), 1)
+ assert_equal(File.stat(@file).atime, t)
+ assert_equal(File.stat(@file).mtime, t)
+ assert_equal(File.lstat(@symlinkfile).atime, stat_ln.atime)
+ assert_equal(File.lstat(@symlinkfile).mtime, stat_ln.mtime)
+ end
+
+ def test_lutime
+ skip("File.lutime not implemented") unless File.respond_to?(:lutime)
+ Dir.mktmpdir('rubytest-lutime') do |tmp|
+ Dir.chdir(tmp) do
+ open('f',?w){}
+ times = [Time.now - 24*100, Time.now - 24*1_000].map(&:round)
+ assert_equal(File.lutime(times[0], times[0], ?f), 1)
+ assert_equal(File.stat(?f).atime.round, times[0])
+ assert_equal(File.stat(?f).mtime.round, times[0])
+
+ # Assume that a platform supporting changing utimens on symlinks
+ # also supports symlinks
+ File.symlink(?f, ?l)
+ assert_equal(File.lutime(times[1], times[1], ?l), 1)
+ assert_equal(File.stat(?f).atime.round, times[0])
+ assert_equal(File.stat(?f).mtime.round, times[0])
+ assert_equal(File.lstat(?l).atime.round, times[1])
+ assert_equal(File.lstat(?l).mtime.round, times[1])
+
+ assert_equal(File.lutime(times[1], times[0], ?l, ?f), 2)
+ assert_equal(File.stat(?f).atime.round, times[1])
+ assert_equal(File.stat(?f).mtime.round, times[0])
+ assert_equal(File.lstat(?l).atime.round, times[1])
+ assert_equal(File.lstat(?l).mtime.round, times[0])
+ end
+ end
end
def test_hardlink