mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
simplify xfs_find_handle() a bit
XFS_IOC_FD_TO_HANDLE can grab a reference to copied ->f_path and let the file go; results in simpler control flow - cleanup is the same for both "by descriptor" and "by pathname" cases. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
54dac3dacc
commit
0d113fcbc2
@ -85,22 +85,23 @@ xfs_find_handle(
|
|||||||
int hsize;
|
int hsize;
|
||||||
xfs_handle_t handle;
|
xfs_handle_t handle;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct fd f = EMPTY_FD;
|
|
||||||
struct path path;
|
struct path path;
|
||||||
int error;
|
int error;
|
||||||
struct xfs_inode *ip;
|
struct xfs_inode *ip;
|
||||||
|
|
||||||
if (cmd == XFS_IOC_FD_TO_HANDLE) {
|
if (cmd == XFS_IOC_FD_TO_HANDLE) {
|
||||||
f = fdget(hreq->fd);
|
CLASS(fd, f)(hreq->fd);
|
||||||
if (!fd_file(f))
|
|
||||||
|
if (fd_empty(f))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
inode = file_inode(fd_file(f));
|
path = fd_file(f)->f_path;
|
||||||
|
path_get(&path);
|
||||||
} else {
|
} else {
|
||||||
error = user_path_at(AT_FDCWD, hreq->path, 0, &path);
|
error = user_path_at(AT_FDCWD, hreq->path, 0, &path);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
inode = d_inode(path.dentry);
|
|
||||||
}
|
}
|
||||||
|
inode = d_inode(path.dentry);
|
||||||
ip = XFS_I(inode);
|
ip = XFS_I(inode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -134,10 +135,7 @@ xfs_find_handle(
|
|||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
out_put:
|
out_put:
|
||||||
if (cmd == XFS_IOC_FD_TO_HANDLE)
|
path_put(&path);
|
||||||
fdput(f);
|
|
||||||
else
|
|
||||||
path_put(&path);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user