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
zfs_path_order(char *name, int *order)
{
int i = 0, error = ENOENT;
char *dir, *env, *envdup;
int i, error = ENOENT;
char *dir, *env, *envdup, *tmp = NULL;
env = getenv("ZPOOL_IMPORT_PATH");
if (env) {
envdup = strdup(env);
dir = strtok(envdup, ":");
while (dir) {
for (dir = strtok_r(envdup, ":", &tmp), i = 0;
dir != NULL;
dir = strtok_r(NULL, ":", &tmp), i++) {
if (strncmp(name, dir, strlen(dir)) == 0) {
*order = i;
error = 0;
break;
}
dir = strtok(NULL, ":");
i++;
}
free(envdup);
} else {