listing mountpoints and getting their properties in Haskell

Hello! I need to list all currently mounted filesystems and get some stats like total space, free space, mount point and physical device. Is there any library capable of obtaining such information from OS itself? Parsing output of 'df' is locale-dependent and error-prone (because of locale settings, output settings etc). Thank you in advance. -- Eugene N Dzhurinsky

Eugene Dzhurinsky wrote:
Hello!
I need to list all currently mounted filesystems and get some stats like total space, free space, mount point and physical device.
Is there any library capable of obtaining such information from OS itself? Parsing output of 'df' is locale-dependent and error-prone (because of locale settings, output settings etc).
Stuff like mount points is Unix-specific, so have a dig around inside the POSIX library. (System.Posix.Files looks promising...) Finding the total free space on a filesystem is something that ought to be possible in a portable way though, and I don't see anything in the standard libraries for doing this.

Eugene Dzhurinsky
Hello!
I need to list all currently mounted filesystems and get some stats like total space, free space, mount point and physical device.
Is there any library capable of obtaining such information from OS itself? Parsing output of 'df' is locale-dependent and error-prone (because of locale settings, output settings etc).
Thank you in advance.
There's mount, which I think has a portable output format, and my df comes with the -P option to switch to POSIX output. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.

Eugene,
The only Linux function that can do this is `statvfs`. But binding to
it weren't implemented in the current libraries.
Year ago I implemented function that queries free size of the mounted
filesystem. The file is attached. To get other parameters you should
only extend `peek` function of the `Storable` class.
Hope it helps.
Vasyl
2010/2/27 Eugene Dzhurinsky
Hello!
I need to list all currently mounted filesystems and get some stats like total space, free space, mount point and physical device.
Is there any library capable of obtaining such information from OS itself? Parsing output of 'df' is locale-dependent and error-prone (because of locale settings, output settings etc).
Thank you in advance.
-- Eugene N Dzhurinsky
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Feb 27, 2010, at 11:47 , Eugene Dzhurinsky wrote:
Is there any library capable of obtaining such information from OS itself? Parsing output of 'df' is locale-dependent and error-prone (because of locale settings, output settings etc).
I don't know of any Haskell bindings offhand, but getmntent() and friends are the standard library interface for identifying mountpoints and statfs()/statvfs() are the interface for getting information about them. Be aware that the latter can be fairly system-dependent. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Sat, Feb 27, 2010 at 06:27:19PM -0500, Brandon S. Allbery KF8NH wrote:
I don't know of any Haskell bindings offhand, but getmntent() and friends are the standard library interface for identifying mountpoints and statfs()/statvfs() are the interface for getting information about them. Be aware that the latter can be fairly system-dependent.
getmntent() isn't in any standard I know about. IMHO, getting information about mounted filesystems will always be system dependent. Ciao, Kili

On Feb 28, 2010, at 05:17 , Matthias Kilian wrote:
On Sat, Feb 27, 2010 at 06:27:19PM -0500, Brandon S. Allbery KF8NH wrote:
I don't know of any Haskell bindings offhand, but getmntent() and friends are the standard library interface for identifying mountpoints and statfs()/statvfs() are the interface for getting information about them. Be aware that the latter can be fairly system-dependent.
getmntent() isn't in any standard I know about. IMHO, getting information about mounted filesystems will always be system dependent.
It's more of a de-facto standard, inherited from System V but not part of SVID and successors. Between Linux/glibc and Solaris you have a goodly chunk of the GHC-relevant world. *BSD and Mac OS X should look at getmntinfo(); I suspect that'll be painful to get at via the FFI, though. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (6)
-
Achim Schneider
-
Andrew Coppin
-
Brandon S. Allbery KF8NH
-
Eugene Dzhurinsky
-
Matthias Kilian
-
Vasyl Pasternak