static int au_hin_alloc(struct au_hnotify *hn, struct inode *h_inode)
{
	int err;
	s32 wd;
	struct inotify_watch *watch;

	err = -EEXIST;
	wd = inotify_find_watch(au_hin_handle, h_inode, &watch);
	if (wd >= 0) {
		put_inotify_watch(watch);
		goto out;
	}

	err = 0;
	inotify_init_watch(&hn->hn_watch);
	wd = inotify_add_watch(au_hin_handle, &hn->hn_watch, h_inode,
			       AuHinMask);
	if (unlikely(wd < 0)) {
		err = wd;
		put_inotify_watch(&hn->hn_watch);
	}

out:
	return err;
}
Exemple #2
0
static void audit_remove_watch(struct audit_watch *watch)
{
	list_del(&watch->wlist);
	put_inotify_watch(&watch->parent->wdata);
	watch->parent = NULL;
	audit_put_watch(watch); /* match initial get */
}
static void aufs_inotify(struct inotify_watch *watch, u32 wd __maybe_unused,
			 u32 mask, u32 cookie __maybe_unused,
			 const char *h_child_name, struct inode *h_child_inode)
{
	struct au_hnotify *hnotify;
	struct qstr h_child_qstr = {
		.name = h_child_name
	};

	/* if IN_UNMOUNT happens, there must be another bug */
	AuDebugOn(mask & IN_UNMOUNT);
	if (mask & (IN_IGNORED | IN_UNMOUNT)) {
		put_inotify_watch(watch);
		return;
	}

#ifdef AuDbgHnotify
	au_debug(1);
	if (1 || !h_child_name || strcmp(h_child_name, AUFS_XINO_FNAME)) {
		AuDbg("i%lu, wd %d, mask 0x%x %s, cookie 0x%x, hcname %s,"
		      " hi%lu\n",
		      watch->inode->i_ino, wd, mask, in_name(mask), cookie,
		      h_child_name ? h_child_name : "",
		      h_child_inode ? h_child_inode->i_ino : 0);
		WARN_ON(1);
	}
	au_debug(0);
#endif

	if (h_child_name)
		h_child_qstr.len = strlen(h_child_name);
	hnotify = container_of(watch, struct au_hnotify, hn_watch);
	au_hnotify(watch->inode, hnotify, mask, &h_child_qstr, h_child_inode);
}