Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c297722 authored by Amy Griffis's avatar Amy Griffis Committed by Al Viro
Browse files

[PATCH] inotify (2/5): add name's inode to event handler



When an inotify event includes a dentry name, also include the inode
associated with that name.

Signed-off-by: default avatarAmy Griffis <amy.griffis@hp.com>
Acked-by: default avatarRobert Love <rml@novell.com>
Acked-by: default avatarJohn McCutchan <john@johnmccutchan.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 2d9048e2
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -232,7 +232,7 @@ static void remove_watch_no_event(struct inotify_watch *watch,
static void remove_watch(struct inotify_watch *watch, struct inotify_handle *ih)
static void remove_watch(struct inotify_watch *watch, struct inotify_handle *ih)
{
{
	remove_watch_no_event(watch, ih);
	remove_watch_no_event(watch, ih);
	ih->in_ops->handle_event(watch, watch->wd, IN_IGNORED, 0, NULL);
	ih->in_ops->handle_event(watch, watch->wd, IN_IGNORED, 0, NULL, NULL);
}
}


/* Kernel API for producing events */
/* Kernel API for producing events */
@@ -275,9 +275,10 @@ void inotify_d_move(struct dentry *entry)
 * @mask: event mask describing this event
 * @mask: event mask describing this event
 * @cookie: cookie for synchronization, or zero
 * @cookie: cookie for synchronization, or zero
 * @name: filename, if any
 * @name: filename, if any
 * @n_inode: inode associated with name
 */
 */
void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
			       const char *name)
			       const char *name, struct inode *n_inode)
{
{
	struct inotify_watch *watch, *next;
	struct inotify_watch *watch, *next;


@@ -292,7 +293,8 @@ void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
			mutex_lock(&ih->mutex);
			mutex_lock(&ih->mutex);
			if (watch_mask & IN_ONESHOT)
			if (watch_mask & IN_ONESHOT)
				remove_watch_no_event(watch, ih);
				remove_watch_no_event(watch, ih);
			ih->in_ops->handle_event(watch, watch->wd, mask, cookie, name);
			ih->in_ops->handle_event(watch, watch->wd, mask, cookie,
						 name, n_inode);
			mutex_unlock(&ih->mutex);
			mutex_unlock(&ih->mutex);
		}
		}
	}
	}
@@ -323,7 +325,8 @@ void inotify_dentry_parent_queue_event(struct dentry *dentry, u32 mask,
	if (inotify_inode_watched(inode)) {
	if (inotify_inode_watched(inode)) {
		dget(parent);
		dget(parent);
		spin_unlock(&dentry->d_lock);
		spin_unlock(&dentry->d_lock);
		inotify_inode_queue_event(inode, mask, cookie, name);
		inotify_inode_queue_event(inode, mask, cookie, name,
					  dentry->d_inode);
		dput(parent);
		dput(parent);
	} else
	} else
		spin_unlock(&dentry->d_lock);
		spin_unlock(&dentry->d_lock);
@@ -407,7 +410,7 @@ void inotify_unmount_inodes(struct list_head *list)
			struct inotify_handle *ih= watch->ih;
			struct inotify_handle *ih= watch->ih;
			mutex_lock(&ih->mutex);
			mutex_lock(&ih->mutex);
			ih->in_ops->handle_event(watch, watch->wd, IN_UNMOUNT, 0,
			ih->in_ops->handle_event(watch, watch->wd, IN_UNMOUNT, 0,
						 NULL);
						 NULL, NULL);
			remove_watch(watch, ih);
			remove_watch(watch, ih);
			mutex_unlock(&ih->mutex);
			mutex_unlock(&ih->mutex);
		}
		}
+2 −1
Original line number Original line Diff line number Diff line
@@ -253,7 +253,8 @@ inotify_dev_get_event(struct inotify_device *dev)
 * Can sleep (calls kernel_event()).
 * Can sleep (calls kernel_event()).
 */
 */
static void inotify_dev_queue_event(struct inotify_watch *w, u32 wd, u32 mask,
static void inotify_dev_queue_event(struct inotify_watch *w, u32 wd, u32 mask,
				    u32 cookie, const char *name)
				    u32 cookie, const char *name,
				    struct inode *ignored)
{
{
	struct inotify_user_watch *watch;
	struct inotify_user_watch *watch;
	struct inotify_device *dev;
	struct inotify_device *dev;
+16 −13
Original line number Original line Diff line number Diff line
@@ -54,16 +54,18 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,


	if (isdir)
	if (isdir)
		isdir = IN_ISDIR;
		isdir = IN_ISDIR;
	inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name);
	inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name,
	inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name);
				  source);
	inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name,
				  source);


	if (target) {
	if (target) {
		inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL);
		inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL, NULL);
		inotify_inode_is_dead(target);
		inotify_inode_is_dead(target);
	}
	}


	if (source) {
	if (source) {
		inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL);
		inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL);
	}
	}
	audit_inode_child(old_name, source, old_dir->i_ino);
	audit_inode_child(old_name, source, old_dir->i_ino);
	audit_inode_child(new_name, target, new_dir->i_ino);
	audit_inode_child(new_name, target, new_dir->i_ino);
@@ -85,7 +87,7 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
 */
 */
static inline void fsnotify_inoderemove(struct inode *inode)
static inline void fsnotify_inoderemove(struct inode *inode)
{
{
	inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL);
	inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL, NULL);
	inotify_inode_is_dead(inode);
	inotify_inode_is_dead(inode);
}
}


@@ -95,7 +97,8 @@ static inline void fsnotify_inoderemove(struct inode *inode)
static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
{
{
	inode_dir_notify(inode, DN_CREATE);
	inode_dir_notify(inode, DN_CREATE);
	inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name);
	inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name,
				  dentry->d_inode);
	audit_inode_child(dentry->d_name.name, dentry->d_inode, inode->i_ino);
	audit_inode_child(dentry->d_name.name, dentry->d_inode, inode->i_ino);
}
}


@@ -106,7 +109,7 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
{
{
	inode_dir_notify(inode, DN_CREATE);
	inode_dir_notify(inode, DN_CREATE);
	inotify_inode_queue_event(inode, IN_CREATE | IN_ISDIR, 0, 
	inotify_inode_queue_event(inode, IN_CREATE | IN_ISDIR, 0, 
				  dentry->d_name.name);
				  dentry->d_name.name, dentry->d_inode);
	audit_inode_child(dentry->d_name.name, dentry->d_inode, inode->i_ino);
	audit_inode_child(dentry->d_name.name, dentry->d_inode, inode->i_ino);
}
}


@@ -123,7 +126,7 @@ static inline void fsnotify_access(struct dentry *dentry)


	dnotify_parent(dentry, DN_ACCESS);
	dnotify_parent(dentry, DN_ACCESS);
	inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
	inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
	inotify_inode_queue_event(inode, mask, 0, NULL);
	inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
}
}


/*
/*
@@ -139,7 +142,7 @@ static inline void fsnotify_modify(struct dentry *dentry)


	dnotify_parent(dentry, DN_MODIFY);
	dnotify_parent(dentry, DN_MODIFY);
	inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
	inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
	inotify_inode_queue_event(inode, mask, 0, NULL);
	inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
}
}


/*
/*
@@ -154,7 +157,7 @@ static inline void fsnotify_open(struct dentry *dentry)
		mask |= IN_ISDIR;
		mask |= IN_ISDIR;


	inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
	inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
	inotify_inode_queue_event(inode, mask, 0, NULL);	
	inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
}
}


/*
/*
@@ -172,7 +175,7 @@ static inline void fsnotify_close(struct file *file)
		mask |= IN_ISDIR;
		mask |= IN_ISDIR;


	inotify_dentry_parent_queue_event(dentry, mask, 0, name);
	inotify_dentry_parent_queue_event(dentry, mask, 0, name);
	inotify_inode_queue_event(inode, mask, 0, NULL);
	inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
}
}


/*
/*
@@ -187,7 +190,7 @@ static inline void fsnotify_xattr(struct dentry *dentry)
		mask |= IN_ISDIR;
		mask |= IN_ISDIR;


	inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
	inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
	inotify_inode_queue_event(inode, mask, 0, NULL);
	inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
}
}


/*
/*
@@ -234,7 +237,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
	if (in_mask) {
	if (in_mask) {
		if (S_ISDIR(inode->i_mode))
		if (S_ISDIR(inode->i_mode))
			in_mask |= IN_ISDIR;
			in_mask |= IN_ISDIR;
		inotify_inode_queue_event(inode, in_mask, 0, NULL);
		inotify_inode_queue_event(inode, in_mask, 0, NULL, NULL);
		inotify_dentry_parent_queue_event(dentry, in_mask, 0,
		inotify_dentry_parent_queue_event(dentry, in_mask, 0,
						  dentry->d_name.name);
						  dentry->d_name.name);
	}
	}
+4 −3
Original line number Original line Diff line number Diff line
@@ -91,7 +91,7 @@ struct inotify_watch {


struct inotify_operations {
struct inotify_operations {
	void (*handle_event)(struct inotify_watch *, u32, u32, u32,
	void (*handle_event)(struct inotify_watch *, u32, u32, u32,
			     const char *);
			     const char *, struct inode *);
	void (*destroy_watch)(struct inotify_watch *);
	void (*destroy_watch)(struct inotify_watch *);
};
};


@@ -102,7 +102,7 @@ struct inotify_operations {
extern void inotify_d_instantiate(struct dentry *, struct inode *);
extern void inotify_d_instantiate(struct dentry *, struct inode *);
extern void inotify_d_move(struct dentry *);
extern void inotify_d_move(struct dentry *);
extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
				      const char *);
				      const char *, struct inode *);
extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
					      const char *);
					      const char *);
extern void inotify_unmount_inodes(struct list_head *);
extern void inotify_unmount_inodes(struct list_head *);
@@ -134,7 +134,8 @@ static inline void inotify_d_move(struct dentry *dentry)


static inline void inotify_inode_queue_event(struct inode *inode,
static inline void inotify_inode_queue_event(struct inode *inode,
					     __u32 mask, __u32 cookie,
					     __u32 mask, __u32 cookie,
					     const char *filename)
					     const char *filename,
					     struct inode *n_inode)
{
{
}
}