[PATCH v2 1/3] fs: configfs: add helper to identify configfs paths
Runyu Xiao <[email protected]>
| Newsgroups | org.infradead.lists.linux-nvme,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
Several nvmet paths need to identify configfs-backed resolved paths while already running under configfs callbacks. Keep the classification in configfs itself so callers can reuse the filesystem-type test instead of open-coding string comparisons. Signed-off-by: Runyu Xiao <[email protected]> --- fs/configfs/mount.c | 6 ++++++ include/linux/configfs.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c index 456c4a2efb53..1204421b61df 100644 --- a/fs/configfs/mount.c +++ b/fs/configfs/mount.c @@ -120,6 +120,12 @@ static struct file_system_type configfs_fs_type = { }; MODULE_ALIAS_FS("configfs"); +bool configfs_path_is_configfs(const struct path *path) +{ + return path->dentry->d_sb->s_type == &configfs_fs_type; +} +EXPORT_SYMBOL_GPL(configfs_path_is_configfs); + struct dentry *configfs_pin_fs(void) { int err = simple_pin_fs(&configfs_fs_type, &configfs_mount, diff --git a/include/linux/configfs.h b/include/linux/configfs.h index 698520b1bfdb..b3426c952835 100644 --- a/include/linux/configfs.h +++ b/include/linux/configfs.h @@ -34,6 +34,7 @@ struct configfs_group_operations; struct configfs_attribute; struct configfs_bin_attribute; struct configfs_subsystem; +struct path; struct config_item { char *ci_name; @@ -243,6 +244,7 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys); int configfs_register_group(struct config_group *parent_group, struct config_group *group); void configfs_unregister_group(struct config_group *group); +bool configfs_path_is_configfs(const struct path *path); void configfs_remove_default_groups(struct config_group *group); -- 2.34.1