Skip to content

Commit 1c54843

Browse files
committed
fhandle: reflow get_path_anchor()
Switch to a more common coding style. Link: https://lore.kernel.org/20250624-work-pidfs-fhandle-v2-5-d02a04858fe3@kernel.org Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent a0d8051 commit 1c54843

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

fs/fhandle.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,25 @@ SYSCALL_DEFINE5(name_to_handle_at, int, dfd, const char __user *, name,
170170

171171
static int get_path_anchor(int fd, struct path *root)
172172
{
173+
if (fd >= 0) {
174+
CLASS(fd, f)(fd);
175+
if (fd_empty(f))
176+
return -EBADF;
177+
*root = fd_file(f)->f_path;
178+
path_get(root);
179+
return 0;
180+
}
181+
173182
if (fd == AT_FDCWD) {
174183
struct fs_struct *fs = current->fs;
175184
spin_lock(&fs->lock);
176185
*root = fs->pwd;
177186
path_get(root);
178187
spin_unlock(&fs->lock);
179-
} else {
180-
CLASS(fd, f)(fd);
181-
if (fd_empty(f))
182-
return -EBADF;
183-
*root = fd_file(f)->f_path;
184-
path_get(root);
188+
return 0;
185189
}
186190

187-
return 0;
191+
return -EBADF;
188192
}
189193

190194
static int vfs_dentry_acceptable(void *context, struct dentry *dentry)

0 commit comments

Comments
 (0)