how to determine if files are on same or different file systems

Jeff Epler jepler at unpythonic.net
Sun Dec 7 22:35:27 EST 2003


You can find the device a file is on using the .st_dev field of its stat
information:
	>>> os.stat("/").st_dev
see the stat manpage for more details.

You can find the magic number for a particular filesystem using statfs(2),
but as far as I can tell this is not exposed in Python.  If it were,
you'd write something like
	>>> os.statfs("/").f_type
to get the type of the filesystem where / resides.  Some f_type values
are mentioned in my statfs(2) manpage, including 
	NFS_SUPER_MAGIC       0x6969
os.statvfs() seems to be unrelated, though my system lacks a manpage for
it.

Jeff





More information about the Python-list mailing list