diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2009-12-17 21:24:26 -0500 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2010-07-28 09:58:56 -0400 |
commit | 22aa425dec9e47051624714ae283eb2b6a473013 (patch) | |
tree | 6412e7241a30f3ce151ff29314d3a39190b8dae7 /fs/notify/fanotify | |
parent | 9bbfc964b89009d0cadcec7027afc92ee742e95e (diff) |
fanotify: create_fd cleanup
Code cleanup which does the fd creation work seperately from the userspace
metadata creation. It fits better with the other code.
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs/notify/fanotify')
-rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index a9ced3feb0bb..cf9c30009825 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
@@ -43,17 +43,14 @@ static struct fsnotify_event *get_one_event(struct fsnotify_group *group, | |||
43 | return fsnotify_remove_notify_event(group); | 43 | return fsnotify_remove_notify_event(group); |
44 | } | 44 | } |
45 | 45 | ||
46 | static int create_and_fill_fd(struct fsnotify_group *group, | 46 | static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event) |
47 | struct fanotify_event_metadata *metadata, | ||
48 | struct fsnotify_event *event) | ||
49 | { | 47 | { |
50 | int client_fd; | 48 | int client_fd; |
51 | struct dentry *dentry; | 49 | struct dentry *dentry; |
52 | struct vfsmount *mnt; | 50 | struct vfsmount *mnt; |
53 | struct file *new_file; | 51 | struct file *new_file; |
54 | 52 | ||
55 | pr_debug("%s: group=%p metadata=%p event=%p\n", __func__, group, | 53 | pr_debug("%s: group=%p event=%p\n", __func__, group, event); |
56 | metadata, event); | ||
57 | 54 | ||
58 | client_fd = get_unused_fd(); | 55 | client_fd = get_unused_fd(); |
59 | if (client_fd < 0) | 56 | if (client_fd < 0) |
@@ -93,9 +90,7 @@ static int create_and_fill_fd(struct fsnotify_group *group, | |||
93 | fd_install(client_fd, new_file); | 90 | fd_install(client_fd, new_file); |
94 | } | 91 | } |
95 | 92 | ||
96 | metadata->fd = client_fd; | 93 | return client_fd; |
97 | |||
98 | return 0; | ||
99 | } | 94 | } |
100 | 95 | ||
101 | static ssize_t fill_event_metadata(struct fsnotify_group *group, | 96 | static ssize_t fill_event_metadata(struct fsnotify_group *group, |
@@ -108,9 +103,9 @@ static ssize_t fill_event_metadata(struct fsnotify_group *group, | |||
108 | metadata->event_len = FAN_EVENT_METADATA_LEN; | 103 | metadata->event_len = FAN_EVENT_METADATA_LEN; |
109 | metadata->vers = FANOTIFY_METADATA_VERSION; | 104 | metadata->vers = FANOTIFY_METADATA_VERSION; |
110 | metadata->mask = fanotify_outgoing_mask(event->mask); | 105 | metadata->mask = fanotify_outgoing_mask(event->mask); |
106 | metadata->fd = create_fd(group, event); | ||
111 | 107 | ||
112 | return create_and_fill_fd(group, metadata, event); | 108 | return metadata->fd; |
113 | |||
114 | } | 109 | } |
115 | 110 | ||
116 | static ssize_t copy_event_to_user(struct fsnotify_group *group, | 111 | static ssize_t copy_event_to_user(struct fsnotify_group *group, |
@@ -123,7 +118,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, | |||
123 | pr_debug("%s: group=%p event=%p\n", __func__, group, event); | 118 | pr_debug("%s: group=%p event=%p\n", __func__, group, event); |
124 | 119 | ||
125 | ret = fill_event_metadata(group, &fanotify_event_metadata, event); | 120 | ret = fill_event_metadata(group, &fanotify_event_metadata, event); |
126 | if (ret) | 121 | if (ret < 0) |
127 | return ret; | 122 | return ret; |
128 | 123 | ||
129 | if (copy_to_user(buf, &fanotify_event_metadata, FAN_EVENT_METADATA_LEN)) | 124 | if (copy_to_user(buf, &fanotify_event_metadata, FAN_EVENT_METADATA_LEN)) |