• Amir Goldstein's avatar
    fanotify: send FAN_DIR_MODIFY event flavor with dir inode and name · 9e2ba2c3
    Amir Goldstein authored
    Dirent events are going to be supported in two flavors:
    
    1. Directory fid info + mask that includes the specific event types
       (e.g. FAN_CREATE) and an optional FAN_ONDIR flag.
    2. Directory fid info + name + mask that includes only FAN_DIR_MODIFY.
    
    To request the second event flavor, user needs to set the event type
    FAN_DIR_MODIFY in the mark mask.
    
    The first flavor is supported since kernel v5.1 for groups initialized
    with flag FAN_REPORT_FID.  It is intended to be used for watching
    directories in "batch mode" - the watcher is notified when directory is
    changed and re-scans the directory content in response.  This event
    flavor is stored more compactly in the event queue, so it is optimal
    for workloads with frequent directory changes.
    
    The second event flavor is intended to be used for watching large
    directories, where the cost of re-scan of the directory on every change
    is considered too high.  The watcher getting the event with the directory
    fid and entry name is expected to call fstatat(2) to query the content of
    the entry after the change.
    
    Legacy inotify events are reported with name and event mask (e.g. "foo",
    FAN_CREATE | FAN_ONDIR).  That can lead users to the conclusion that
    there is *currently* an entry "foo" that is a sub-directory, when in fact
    "foo" may be negative or non-dir by the time user gets the event.
    
    To make it clear that the current state of the named entry is unknown,
    when reporting an event with name info, fanotify obfuscates the specific
    event types (e.g. create,delete,rename) and uses a common event type -
    FAN_DIR_MODIFY to describe the change.  This should make it harder for
    users to make wrong assumptions and write buggy filesystem monitors.
    
    At this point, name info reporting is not yet implemented, so trying to
    set FAN_DIR_MODIFY in mark mask will return -EINVAL.
    
    Link: https://lore.kernel.org/r/20200319151022.31456-12-amir73il@gmail.comSigned-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
    Signed-off-by: default avatarJan Kara <jack@suse.cz>
    9e2ba2c3
fsnotify.c 11.2 KB