mirror of https://github.com/torvalds/linux.git
fhandle: convert do_handle_open() to FD_ADD()
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-4-b6efa1706cfd@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
a5fa9ab846
commit
fbe58faa69
30
fs/fhandle.c
30
fs/fhandle.c
|
|
@ -404,32 +404,28 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct file *file_open_handle(struct path *path, int open_flag)
|
||||||
|
{
|
||||||
|
const struct export_operations *eops;
|
||||||
|
|
||||||
|
eops = path->mnt->mnt_sb->s_export_op;
|
||||||
|
if (eops->open)
|
||||||
|
return eops->open(path, open_flag);
|
||||||
|
|
||||||
|
return file_open_root(path, "", open_flag, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static long do_handle_open(int mountdirfd, struct file_handle __user *ufh,
|
static long do_handle_open(int mountdirfd, struct file_handle __user *ufh,
|
||||||
int open_flag)
|
int open_flag)
|
||||||
{
|
{
|
||||||
long retval = 0;
|
long retval;
|
||||||
struct path path __free(path_put) = {};
|
struct path path __free(path_put) = {};
|
||||||
struct file *file;
|
|
||||||
const struct export_operations *eops;
|
|
||||||
|
|
||||||
retval = handle_to_path(mountdirfd, ufh, &path, open_flag);
|
retval = handle_to_path(mountdirfd, ufh, &path, open_flag);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
CLASS(get_unused_fd, fd)(open_flag);
|
return FD_ADD(open_flag, file_open_handle(&path, open_flag));
|
||||||
if (fd < 0)
|
|
||||||
return fd;
|
|
||||||
|
|
||||||
eops = path.mnt->mnt_sb->s_export_op;
|
|
||||||
if (eops->open)
|
|
||||||
file = eops->open(&path, open_flag);
|
|
||||||
else
|
|
||||||
file = file_open_root(&path, "", open_flag, 0);
|
|
||||||
if (IS_ERR(file))
|
|
||||||
return PTR_ERR(file);
|
|
||||||
|
|
||||||
fd_install(fd, file);
|
|
||||||
return take_fd(fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue