Make short uuid specification for allow-discards work

1) strstr " $discarduuids " did not remove the optional
'luks-' prefix from the argument as the documentation says.

2) The lookup seems backwards. $luksdev ($luks in the other code copy)
is the full uuid and thus one should check whether the user-supplied
argument (short form) is contained therein, not the other way around.

Before this commit, the only way to trigger allow-discards was to
specify the full uuid without the 'luks-' prefix.
master
Robert Buchholz 2012-11-11 20:25:06 +01:00 committed by Harald Hoyer
parent 64d144aece
commit 065fc56ab2
2 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ fi
# parse for allow-discards
if strstr "$(cryptsetup --help)" "allow-discards"; then
if discarduuids=$(getargs "rd.luks.allow-discards"); then
if strstr " $discarduuids " " ${luks##luks-}"; then
if strstr " ${luksdev##luks-} " " ${discarduuids##luks-}"; then
allowdiscards="allow-discards"
fi
elif getargbool rd.luks.allow-discards; then

View File

@ -97,7 +97,7 @@ done
# parse for allow-discards
if strstr "$(cryptsetup --help)" "allow-discards"; then
if discarduuids=$(getargs "rd.luks.allow-discards"); then
if strstr " $discarduuids " " ${luksdev##luks-}"; then
if strstr " ${luksdev##luks-} " " ${discarduuids##luks-}"; then
allowdiscards="--allow-discards"
fi
elif getargbool rd.luks.allow-discards; then