Re: Loop-aes and a changed block device size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jari Ruusu wrote:
> > Would it be worth the effort to include a this functionality into losetup?
> 
> Done. It is now "losetup -R /dev/loop0", unless someone vetoes that.

"losetup -R /dev/loop0" seems to work okay on LVM2 volumes. Unpatched
ext2online tool used to resize mounted ext3 file system seems to have little
problem. If encrypted file system is mounted like this:

  losetup -e AES128 -K /etc/fubar.gpg /dev/loop0 /dev/mapper/foo-bar
  mount -t ext3 /dev/loop0 /mnt

Then ext2online should work without modifications (I didn't test above type
mount). However, above type mount does not detach the loop device
automatically on umount. Usually I put loop options to /etc/fstab, which is
equivalent to this type mount:

  mount -t ext3 /dev/mapper/foo-bar /mnt -o loop=/dev/loop0,encryption=AES128,gpgkey=/etc/fubar.gpg
    
That makes umount detach the loop device automatically. But... with above
type mount options, ext2online failed to find the clear-text device
/dev/loop0 from mount options, saying it couldn't find ext3 superblock on
/dev/mapper/foo-bar. Of course it can't find any superblock in there,
because that data is encrypted.

Below is a patch that makes ext2online understand loop mount options and
makes it look for the superblock in the loop device. This patch fixed the
problem for me.

-- 
Jari Ruusu  1024R/3A220F51 5B 4B F9 BB D3 3F 52 E9  DB 1D EB E3 24 0E A9 DD


--- ext2resize-1.1.19/src/ext2online.c.old	Thu Sep 30 17:12:01 2004
+++ ext2resize-1.1.19/src/ext2online.c	Sun Sep 18 19:43:22 2005
@@ -165,6 +165,13 @@
 				*dir = NULL;
 			}
 
+			/* if necessary, redirect *dev to loop device */
+			if((index2 = hasmntopt(ent, "loop")) != NULL) {
+				extern char *xstrdup(const char *);
+				char *index3 = xstrdup(index2);
+				if((index2 = strchr(index3, ',')) != NULL) *index2 = 0;
+				if(strlen(index3) > 5) *dev = index3 + 5;
+			}
 again:
 			/* Don't copy options that "mount" parses for us */
 			if ((index = hasmntopt(ent, "noatime")) != NULL ||
@@ -173,6 +180,13 @@
 			    (index = hasmntopt(ent, "nosuid")) != NULL ||
 			    (index = hasmntopt(ent, "rw")) != NULL ||
 			    (index = hasmntopt(ent, "sync")) != NULL ||
+			    (index = hasmntopt(ent, "phash")) != NULL ||
+			    (index = hasmntopt(ent, "loinit")) != NULL ||
+			    (index = hasmntopt(ent, "gpgkey")) != NULL ||
+			    (index = hasmntopt(ent, "gpghome")) != NULL ||
+			    (index = hasmntopt(ent, "offset")) != NULL ||
+			    (index = hasmntopt(ent, "sizelimit")) != NULL ||
+			    (index = hasmntopt(ent, "encryption")) != NULL ||
 			    (index = hasmntopt(ent, "loop")) != NULL) {
 				if ((index2 = strchr(index, ',')) == NULL)
 					index[0] = '\0';

-
Linux-crypto:  cryptography in and on the Linux system
Archive:       http://mail.nl.linux.org/linux-crypto/


[Index of Archives]     [Kernel]     [Linux Crypto]     [Gnu Crypto]     [Gnu Classpath]     [Netfilter]     [Bugtraq]
  Powered by Linux