public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "binli at opensuse dot org" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug nscd/14906] inotify failed when /etc/hosts file change
Date: Mon, 03 Dec 2012 10:40:00 -0000 [thread overview]
Message-ID: <bug-14906-131-hmb3ZMUa1c@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-14906-131@http.sourceware.org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=14906
--- Comment #2 from Bin Li <binli at opensuse dot org> 2012-12-03 10:40:11 UTC ---
Miklos Szeredi 2012-10-15 15:27:29 UTC
(In reply to comment #20)
> I can make the program work as expected also in the light of overwriting
> renames, when I'm handling a IN_IGNORED event by recreating the watch on
> /etc/hosts, like this in the inner loop:
>
> if (buf.wd == watch && (buf.mask & IN_IGNORED) != 0)
> {
> /* Recreate watch */
> watch = inotify_add_watch (fd, "/etc/hosts", IN_DELETE_SELF |
> IN_MODIFY /* | IN_MOVE */);
> printf ("Added watch on /etc/hosts, as watch %d\n", watch);
> if (watch < 0)
> bark ("inotify_add_watch");
> }
>
> That's for sure surprising limitation of the interface. Is this really how
> it's supposed to be used?
The watch descriptor returned by inotify_add_watch() refers to the inode, not
the path name. This is analogous to open(2) returning a file descriptor that
refers to the inode, not the pathname.
So yes, adding IN_DELETE_SELF and IN_MOVE_SELF to the watches is a good way to
monitor whether changes to the file _name_ were made.
Note: inotify is an unreliable interface by design and the application should
provide a backup mechanism for theoretical cases when events are lost (e.g. by
checking the modification time of the file periodically).
Also see "Limitations and caveats" section in the inofity(7) manpage.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
next prev parent reply other threads:[~2012-12-03 10:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-03 10:37 [Bug nscd/14906] New: " binli at opensuse dot org
2012-12-03 10:39 ` [Bug nscd/14906] " binli at opensuse dot org
2012-12-03 10:40 ` binli at opensuse dot org [this message]
2012-12-03 10:43 ` binli at opensuse dot org
2012-12-03 10:45 ` binli at opensuse dot org
2015-02-18 2:12 ` carlos at redhat dot com
2015-02-18 6:25 ` carlos at redhat dot com
2015-03-13 15:11 ` cvs-commit at gcc dot gnu.org
2015-03-13 18:12 ` carlos at redhat dot com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-14906-131-hmb3ZMUa1c@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=glibc-bugs@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).