diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-08-19 12:04:24 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-09-26 21:08:56 -0400 |
commit | 483ce1d4b8c3b82bc9c9a1dd9dbc44f50b3aaf5a (patch) | |
tree | 46a43df814fc7f7bb0c22d0c47fabb7db95d7ada /drivers | |
parent | 0ee8cdfe6af052deb56dccd54838a1eb32fb4ca2 (diff) |
take descriptor-related part of close() to file.c
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/android/binder.c | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index 9e1a98a360d4..f71d624995ea 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c | |||
@@ -391,42 +391,16 @@ static void task_fd_install( | |||
391 | } | 391 | } |
392 | 392 | ||
393 | /* | 393 | /* |
394 | * copied from __put_unused_fd in open.c | ||
395 | */ | ||
396 | static void __put_unused_fd(struct files_struct *files, unsigned int fd) | ||
397 | { | ||
398 | struct fdtable *fdt = files_fdtable(files); | ||
399 | __clear_open_fd(fd, fdt); | ||
400 | if (fd < files->next_fd) | ||
401 | files->next_fd = fd; | ||
402 | } | ||
403 | |||
404 | /* | ||
405 | * copied from sys_close | 394 | * copied from sys_close |
406 | */ | 395 | */ |
407 | static long task_close_fd(struct binder_proc *proc, unsigned int fd) | 396 | static long task_close_fd(struct binder_proc *proc, unsigned int fd) |
408 | { | 397 | { |
409 | struct file *filp; | ||
410 | struct files_struct *files = proc->files; | ||
411 | struct fdtable *fdt; | ||
412 | int retval; | 398 | int retval; |
413 | 399 | ||
414 | if (files == NULL) | 400 | if (proc->files == NULL) |
415 | return -ESRCH; | 401 | return -ESRCH; |
416 | 402 | ||
417 | spin_lock(&files->file_lock); | 403 | retval = __close_fd(proc->files, fd); |
418 | fdt = files_fdtable(files); | ||
419 | if (fd >= fdt->max_fds) | ||
420 | goto out_unlock; | ||
421 | filp = fdt->fd[fd]; | ||
422 | if (!filp) | ||
423 | goto out_unlock; | ||
424 | rcu_assign_pointer(fdt->fd[fd], NULL); | ||
425 | __clear_close_on_exec(fd, fdt); | ||
426 | __put_unused_fd(files, fd); | ||
427 | spin_unlock(&files->file_lock); | ||
428 | retval = filp_close(filp, files); | ||
429 | |||
430 | /* can't restart close syscall because file table entry was cleared */ | 404 | /* can't restart close syscall because file table entry was cleared */ |
431 | if (unlikely(retval == -ERESTARTSYS || | 405 | if (unlikely(retval == -ERESTARTSYS || |
432 | retval == -ERESTARTNOINTR || | 406 | retval == -ERESTARTNOINTR || |
@@ -435,10 +409,6 @@ static long task_close_fd(struct binder_proc *proc, unsigned int fd) | |||
435 | retval = -EINTR; | 409 | retval = -EINTR; |
436 | 410 | ||
437 | return retval; | 411 | return retval; |
438 | |||
439 | out_unlock: | ||
440 | spin_unlock(&files->file_lock); | ||
441 | return -EBADF; | ||
442 | } | 412 | } |
443 | 413 | ||
444 | static void binder_set_nice(long nice) | 414 | static void binder_set_nice(long nice) |