haskell-fswatch / hfsnotify

Unified Haskell interface for basic file system notifications
BSD 3-Clause "New" or "Revised" License
136 stars 40 forks source link

Does creation/deletion of a hard-link trigger a modification event? #93

Closed saurabhnanda closed 4 years ago

saurabhnanda commented 4 years ago

I'm trying to chase down some weird behavior where modification events are being triggered by fsnotify, if hard-links to files (withing watched directories) are either created or deleted.

Note: The hard-link is NOT being created inside the watched directory. Instead, a hard-link TO a watched file (i.e inside a watched directory) is being created in a directory that is not being watched.

I have been unable to pin-point what is causing these events to be triggered, but is this known/expected behaviour?

thomasjm commented 4 years ago

Yes I think this behavior makes sense, since the reference count for hard links is stored in the inode itself (I think) and therefore creating a new link will cause a change to the file metadata.

The man page for inotify actually mentions this explicitly, saying an IN_ATTRIB event will be fired when there's a change in link count.

thomasjm commented 4 years ago

@saurabhnanda I'm going to close this, but feel free to let me know if there are more questions or a feature request connected with it.