Skip to content

inotifywait sometimes loses track of directories when they're renamed #4

@acrawley

Description

@acrawley

It seems like in order for this to work, you have to listen to both MOVED_FROM and MOVED_TO (or just MOVE). This is on a generic EXT4 fs, kernel 2.6.33, and inotifywait 3.13

Listening only to CREATE - file created in a renamed directory is shown with the directory's original name
[root@ein ~]# inotifywait -mrq -e create test &
[1] 14895
[root@ein ~]# cd test
[root@ein ~/test]# mkdir test
test/ CREATE,ISDIR test
[root@ein ~/test]# mv test test2
[root@ein ~/test]# cd test2
[root@ein ~/test/test2]# touch file
test/test/ CREATE file

Listening to CREATE and MOVED_TO - file created in a renamed directory is shown with the directory's original name
[root@ein ~]# inotifywait -mrq -e create -e moved_to test &
[1] 14909
[root@ein ~]# cd test
[root@ein ~/test]# mkdir test
test/ CREATE,ISDIR test
[root@ein ~/test]# mv test test2
test/ MOVED_TO,ISDIR test2
[root@ein ~/test]# cd test2
[root@ein ~/test/test2]# touch file
test/test/ CREATE file

Listening to CREATE, MOVED_TO, and MOVED_FROM - file created in a renamed directory is shown with the correct name
[root@ein ~]# inotifywait -mrq -e create -e moved_to -e moved_from test &
[1] 14918
[root@ein ~]# cd test
[root@ein ~/test]# mkdir test
test/ CREATE,ISDIR test
[root@ein ~/test]# mv test test2
test/ MOVED_FROM,ISDIR test
test/ MOVED_TO,ISDIR test2
[root@ein ~/test]# cd test2
[root@ein ~/test/test2]# touch file
test/test2/ CREATE file

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions