mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-29 01:51:39 +00:00
fsnotify: include pathnames with entries when possible
When inotify wants to send events to a directory about a child it includes the name of the original file. This patch collects that filename and makes it available for notification. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Al Viro <viro@zeniv.linux.org.uk> Cc: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
a2d8bc6cb4
commit
62ffe5dfba
4 changed files with 41 additions and 21 deletions
|
@ -114,7 +114,8 @@ void __fsnotify_parent(struct dentry *dentry, __u32 mask)
|
||||||
* specifies these are events which came from a child. */
|
* specifies these are events which came from a child. */
|
||||||
mask |= FS_EVENT_ON_CHILD;
|
mask |= FS_EVENT_ON_CHILD;
|
||||||
|
|
||||||
fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
|
||||||
|
dentry->d_name.name);
|
||||||
dput(parent);
|
dput(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +132,7 @@ EXPORT_SYMBOL_GPL(__fsnotify_parent);
|
||||||
* out to all of the registered fsnotify_group. Those groups can then use the
|
* out to all of the registered fsnotify_group. Those groups can then use the
|
||||||
* notification event in whatever means they feel necessary.
|
* notification event in whatever means they feel necessary.
|
||||||
*/
|
*/
|
||||||
void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is)
|
void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const char *file_name)
|
||||||
{
|
{
|
||||||
struct fsnotify_group *group;
|
struct fsnotify_group *group;
|
||||||
struct fsnotify_event *event = NULL;
|
struct fsnotify_event *event = NULL;
|
||||||
|
@ -156,7 +157,7 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is)
|
||||||
if (!group->ops->should_send_event(group, to_tell, mask))
|
if (!group->ops->should_send_event(group, to_tell, mask))
|
||||||
continue;
|
continue;
|
||||||
if (!event) {
|
if (!event) {
|
||||||
event = fsnotify_create_event(to_tell, mask, data, data_is);
|
event = fsnotify_create_event(to_tell, mask, data, data_is, file_name);
|
||||||
/* shit, we OOM'd and now we can't tell, maybe
|
/* shit, we OOM'd and now we can't tell, maybe
|
||||||
* someday someone else will want to do something
|
* someday someone else will want to do something
|
||||||
* here */
|
* here */
|
||||||
|
|
|
@ -78,6 +78,7 @@ void fsnotify_put_event(struct fsnotify_event *event)
|
||||||
if (event->data_type == FSNOTIFY_EVENT_PATH)
|
if (event->data_type == FSNOTIFY_EVENT_PATH)
|
||||||
path_put(&event->path);
|
path_put(&event->path);
|
||||||
|
|
||||||
|
kfree(event->file_name);
|
||||||
kmem_cache_free(fsnotify_event_cachep, event);
|
kmem_cache_free(fsnotify_event_cachep, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,6 +263,9 @@ static void initialize_event(struct fsnotify_event *event)
|
||||||
event->data_type = FSNOTIFY_EVENT_NONE;
|
event->data_type = FSNOTIFY_EVENT_NONE;
|
||||||
|
|
||||||
event->to_tell = NULL;
|
event->to_tell = NULL;
|
||||||
|
|
||||||
|
event->file_name = NULL;
|
||||||
|
event->name_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -274,9 +278,10 @@ static void initialize_event(struct fsnotify_event *event)
|
||||||
* @mask what actually happened.
|
* @mask what actually happened.
|
||||||
* @data pointer to the object which was actually affected
|
* @data pointer to the object which was actually affected
|
||||||
* @data_type flag indication if the data is a file, path, inode, nothing...
|
* @data_type flag indication if the data is a file, path, inode, nothing...
|
||||||
|
* @name the filename, if available
|
||||||
*/
|
*/
|
||||||
struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
|
struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
|
||||||
void *data, int data_type)
|
void *data, int data_type, const char *name)
|
||||||
{
|
{
|
||||||
struct fsnotify_event *event;
|
struct fsnotify_event *event;
|
||||||
|
|
||||||
|
@ -285,6 +290,15 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
initialize_event(event);
|
initialize_event(event);
|
||||||
|
|
||||||
|
if (name) {
|
||||||
|
event->file_name = kstrdup(name, GFP_KERNEL);
|
||||||
|
if (!event->file_name) {
|
||||||
|
kmem_cache_free(fsnotify_event_cachep, event);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
event->name_len = strlen(event->file_name);
|
||||||
|
}
|
||||||
event->to_tell = to_tell;
|
event->to_tell = to_tell;
|
||||||
|
|
||||||
switch (data_type) {
|
switch (data_type) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ static inline void fsnotify_link_count(struct inode *inode)
|
||||||
{
|
{
|
||||||
inotify_inode_queue_event(inode, IN_ATTRIB, 0, NULL, NULL);
|
inotify_inode_queue_event(inode, IN_ATTRIB, 0, NULL, NULL);
|
||||||
|
|
||||||
fsnotify(inode, FS_ATTRIB, inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(inode, FS_ATTRIB, inode, FSNOTIFY_EVENT_INODE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -91,8 +91,8 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
|
||||||
inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name,
|
inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name,
|
||||||
source);
|
source);
|
||||||
|
|
||||||
fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE);
|
fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name);
|
||||||
fsnotify(new_dir, new_dir_mask, new_dir, FSNOTIFY_EVENT_INODE);
|
fsnotify(new_dir, new_dir_mask, new_dir, FSNOTIFY_EVENT_INODE, new_name);
|
||||||
|
|
||||||
if (target) {
|
if (target) {
|
||||||
inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL, NULL);
|
inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL, NULL);
|
||||||
|
@ -104,7 +104,7 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
|
||||||
|
|
||||||
if (source) {
|
if (source) {
|
||||||
inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL);
|
inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL);
|
||||||
fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL);
|
||||||
}
|
}
|
||||||
audit_inode_child(new_name, moved, new_dir);
|
audit_inode_child(new_name, moved, new_dir);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ static inline void fsnotify_inoderemove(struct inode *inode)
|
||||||
inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL, NULL);
|
inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL, NULL);
|
||||||
inotify_inode_is_dead(inode);
|
inotify_inode_is_dead(inode);
|
||||||
|
|
||||||
fsnotify(inode, FS_DELETE_SELF, inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(inode, FS_DELETE_SELF, inode, FSNOTIFY_EVENT_INODE, NULL);
|
||||||
__fsnotify_inode_delete(inode);
|
__fsnotify_inode_delete(inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
|
||||||
dentry->d_inode);
|
dentry->d_inode);
|
||||||
audit_inode_child(dentry->d_name.name, dentry, inode);
|
audit_inode_child(dentry->d_name.name, dentry, inode);
|
||||||
|
|
||||||
fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -166,7 +166,7 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct
|
||||||
fsnotify_link_count(inode);
|
fsnotify_link_count(inode);
|
||||||
audit_inode_child(new_dentry->d_name.name, new_dentry, dir);
|
audit_inode_child(new_dentry->d_name.name, new_dentry, dir);
|
||||||
|
|
||||||
fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -180,7 +180,7 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
|
||||||
inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode);
|
inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode);
|
||||||
audit_inode_child(dentry->d_name.name, dentry, inode);
|
audit_inode_child(dentry->d_name.name, dentry, inode);
|
||||||
|
|
||||||
fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -197,7 +197,7 @@ static inline void fsnotify_access(struct dentry *dentry)
|
||||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||||
|
|
||||||
fsnotify_parent(dentry, mask);
|
fsnotify_parent(dentry, mask);
|
||||||
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -214,7 +214,7 @@ static inline void fsnotify_modify(struct dentry *dentry)
|
||||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||||
|
|
||||||
fsnotify_parent(dentry, mask);
|
fsnotify_parent(dentry, mask);
|
||||||
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -231,7 +231,7 @@ static inline void fsnotify_open(struct dentry *dentry)
|
||||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||||
|
|
||||||
fsnotify_parent(dentry, mask);
|
fsnotify_parent(dentry, mask);
|
||||||
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -250,7 +250,7 @@ static inline void fsnotify_close(struct file *file)
|
||||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||||
|
|
||||||
fsnotify_parent(dentry, mask);
|
fsnotify_parent(dentry, mask);
|
||||||
fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE);
|
fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -267,7 +267,7 @@ static inline void fsnotify_xattr(struct dentry *dentry)
|
||||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||||
|
|
||||||
fsnotify_parent(dentry, mask);
|
fsnotify_parent(dentry, mask);
|
||||||
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -303,7 +303,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
|
||||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||||
|
|
||||||
fsnotify_parent(dentry, mask);
|
fsnotify_parent(dentry, mask);
|
||||||
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
|
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,9 @@ struct fsnotify_event {
|
||||||
int data_type; /* which of the above union we have */
|
int data_type; /* which of the above union we have */
|
||||||
atomic_t refcnt; /* how many groups still are using/need to send this event */
|
atomic_t refcnt; /* how many groups still are using/need to send this event */
|
||||||
__u32 mask; /* the type of access, bitwise OR for FS_* event types */
|
__u32 mask; /* the type of access, bitwise OR for FS_* event types */
|
||||||
|
|
||||||
|
char *file_name;
|
||||||
|
size_t name_len;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -224,7 +227,7 @@ struct fsnotify_mark_entry {
|
||||||
/* called from the vfs helpers */
|
/* called from the vfs helpers */
|
||||||
|
|
||||||
/* main fsnotify call to send events */
|
/* main fsnotify call to send events */
|
||||||
extern void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is);
|
extern void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const char *name);
|
||||||
extern void __fsnotify_parent(struct dentry *dentry, __u32 mask);
|
extern void __fsnotify_parent(struct dentry *dentry, __u32 mask);
|
||||||
extern void __fsnotify_inode_delete(struct inode *inode);
|
extern void __fsnotify_inode_delete(struct inode *inode);
|
||||||
|
|
||||||
|
@ -319,10 +322,12 @@ extern void fsnotify_put_mark(struct fsnotify_mark_entry *entry);
|
||||||
|
|
||||||
/* put here because inotify does some weird stuff when destroying watches */
|
/* put here because inotify does some weird stuff when destroying watches */
|
||||||
extern struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
|
extern struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
|
||||||
void *data, int data_is);
|
void *data, int data_is, const char *name);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static inline void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is)
|
static inline void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
|
||||||
|
const char *name);
|
||||||
{}
|
{}
|
||||||
|
|
||||||
static inline void __fsnotify_parent(struct dentry *dentry, __u32 mask)
|
static inline void __fsnotify_parent(struct dentry *dentry, __u32 mask)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue