Linux-Fsdevel Archive mirror
 help / color / mirror / Atom feed
From: Jonathan Gilbert <logic@deltaq.org>
To: linux-fsdevel@vger.kernel.org
Subject: fanotify and files being moved or deleted
Date: Mon, 20 May 2024 20:03:38 -0500	[thread overview]
Message-ID: <CAPSOpYs6Axo03bKGP1=zaJ9+f=boHvpmYj2GmQL1M3wUQnkyPw@mail.gmail.com> (raw)

Hello :-)

I want to use fanotify to construct a best-effort log of changes to
the filesystem over time. It would be super useful if events like
FAN_MOVE_SELF and FAN_DELETE_SELF could report the path that the file
_was_ at just prior to the event. Reporting an FID value is of limited
use, because even if it still exists, looking up the name (e.g. by
open_by_handle_at, the way fatrace does) will only reveal the new name
after a FAN_MOVE_SELF -- and after a FAN_DELETE_SELF, the file no
longer has any path!

I understand that in terms of a strictly accurate reconstruction of
changes over time, fanotify events are of limited use, because they
aren't guaranteed to be ordered and from what I have read it seems it
is possible for some changes to "slip through" from time to time. But,
this is not a problem for my use case.

I have no idea what things are available where in the kernel code that
generates these events, but in the course of writing the code that
reads the event data that gets sent to an fanotify fd, I was thinking
that the simplest way to achieve this would be for FAN_MOVE_SELF and
FAN_DELETE_SELF events to have associated info structures with paths
in them. FAN_DELETE_SELF could provide an info structure with the path
that just got unlinked, and FAN_MOVE_SELF could provide two info
structures, one for the old path and one for the new.

Of course, it is possible that this information isn't currently
available at the spot where the events are being generated!

But, this would be immensely useful to my use case. Any possibility?

Thanks,

Jonathan Gilbert

             reply	other threads:[~2024-05-21  1:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21  1:03 Jonathan Gilbert [this message]
2024-05-21  3:58 ` fanotify and files being moved or deleted Amir Goldstein
2024-05-21 16:03   ` Jonathan Gilbert
2024-05-21 17:13     ` Amir Goldstein
2024-05-21 21:09       ` Jonathan Gilbert
2024-05-22  5:21         ` Amir Goldstein
2024-05-22  5:26           ` Amir Goldstein

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='CAPSOpYs6Axo03bKGP1=zaJ9+f=boHvpmYj2GmQL1M3wUQnkyPw@mail.gmail.com' \
    --to=logic@deltaq.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /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).