Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 28017
b: refs/heads/master
c: a9dc971
h: refs/heads/master
i:
  28015: dd60387
v: v3
  • Loading branch information
Amy Griffis authored and Al Viro committed Jun 20, 2006
1 parent 636f77e commit c17bed9
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7c29772288b7026504cfe75bfd90d40fbd1574bf
refs/heads/master: a9dc971d3fdb857a2bcd6d53238125a2cd31d5f4
64 changes: 58 additions & 6 deletions trunk/fs/inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,19 @@ struct inotify_handle *inotify_init(const struct inotify_operations *ops)
}
EXPORT_SYMBOL_GPL(inotify_init);

/**
* inotify_init_watch - initialize an inotify watch
* @watch: watch to initialize
*/
void inotify_init_watch(struct inotify_watch *watch)
{
INIT_LIST_HEAD(&watch->h_list);
INIT_LIST_HEAD(&watch->i_list);
atomic_set(&watch->count, 0);
get_inotify_watch(watch); /* initial get */
}
EXPORT_SYMBOL_GPL(inotify_init_watch);

/**
* inotify_destroy - clean up and destroy an inotify instance
* @ih: inotify handle
Expand Down Expand Up @@ -514,6 +527,37 @@ void inotify_destroy(struct inotify_handle *ih)
}
EXPORT_SYMBOL_GPL(inotify_destroy);

/**
* inotify_find_watch - find an existing watch for an (ih,inode) pair
* @ih: inotify handle
* @inode: inode to watch
* @watchp: pointer to existing inotify_watch
*
* Caller must pin given inode (via nameidata).
*/
s32 inotify_find_watch(struct inotify_handle *ih, struct inode *inode,
struct inotify_watch **watchp)
{
struct inotify_watch *old;
int ret = -ENOENT;

mutex_lock(&inode->inotify_mutex);
mutex_lock(&ih->mutex);

old = inode_find_handle(inode, ih);
if (unlikely(old)) {
get_inotify_watch(old); /* caller must put watch */
*watchp = old;
ret = old->wd;
}

mutex_unlock(&ih->mutex);
mutex_unlock(&inode->inotify_mutex);

return ret;
}
EXPORT_SYMBOL_GPL(inotify_find_watch);

/**
* inotify_find_update_watch - find and update the mask of an existing watch
* @ih: inotify handle
Expand Down Expand Up @@ -593,10 +637,6 @@ s32 inotify_add_watch(struct inotify_handle *ih, struct inotify_watch *watch,
goto out;
ret = watch->wd;

atomic_set(&watch->count, 0);
INIT_LIST_HEAD(&watch->h_list);
INIT_LIST_HEAD(&watch->i_list);

/* save a reference to handle and bump the count to make it official */
get_inotify_handle(ih);
watch->ih = ih;
Expand All @@ -607,8 +647,6 @@ s32 inotify_add_watch(struct inotify_handle *ih, struct inotify_watch *watch,
*/
watch->inode = igrab(inode);

get_inotify_watch(watch); /* initial get */

if (!inotify_inode_watched(inode))
set_dentry_child_flags(inode, 1);

Expand Down Expand Up @@ -659,6 +697,20 @@ int inotify_rm_wd(struct inotify_handle *ih, u32 wd)
}
EXPORT_SYMBOL_GPL(inotify_rm_wd);

/**
* inotify_rm_watch - remove a watch from an inotify instance
* @ih: inotify handle
* @watch: watch to remove
*
* Can sleep.
*/
int inotify_rm_watch(struct inotify_handle *ih,
struct inotify_watch *watch)
{
return inotify_rm_wd(ih, watch->wd);
}
EXPORT_SYMBOL_GPL(inotify_rm_watch);

/*
* inotify_setup - core initialization function
*/
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/inotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ static int create_watch(struct inotify_device *dev, struct inode *inode,

atomic_inc(&dev->user->inotify_watches);

inotify_init_watch(&watch->wdata);
ret = inotify_add_watch(dev->ih, &watch->wdata, inode, mask);
if (ret < 0)
free_inotify_user_watch(&watch->wdata);
Expand Down
20 changes: 20 additions & 0 deletions trunk/include/linux/inotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@ extern u32 inotify_get_cookie(void);
/* Kernel Consumer API */

extern struct inotify_handle *inotify_init(const struct inotify_operations *);
extern void inotify_init_watch(struct inotify_watch *);
extern void inotify_destroy(struct inotify_handle *);
extern __s32 inotify_find_watch(struct inotify_handle *, struct inode *,
struct inotify_watch **);
extern __s32 inotify_find_update_watch(struct inotify_handle *, struct inode *,
u32);
extern __s32 inotify_add_watch(struct inotify_handle *, struct inotify_watch *,
struct inode *, __u32);
extern int inotify_rm_watch(struct inotify_handle *, struct inotify_watch *);
extern int inotify_rm_wd(struct inotify_handle *, __u32);
extern void get_inotify_watch(struct inotify_watch *);
extern void put_inotify_watch(struct inotify_watch *);
Expand Down Expand Up @@ -163,10 +167,20 @@ static inline struct inotify_handle *inotify_init(const struct inotify_operation
return ERR_PTR(-EOPNOTSUPP);
}

static inline void inotify_init_watch(struct inotify_watch *watch)
{
}

static inline void inotify_destroy(struct inotify_handle *ih)
{
}

static inline __s32 inotify_find_watch(struct inotify_handle *ih, struct inode *inode,
struct inotify_watch **watchp)
{
return -EOPNOTSUPP;
}

static inline __s32 inotify_find_update_watch(struct inotify_handle *ih,
struct inode *inode, u32 mask)
{
Expand All @@ -180,6 +194,12 @@ static inline __s32 inotify_add_watch(struct inotify_handle *ih,
return -EOPNOTSUPP;
}

static inline int inotify_rm_watch(struct inotify_handle *ih,
struct inotify_watch *watch)
{
return -EOPNOTSUPP;
}

static inline int inotify_rm_wd(struct inotify_handle *ih, __u32 wd)
{
return -EOPNOTSUPP;
Expand Down

0 comments on commit c17bed9

Please sign in to comment.