linux/libzutil: zfs_path_order: remove strtok

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12094
This commit is contained in:
наб 2021-05-20 22:51:06 +02:00 committed by Brian Behlendorf
parent 2a8c606082
commit 31f4c8cb19
1 changed files with 5 additions and 6 deletions

View File

@ -283,21 +283,20 @@ zpool_default_search_paths(size_t *count)
static int static int
zfs_path_order(char *name, int *order) zfs_path_order(char *name, int *order)
{ {
int i = 0, error = ENOENT; int i, error = ENOENT;
char *dir, *env, *envdup; char *dir, *env, *envdup, *tmp = NULL;
env = getenv("ZPOOL_IMPORT_PATH"); env = getenv("ZPOOL_IMPORT_PATH");
if (env) { if (env) {
envdup = strdup(env); envdup = strdup(env);
dir = strtok(envdup, ":"); for (dir = strtok_r(envdup, ":", &tmp), i = 0;
while (dir) { dir != NULL;
dir = strtok_r(NULL, ":", &tmp), i++) {
if (strncmp(name, dir, strlen(dir)) == 0) { if (strncmp(name, dir, strlen(dir)) == 0) {
*order = i; *order = i;
error = 0; error = 0;
break; break;
} }
dir = strtok(NULL, ":");
i++;
} }
free(envdup); free(envdup);
} else { } else {