Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8166162

(fs) Cannot obtain FileStore if device of path is not in /proc/mounts

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 9
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
      None

      Description

      If the class GetFileStore included below is for example run in a chroot environment it will fail with an IOException whose message is "Mount point not found".

      import java.nio.file.Files;
      import java.nio.file.FileStore;
      import java.nio.file.Path;
      import java.nio.file.Paths;

      public class GetFileStore {
          public static void main(String[] args) throws Throwable {
              String userDir = System.getProperty("user.dir");
              System.out.printf("Retrieving FileStore for %s%n", userDir);
              Path path = Paths.get(userDir);
              FileStore fileStore = Files.getFileStore(path);
              System.out.printf("%s is in FileStore %s of type %s%n",
                                userDir, fileStore.name(), fileStore.type());
          }
      }

      For example if /proc/mounts contains only

      none /proc proc rw,relatime 0 0

      running the above class within /home behaves as follows:

      /home# java GetFileStore
      Retrieving FileStore for /home
      Exception in thread "main" java.io.IOException: Mount point not found
      at sun.nio.fs.LinuxFileStore.findMountEntry(java.base/LinuxFileStore.java:91)
      at sun.nio.fs.UnixFileStore.<init>(java.base/UnixFileStore.java:65)
      at sun.nio.fs.LinuxFileStore.<init>(java.base/LinuxFileStore.java:44)
      at sun.nio.fs.LinuxFileSystemProvider.getFileStore(java.base/LinuxFileSystemProvider.java:51)
      at sun.nio.fs.LinuxFileSystemProvider.getFileStore(java.base/LinuxFileSystemProvider.java:39)
      at sun.nio.fs.UnixFileSystemProvider.getFileStore(java.base/UnixFileSystemProvider.java:369)
      at java.nio.file.Files.getFileStore(java.base/Files.java:1464)
      at GetFileStore.main(GetFileStore.java:11)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bpb Brian Burkhalter
                Reporter:
                bpb Brian Burkhalter
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: