monitor: Fix directory symlink deletion handling

When a symlink to a direcotry is deleted inotify cannot tell it from a
regular file rendering all its children orphans.
This sometimes leads to an unexpected effect - they may appear later in
a newly created directory when it gets an id used by the deleted symlink.
This commit is contained in:
Georgy Kibardin
2023-05-19 20:05:50 +03:00
committed by Justin Maggard
parent 0a6e10e821
commit c5c4d9e169
3 changed files with 25 additions and 9 deletions

View File

@@ -366,7 +366,16 @@ inotify_thread(void *arg)
if ( event->mask & IN_ISDIR )
monitor_remove_directory(pollfds[0].fd, path_buf);
else
{
monitor_remove_file(path_buf);
/*
* When a symlink to a directory is deleted
* we cannot tell it from a regular file deletion
* to prevent its children from becoming orphans
* we delete the whole tree when it exists
*/
monitor_remove_tree(path_buf);
}
}
free(esc_name);
}