Commit c921b40d authored by Al Viro's avatar Al Viro

autofs4: don't open-code fd_install()

The only difference between autofs_dev_ioctl_fd_install() and
fd_install() is __set_close_on_exec() done by the latter.  Just
use get_unused_fd_flags(O_CLOEXEC) to allocate the descriptor
and be done with that...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 1a7bd226
...@@ -221,20 +221,6 @@ static int test_by_type(struct path *path, void *p) ...@@ -221,20 +221,6 @@ static int test_by_type(struct path *path, void *p)
return ino && ino->sbi->type & *(unsigned *)p; return ino && ino->sbi->type & *(unsigned *)p;
} }
static void autofs_dev_ioctl_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);
__set_close_on_exec(fd, fdt);
spin_unlock(&files->file_lock);
}
/* /*
* Open a file descriptor on the autofs mount point corresponding * Open a file descriptor on the autofs mount point corresponding
* to the given path and device number (aka. new_encode_dev(sb->s_dev)). * to the given path and device number (aka. new_encode_dev(sb->s_dev)).
...@@ -243,7 +229,7 @@ static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid) ...@@ -243,7 +229,7 @@ static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid)
{ {
int err, fd; int err, fd;
fd = get_unused_fd(); fd = get_unused_fd_flags(O_CLOEXEC);
if (likely(fd >= 0)) { if (likely(fd >= 0)) {
struct file *filp; struct file *filp;
struct path path; struct path path;
...@@ -264,7 +250,7 @@ static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid) ...@@ -264,7 +250,7 @@ static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid)
goto out; goto out;
} }
autofs_dev_ioctl_fd_install(fd, filp); fd_install(fd, filp);
} }
return fd; return fd;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment