]> go.fuhry.dev Git - fsnotify.git/commit
Do not suppress Chmod on non-existent file (#260)
authorKir Kolyshkin <kolyshkin@gmail.com>
Thu, 21 Jul 2022 11:32:11 +0000 (04:32 -0700)
committerGitHub <noreply@github.com>
Thu, 21 Jul 2022 11:32:11 +0000 (13:32 +0200)
commit4193dfd6fb01f55805360fc55b3f46be8749808c
tree21e8e85985278842f89356d13f6038f0d67e9100
parent6ae56b78f545a5be2fc9e9bb6013443a35716fc4
Do not suppress Chmod on non-existent file (#260)

Currently fsnotify suppresses a Chmod event if the file does not exist
when the event is received.

This makes it impossible to use fsnotify to detect when an opened file
is removed. In such case the Linux kernel sends IN_ATTRIB event,
as described in inotify(7) man page:

> IN_ATTRIB (*)
>        Metadata  changed—for example, permissions (e.g., chmod(2)),
>        timestamps (e.g., utimensat(2)), extended attributes  (setx‐
>        attr(2)), link count (since Linux 2.6.25; e.g., for the tar‐
>        get of link(2) and for unlink(2)), and user/group ID  (e.g.,
>        chown(2)).

(to clarify, in this very case it's link count that changes).

To fix:
 * Modify the code to only suppress MODIFY and CREATE events.
 * Add a test case to verify Chmod event is delivered.

While at it, fix the comment in ignoreLinux() to use the up-to-date
terminology (event ops).

A test case is added.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
inotify.go
inotify_test.go