I'm know I can monitor (using poll, or select) on the files /proc/mount or /etc/mtab and findout WHEN a filesystem is mounted or unmounted. Also I can use getmntent for getting a list of mounted filesystems.

My app is intended to monitor the mounted filesystem and report any change (mount or unmount).

My solution:

  1. Detect some change in /proc/mounts.
  2. Get all currently mounted filesystem with getmntent.
  3. Compare the obtained list with some previous list.
  4. Process the difference.

But I need to know if there are some way to get the last filesystem mounted when polling from /proc/mounts or /etc/mtab. Just reading the file or polling data into some structure (like mntent for instance.)

  • 1
    The Audit framework and the associated user space daemon, auditd, is the right tool for monitoring system calls, including mount(2), I think. – Sami Laine Apr 26 '14 at 11:56
  • It is a good tool, but I don't want my app to depend on others. – Raydel Miranda Apr 28 '14 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.