1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

flags: improve unknown flags logic

Use same logic as with unknown segment type - so preserve such
name fully with all flags just with UNKNOWN segment type bits.
This commit is contained in:
Zdenek Kabelac 2017-05-30 15:59:42 +02:00 committed by Heinz Mauelshagen
parent d1ac6108c3
commit fb86bddda2

View File

@ -229,16 +229,22 @@ int read_segtype_lvflags(uint64_t *status, char *segtype_str)
unsigned i; unsigned i;
const struct flag *flags = _lv_flags; const struct flag *flags = _lv_flags;
char *delim; char *delim;
char *flag; char *flag, *buffer, *str;
if (!(delim = strchr(segtype_str, '+'))) if (!(str = strchr(segtype_str, '+')))
return 1; /* No flags */ return 1; /* No flags */
*delim = '\0'; /* Cut away 1st. '+' */ if (!(buffer = dm_strdup(str + 1))) {
log_error("Cannot duplicate segment string.");
return 0;
}
delim = buffer;
do { do {
flag = delim + 1; flag = delim;
if ((delim = strchr(segtype_str, '+'))) if ((delim = strchr(delim, '+')))
*delim = '\0'; *delim++ = '\0';
for (i = 0; flags[i].description; i++) for (i = 0; flags[i].description; i++)
if ((flags[i].kind & SEGTYPE_FLAG) && if ((flags[i].kind & SEGTYPE_FLAG) &&
@ -247,12 +253,16 @@ int read_segtype_lvflags(uint64_t *status, char *segtype_str)
break; break;
} }
if (!flags[i].description) { } while (delim && flags[i].description); /* Till no more flags in type appear */
log_error("Unknown flag %s passed with segment type %s.",
flag, segtype_str); if (!flags[i].description)
return 0; /* Unknown flag is incompatible */ /* Unknown flag is incompatible - returns unmodified segtype_str */
} log_warn("WARNING: Unrecognised flag %s in segment type %s.",
} while (delim); /* Till no more flags in type appear */ flag, segtype_str);
else
*str = '\0'; /* Cut away 1st. '+' */
dm_free(buffer);
return 1; return 1;
} }