Skip to contentSkip to conversation

master - fsadm: add luks specific error message for small devices

PATCH Ondrej Kozina 1 participant 1 message Oct 24, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6df7917581eea9eef3cf5144a870df9207be15df
Commit:        6df7917581eea9eef3cf5144a870df9207be15df
Parent:        888dd33148563e95b2b3faac98f6c6dd5f00a60a
Author:        Ondrej Kozina <[email protected]>
AuthorDate:    Mon Oct 23 15:31:44 2017 +0200
Committer:     Ondrej Kozina <[email protected]>
CommitterDate: Tue Oct 24 13:40:50 2017 +0200

fsadm: add luks specific error message for small devices

---
 scripts/fsadm.sh |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
scripts/fsadm.sh +4 -0
index a68c7b8..3d0fdcd 100755
@@ -581,6 +581,10 @@ resize_luks() {
 		error "New size is not sector alligned"
 	fi
 
+	if [ $((NEWBLOCKCOUNT - CRYPT_DATA_OFFSET)) -lt 1 ]; then
+		error "New size is smaller than minimum ($(((CRYPT_DATA_OFFSET + 1) * 512)) bytes) for LUKS device $VOLUME"
+	fi
+
 	NEWCBLOCKCOUNT=$((NEWBLOCKCOUNT - CRYPT_DATA_OFFSET))
 	NEWFSIZE=$(( NEWCBLOCKCOUNT * 512))