fanotify: introduce a generic info record copying helper
authorMatthew Bobrowski <repnop@google.com>
Sun, 8 Aug 2021 05:25:58 +0000 (15:25 +1000)
committerJan Kara <jack@suse.cz>
Tue, 10 Aug 2021 10:55:37 +0000 (12:55 +0200)
commit0aca67bb7f0d8c997dfef8ff0bfeb0afb361f0e6
treeea67a7e163a2d6cf24d18212da2c525ce6afb0a7
parentd3424c9bac893bd06f38a20474cd622881d384ca
fanotify: introduce a generic info record copying helper

The copy_info_records_to_user() helper allows for the separation of
info record copying routines/conditionals from copy_event_to_user(),
which reduces the overall clutter within this function. This becomes
especially true as we start introducing additional info records in the
future i.e. struct fanotify_event_info_pidfd. On success, this helper
returns the total amount of bytes that have been copied into the user
supplied buffer and on error, a negative value is returned to the
caller.

The newly defined macro FANOTIFY_INFO_MODES can be used to obtain info
record types that have been enabled for a specific notification
group. This macro becomes useful in the subsequent patch when the
FAN_REPORT_PIDFD initialization flag is introduced.

Link: https://lore.kernel.org/r/8872947dfe12ce8ae6e9a7f2d49ea29bc8006af0.1628398044.git.repnop@google.com
Signed-off-by: Matthew Bobrowski <repnop@google.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/notify/fanotify/fanotify_user.c
include/linux/fanotify.h