Commit 03cb8a0a authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Pavel Emelyanov

fix the wrong usage of strtok() in fsname_is_auto()

I am stupid. fsname_is_auto() can't use strtok(), the 2nd call will
see zeroes instead of commas in fsauto_names.

Add the css_contains() helper and change fsname_is_auto() to use it.
Signed-off-by: 's avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 0dfdd052
......@@ -1367,22 +1367,34 @@ static struct fstype fstypes[32] = {
static char *fsauto_names;
static bool fsname_is_auto(const char *name)
static bool css_contains(const char *css, const char *str)
{
const char *p;
int len = strlen(str);
const char *cur;
if (!len)
return false;
for (cur = css; (cur = strstr(cur, str)); cur += len) {
if (cur > css && cur[-1] != ',')
continue;
if (cur[len] && cur[len] != ',')
continue;
return true;
}
return false;
}
static bool fsname_is_auto(const char *name)
{
if (!fsauto_names)
return false;
if (strcmp(fsauto_names, "all") == 0)
return true;
for (p = strtok(fsauto_names, ","); p; p = strtok(NULL, ",")) {
if (strcmp(name, p) == 0)
return true;
}
return false;
return css_contains(fsauto_names, name);
}
bool add_fsname_auto(const char *names)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment