Bug 115571 - Watching a directory with inotify does not trigger events on hardlinks
Summary: Watching a directory with inotify does not trigger events on hardlinks
Status: NEW
Alias: None
Product: Other
Classification: Unclassified
Component: Other (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: other_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-31 01:34 UTC by sworddragon2
Modified: 2020-03-05 22:55 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.4.6
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Testcase (731 bytes, text/x-csrc)
2016-03-31 01:34 UTC, sworddragon2
Details

Description sworddragon2 2016-03-31 01:34:57 UTC
Created attachment 211201 [details]
Testcase

I'm noticing that watching a directory with inotify does not trigger events on hardlinks. In the attachments is an example which demonstrates this. It needs just to be compiled for example with "gcc -Wall -pedantic -o test test.c" and then executed. It prints "testfile1.txt" (the event on the normal file) while I would also expect it to print "testfile2.txt" (the hardlink).
Comment 1 Vitaly Lipatov 2020-03-05 22:55:37 UTC
See also https://bugzilla.gnome.org/show_bug.cgi?id=532815
They add G_FILE_MONITOR_WATCH_HARDLINKS flag and make workaround for case with hard links

g_file_monitor_file can be used with G_FILE_MONITOR_WATCH_HARD_LINKS flag for get events from hard link. This works only for a file, not for whole directory.
https://developer.gnome.org/gio/2.60/GFile.html

Note You need to log in before you can comment on or make changes to this bug.