[PATCH] vfs: allow O_PATH file descriptors for open_by_handle_at()

From: NeilBrown
Date: Fri May 28 2021 - 01:17:22 EST



The purpose of the "mount_fd" arg to open_by_handle_at() is solely to
identify a particular mount. i.e. it indicates "a location in the
filesystem tree" which is one of the purposes of O_PATH.

So change fdget() to fdget_raw().

Cc: stable@xxxxxxxxxxxxxxx # O_PATH introduced in 3.0+
Signed-off-by: NeilBrown <neilb@xxxxxxx>
---

This seems generally sensible, but will particularly be useful in
preparing the Lustre filesystem for upstream.

fs/fhandle.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fhandle.c b/fs/fhandle.c
index ec6feeccc276..0020a0afdf86 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -122,7 +122,7 @@ static struct vfsmount *get_vfsmount_from_fd(int fd)
mnt = mntget(fs->pwd.mnt);
spin_unlock(&fs->lock);
} else {
- struct fd f = fdget(fd);
+ struct fd f = fdget_raw(fd);
if (!f.file)
return ERR_PTR(-EBADF);
mnt = mntget(f.file->f_path.mnt);
--
2.31.1