Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As the title implies, I want to know how to watch disk free space change on Linux instead polling it periodically via statfs. When the free space is changed, a signal is emitted to allow the application having a chance to handle the change event.

On Windows, it can be done by FindFirstChangeNotification with FILE_NOTIFY_CHANGE_SIZE. When the free space is changed, the HANDLE object returend by FindFirstChangeNotification gets signaled and let application do something.

Is there any similar way to do that on Linux? Thanks.

share|improve this question

migrated from Sep 8 '12 at 15:16

This question came from our site for professional and enthusiast programmers.

Not exactly the same, but you could use inotify with IN_MODIFY.

share|improve this answer
But inotify can not watch the directory recursively. Suppose the /dev/sda1 is mounted at /home, the changes in the sub-directories of /home can not trigger inotify which is watching /hoem. – Bob Sep 8 '12 at 10:13

You must log in to answer this question.