/** * Get the file store type of a path. for example, /dev/sdd1(store name) /w2-gst-dev40d(mount * point) ext4(type) * * @return file store type */ public String getFileStoreType(final String path) { File diskFile = new File(path); if (!diskFile.exists()) { diskFile = diskFile.getParentFile(); } Path currentPath = diskFile.toPath(); if (currentPath.isAbsolute() && Files.exists(currentPath)) { try { FileStore store = Files.getFileStore(currentPath); return store.type(); } catch (IOException e) { return null; } } return null; }
if ("tmpfs".equals(store.type())) { return false;
@Override public String type() { return in.type(); }
public static FsInfo.Path getFSInfo(NodePath nodePath) throws IOException { FsInfo.Path fsPath = new FsInfo.Path(); fsPath.path = nodePath.path.toAbsolutePath().toString(); // NOTE: we use already cached (on node startup) FileStore and spins // since recomputing these once per second (default) could be costly, // and they should not change: fsPath.total = adjustForHugeFilesystems(nodePath.fileStore.getTotalSpace()); fsPath.free = adjustForHugeFilesystems(nodePath.fileStore.getUnallocatedSpace()); fsPath.available = adjustForHugeFilesystems(nodePath.fileStore.getUsableSpace()); fsPath.type = nodePath.fileStore.type(); fsPath.mount = nodePath.fileStore.toString(); return fsPath; }
@Override public String type() { return fileStore.type(); }
@Override public String type() { return fileStore.type(); }
@Override public String type() { return fileStore.type(); }
@Override public String type() { return in.type(); }
@Override public String type() { return in.type(); }
@Override public String type() { return in.type(); }
@Override public String type() { return in.type(); }
FileSystem fs = FileSystems.getDefault(); for (Path rootPath : fs.getRootDirectories()) { try { FileStore store = Files.getFileStore(rootPath); System.out.println(rootPath + ": " + store.type()); } catch (IOException e) { System.out.println(rootPath + ": " + "<error getting store details>"); } }
import java.nio.*; .... for (FileStore store: FileSystems.getDefault().getFileStores()) { System.out.printf("%s: %s%n", store.name(), store.type()); }
public static String getSystemFileType(String filePath) throws IOException { File file = new File(filePath); if (!file.exists()) { file = file.getParentFile(); } return Files.getFileStore(file.toPath()).type(); } }
protected SpaceAvailableExtensionInfo doSpaceAvailable(int id, String path) throws IOException { Path nrm = resolveNormalizedLocation(path); ServerSession session = getServerSession(); if (log.isDebugEnabled()) { log.debug("doSpaceAvailable({})[id={}] path={}[{}]", session, id, path, nrm); } FileStore store = Files.getFileStore(nrm); if (log.isTraceEnabled()) { log.trace("doSpaceAvailable({})[id={}] path={}[{}] - {}[{}]", session, id, path, nrm, store.name(), store.type()); } return new SpaceAvailableExtensionInfo(store); }
@Test @Category( FileStores.class ) public void testFileStoresHaveAType() { for( FileStore store : FS.getFileStores() ) { assertThat( store.type()).isNotNull(); } }
public static FsInfo.Path getFSInfo(NodePath nodePath) throws IOException { FsInfo.Path fsPath = new FsInfo.Path(); fsPath.path = nodePath.path.toAbsolutePath().toString(); // NOTE: we use already cached (on node startup) FileStore and spins // since recomputing these once per second (default) could be costly, // and they should not change: fsPath.total = adjustForHugeFilesystems(nodePath.fileStore.getTotalSpace()); fsPath.free = adjustForHugeFilesystems(nodePath.fileStore.getUnallocatedSpace()); fsPath.available = adjustForHugeFilesystems(nodePath.fileStore.getUsableSpace()); fsPath.type = nodePath.fileStore.type(); fsPath.mount = nodePath.fileStore.toString(); return fsPath; }
public static FsInfo.Path getFSInfo(NodePath nodePath) throws IOException { FsInfo.Path fsPath = new FsInfo.Path(); fsPath.path = nodePath.path.toAbsolutePath().toString(); // NOTE: we use already cached (on node startup) FileStore and spins // since recomputing these once per second (default) could be costly, // and they should not change: fsPath.total = adjustForHugeFilesystems(nodePath.fileStore.getTotalSpace()); fsPath.free = adjustForHugeFilesystems(nodePath.fileStore.getUnallocatedSpace()); fsPath.available = adjustForHugeFilesystems(nodePath.fileStore.getUsableSpace()); fsPath.type = nodePath.fileStore.type(); fsPath.mount = nodePath.fileStore.toString(); return fsPath; }
@Test public void type() { Assert.assertEquals("Type of the file store should be \"shrinkwrap\"", "shrinkwrap", this.fileStore.type()); }
DiskStatus(FileStore fileStore) throws IOException { this(fileStore.type(), BytesValues.of(fileStore.getUsableSpace()), BytesValues.of(fileStore.getTotalSpace()), BytesValues.of(fileStore.getTotalSpace() - fileStore.getUnallocatedSpace()), (float) (fileStore.getTotalSpace() - fileStore.getUnallocatedSpace()) / fileStore.getTotalSpace() * 100); } }