Re: [PATCH v3 3/5] fanotify/fanotify_user.c: minor cosmetic adjustments to fid labels

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

 



On Wed, Jul 21, 2021 at 9:18 AM Matthew Bobrowski <repnop@xxxxxxxxxx> wrote:
>
> With the idea to support additional info record types in the future
> i.e. fanotify_event_info_pidfd, it's a good idea to rename some of the
> labels assigned to some of the existing fid related functions,
> parameters, etc which more accurately represent the intent behind
> their usage.
>
> For example, copy_info_to_user() was defined with a generic function
> label, which arguably reads as being supportive of different info
> record types, however the parameter list for this function is
> explicitly tailored towards the creation and copying of the
> fanotify_event_info_fid records. This same point applies to the macro
> defined as FANOTIFY_INFO_HDR_LEN.
>
> With fanotify_event_info_len(), we change the parameter label so that
> the function implies that it can be extended to calculate the length
> for additional info record types.
>
> Signed-off-by: Matthew Bobrowski <repnop@xxxxxxxxxx>

Reviewed-by: Amir Goldstein <amir73il@xxxxxxxxx>

> ---
>  fs/notify/fanotify/fanotify_user.c | 33 +++++++++++++++++-------------
>  1 file changed, 19 insertions(+), 14 deletions(-)
>
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index 64864fb40b40..182fea255376 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -104,7 +104,7 @@ struct kmem_cache *fanotify_path_event_cachep __read_mostly;
>  struct kmem_cache *fanotify_perm_event_cachep __read_mostly;
>
>  #define FANOTIFY_EVENT_ALIGN 4
> -#define FANOTIFY_INFO_HDR_LEN \
> +#define FANOTIFY_FID_INFO_HDR_LEN \
>         (sizeof(struct fanotify_event_info_fid) + sizeof(struct file_handle))
>
>  static int fanotify_fid_info_len(int fh_len, int name_len)
> @@ -114,10 +114,11 @@ static int fanotify_fid_info_len(int fh_len, int name_len)
>         if (name_len)
>                 info_len += name_len + 1;
>
> -       return roundup(FANOTIFY_INFO_HDR_LEN + info_len, FANOTIFY_EVENT_ALIGN);
> +       return roundup(FANOTIFY_FID_INFO_HDR_LEN + info_len,
> +                      FANOTIFY_EVENT_ALIGN);
>  }
>
> -static int fanotify_event_info_len(unsigned int fid_mode,
> +static int fanotify_event_info_len(unsigned int info_mode,
>                                    struct fanotify_event *event)
>  {
>         struct fanotify_info *info = fanotify_event_info(event);
> @@ -128,7 +129,8 @@ static int fanotify_event_info_len(unsigned int fid_mode,
>
>         if (dir_fh_len) {
>                 info_len += fanotify_fid_info_len(dir_fh_len, info->name_len);
> -       } else if ((fid_mode & FAN_REPORT_NAME) && (event->mask & FAN_ONDIR)) {
> +       } else if ((info_mode & FAN_REPORT_NAME) &&
> +                  (event->mask & FAN_ONDIR)) {
>                 /*
>                  * With group flag FAN_REPORT_NAME, if name was not recorded in
>                  * event on a directory, we will report the name ".".
> @@ -303,9 +305,10 @@ static int process_access_response(struct fsnotify_group *group,
>         return -ENOENT;
>  }
>
> -static int copy_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh,
> -                            int info_type, const char *name, size_t name_len,
> -                            char __user *buf, size_t count)
> +static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh,
> +                                int info_type, const char *name,
> +                                size_t name_len,
> +                                char __user *buf, size_t count)
>  {
>         struct fanotify_event_info_fid info = { };
>         struct file_handle handle = { };
> @@ -466,10 +469,11 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
>         if (fanotify_event_dir_fh_len(event)) {
>                 info_type = info->name_len ? FAN_EVENT_INFO_TYPE_DFID_NAME :
>                                              FAN_EVENT_INFO_TYPE_DFID;
> -               ret = copy_info_to_user(fanotify_event_fsid(event),
> -                                       fanotify_info_dir_fh(info),
> -                                       info_type, fanotify_info_name(info),
> -                                       info->name_len, buf, count);
> +               ret = copy_fid_info_to_user(fanotify_event_fsid(event),
> +                                           fanotify_info_dir_fh(info),
> +                                           info_type,
> +                                           fanotify_info_name(info),
> +                                           info->name_len, buf, count);
>                 if (ret < 0)
>                         goto out_close_fd;
>
> @@ -515,9 +519,10 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
>                         info_type = FAN_EVENT_INFO_TYPE_FID;
>                 }
>
> -               ret = copy_info_to_user(fanotify_event_fsid(event),
> -                                       fanotify_event_object_fh(event),
> -                                       info_type, dot, dot_len, buf, count);
> +               ret = copy_fid_info_to_user(fanotify_event_fsid(event),
> +                                           fanotify_event_object_fh(event),
> +                                           info_type, dot, dot_len,
> +                                           buf, count);
>                 if (ret < 0)
>                         goto out_close_fd;
>
> --
> 2.32.0.432.gabb21c7263-goog
>
> /M



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux