Fix in-kernel sysfs entries

The recent sysfs zfs properties feature breaks the in-kernel
builds of zfs (sans module).  When not built as a module add
the sysfs entries under /sys/fs/zfs/.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Don Brady <don.brady@delphix.com>
Closes #7868 
Closes #7872
This commit is contained in:
Don Brady
2018-09-06 22:44:52 -06:00
committed by Brian Behlendorf
parent e7b677aa5d
commit 73a5ec30bf
4 changed files with 40 additions and 30 deletions
+27 -13
View File
@@ -159,6 +159,32 @@ 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_impl(const char *scope, const char *name, const char *sysfs)
{
struct stat64 statbuf;
char *path;
boolean_t supported = B_FALSE;
int len;
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)
{
@@ -171,19 +197,7 @@ zfs_mod_supported_feature(const char *name)
#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);
if (len > 0) {
supported = !!(stat64(path, &statbuf) == 0);
free(path);
}
return (supported);
return (zfs_mod_supported(ZFS_SYSFS_POOL_FEATURES, name));
#endif
}
+2 -14
View File
@@ -81,20 +81,8 @@ zfs_mod_supported_prop(const char *name, zfs_type_t type)
#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,
(type == ZFS_TYPE_POOL) ? ZFS_SYSFS_POOL_PROPERTIES :
ZFS_SYSFS_DATASET_PROPERTIES, name);
if (len > 0) {
supported = !!(stat64(path, &statbuf) == 0);
free(path);
}
return (supported);
return (zfs_mod_supported(type == ZFS_TYPE_POOL ?
ZFS_SYSFS_POOL_PROPERTIES : ZFS_SYSFS_DATASET_PROPERTIES, name));
#endif
}