]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
move put_unused_fd() and fd_install() to fs/file.c
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 16 Aug 2012 01:03:26 +0000 (21:03 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 27 Sep 2012 01:08:55 +0000 (21:08 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/file.c
fs/open.c

index 4ce4a0fcf320c245b74dce5b129f36f4edff0688..78cf88f2a0e88b0d265e6dfb95c9269e0a3be3e0 100644 (file)
--- a/fs/file.c
+++ b/fs/file.c
@@ -569,3 +569,47 @@ int get_unused_fd_flags(unsigned flags)
        return __alloc_fd(current->files, 0, rlimit(RLIMIT_NOFILE), flags);
 }
 EXPORT_SYMBOL(get_unused_fd_flags);
+
+static void __put_unused_fd(struct files_struct *files, unsigned int fd)
+{
+       struct fdtable *fdt = files_fdtable(files);
+       __clear_open_fd(fd, fdt);
+       if (fd < files->next_fd)
+               files->next_fd = fd;
+}
+
+void put_unused_fd(unsigned int fd)
+{
+       struct files_struct *files = current->files;
+       spin_lock(&files->file_lock);
+       __put_unused_fd(files, fd);
+       spin_unlock(&files->file_lock);
+}
+
+EXPORT_SYMBOL(put_unused_fd);
+
+/*
+ * Install a file pointer in the fd array.
+ *
+ * The VFS is full of places where we drop the files lock between
+ * setting the open_fds bitmap and installing the file in the file
+ * array.  At any such point, we are vulnerable to a dup2() race
+ * installing a file in the array before us.  We need to detect this and
+ * fput() the struct file we are about to overwrite in this case.
+ *
+ * It should never happen - if we allow dup2() do it, _really_ bad things
+ * will follow.
+ */
+
+void fd_install(unsigned int fd, struct file *file)
+{
+       struct files_struct *files = current->files;
+       struct fdtable *fdt;
+       spin_lock(&files->file_lock);
+       fdt = files_fdtable(files);
+       BUG_ON(fdt->fd[fd] != NULL);
+       rcu_assign_pointer(fdt->fd[fd], file);
+       spin_unlock(&files->file_lock);
+}
+
+EXPORT_SYMBOL(fd_install);
index e1f2cdb91a4dc494473986f1b0c8b91f23614a43..c525bd0e65b67d792ad6c2687a5a85273ba6031e 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -803,50 +803,6 @@ struct file *dentry_open(const struct path *path, int flags,
 }
 EXPORT_SYMBOL(dentry_open);
 
-static void __put_unused_fd(struct files_struct *files, unsigned int fd)
-{
-       struct fdtable *fdt = files_fdtable(files);
-       __clear_open_fd(fd, fdt);
-       if (fd < files->next_fd)
-               files->next_fd = fd;
-}
-
-void put_unused_fd(unsigned int fd)
-{
-       struct files_struct *files = current->files;
-       spin_lock(&files->file_lock);
-       __put_unused_fd(files, fd);
-       spin_unlock(&files->file_lock);
-}
-
-EXPORT_SYMBOL(put_unused_fd);
-
-/*
- * Install a file pointer in the fd array.
- *
- * The VFS is full of places where we drop the files lock between
- * setting the open_fds bitmap and installing the file in the file
- * array.  At any such point, we are vulnerable to a dup2() race
- * installing a file in the array before us.  We need to detect this and
- * fput() the struct file we are about to overwrite in this case.
- *
- * It should never happen - if we allow dup2() do it, _really_ bad things
- * will follow.
- */
-
-void fd_install(unsigned int fd, struct file *file)
-{
-       struct files_struct *files = current->files;
-       struct fdtable *fdt;
-       spin_lock(&files->file_lock);
-       fdt = files_fdtable(files);
-       BUG_ON(fdt->fd[fd] != NULL);
-       rcu_assign_pointer(fdt->fd[fd], file);
-       spin_unlock(&files->file_lock);
-}
-
-EXPORT_SYMBOL(fd_install);
-
 static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op)
 {
        int lookup_flags = 0;