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)
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)
- relates to
-
JDK-8165323 (fs) Files.getFileStore fails with "Mount point not found" in chroot environment
- Resolved
-
JDK-8165852 (fs) Mount point not found for a file which is present in overlayfs
- Closed