libzutil: zfs_resolve_shortname: 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:
parent
91d6780671
commit
2a8c606082
|
@ -41,18 +41,18 @@ int
|
||||||
zfs_resolve_shortname(const char *name, char *path, size_t len)
|
zfs_resolve_shortname(const char *name, char *path, size_t len)
|
||||||
{
|
{
|
||||||
int i, error = -1;
|
int i, error = -1;
|
||||||
char *dir, *env, *envdup;
|
char *dir, *env, *envdup, *tmp = NULL;
|
||||||
|
|
||||||
env = getenv("ZPOOL_IMPORT_PATH");
|
env = getenv("ZPOOL_IMPORT_PATH");
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
|
|
||||||
if (env) {
|
if (env) {
|
||||||
envdup = strdup(env);
|
envdup = strdup(env);
|
||||||
dir = strtok(envdup, ":");
|
for (dir = strtok_r(envdup, ":", &tmp);
|
||||||
while (dir && error) {
|
dir != NULL && error != 0;
|
||||||
|
dir = strtok_r(NULL, ":", &tmp)) {
|
||||||
(void) snprintf(path, len, "%s/%s", dir, name);
|
(void) snprintf(path, len, "%s/%s", dir, name);
|
||||||
error = access(path, F_OK);
|
error = access(path, F_OK);
|
||||||
dir = strtok(NULL, ":");
|
|
||||||
}
|
}
|
||||||
free(envdup);
|
free(envdup);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue