python modules for handling disks and filesystems

Michael Stone michael at laptop.org
Sun Aug 3 16:54:32 UTC 2008


Ahmed,

I'm not aware of an agreed-upon solution to your problem but,
fortunately, there are many ways to approach your request. How important
is portability to you?

Anyway, here are two thoughts:

a) You might consider wrapping the appropriate syscalls or libc
functions with ctypes, e.g.

  http://dev.laptop.org/git?p=users/mstone/security;a=blob;f=rainbow/rainbow/util.py;hb=cli
  (MIT-licensed; very non-portable, but effective where it works)

Beware that calling sys_mount directly through glibc's mount will not
update /etc/mtab. This means that the 'mounted filesystems list' listed
by the 'mount' executable will not coincide with the contents of
/proc/mounts. Also beware of people who use Linux's mount-point
namespaces via unshare() or clone() w/ the CLONE_NEWNS flag.

(Naturally, other mechanisms for wrapping C functions into Python will
permit you to achieve similar ends.)

b) Talk to some system service or executable that already knows how to
deal with mounting; e.g. the 'mount' binary via subprocess or HAL over
D-Bus.

Regards,

Michael

P.S. - If you do find a standard way to accomplish this, please speak
up. I certainly could use one. :)




More information about the fedora-devel-list mailing list