Merge pull request #14135 from rmuir/jail_filestore_exception

Give a better exception when running from freebsd jail without enforce_statfs=1
This commit is contained in:
Robert Muir 2015-10-23 23:23:56 -04:00
commit c7f5911d1b
2 changed files with 13 additions and 1 deletions

View File

@ -84,7 +84,18 @@ class ESFileStore extends FileStore {
return getFileStoreWindows(path, fileStores);
}
FileStore store = Files.getFileStore(path);
final FileStore store;
try {
store = Files.getFileStore(path);
} catch (IOException unexpected) {
// give a better error message if a filestore cannot be retrieved from inside a FreeBSD jail.
if (Constants.FREE_BSD) {
throw new IOException("Unable to retrieve mount point data for " + path +
". If you are running within a jail, set enforce_statfs=1. See jail(8)", unexpected);
} else {
throw unexpected;
}
}
try {
String mount = getMountPointLinux(store);

View File

@ -304,6 +304,7 @@ public class Environment {
* no permissions to the actual mount point are required.
* <li>Exception handling has the same semantics as {@link Files#getFileStore(Path)}.
* <li>Works around https://bugs.openjdk.java.net/browse/JDK-8034057.
* <li>Gives a better exception when filestore cannot be retrieved from inside a FreeBSD jail.
* </ul>
*/
public static FileStore getFileStore(Path path) throws IOException {