mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-24 17:57:48 +03:00
thin: tighten discard string conversions
Respond with "unknown" rather than a NULL pointer if there's an internal error and the discard value is invalid. Don't accept 'no_passdown' or 'no-passdown' variants in the LVM metadata: this is written by the program so should only ever contain "nopassdown" and should be validated strictly against that.
This commit is contained in:
parent
adfa778a58
commit
7b5ea9a5a8
@ -433,10 +433,7 @@ int get_pool_discard(const char *str, thin_discard_t *discard)
|
||||
{
|
||||
if (!strcasecmp(str, "passdown"))
|
||||
*discard = THIN_DISCARD_PASSDOWN;
|
||||
/* Allow some variation in thin parameter */
|
||||
else if (!strcasecmp(str, "nopassdown") ||
|
||||
!strcasecmp(str, "no-passdown") ||
|
||||
!strcasecmp(str, "no_passdown"))
|
||||
else if (!strcasecmp(str, "nopassdown"))
|
||||
*discard = THIN_DISCARD_NO_PASSDOWN;
|
||||
else if (!strcasecmp(str, "ignore"))
|
||||
*discard = THIN_DISCARD_IGNORE;
|
||||
@ -459,7 +456,7 @@ const char *get_pool_discard_name(thin_discard_t discard)
|
||||
return "ignore";
|
||||
}
|
||||
|
||||
log_error(INTERNAL_ERROR "Uknown discard type.");
|
||||
log_error(INTERNAL_ERROR "Uknown discard type encountered.");
|
||||
|
||||
return NULL;
|
||||
return "unknown";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user