Subject: Re: bug#26126: 26.0.50; file-notify-rm-watch removes arbitrary watches

From: Andreas Politz <[email-masked]>
Date: Fri, 24 Mar 2017 21:44:28 +0100

Hey !

Below is a second version of the previous patch.  It is somewhat
conservative, since neither did I attempt to

+ further simplify filenotify.el nor

+ handle differing masks in inotify.c .

--

I also thought about the test-cases and more generally about how to
develop a specification for this library, i.e. how do we want this to
behave.  Do we have the desire that it works uniformly across all
participating back-ends ? And is that even possible ?

I think it is to easy to adapt the tests for each back-end, until they
succeed and thereby potentially masking actual bugs.

One way to go about this would be to write a series of definitive
unit-tests which specify the intended behavior. Then, allow them to fail
for a specific back-end, until someone has fixed potential bugs for it
and confirmed that the test succeeds.  This would allow for an
incremental improvement on fairly solid grounds.  I'm assuming that
people of the future are interested in improving their used back-end
(e.g. make kqueue watch directories properly, if that is possible).

Anyway, I was bored today, so I took a look at what events these
libraries actually produce, the result of which you may also find below.

Finally, I'm tempted to suggest to get rid of the flags argument of
file-notify-add-watch.  As it is, things are already complicated enough
and we don't seem to have many people working on this.  I think we could
make it backward-compatible to a certain degree.  Note also, that many
file operations trigger both kinds of events anyway.

--

--

                            inotify                         w32notify                       kqueue                          gfilenotify                     gvfs-monitor-dir                inotifywait
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
file-create     file        created file                    created file                    skipped                         created file                    created file                    created file
                            deleted file                    deleted file                                                    deleted file                    attr-changed file               attr-changed file
                            stopped file                    stopped file                                                    stopped file                    deleted file                    deleted file
                                                                                                                                                            stopped file                    stopped file

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
file-read       file        deleted file                    deleted file                    deleted file                    deleted file                    deleted file                    deleted file
                            stopped file                    stopped file                    stopped file                    stopped file                    stopped file                    stopped file

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
file-write      file        changed file                    changed file                    attr-changed file               changed file                    changed file                    changed file
                            deleted file                    changed file                    changed file                    changed file                    changed file                    changed file
                            stopped file                    deleted file                    deleted file                    deleted file                    attr-changed file               attr-changed file
                                                            stopped file                    stopped file                    stopped file                    deleted file                    deleted file
                                                                                                                                                            stopped file                    stopped file

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
file-attrib     file        attr-changed file               changed file                    attr-changed file               attr-changed file               attr-changed file               attr-changed file
                            deleted file                    deleted file                    deleted file                    deleted file                    deleted file                    deleted file
                            stopped file                    stopped file                    stopped file                    stopped file                    stopped file                    stopped file

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
file-rename     dir         renamed dir/src dir/dest        deleted dir/dest                deleted dir                     renamed dir/src dir/dest        renamed dir/src dir/dest        renamed dir/src dir/dest
                            created dir/dest                renamed dir/src dir/dest        stopped dir                     deleted dir/dest                attr-changed dir/dest           attr-changed dir/dest
                            deleted dir/dest                timedout 12                                                     deleted dir                     attr-changed dir/dest           attr-changed dir/dest
                            deleted dir                     stopped dir                                                     stopped dir                     deleted dir/dest                deleted dir/dest
                            stopped dir                                                                                                                     deleted dir                     deleted dir
                                                                                                                                                            stopped dir                     stopped dir

                dir/src     deleted dir                     timedout 12                     deleted dir/src                 renamed dir/src dir/dest        renamed dir/src dir/dest        renamed dir/src dir/dest
                            stopped dir/src                 stopped dir/src                 stopped dir/src                 stopped dir/src                 stopped dir/src                 stopped dir/src
                                                                                            deleted dir/src

                dir/dest    renamed dir/src dir/dest        deleted dir/dest                deleted dir/dest                renamed dir/src dir/dest        renamed dir/src dir/dest        renamed dir/src dir/dest
                            deleted dir/dest                stopped dir/dest                stopped dir/dest                deleted dir/dest                attr-changed dir/dest           attr-changed dir/dest
                            stopped dir/dest                                                                                stopped dir/dest                attr-changed dir/dest           attr-changed dir/dest
                                                                                                                                                            deleted dir/dest                deleted dir/dest
                                                                                                                                                            stopped dir/dest                stopped dir/dest

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dir-create      dir         created dir                     created dir                     skipped                         created dir                     created dir                     created anon-1
                            deleted dir                     deleted dir                                                     deleted dir                     deleted dir                     deleted anon-1
                            stopped dir                     stopped dir                                                     stopped dir                     stopped dir                     timedout 12
                                                                                                                                                                                            stopped dir

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dir-read        dir         deleted dir                     timedout 12                     deleted dir                     deleted dir                     deleted dir                     deleted dir
                            stopped dir                     stopped dir                     stopped dir                     stopped dir                     stopped dir                     stopped dir

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dir-create-file dir         deleted dir/file                deleted dir/file                deleted dir                     deleted dir/file                deleted dir/file                deleted dir/file
                            deleted dir                     timedout 12                     stopped dir                     deleted dir                     deleted dir                     deleted dir
                            stopped dir                     stopped dir                                                     stopped dir                     stopped dir                     stopped dir

                dir/file    deleted dir/file                deleted dir/file                deleted dir/file                deleted dir/file                deleted dir/file                deleted dir/file
                            stopped dir/file                stopped dir/file                stopped dir/file                stopped dir/file                stopped dir/file                stopped dir/file

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dir-create-dir  dir         deleted dir/dir                 deleted dir/dir                 deleted dir                     deleted dir/dir                 deleted dir/dir                 deleted dir
                            deleted dir                     timedout 12                     stopped dir                     deleted dir                     deleted dir                     stopped dir
                            stopped dir                     stopped dir                                                     stopped dir                     stopped dir

                dir/dir     deleted dir/dir                 timedout 12                     deleted dir/dir                 deleted dir/dir                 deleted dir/dir                 deleted dir/dir
                            stopped dir/dir                 stopped dir/dir                 stopped dir/dir                 stopped dir/dir                 stopped dir/dir                 stopped dir/dir

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dir-attrib      dir         attr-changed dir                timedout 12                     attr-changed dir                attr-changed dir                attr-changed dir                attr-changed dir
                            deleted dir                     stopped dir                     deleted dir                     deleted dir                     deleted dir                     deleted dir
                            stopped dir                                                     stopped dir                     stopped dir                     stopped dir                     stopped dir

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dir-rename      dir         renamed dir/src dir/dest        deleted dir/src                 skipped                         renamed dir/src dir/dest        deleted dir/src                 renamed dir anon-1
                            deleted dir                     timedout 12                                                     deleted dir                     deleted dir                     deleted dir
                            stopped dir                     stopped dir                                                     stopped dir                     stopped dir                     stopped dir

                dir/src     deleted dir/src                 timedout 12                     skipped                         deleted dir/src                 deleted dir/src                 deleted dir/src
                            stopped dir/src                 stopped dir/src                                                 stopped dir/src                 stopped dir/src                 stopped dir/src

                dir/dest    renamed dir/src dir/dest        created dir/dest                skipped                         created dir/dest                created dir/dest                attr-changed anon-1
                            deleted dir/dest                deleted dir/dest                                                deleted dir/dest                attr-changed dir/dest           attr-changed anon-1
                            stopped dir/dest                stopped dir/dest                                                stopped dir/dest                attr-changed dir/dest           deleted anon-1
                                                                                                                                                            deleted dir/dest                deleted anon-1
                                                                                                                                                            stopped dir/dest                timedout 12
                                                                                                                                                                                            stopped dir/dest

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

;; Local Variables:
;; truncate-lines: t
;; End:

-ap