chiark / gitweb /
add FSCK_ON_MOUNT option
authorwry@lapis <wry@lapis>
Sun, 20 Jun 2010 08:53:59 +0000 (09:53 +0100)
committerwry@lapis <wry@lapis>
Sun, 20 Jun 2010 08:53:59 +0000 (09:53 +0100)
chiark-cryptdisk/config
chiark-cryptdisk/examine
chiark-cryptdisk/functions
debian/changelog

index b9ffbcb..069bf8e 100644 (file)
@@ -10,6 +10,9 @@ MAILTO=root@localhost
 # Do we want to send the drive to sleep when we're finished?
 SLEEP_DRIVE=no
 
+# Do we want to try to fsck on mount? Usually you do.
+FSCK_ON_MOUNT=yes
+
 lib=/usr/lib/chiark-cryptdisk
 dev=`/usr/lib/chiark-cryptdisk/search-for-sata ${MODULE}`
 mapname=cryptbackup
index c528522..6d56a17 100755 (executable)
@@ -9,6 +9,9 @@ test $# = 0 || fail "usage: .../examine [--rw]"
 
 do_identify
 do_dmsetup $keyid
+if [ "x${FSCK_ON_MOUNT}" = "xy" ] || [ "x${FSCK_ON_MOUNT}" = "xyes" ]; then
+       do_fsck
+fi
 do_mount $ro
 echo 'mounted.'
 egrep . /dev/null $mnt/disk-id ||:
index a703395..03cb5f9 100644 (file)
@@ -45,6 +45,19 @@ undo_mount () {
        umount /dev/mapper/$mapname
 }
 
+do_fsck () {
+       RV=0
+       fsck -a -T -t $fstype /dev/mapper/$mapname || RV=$?
+       case "$RV" in
+               0) ;;
+               1) echo "fsck preened - filesystem was modified but is ok" ;;
+               *)      echo "ERROR: fsck failed with code $RV! Manual attention required."
+                       exit 5 ;;
+       esac
+# CAUTION: on ext2, '-a' maps to '-p' - preen - only make safe repairs.
+# This may not be the case for other filesystems.
+}
+
 do_identify () {
        printf 'reading partition table... '
        our_dd count=1 if=/dev/$dev of=${TMP}/dev-parttable
index f3ea612..73371dd 100644 (file)
@@ -3,8 +3,9 @@ chiark-cryptdisk (0.2.1) unstable; urgency=low
   * search-for-sata: Add logic to detect and cope with 2.6.32-style sysfs. 
   * config: add SLEEP_DRIVE param
   * unmount: hdparm -Y only if SLEEP_DRIVE == "y" or "yes". 
+  * config: add FSCK_ON_MOUNT option
 
- -- Ross Younger <wry-deb@impropriety.org.uk>  Sat, 19 Jun 2010 10:49:09 +0100
+ -- Ross Younger <wry-deb@impropriety.org.uk>  Sun, 20 Jun 2010 09:53:40 +0100
 
 chiark-cryptdisk (0.2) unstable; urgency=low