JDK 9 RFR of 8165323: (fs) Files.getFileStore fails with "Mount point not found" in chroot environment

Brian Burkhalter brian.burkhalter at oracle.com
Wed Sep 14 21:13:04 UTC 2016

Please review at your convenience.

Issue:	https://bugs.openjdk.java.net/browse/JDK-8165323
Patch:	[1]

The build failure is due to the attempt to create a FileStore which on Linux requires that “/proc/mounts” exists and contains an entry for the ultimate parent of the path of interest. The path of interest in this case is one for which it is desired to determine whether a PosixFileAttributeView is supported. In a chroot environment, /proc/mounts might not exist or it might contain only minimal content, e.g.,

$ cat /proc/mounts
none /proc proc rw,relatime 0 0

The problem is circumvented by replacing the use of FileStore in jlink. With this change ‘make images’ succeeds in the chroot environment; a Linux-only standard regression test run is in progress.

While this change fixes the problematic failure in the build, it does not address the inability to create a FileStore in a chroot environment. Perhaps a separate issue should be filed for this problem? In particular, might it be possible in a chroot environment to create some kind of (potentially faked-out) FileStore when the path for which it is desired is absolute?



[1] diff

--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
@@ -188,7 +188,8 @@
             storeFiles(modules, release);
-            if (Files.getFileStore(root).supportsFileAttributeView(PosixFileAttributeView.class)) {
+            if (root.getFileSystem().supportedFileAttributeViews()
+                    .contains("posix")) {
                 // launchers in the bin directory need execute permission.
                 // On Windows, "bin" also subdirectories containing jvm.dll.
                 if (Files.isDirectory(bin)) {
@@ -282,8 +283,8 @@
                         StandardOpenOption.CREATE_NEW)) {
-                if (Files.getFileStore(root.resolve("bin"))
-                        .supportsFileAttributeView(PosixFileAttributeView.class)) {
+                if (root.resolve("bin").getFileSystem()
+                        .supportedFileAttributeViews().contains("posix")) {

More information about the nio-dev mailing list