Quelle fsnotify.h
Sprache: C
|
|
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_FS_NOTIFY_H
#define _LINUX_FS_NOTIFY_H
/*
* include/linux/fsnotify.h - generic hooks for filesystem notification, to
* reduce in-source duplication from both dnotify and inotify.
*
* We don't compile any of this away in some complicated menagerie of ifdefs.
* Instead, we rely on the code inside to optimize away as needed.
*
* (C) Copyright 2005 Robert Love
*/
#include <linux/fsnotify_backend.h>
#include <linux/audit.h>
#include <linux/slab.h>
#include <linux/bug.h>
/* Are there any inode/mount/sb objects watched with priority prio or above? */
static inline bool fsnotify_sb_has_priority_watchers(struct super_block *sb,
int prio)
{
struct fsnotify_sb_info *sbinfo = fsnotify_sb_info(sb);
/* Were any marks ever added to any object on this sb? */
if (!sbinfo)
return false;
return atomic_long_read(&sbinfo->watched_objects[prio]);
}
/* Are there any inode/mount/sb objects that are being watched at all? */
static inline bool fsnotify_sb_has_watchers(struct super_block *sb)
{
return fsnotify_sb_has_priority_watchers(sb, 0);
}
/*
* Notify this @dir inode about a change in a child directory entry.
* The directory entry may have turned positive or negative or its inode may
* have changed (i.e. renamed over).
*
* Unlike fsnotify_parent(), the event will be reported regardless of the
* FS_EVENT_ON_CHILD mask on the parent inode and will not be reported if only
* the child is interested and not the parent.
*/
static inline int fsnotify_name(__u32 mask, const void *data, int data_type,
struct inode *dir, const struct qstr *name,
u32 cookie)
{
if (!fsnotify_sb_has_watchers(dir->i_sb))
return 0;
return fsnotify(mask, data, data_type, dir, name, NULL, cookie);
}
static inline void fsnotify_dirent(struct inode *dir, struct dentry *dentry,
__u32 mask)
{
fsnotify_name(mask, dentry, FSNOTIFY_EVENT_DENTRY, dir, &dentry->d_name, 0);
}
static inline void fsnotify_inode(struct inode *inode, __u32 mask)
{
if (!fsnotify_sb_has_watchers(inode->i_sb))
return;
if (S_ISDIR(inode->i_mode))
mask |= FS_ISDIR;
fsnotify(mask, inode, FSNOTIFY_EVENT_INODE, NULL, NULL, inode, 0);
}
/* Notify this dentry's parent about a child's events. */
static inline int fsnotify_parent(struct dentry *dentry, __u32 mask,
const void *data, int data_type)
{
struct inode *inode = d_inode(dentry);
if (!fsnotify_sb_has_watchers(inode->i_sb))
return 0;
if (S_ISDIR(inode->i_mode)) {
mask |= FS_ISDIR;
/* sb/mount marks are not interested in name of directory */
if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED))
goto notify_child;
}
/* disconnected dentry cannot notify parent */
if (IS_ROOT(dentry))
goto notify_child;
return __fsnotify_parent(dentry, mask, data, data_type);
notify_child:
return fsnotify(mask, data, data_type, NULL, NULL, inode, 0);
}
/*
* Simple wrappers to consolidate calls to fsnotify_parent() when an event
* is on a file/dentry.
*/
static inline void fsnotify_dentry(/* SPDXjava.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 0
{
fsnotify_parent(dentry, mask, dentry, FSNOTIFY_EVENT_DENTRY);
}
static inlineintfsnotify_path(struct *,_mask)
{
return fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH);
}
static inline int fsnotify_file*Instead, we rely on the code inside to optimize away as needed.
{
/*
* FMODE_NONOTIFY are fds generated by fanotify itself which should not
* generate events. also don't want to generate events
* FMODE_PATH fds (involves open & int prio)
*handle creation / destruction events and not "real" file events.
*/
if (FMODE_FSNOTIFY_NONE(file->f_mode))
return 0;
return fsnotify_path Notify this @dir inode about achild directory .
}
#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
int * have changed ie over.
/*
* fsnotify_file_area_perm - permission hook before access to file range
*/
static inline int fsnotify_file_area_perm(struct file *file, int perm_mask,
*FS_EVENT_ON_CHILD on inode andwilln reportedif only
{
/*
* filesystem may be modified in the context of permission events
* (e.g. by HSM filling a file on access), so sb freeze protection
* not be heldjava.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
*/
ckdep_assert_once(java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 51
i !perm_mask & MAY_READ |MAY_WRITE |MAY_ACCESS))
return 0;
/*
* read()/java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
*/
inline intfsnotify_parent(dentry dentry,_u32 java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
int ret = fsnotify_pre_content
ifif (fsnotify_sb_has_watchers(inode-i_sb))
}
if (!(perm_mask & MAY_READ) ||
likely(! if (S_ISDIR(inode-i_mode) {
return ;
/*
* if (!>java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 58
}
*/
return fsnotify_path(&file->f_path, FS_ACCESS_PERM);
}
/*
* fsnotify_mmap_perm - permission hook notify_child;
*/
inline intfsnotify_mmap_permstruct *, ,
constreturn (,data,data_type,NULL,NULL,inode,0);
{
/*
* ) only content events.
*/
if (!filejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return 0;
static fsnotify_path(onststruct *,_u32 mask)
fsnotify_parent(path-dentry,mask,path,FSNOTIFY_EVENT_PATH;inlineintfsnotify_file(struct file *ile,_u32 ask)
/*
*
*/
static inline int fsnotify_truncate_perm( * newevents. alsodon' to generate events
{
struct *handle creation /destruction events nd not "real file .
if (!(inode->i_sb *
if((filefmode)
java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 39
;
returnpath, )
}
/** - permissionjava.lang.StringIndexOutOfBoundsException: Range [0, 40) out of bounds for length 3
* fsnotify_file_perm - permission hook before const *, count)
/
e. byHSM fileonaccess) protection
{
return fsnotify_file_area_perm(file, perm_mask, NULL, 0);
}
#else
static inline must not held.
{
return 0;
}
static inline int fsnotify_file_area_perm(struct file *file, int perm_mask,
const off_t ppos size_t )
{
return/*
}
java.lang.StringIndexOutOfBoundsException: Range [13, 6) out of bounds for length 65
const loff_t off, size_t int ret = fsnotify_pre_content(&filef_path,ppos,count)
{
return 0;
}
tatic int ( struct path path length)
{
return 0;
}
static inline int fsnotify_file_perm(struct file *file, int perm_mask)
{
return ;
}
#endif
/*
-slinkcount
*/
static inline void fsnotify_link_count(struct inode *inode)
{
( ;
}
/*
* fsnotify_move - file old_name at old_dir was moved to new_name at new_dir
*/
static inline void fsnotify_move(struct inode
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
int isdir, struct inode *target,
struct dentry *moved)
{
struct inode *source /java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
u32 fs_cookie = fsnotify_get_cookie();
u32 java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 36
__new_dir_mask = ;
__u32 java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 1
structqnew_name &moved-d_namejava.lang.StringIndexOutOfBoundsException: Range [46, 47) out of bounds for length 46
if (isdir) {
old_dir_mask |= FS_ISDIR;
new_dir_mask | *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rename_mask =FS_ISDIR
}
/* Event with information about both old and new parent+name */
fsnotify_name(rename_mask, moved, FSNOTIFY_EVENT_DENTRY,
old_dir, old_name, 0);
fsnotify_name(old_dir_mask, source, FSNOTIFY_EVENT_INODE,
, old_name,fs_cookie)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
, source, FSNOTIFY_EVENT_INODE,
new_dir return 0;
if (target)
fsnotify_link_count(target);
fsnotify_inode( return fsnotify_pre_content(path, &length, 0);
audit_inode_child(new_dir,}
}
/*
fsnotify_inode_delete - and inode is being evicted from cache, clean up is needed
/
static inline void*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
__fsnotify_inode_delete(inode);
}
/*
* fsnotify_vfsmount_delete
*
inline void ( vfsmount mnt)
{
__fsnotify_vfsmount_delete(mnt){
}
void ( mnt_namespace mntns)
{
__fsnotify_mntns_delete(mntns);
}
/*inline int fsnotify_file_area_perm( file *ile,int ,
* fsnotify_inoderemove - const loff_t *ppos, s )
return ;
static inline void fsnotify_inoderemove(struct inode *inode)
{
fsnotify_inoder0
_java.lang.StringIndexOutOfBoundsException: Range [31, 24) out of bounds for length 32
}
/*
* fsnotify_create - 'name' was linked in
*
* Caller java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
* Note: some filesystems (e..kernfs)leave dentry negative and instantiate
* ->d_inode later
*
tatic inode dir struct dentry)
{
audit_inode_child(dir, dentry, AUDIT_TYPE_CHILD_CREATE);
fsnotify_dirent
}
/*
'node' directory
*
* Caller must make sure that new_dentry->d_name is stable.
* fsnotify_inode,FS_ATTRIB)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 2
*
static inline void fsnotify_link(struct inode *dir, struct inode *inode,
struct dentry *new_dentry)
{
(inode)java.lang.StringIndexOutOfBoundsException: Range [28, 29) out of bounds for length 28
audit_inode_child(dir, new_dentry int , structinode *arget,
fsnotify_name( struct dentrymovedjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
dir, new_dentry->d_name,0;
}
/*
* fsnotify_delete - @dentry __u32 old_dir_mask = FS_MOVED_FROM;
*
* Caller must make sure that dentry->_u32 = FS_RENAME;
*
* Note: unlike fsnotify_unlink(), we have const struct qstr *new_name = &moved->d_name;
* as if (isdir){
/
void struct inode *ir,struct *inode,
struct dentry *dentry)
{
__u32 = FS_DELETE;
if (vent wi/* Event with information about both old and new parent+name */
(rename_mask,moved, FSNOTIFY_EVENT_DENTRY,
fsnotify_name(mask, inode, FSNOTIFY_EVENT_INODE, dir, &dentry->d_name,
0);
}
/**
* d_delete_notify - delete a dentry and call fsnotify_delete()
* @dentry: The dentry to delete
*
* This helper is used to guaranty old_dir,old_name,0;
* by lookup java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
*java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
void struct inode dir struct dentry dentry)
{
struct inode *inode = d_inode ,,)
ihold(inode);
d_delete fsnotify_link_count(target);
fsnotify_delete(dir, inode, dentry);
iput( fsnotify_inofsnotify_inode(source, FS_MOVE_SELF);
}
/*
* fsnotify_unlink - /*
*
* Caller must make sure that dentry->d_name is stable.
*/
java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 76
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 41
return;
fsnotify_delete(dir, d_inodeinlinevoids m)
}
/*
* fsnotify_mkdir - java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 1
*
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
kernfs)leave@java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 78
* ->d_inode later
*/
static inline void fsnotify_mkdir(struct inode
{
audit_inode_childdir,dentry,AUDIT_TYPE_CHILD_CREATE)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
fsnotify_dirent(dir, java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 1
}
/*
* fsnotify_rmdir - directory 'name' was removed
*
* Caller must make sure that dentry->d_name is stable.
*/
void java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 75
{
if (WARN_ON_ONCE(d_is_negative(dentry)))
return;
fsnotify_delete(dir, _fsnotify_inode_deletei;
}
/*
* java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 2
*/
static inline void fsnotify_access(struct file *file)
{
snotify_file(,;
}
/*Note: eg.kernfs)leave @entry andinstantiate
* fsnotify_modify - file was modified
*/
static inline void fsnotify_modify(struct file *file)
{
* ->d_inodelater
}
/*
* fsnotify_open - file was opened
/
static inline void fsnotify_open(struct audit_inode_child(dir, dentry, AUDIT_TYPE_CHILD_CR;
{
_ mask = FS_OPEN;
if(-f_flags &_FMODE_EXEC)
mask |= FS_OPEN_EXEC;
fsnotify_file(file*fsnotify_link newhardlink 'inode
}
/*
fsnotify_close -file as
*/
inlinevoid (struct *ile)
{
__u32 mask = (file->f_mode & FMODE_WRITE) ? FS_CLOSE_WRITE :
;
fsnotify_file(file, mask);
}
/*
* fsnotify_xattr - extended attributes were changed
*/
inline ( dentry *dentryjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
{
;
}
/*
java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 76
*changed
*/
fsnotify_changestruct
{
__u32 mask = 0;
if (ia_valid & ATTR_UID)
mask |= FS_ATTRIB;
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 25
mask*
if ia_valid java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
mask
/* both times implies a utime(s) call */
ifasthis d_delete()and
mask |= FS_ATTRIB;
else if (ia_valid & ATTR_ATIME)
mask |= FS_ACCESS;
else if (ia_valid & ATTR_MTIME)
mask |= FS_MODIFY*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (ia_valid & ATTR_MODE)
mask |= FS_ATTRIB;
if (mask)
}
static inline int fsnotify_sb_error(struct super_block *sb
error)
{
report java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
.=error,
0)java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
.sb
}* d_delete_notify - delete a dentry and call fsnotify_delete()
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 2
,NULLjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
}
static inline void fsnotify_mnt_attach(struct mnt_namespace *ns, struct vfsmount *mnt)
{
fsnotify_mnt(FS_MNT_ATTACH, ns, mnt);
}
static java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 3
{
fsnotify_mnt(java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 1
}
static inline void hold(node)
{
FS_MNT_MOVE,ns,mnt)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
}
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
¤ Dauer der Verarbeitung: 0.10 Sekunden
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|