fix: Directly store inotify subscription paths
This fixes segmentations faults on Linux when using inotify and
renaming both a directory (a.k.a the parent) and one of its
sub-directories (a.k.a. the children).
When watching a new directory, the InotifyBackend will store a pointer to this directory's DirEntry to have access to its path. Also, when a directory is deleted, its DirEntry is erased as well as its content's entries. Finally, the InotifyBackend treats moves as a combination of a deletion and a creation, both in terms of events and entries.
Therefore, when processing a parent move followed by a child
renaming, the InotifyBackend will follow these steps:
- process the
parentdeletion by removing its subscription, its associated DirEntry and thechildDirEntry - process the
parentcreation at its new path by creating a new subscription and a new DirEntry - try to process the
childdeletion and crash because its associated DirEntry does not exist anymore and thus its pointer in the subscription cannot be dereferenced
We could prevent the segmentation fault by removing the children's
subscriptions with the parent one when processing theparent
deletion but this would mean missing the child renaming.
In the end, we solve the issue by directly storing the watched
directory's path in the subscription rather than a pointer to a
DirEntry. By doing so, even when the child DirEntry is deleted, the
subscription for this directory will have access to its path and be
able to process inotify events.