Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Sep 8 '12 at 15:16

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.