os.statvfs on FreeBSD

Martin von Loewis loewis at informatik.hu-berlin.de
Sun Jun 17 13:27:19 CEST 2001

t_messmer at yahoo.com (Tom Messmer) writes:

> Thanks for looking at this, I took some time and noticed that there
> was really no statvfs system call in FreeBSD (stable) and thought it
> might be possible to use the statfs call and map it to the same tuple
> returned by python's os.statvfs routine. Er, but thats as far as I got
> with it so far because I'm new at Python and not much of a programmer
> anyway. I looked at the os module itself and saw that it calls posix
> for unix-like systems, but from there I couldnt tell how it accesses
> system calls. If someone would care to explain this I'd love to hear
> about it

It's really not that difficult: os.py gets most functions from the
posix module on your system. This, in turn, is implemented in
Modules/posixmodule.c. It provides statvfs if the configure had
detected the system call in the C library, and had thus defined

If you look at posix_statvfs, you see that it really only calls the OS
statvfs, and then builds a Python tuple from the results.

If the system provides statfs, I think it would be better to support
this in addition to statvfs. The fields of the calls vary slightly in
their semantics, and an application might need to know whether it got
the real values from the system, or emulated values.

If you want to provide statfs in posixmodule, just model it after
statvfs. Search the entire Python source code for all occurrences of
statvfs (take particular notice of those in configure.in). If you
succeed, please post your patch to sf.net/projects/python.


More information about the Python-list mailing list