Some Python posix-related questions

John Abel john.abel at
Tue Feb 25 10:38:27 CET 2003


Can only help you with no 1, I'm afraid.  The easiest way, is to parse 
/etc/mnttab, though again, this isn't that portable, though this is 
basically what df does.  If you do, then you could use:

def GetSpace( path ):
    s = os.statvfs(path)
    return s[statvfs.F_BAVAIL] * long(s[statvfs.F_BSIZE])



Tim Daneliuk wrote:

> 1) On Unix-like (posix) systems, is there some reasonably straighforward
>    way to get the mount information back.  What I really want is:
>      - The device name
>      - Total available space
>      - Available free space
>      - Mount point
>   I would prefer to not have to parse the results of the 'df' command to
>   do this, since I cannot guarantee portability of the output of this
>   command on all systems.
> 2) What does Mac OS X return for  I have a program that is
>    coded to work properly when returns 'nt' or 'posix'.  I
>    was kinda hoping that OS X returns 'posix' (and my program should
>    thus work there), as I have no access to such as system.
> TIA,
> ------------------------------------------------------------------------------
> Tim Daneliuk
> tundra at

More information about the Python-list mailing list