diff options
Diffstat (limited to 'module/zcommon/zfeature_common.c')
-rw-r--r-- | module/zcommon/zfeature_common.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/module/zcommon/zfeature_common.c b/module/zcommon/zfeature_common.c index c86f98ac2..e630481cb 100644 --- a/module/zcommon/zfeature_common.c +++ b/module/zcommon/zfeature_common.c @@ -159,31 +159,45 @@ deps_contains_feature(const spa_feature_t *deps, const spa_feature_t feature) return (B_FALSE); } +#if !defined(_KERNEL) && !defined(LIB_ZPOOL_BUILD) static boolean_t -zfs_mod_supported_feature(const char *name) +zfs_mod_supported_impl(const char *scope, const char *name, const char *sysfs) { - /* - * The zfs module spa_feature_table[], whether in-kernel or in - * libzpool, always supports all the features. libzfs needs to - * query the running module, via sysfs, to determine which - * features are supported. - */ -#if defined(_KERNEL) || defined(LIB_ZPOOL_BUILD) - return (B_TRUE); -#else struct stat64 statbuf; char *path; boolean_t supported = B_FALSE; int len; - len = asprintf(&path, "%s/%s/%s", ZFS_SYSFS_DIR, - ZFS_SYSFS_POOL_FEATURES, name); + len = asprintf(&path, "%s/%s/%s", sysfs, scope, name); if (len > 0) { supported = !!(stat64(path, &statbuf) == 0); free(path); } return (supported); +} + +boolean_t +zfs_mod_supported(const char *scope, const char *name) +{ + return (zfs_mod_supported_impl(scope, name, ZFS_SYSFS_DIR) || + zfs_mod_supported_impl(scope, name, ZFS_SYSFS_ALT_DIR)); +} +#endif + +static boolean_t +zfs_mod_supported_feature(const char *name) +{ + /* + * The zfs module spa_feature_table[], whether in-kernel or in + * libzpool, always supports all the features. libzfs needs to + * query the running module, via sysfs, to determine which + * features are supported. + */ +#if defined(_KERNEL) || defined(LIB_ZPOOL_BUILD) + return (B_TRUE); +#else + return (zfs_mod_supported(ZFS_SYSFS_POOL_FEATURES, name)); #endif } |