Issue #7106 has been updated by kwilczynski (Krzysztof Wilczynski).


Hey,

Definitely a nice to have feature in the standard library :)

And so... few thoughts / ideas ...

On Linux, it would require both the glibc >= 2.6 and kernel >= 2.6.22 since lutimes() on linux uses the utimensat() system-call (and then do_times() which provides actual interface) with the AT_SYMLINK_NOFOLLOW flag set (defined in fcntl.h). In other words, it might cause problems to some people running older / ancient kernels or having old older glibc. Kernel and glibc would also have to support nanoseconds in the "timespec" struct (e.g. tv_nsec, etc) which is what a similar bug touches on: http://bugs.ruby-lang.org/issues/7109.

On *BSD, I guess both kernel and libc support it (at least as per the documentation).

Then, on Solaris / OpenSolaris (or anything that does not have necessary capability), we could create a new temporary symbolic link (with safe unpredictable and randomly generated name) and then move it over to clobber old symbolic link rely on the sheer fact that rename()[1] on most Unix-alike systems should be atomic (it is most of the time guaranteed to be such on the same file system) and should be fast (and in a case of any errors we do not loose original link; excluding critical I/O errors or sudden power down, etc).

On Windows... I have no idea :)

Anyway, hope that helps a little :)

1. http://linux.die.net/man/2/rename

KW
----------------------------------------
Feature #7106: FileUtils.touch should allow touching the symlink itself rather than the file the link points to
https://bugs.ruby-lang.org/issues/7106#change-30175

Author: cirrusthinking (Alessandro Diaferia)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 1.9.3


Most systems support POSIX lutimes sys call that allows a symlink to be touched. I'd like to see this feature implemented.
Unfortunately I'd like to see this feature on Solaris as soon as possible but I cannot see lutimes syscall supported there.


-- 
http://bugs.ruby-lang.org/