From: Hongbo Li <lihongbo22@huawei.com>
To: <viro@zeniv.linux.org.uk>, <brauner@kernel.org>, <jack@suse.cz>,
<tytso@mit.edu>, <adilger.kernel@dilger.ca>
Cc: <lczerner@redhat.com>, <cmaiolino@redhat.com>,
<linux-fsdevel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
<yi.zhang@huawei.com>, <lihongbo22@huawei.com>
Subject: [PATCH 2/4] fs: add path parser for filesystem mount option.
Date: Mon, 27 May 2024 09:47:15 +0800 [thread overview]
Message-ID: <20240527014717.690140-3-lihongbo22@huawei.com> (raw)
In-Reply-To: <20240527014717.690140-1-lihongbo22@huawei.com>
`fsparam_path` uses `fs_param_is_path` to parse the option, but it
is currently empty. The new mount api has considered this option in
`fsconfig`(that is FSCONFIG_SET_PATH). Here we add general path parser
in filesystem layer. Currently, no filesystem uses this function to
parse parameters, we add `void *ptr` in `fs_parse_result` to point to
the target structure(such as `struct inode *`).
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
fs/fs_parser.c | 18 ++++++++++++++++++
include/linux/fs_parser.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/fs/fs_parser.c b/fs/fs_parser.c
index 48f60ecfcca0..c41a13e564c4 100644
--- a/fs/fs_parser.c
+++ b/fs/fs_parser.c
@@ -367,6 +367,24 @@ EXPORT_SYMBOL(fs_param_is_blockdev);
int fs_param_is_path(struct p_log *log, const struct fs_parameter_spec *p,
struct fs_parameter *param, struct fs_parse_result *result)
{
+ int ret;
+ struct filename *f;
+ struct path path;
+
+ if (param->type != fs_value_is_filename)
+ return fs_param_bad_value(log, param);
+ if (!*param->string && (p->flags & fs_param_can_be_empty))
+ return 0;
+
+ f = param->name;
+ ret = filename_lookup(param->dirfd, f, LOOKUP_FOLLOW, &path, NULL);
+ if (ret < 0) {
+ error_plog(log, "%s: Lookup failure for '%s'", param->key, f->name);
+ return fs_param_bad_value(log, param);
+ }
+ result->ptr = d_backing_inode(path.dentry);
+ path_put(&path);
+
return 0;
}
EXPORT_SYMBOL(fs_param_is_path);
diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h
index d3350979115f..489c71d06a5f 100644
--- a/include/linux/fs_parser.h
+++ b/include/linux/fs_parser.h
@@ -57,6 +57,7 @@ struct fs_parse_result {
int int_32; /* For spec_s32/spec_enum */
unsigned int uint_32; /* For spec_u32{,_octal,_hex}/spec_enum */
u64 uint_64; /* For spec_u64 */
+ const void *ptr; /* For spec_ptr */
};
};
--
2.34.1
next prev parent reply other threads:[~2024-05-27 1:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 1:47 [PATCH 0/4] enhance the path resolution capability in fs_parser Hongbo Li
2024-05-27 1:47 ` [PATCH 1/4] fs: add blockdev parser for filesystem mount option Hongbo Li
2024-05-27 3:22 ` kernel test robot
2024-05-27 1:47 ` Hongbo Li [this message]
2024-05-27 1:47 ` [PATCH 3/4] fs: ext4: support relative path for `journal_path` in " Hongbo Li
2024-05-27 1:47 ` [PATCH 4/4] fs: remove fs_lookup_param and its description Hongbo Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240527014717.690140-3-lihongbo22@huawei.com \
--to=lihongbo22@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=brauner@kernel.org \
--cc=cmaiolino@redhat.com \
--cc=jack@suse.cz \
--cc=lczerner@redhat.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=yi.zhang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox