FileStore... getRootPath() ?

John Hendrikx hjohn at xs4all.nl
Wed Jun 30 14:43:33 PDT 2010


Alan Bateman wrote:
> John Hendrikx wrote:
>> :
>>
>> Is this an oversight or is there perhaps an even more elegant way to 
>> find this information?
>>
>> Note that even on Linux, with just "one" root (/), the added choice 
>> for other volumes (which have different free space values) is 
>> invaluable for the user.  In other words, I'd like to present the 
>> user with the choice of for example: /, /data, /temp, /raid1 and /raid2.
> I think you're looking for the mount points, which FileStore doesn't 
> currently make available - it could do, but needs a bit of research to 
> make sure that we wouldn't have any issues on other platforms. 
Yes, the mount points would be the information I'd be looking for.  For 
the moment, it seems that the list of available FileStores matches 
pretty closely (atleast on Windows and Linux... I could test on Solaris 
as well).
> That said,  it's not clear to me that you'd want to present all of 
> them to the end-user and there probably isn't an easy way to filter 
> them either.
Well, the filtering would simply do the following (for Linux, Windows 
does not need any filtering, although applying the same filter would not 
adversely affect the result):

1) spaceAttribs.totalSpace() != 0;  (eliminates /proc, /sys, etc..)
2) fileStore.type() != "tmpfs"; (eliminates /dev, /dev/shm, etc..)

And although this is a bit of a kludge, on my test systems that leaves 
me with only the mountpoints, ie.:

/ (/dev/hda2)
/data (/dev/md0)
/raid1 (/dev/mapper/raid1)
/raid2 (/dev/mapper/raid2)
/temp (/dev/mapper/temp)

Those are then easy to present in a multi-column list with total size 
and free space information.

Reasons for needing such a list:

1) Allowing the user to select an entire volume (for backup, or 
(restore) destination) for example.
2) Giving the user a start point for navigating the directory tree (on 
Windows the drive letters work, although My Computer would be better.  
On Linux "/" works, but is clumsy... most native apps will have a list 
of mount points somewhere).
3) Informational.  Free and Total space shown in a monitoring 
application or perhaps to select a suitable location to install 
something big (with sufficient free space) :)

I realize what I'm trying to do is probably a bit beyond NIO2's scope -- 
but providing the user with a fully functional view of the filesystems 
on a (any?) system is now close to possible (hence why I'm trying this).

--John



More information about the nio-dev mailing list