Python find

G

George Sakkis

Hi all,

I started writing a module to reproduce Gnu-find functionality in python (as
far as I know, there's not one available; pyfind
(http://www.anti-particle.com/pyfind.shtml) seems a bit relevant from it's
webpage, though most links there are broken - also it's more of a standalone
GUI tool than a reusable module). Some questions I have for now:

- How can one get the filesystem name from python (e.g. for testing
'find -fstype nfs') ?
- Does os.readlink perform a call to os.stat or os.lstat (or the equivalent
C system calls) ? If yes, I would like to rewrite it for the case the stat
info for a file has already been cached.
- Before I write it from scratch, is there a converter for Unix permission
strings (like "+go=rw") to numeric modes ?

Thanks,

George
 
J

Jeff Epler

- How can one get the filesystem name from python (e.g. for testing
'find -fstype nfs') ?

You need to call "statfs" which I don't believe is available in Python
without an extension module.

I only know of the incomplete list of magic numbers to filesystem types
listed in "man statfs", not a real way to find the filesystem name.

Another option would getmntent() or (linux only) parsing /proc/mounts
parser.
- Does os.readlink perform a call to os.stat or os.lstat (or the equivalent
C system calls) ? If yes, I would like to rewrite it for the case the stat
info for a file has already been cached.

No, at least on my system it uses the readlink syscall. I don't see the
readlink information contained anywhere in the stat/lstat structure.
- Before I write it from scratch, is there a converter for Unix permission
strings (like "+go=rw") to numeric modes ?

Not that I recall seeing...

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top