aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/lib/libzutil/zutil_import.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/lib/libzutil/zutil_import.c')
-rw-r--r--sys/contrib/openzfs/lib/libzutil/zutil_import.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/sys/contrib/openzfs/lib/libzutil/zutil_import.c b/sys/contrib/openzfs/lib/libzutil/zutil_import.c
index 5d7b4a946c1e..65f462e42cd0 100644
--- a/sys/contrib/openzfs/lib/libzutil/zutil_import.c
+++ b/sys/contrib/openzfs/lib/libzutil/zutil_import.c
@@ -233,7 +233,7 @@ fix_paths(libpc_handle_t *hdl, nvlist_t *nv, name_entry_t *names)
uint_t c, children;
uint64_t guid;
name_entry_t *ne, *best;
- char *path;
+ const char *path;
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
&child, &children) == 0) {
@@ -497,7 +497,7 @@ get_configs(libpc_handle_t *hdl, pool_list_t *pl, boolean_t active_ok,
uint_t i, nspares, nl2cache;
boolean_t config_seen;
uint64_t best_txg;
- char *name, *hostname = NULL;
+ const char *name, *hostname = NULL;
uint64_t guid;
uint_t children = 0;
nvlist_t **child = NULL;
@@ -591,8 +591,8 @@ get_configs(libpc_handle_t *hdl, pool_list_t *pl, boolean_t active_ok,
* hostname (if available)
*/
uint64_t state, version;
- char *comment = NULL;
- char *compatibility = NULL;
+ const char *comment = NULL;
+ const char *compatibility = NULL;
version = fnvlist_lookup_uint64(tmp,
ZPOOL_CONFIG_VERSION);
@@ -1161,12 +1161,12 @@ slice_cache_compare(const void *arg1, const void *arg2)
static int
label_paths_impl(libpc_handle_t *hdl, nvlist_t *nvroot, uint64_t pool_guid,
- uint64_t vdev_guid, char **path, char **devid)
+ uint64_t vdev_guid, const char **path, const char **devid)
{
nvlist_t **child;
uint_t c, children;
uint64_t guid;
- char *val;
+ const char *val;
int error;
if (nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN,
@@ -1204,7 +1204,8 @@ label_paths_impl(libpc_handle_t *hdl, nvlist_t *nvroot, uint64_t pool_guid,
* The returned pointers are only valid as long as label remains valid.
*/
int
-label_paths(libpc_handle_t *hdl, nvlist_t *label, char **path, char **devid)
+label_paths(libpc_handle_t *hdl, nvlist_t *label, const char **path,
+ const char **devid)
{
nvlist_t *nvroot;
uint64_t pool_guid;
@@ -1473,7 +1474,7 @@ zpool_find_import_impl(libpc_handle_t *hdl, importargs_t *iarg,
}
if (iarg->poolname != NULL && !aux) {
- char *pname;
+ const char *pname;
matched = nvlist_lookup_string(config,
ZPOOL_CONFIG_POOL_NAME, &pname) == 0 &&
@@ -1547,7 +1548,7 @@ static int
discover_cached_paths(libpc_handle_t *hdl, nvlist_t *nv,
avl_tree_t *cache, pthread_mutex_t *lock)
{
- char *path = NULL;
+ const char *path = NULL;
ssize_t dl;
uint_t children;
nvlist_t **child;
@@ -1564,12 +1565,21 @@ discover_cached_paths(libpc_handle_t *hdl, nvlist_t *nv,
* our directory cache.
*/
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0) {
- if ((dl = zfs_dirnamelen(path)) == -1)
- path = (char *)".";
- else
- path[dl] = '\0';
- return (zpool_find_import_scan_dir(hdl, lock, cache,
- path, 0));
+ int ret;
+ char c = '\0';
+ if ((dl = zfs_dirnamelen(path)) == -1) {
+ path = ".";
+ } else {
+ c = path[dl];
+ ((char *)path)[dl] = '\0';
+
+ }
+ ret = zpool_find_import_scan_dir(hdl, lock, cache,
+ path, 0);
+ if (c != '\0')
+ ((char *)path)[dl] = c;
+
+ return (ret);
}
return (0);
}
@@ -1588,7 +1598,7 @@ zpool_find_import_cached(libpc_handle_t *hdl, importargs_t *iarg)
nvlist_t *raw, *src, *dst;
nvlist_t *pools;
nvpair_t *elem;
- char *name;
+ const char *name;
uint64_t this_guid;
boolean_t active;
@@ -1818,10 +1828,10 @@ zpool_search_import(libpc_handle_t *hdl, importargs_t *import)
}
static boolean_t
-pool_match(nvlist_t *cfg, char *tgt)
+pool_match(nvlist_t *cfg, const char *tgt)
{
uint64_t v, guid = strtoull(tgt, NULL, 0);
- char *s;
+ const char *s;
if (guid != 0) {
if (nvlist_lookup_uint64(cfg, ZPOOL_CONFIG_POOL_GUID, &v) == 0)
@@ -1906,7 +1916,7 @@ for_each_vdev_cb(void *zhp, nvlist_t *nv, pool_vdev_iter_f func,
uint_t c, children;
int ret = 0;
int i;
- char *type;
+ const char *type;
const char *list[] = {
ZPOOL_CONFIG_SPARES,