[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240719-fsconfig-fsparam_fd-fixes-v1-2-7ccd315c2ad4@cyphar.com>
Date: Fri, 19 Jul 2024 00:34:23 +1000
From: Aleksa Sarai <cyphar@...har.com>
To: Ian Kent <raven@...maw.net>, Bill O'Donnell <bodonnel@...hat.com>,
Christian Brauner <brauner@...nel.org>, Jan Harkes <jaharkes@...cmu.edu>,
coda@...cmu.edu, Eric Sandeen <sandeen@...hat.com>,
David Howells <dhowells@...hat.com>
Cc: autofs@...r.kernel.org, linux-kernel@...r.kernel.org,
codalist@...a.cs.cmu.edu, Aleksa Sarai <cyphar@...har.com>
Subject: [PATCH 2/2] coda: support FSCONFIG_SET_FD for fd mount flag
It's possible for users to pass file descriptors directly using
FSCONFIG_SET_FD, but the old version only supported the string-based
passing of file descriptors.
Fixes: 5916f439f2eb ("Convert coda to use the new mount API")
Signed-off-by: Aleksa Sarai <cyphar@...har.com>
---
fs/coda/inode.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 6898dc621011..df477a7218a2 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -122,21 +122,27 @@ static const struct fs_parameter_spec coda_param_specs[] = {
static int coda_parse_fd(struct fs_context *fc, int fd)
{
struct coda_fs_context *ctx = fc->fs_private;
- struct fd f;
+ struct file *file;
struct inode *inode;
int idx;
- f = fdget(fd);
- if (!f.file)
+ if (param->type == fs_value_is_file) {
+ file = param->file;
+ param->file = NULL;
+ } else {
+ file = fget(result->uint_32);
+ }
+ if (!file)
return -EBADF;
- inode = file_inode(f.file);
+
+ inode = file_inode(file);
if (!S_ISCHR(inode->i_mode) || imajor(inode) != CODA_PSDEV_MAJOR) {
- fdput(f);
+ fput(file);
return invalf(fc, "code: Not coda psdev");
}
idx = iminor(inode);
- fdput(f);
+ fput(file);
if (idx < 0 || idx >= MAX_CODADEVS)
return invalf(fc, "coda: Bad minor number");
--
2.45.2
Powered by blists - more mailing lists