0

I'm writing pure C application which should be able to traverse some directory recursively. When I set / as this directory and application starts at some time I get fails of lstat() - I get list of nodes in directory and later when I'm doing lstat() on some of these nodes it fails. This often happens in /proc filesystem.

I know that this is dynamic filesystem which could be changed very often.

How can I traverse these filesystems? When at any time getting snapshot (nodes of directory) can be different from real state of filesystem. Also find / -iname "*" doesn't fails and shows files including inside /proc.

likern
  • 3,744
  • 5
  • 36
  • 47
  • I'm sorry, this sounds like a dumb question, but which language are you using to write the application? – gcandal Jul 12 '13 at 10:42
  • pure C application, with using libc and glib libraries. – likern Jul 12 '13 at 10:46
  • 'find' only gets the entries of the directory; it does not stat the entries individually. Had you done a stat on the entries ("find /proc/ |xargs stat >/dev/null"), you would have got a ENOENT for the stale files. – itisravi Jul 16 '13 at 06:49
  • But how this possible if find is traversing recursively? To get entries of directory 'find' should know that it's directory. How it can get entries of /var/tmp/test directory without checking that /var and later /var/tmp/ are directories too? – likern Jul 16 '13 at 15:10

0 Answers0