Re: [PATCH v2 1/2] fanotify.7, fanotify_init.2: Document FAN_REPORT_TARGET_FID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 22, 2022 at 7:41 PM Amir Goldstein <amir73il@xxxxxxxxx> wrote:
>
> FAN_REPORT_TARGET_FID adds an information record about the child
> to directory entry modification events (create/delete/move).
>
> This flag also adds sanity checks that directory modification events
> (create,delete,moved) cannot be set in mask of a non-dir inode mark.
>
> Note that while FAN_REPORT_TARGET_FID was merged to v5.17, the sanity
> checks resulting in ENOTDIR were merged as fix commit ceaf69f8eadc
> ("fanotify: do not allow setting dirent events in mask of non-dir")
> to v5.18 and backported to v5.17.9.
>
> Reviewed-by: Matthew Bobrowski <repnop@xxxxxxxxxx>
> Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
> ---
>  man2/fanotify_init.2 | 40 +++++++++++++++++++++++++++++++++++++---
>  man2/fanotify_mark.2 |  8 ++++++++
>  man7/fanotify.7      | 27 +++++++++++++--------------
>  3 files changed, 58 insertions(+), 17 deletions(-)
>
> diff --git a/man2/fanotify_init.2 b/man2/fanotify_init.2
> index 9abec5fca..ac4d3a305 100644
> --- a/man2/fanotify_init.2
> +++ b/man2/fanotify_init.2
> @@ -182,9 +182,11 @@ and
>  .BR FAN_MOVE_SELF .
>  All the events above require an fanotify group that identifies filesystem
>  objects by file handles.
> -Note that for the directory entry modification events the reported file handle
> -identifies the modified directory and not the created/deleted/moved child
> -object.
> +Note that without the flag
> +.BR FAN_REPORT_TARGET_FID ,
> +for the directory entry modification events,
> +there is an inforamtion record that identifies the modified directory
> +and not the created/deleted/moved child object.
>  The use of
>  .B FAN_CLASS_CONTENT
>  or
> @@ -282,6 +284,38 @@ for additional details.
>  .B FAN_REPORT_DFID_NAME
>  This is a synonym for
>  .RB ( FAN_REPORT_DIR_FID | FAN_REPORT_NAME ).
> +.TP
> +.BR FAN_REPORT_TARGET_FID " (since Linux 5.17)"
> +.\" commit d61fd650e9d206a71fda789f02a1ced4b19944c4
> +Events for fanotify groups initialized with this flag
> +will contain additional information about the child
> +correlated with directory entry modification events.
> +This flag must be provided in conjunction with the flags
> +.BR FAN_REPORT_FID ,
> +.B FAN_REPORT_DIR_FID
> +and
> +.BR FAN_REPORT_NAME .
> +or else the error
> +.B EINVAL
> +will be returned.
> +For the directory entry modification events
> +.BR FAN_CREATE ,
> +.BR FAN_DELETE ,
> +and
> +.BR FAN_MOVE ,
> +an additional record of type
> +.BR FAN_EVENT_INFO_TYPE_FID ,
> +is reported in addition to the information record of type
> +.B FAN_EVENT_INFO_TYPE_DFID
> +or
> +.BR FAN_EVENT_INFO_TYPE_DFID_NAME .
> +The additional record includes a file handle
> +that identifies the filesystem child object
> +that the directory entry is referring to.
> +.TP
> +.B FAN_REPORT_DFID_NAME_TARGET
> +This is a synonym for
> +.RB ( FAN_REPORT_DFID_NAME | FAN_REPORT_FID | FAN_REPORT_TARGET_FID ).
>  .PP
>  .TP
>  .BR FAN_REPORT_PIDFD " (since Linux 5.15)"
> diff --git a/man2/fanotify_mark.2 b/man2/fanotify_mark.2
> index 3dc538b7f..eeaddd173 100644
> --- a/man2/fanotify_mark.2
> +++ b/man2/fanotify_mark.2
> @@ -472,6 +472,14 @@ and
>  and
>  .I pathname
>  do not specify a directory.
> +For an fanotify group that was initialized with flag
> +.BR FAN_REPORT_TARGET_FID ,
> +this error will also be returned
> +when trying to set directory entry modification events
> +(e.g.,
> +.BR FAN_CREATE ,
> +.BR FAN_DELETE )
> +in the mask of a non directory inode mark.

Alex,

I hope the reviewers won't mind, but because we are adding more
reasons of ENOTDIR
later on, I think this section would look better with every ENOTDIR
reason in a paragraph
of its own, like this:

.TP
.B ENOTDIR
.I flags
contains
.BR FAN_MARK_ONLYDIR ,
and
.I dirfd
and
.I pathname
do not specify a directory.
.TP
.B ENOTDIR
The fanotify group was initialized with flag
.BR FAN_REPORT_TARGET_FID ,
.I mask
contains directory entry modification events
(e.g.,
.BR FAN_CREATE ,
.BR FAN_DELETE ) ,
and
.I dirfd
and
.I pathname
do not specify a directory.
.TP

The end result [1] after the following FAN_RENAME patch looks like this:

       ENOTDIR
              flags contains FAN_MARK_ONLYDIR, and dirfd and pathname
do not specify a directory.

       ENOTDIR
              mask contains FAN_RENAME, and dirfd and pathname do not
specify a directory.

       ENOTDIR
              The fanotify group was initialized with flag
FAN_REPORT_TARGET_FID, mask contains
              directory entry modification events (e.g., FAN_CREATE,
FAN_DELETE), and dirfd and
              pathname do not  specify  a directory.

BTW, I could not figure out what causes the line break after ENOTDIR.
Other errors look similarly formatted and don't have this line break.

Thanks,
Amir.

[1] https://github.com/amir73il/man-pages/commits/fan_rename



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux