On Sat, Aug 3, 2024 at 6:52 PM Amir Goldstein <amir73il@xxxxxxxxx> wrote: > > On Thu, Aug 1, 2024 at 6:31 PM Jan Kara <jack@xxxxxxx> wrote: > > > > On Thu 25-07-24 14:19:39, Josef Bacik wrote: > > > From: Amir Goldstein <amir73il@xxxxxxxxx> > > > > > > The new FS_PRE_ACCESS permission event is similar to FS_ACCESS_PERM, > > > but it meant for a different use case of filling file content before > > > access to a file range, so it has slightly different semantics. > > > > > > Generate FS_PRE_ACCESS/FS_ACCESS_PERM as two seperate events, same as > > > we did for FS_OPEN_PERM/FS_OPEN_EXEC_PERM. > > > > > > FS_PRE_MODIFY is a new permission event, with similar semantics as > > > FS_PRE_ACCESS, which is called before a file is modified. > > > > > > FS_ACCESS_PERM is reported also on blockdev and pipes, but the new > > > pre-content events are only reported for regular files and dirs. > > > > > > The pre-content events are meant to be used by hierarchical storage > > > managers that want to fill the content of files on first access. > > > > > > Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> > > > > The patch looks good. Just out of curiosity: > > > > > diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h > > > index 8be029bc50b1..21e72b837ec5 100644 > > > --- a/include/linux/fsnotify_backend.h > > > +++ b/include/linux/fsnotify_backend.h > > > @@ -56,6 +56,9 @@ > > > #define FS_ACCESS_PERM 0x00020000 /* access event in a permissions hook */ > > > #define FS_OPEN_EXEC_PERM 0x00040000 /* open/exec event in a permission hook */ > > > > > > +#define FS_PRE_ACCESS 0x00100000 /* Pre-content access hook */ > > > +#define FS_PRE_MODIFY 0x00200000 /* Pre-content modify hook */ > > > > Why is a hole left here in the flag space? > > Can't remember. > > Currently we have a draft design for two more events > FS_PATH_ACCESS, FS_PATH_MODIFY > https://github.com/amir73il/man-pages/commits/fan_pre_path > > So might have been a desire to keep the pre-events group on the nibble. Funny story. I straced a program with latest FS_PRE_ACCESS (0x00080000) and see what I got: fanotify_mark(3, FAN_MARK_ADD|FAN_MARK_MOUNT, FAN_CLOSE_WRITE|FAN_OPEN_PERM|FAN_ACCESS_PERM|FAN_DIR_MODIFY|FAN_ONDIR, AT_FDCWD, "/vdd") = 0 "FAN_DIR_MODIFY"! a blast from the past [1] It would have been nice if we reserved 0x00080000 for FAN_PATH_MODIFY [2] to be a bit less confusing for users with old strace. WDYT? Thanks, Amir. [1] https://lore.kernel.org/linux-fsdevel/20200612093343.5669-18-amir73il@xxxxxxxxx/ [2] https://github.com/amir73il/man-pages/commits/fan_pre_path