@@ -114,36 +114,6 @@ static int create_fd(struct fsnotify_group *group,
114
114
return client_fd ;
115
115
}
116
116
117
- static int fill_event_metadata (struct fsnotify_group * group ,
118
- struct fanotify_event_metadata * metadata ,
119
- struct fsnotify_event * fsn_event ,
120
- struct file * * file )
121
- {
122
- int ret = 0 ;
123
- struct fanotify_event * event ;
124
-
125
- pr_debug ("%s: group=%p metadata=%p event=%p\n" , __func__ ,
126
- group , metadata , fsn_event );
127
-
128
- * file = NULL ;
129
- event = container_of (fsn_event , struct fanotify_event , fse );
130
- metadata -> event_len = FAN_EVENT_METADATA_LEN ;
131
- metadata -> metadata_len = FAN_EVENT_METADATA_LEN ;
132
- metadata -> vers = FANOTIFY_METADATA_VERSION ;
133
- metadata -> reserved = 0 ;
134
- metadata -> mask = event -> mask & FANOTIFY_OUTGOING_EVENTS ;
135
- metadata -> pid = pid_vnr (event -> pid );
136
- if (unlikely (event -> mask & FAN_Q_OVERFLOW ))
137
- metadata -> fd = FAN_NOFD ;
138
- else {
139
- metadata -> fd = create_fd (group , event , file );
140
- if (metadata -> fd < 0 )
141
- ret = metadata -> fd ;
142
- }
143
-
144
- return ret ;
145
- }
146
-
147
117
static struct fanotify_perm_event * dequeue_event (
148
118
struct fsnotify_group * group , int fd )
149
119
{
@@ -205,37 +175,50 @@ static int process_access_response(struct fsnotify_group *group,
205
175
}
206
176
207
177
static ssize_t copy_event_to_user (struct fsnotify_group * group ,
208
- struct fsnotify_event * event ,
178
+ struct fsnotify_event * fsn_event ,
209
179
char __user * buf , size_t count )
210
180
{
211
- struct fanotify_event_metadata fanotify_event_metadata ;
212
- struct file * f ;
181
+ struct fanotify_event_metadata metadata ;
182
+ struct fanotify_event * event ;
183
+ struct file * f = NULL ;
213
184
int fd , ret ;
214
185
215
- pr_debug ("%s: group=%p event=%p\n" , __func__ , group , event );
186
+ pr_debug ("%s: group=%p event=%p\n" , __func__ , group , fsn_event );
216
187
217
- ret = fill_event_metadata (group , & fanotify_event_metadata , event , & f );
218
- if (ret < 0 )
219
- return ret ;
188
+ event = container_of (fsn_event , struct fanotify_event , fse );
189
+ metadata .event_len = FAN_EVENT_METADATA_LEN ;
190
+ metadata .metadata_len = FAN_EVENT_METADATA_LEN ;
191
+ metadata .vers = FANOTIFY_METADATA_VERSION ;
192
+ metadata .reserved = 0 ;
193
+ metadata .mask = event -> mask & FANOTIFY_OUTGOING_EVENTS ;
194
+ metadata .pid = pid_vnr (event -> pid );
195
+
196
+ if (unlikely (event -> mask & FAN_Q_OVERFLOW )) {
197
+ fd = FAN_NOFD ;
198
+ } else {
199
+ fd = create_fd (group , event , & f );
200
+ if (fd < 0 )
201
+ return fd ;
202
+ }
203
+ metadata .fd = fd ;
220
204
221
- fd = fanotify_event_metadata .fd ;
222
205
ret = - EFAULT ;
223
206
/*
224
207
* Sanity check copy size in case get_one_event() and
225
208
* fill_event_metadata() event_len sizes ever get out of sync.
226
209
*/
227
- if (WARN_ON_ONCE (fanotify_event_metadata .event_len > count ))
210
+ if (WARN_ON_ONCE (metadata .event_len > count ))
228
211
goto out_close_fd ;
229
- if ( copy_to_user ( buf , & fanotify_event_metadata ,
230
- fanotify_event_metadata .event_len ))
212
+
213
+ if ( copy_to_user ( buf , & metadata , metadata .event_len ))
231
214
goto out_close_fd ;
232
215
233
- if (fanotify_is_perm_event (FANOTIFY_E ( event ) -> mask ))
234
- FANOTIFY_PE (event )-> fd = fd ;
216
+ if (fanotify_is_perm_event (event -> mask ))
217
+ FANOTIFY_PE (fsn_event )-> fd = fd ;
235
218
236
219
if (fd != FAN_NOFD )
237
220
fd_install (fd , f );
238
- return fanotify_event_metadata .event_len ;
221
+ return metadata .event_len ;
239
222
240
223
out_close_fd :
241
224
if (fd != FAN_NOFD ) {
0 commit comments