aboutsummaryrefslogtreecommitdiffstats
path: root/fs/file.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-08-19 12:04:24 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-09-26 21:08:56 -0400
commit483ce1d4b8c3b82bc9c9a1dd9dbc44f50b3aaf5a (patch)
tree46a43df814fc7f7bb0c22d0c47fabb7db95d7ada /fs/file.c
parent0ee8cdfe6af052deb56dccd54838a1eb32fb4ca2 (diff)
take descriptor-related part of close() to file.c
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/file.c')
-rw-r--r--fs/file.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/fs/file.c b/fs/file.c
index 6eef55ce30c9..fd4694e688ab 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -626,6 +626,32 @@ void fd_install(unsigned int fd, struct file *file)
626 626
627EXPORT_SYMBOL(fd_install); 627EXPORT_SYMBOL(fd_install);
628 628
629/*
630 * The same warnings as for __alloc_fd()/__fd_install() apply here...
631 */
632int __close_fd(struct files_struct *files, unsigned fd)
633{
634 struct file *file;
635 struct fdtable *fdt;
636
637 spin_lock(&files->file_lock);
638 fdt = files_fdtable(files);
639 if (fd >= fdt->max_fds)
640 goto out_unlock;
641 file = fdt->fd[fd];
642 if (!file)
643 goto out_unlock;
644 rcu_assign_pointer(fdt->fd[fd], NULL);
645 __clear_close_on_exec(fd, fdt);
646 __put_unused_fd(files, fd);
647 spin_unlock(&files->file_lock);
648 return filp_close(file, files);
649
650out_unlock:
651 spin_unlock(&files->file_lock);
652 return -EBADF;
653}
654
629struct file *fget(unsigned int fd) 655struct file *fget(unsigned int fd)
630{ 656{
631 struct file *file; 657 struct file *file;