8220793: (fs) No support for changing modification time of symlink
Brian Burkhalter
brian.burkhalter at oracle.com
Fri Apr 19 00:24:15 UTC 2019
For issue [1] please review the patch [2]. It implements setting the access and modification times of an unfollowed symbolic link on Linux and macOS.
The patch uses the library function lutimes(3). The supported Unix platforms for lutimes() appear to be Linux and the BSDs, but neither Solaris (verified) nor AIX. Therefore the native function lutimes0() is a no-op for Unix platforms other than Linux and the BSDs.
For purposes of testing, a version of the test without the @requires tag was used to enable its execution on Solaris. The results of running the test without and with the library changes applied are as follows:
Test w/o fix Test with fix
Linux Fail [3] Pass
macOS Fail [3] Pass
Solaris Fail [4] Fail [5]
Windows Pass Pass
For Solaris, this represents a behavioral change from throwing a FileSystemException to silently not changing the time attributes of the link. I don’t know whether this is an acceptable change. The possibility of falling back to utimes(2) in lutimes0() does not work as it modifies the time attributes of the file pointed to by the link but leaves those of the link itself unchanged.
Thanks,
Brian
[1] https://bugs.openjdk.java.net/browse/JDK-8220793
[2] http://cr.openjdk.java.net/~bpb/8220793/webrev.00/
[3] FileSystemException from NIO
java.nio.file.FileSystemException: /var/folders/m5/7p8b2jls02bb8w1q571kvtgh0000gq/T/name1606909272325238266/link: Too many levels of symbolic links or unable to access attributes of symbolic link
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:96)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.setTimes(UnixFileAttributeViews.java:85)
at SymlinkTime.main(SymlinkTime.java:76)
[4] FileSystemException from NIO
java.nio.file.FileSystemException: /var/tmp/name18128007785949580669/link: Number of symbolic links encountered during path name traversal exceeds MAXSYMLINKS or unable to access attributes of symbolic link
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:96)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.setTimes(UnixFileAttributeViews.java:85)
at SymlinkTime.main(SymlinkTime.java:76)
[5] Test failure due to unexpected results
java.lang.RuntimeException: Link - modification time: expected 2001-09-09T01:47:40Z, actual 2019-04-18T22:23:08.772611Z;
access time: expected 2001-09-09T01:48:40Z, actual 2019-04-18T22:23:08.773325Z.
at SymlinkTime.check(SymlinkTime.java:105)
at SymlinkTime.main(SymlinkTime.java:83)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190418/568a855a/attachment.html>
More information about the nio-dev
mailing list