getfsstat(2) based BsdFileSystem.getMountEntries()
Kurt Miller
kurt at intricatesoftware.com
Tue May 26 07:46:20 PDT 2009
The current BsdFileSystem.getMountEntries() implementation parses
/etc/fstab. Apple doesn't use /etc/fstab so that wont work for Apple,
however all BSD's and Apple have getfsstat(2). Please test the attached
patch on OS X to see if it makes the following test program work:
*** MountTest.java ***:
import java.util.*;
import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.*;
class MountTest {
public static void main(String[] a) {
for (FileStore store: FileSystems.getDefault().getFileStores()) {
System.out.println("FileStore: " + store);
System.out.println(" type: " + store.type() +
" isReadOnly: " + store.isReadOnly());
try {
FileStoreSpaceAttributes attrs =
Attributes.readFileStoreSpaceAttributes(
store);
long total = attrs.totalSpace() / 1024;
long used = (attrs.totalSpace() - attrs.unallocatedSpace()) / 1024;
long avail = attrs.usableSpace() / 1024;
System.out.format(" total %12d used %12d avail %12d%n", total,
used, ava
il);
} catch(IOException ex) {
ex.printStackTrace();
}
}
}
}
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: getfsstat.diff
Url: http://mail.openjdk.java.net/pipermail/bsd-port-dev/attachments/20090526/11d34dc2/getfsstat.diff
More information about the bsd-port-dev
mailing list