JDK-6648209 : File needs method to enumerate underlying file systems
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2008-01-08
  • Updated: 2011-02-16
  • Resolved: 2009-02-16
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
For a Windows system, File.listRoots() will provide a list of mounted partitions.  For a Unix or Linux system,File.listRoots() provides only one root, the root partition.  No information about other mounted partitions can be accessed.

JUSTIFICATION :
File.getTotalSpace(), File.getFreeSapce(), File.getUsableSpace() all proport to allow a user to manage his hard disk space.  For a windows machine, this is possible because File.listRoots() will actually provide the necessary information.  However, for Unix and Linux there is not way to find the drives to get this information.  So, for a Windows box, you can use these tools to explore and find a drive with the requisite space.  For Linux, this only reports the root partition and makes the system look like it has almost no hard drive space because you can't directly find the other hard drives where the partition is.

I am writing an display application to show the available hard drives and how much space is available on them.  Works great for Windows.  For Linux, I have to manually read /etc/fstab to get the partition information otherwise I can't find the drives to show the amount of space used.  Once I manually find the name of the partition, the space functions work correctly, so the only problem is getting the list of mounted partions to feed the space functions.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Need to get a list of mounted partitions for which File.getTotalSpace(), File.getFreeSapce(), File.getUsableSpace() will report results.
ACTUAL -
Function is not currently supported on Linux or Solaris.  Suggest:
File[]System.mountedPartitions()

CUSTOMER SUBMITTED WORKAROUND :
Manually reading /etc/ftab is the workaround.

Comments
EVALUATION JSR-203/NIO.2, in progress for jdk7, defines a method to enumerate the underlying file stores. Each file store can be queried to get its total/allocated/unallocated so writing a df(1M) like utility is trivial.
08-01-2008