[Pkg-loop-aes-commits] r1424 - in /trunk/loop-aes-utils: ./ debian/changelog debian/patches/20loop-AES.dpatch

xam at users.alioth.debian.org xam at users.alioth.debian.org
Sat Aug 11 14:22:41 UTC 2007


Author: xam
Date: Sat Aug 11 14:22:41 2007
New Revision: 1424

URL: http://svn.debian.org/wsvn/pkg-loop-aes/?sc=1&rev=1424
Log:
Update loop-AES patch to v3.2a and rebase against util-linux-ng 2.13-rc3

Modified:
    trunk/loop-aes-utils/   (props changed)
    trunk/loop-aes-utils/debian/changelog
    trunk/loop-aes-utils/debian/patches/20loop-AES.dpatch

Propchange: trunk/loop-aes-utils/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Sat Aug 11 14:22:41 2007
@@ -1,4 +1,4 @@
-02a4734a-7125-4a10-a2dd-ccf7f6155d04:/local/pkg-loop-aes/trunk/loop-aes-utils:10985
+02a4734a-7125-4a10-a2dd-ccf7f6155d04:/local/pkg-loop-aes/trunk/loop-aes-utils:10986
 53348a03-e5de-0310-b097-96e6f85ea926:/import/loop-aes-utils/branches/2.12-alternative:120
 53348a03-e5de-0310-b097-96e6f85ea926:/import/loop-aes-utils/branches/2.12-dpatch:196
 53348a03-e5de-0310-b097-96e6f85ea926:/import/loop-aes-utils/trunk/current:338

Modified: trunk/loop-aes-utils/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-loop-aes/trunk/loop-aes-utils/debian/changelog?rev=1424&op=diff
==============================================================================
--- trunk/loop-aes-utils/debian/changelog (original)
+++ trunk/loop-aes-utils/debian/changelog Sat Aug 11 14:22:41 2007
@@ -3,6 +3,8 @@
   * New upstream release
   * Sync with util-linux 2.13~rc-3: All patches in
     debian/patches/* included upstream.
+  * Update loop-AES patch to v3.2a and rebase against
+    util-linux-ng 2.13-rc3
 
  -- Max Vozeler <xam at debian.org>  Sat, 11 Aug 2007 15:24:42 +0200
 

Modified: trunk/loop-aes-utils/debian/patches/20loop-AES.dpatch
URL: http://svn.debian.org/wsvn/pkg-loop-aes/trunk/loop-aes-utils/debian/patches/20loop-AES.dpatch?rev=1424&op=diff
==============================================================================
--- trunk/loop-aes-utils/debian/patches/20loop-AES.dpatch (original)
+++ trunk/loop-aes-utils/debian/patches/20loop-AES.dpatch Sat Aug 11 14:22:41 2007
@@ -1,75 +1,41 @@
 #! /bin/sh /usr/share/dpatch/dpatch-run
 ## 20loop-AES.dpatch by Max Vozeler <xam at debian.org>
 ##
-## DP: This dpatch consists of util-linux-2.12r.diff from the 
-## DP: loop-AES source tarball. The patch was written by Jari Ruusu 
-## DP: <jariruusu at users.sourceforge.net>
+## DP: This dpatch is based on util-linux-2.12r.diff from the 
+## DP: loop-AES source tarball, originally written by Jari Ruusu 
+## DP: <jariruusu at users.sourceforge.net>. It has been ported to
+## DP: util-linux-ng 2.13-pre3 by Max Vozeler.
 
 @DPATCH@
-diff -urN util-linux-2.12r/mount/Makefile util-linux-2.12r-AES/mount/Makefile
---- util-linux-2.12r/mount/Makefile	2004-12-22 11:32:08.000000000 +0200
-+++ util-linux-2.12r-AES/mount/Makefile	2005-09-24 14:48:53.000000000 +0300
-@@ -29,7 +29,6 @@
- 
- MAYBE = pivot_root swapoff
- 
--LO_OBJS = lomount.o $(LIB)/xstrncpy.o
- NFS_OBJS = nfsmount.o nfsmount_xdr.o nfsmount_clnt.o
- GEN_FILES = nfsmount.h nfsmount_xdr.c nfsmount_clnt.c
- 
-@@ -49,24 +48,33 @@
- 
- mount: mount.o fstab.o sundries.o xmalloc.o realpath.o mntent.o version.o \
-        get_label_uuid.o mount_by_label.o mount_blkid.o mount_guess_fstype.o \
--       getusername.o $(LIB)/setproctitle.o $(LIB)/env.o $(NFS_OBJS) $(LO_OBJS)
-+	getusername.o $(LIB)/setproctitle.o $(LIB)/env.o $(NFS_OBJS) lomount.o \
-+	loumount.o loop.o sha512.o rmd160.o aes.o $(LIB)/xstrncpy.o
- 	$(LINK) $^ -o $@ $(BLKID_LIB)
- 
- umount: umount.o fstab.o sundries.o xmalloc.o realpath.o mntent.o \
- 	getusername.o get_label_uuid.o mount_by_label.o mount_blkid.o \
--	version.o $(LIB)/env.o $(LO_OBJS)
-+	version.o $(LIB)/env.o loumount.o
- 	$(LINK) $^ -o $@ $(BLKID_LIB)
- 
- swapon:	swapon.o version.o xmalloc.o \
--	get_label_uuid.o mount_by_label.o mount_blkid.o
-+	get_label_uuid.o mount_by_label.o mount_blkid.o loop.o sha512.o $(LIB)/xstrncpy.o
- 	$(LINK) $^ -o $@ $(BLKID_LIB)
- 
- main_losetup.o: lomount.c
- 	$(COMPILE) -DMAIN lomount.c -o $@
- 
--losetup: main_losetup.o $(LIB)/xstrncpy.o
-+losetup: main_losetup.o loumount.o loop.o sha512.o rmd160.o aes.o $(LIB)/xstrncpy.o
- 	$(LINK) $^ -o $@
- 
-+loop.o lomount.o main_losetup.o swapon.o: loop.h
-+
-+sha512.o lomount.o main_losetup.o swapon.o: sha512.h
-+
-+rmd160.o lomount.o main_losetup.o: rmd160.h
-+
-+aes.o lomount.o main_losetup.o: aes.h
-+
- mount.o umount.o nfsmount.o losetup.o fstab.o realpath.o sundries.o: sundries.h
- 
- mount.o umount.o fstab.o sundries.o: fstab.h
-@@ -79,9 +87,9 @@
- 
- mount.o umount.o getusername.o: getusername.h
- 
--mount.o umount.o losetup.o lomount.o: lomount.h loop.h my_dev_t.h
-+mount.o umount.o losetup.o lomount.o loumount.o: lomount.h loop.h
- 
--swapon.o: swap_constants.h swapargs.h
-+swapon.o: swap_constants.h swapargs.h loop.h
- 
- sundries.o nfsmount.o nfsmount_xdr.o nfsmount_clnt.o: nfsmount.h
- 
-diff -urN util-linux-2.12r/mount/aes.c util-linux-2.12r-AES/mount/aes.c
---- util-linux-2.12r/mount/aes.c	1970-01-01 02:00:00.000000000 +0200
-+++ util-linux-2.12r-AES/mount/aes.c	2005-09-24 14:48:53.000000000 +0300
+diff --git a/mount/Makefile.am b/mount/Makefile.am
+index f40bdd7..2688a6b 100644
+--- a/mount/Makefile.am
++++ b/mount/Makefile.am
+@@ -13,6 +13,7 @@ headers_common = fstab.h linux_fs.h mount_mntent.h mount_constants.h my_dev_t.h
+ 	getusername.h loop.h sundries.h
+ 
+ mount_common = fstab.c mount_mntent.c getusername.c lomount.c \
++	loumount.c loop.c sha512.c rmd160.c aes.c \
+ 	$(utils_common) $(headers_common) ../lib/env.c
+ 
+ mount_SOURCES = mount.c $(mount_common) ../lib/setproctitle.c
+@@ -23,9 +24,9 @@ umount_SOURCES = umount.c $(mount_common)
+ umount_CFLAGS = $(SUID_CFLAGS) $(AM_CFLAGS)
+ umount_LDFLAGS = $(SUID_LDFLAGS) $(AM_LDFLAGS)
+ 
+-swapon_SOURCES = swapon.c swap_constants.h $(utils_common)
++swapon_SOURCES = swapon.c swap_constants.h $(utils_common) loop.c sha512.c
+ 
+-losetup_SOURCES = lomount.c loop.h lomount.h
++losetup_SOURCES = lomount.c loop.h lomount.h loumount.c loop.c sha512.c rmd160.c aes.c
+ losetup_CPPFLAGS = -DMAIN $(AM_CPPFLAGS)
+ 
+ mount_LDADD = $(LDADD_common)
+diff --git a/mount/aes.c b/mount/aes.c
+new file mode 100644
+index 0000000..c81099a
+--- /dev/null
++++ b/mount/aes.c
 @@ -0,0 +1,299 @@
 +// I retain copyright in this code but I encourage its free use provided
 +// that I don't carry any responsibility for the results. I am especially 
@@ -370,9 +336,11 @@
 +
 +    state_out(out_blk, b0);
 +}
-diff -urN util-linux-2.12r/mount/aes.h util-linux-2.12r-AES/mount/aes.h
---- util-linux-2.12r/mount/aes.h	1970-01-01 02:00:00.000000000 +0200
-+++ util-linux-2.12r-AES/mount/aes.h	2005-09-24 14:48:53.000000000 +0300
+diff --git a/mount/aes.h b/mount/aes.h
+new file mode 100644
+index 0000000..4f1e3b3
+--- /dev/null
++++ b/mount/aes.h
 @@ -0,0 +1,97 @@
 +// I retain copyright in this code but I encourage its free use provided
 +// that I don't carry any responsibility for the results. I am especially 
@@ -471,9 +439,10 @@
 +// if their parameters have not changed.
 +
 +#endif  // _AES_H
-diff -urN util-linux-2.12r/mount/lomount.c util-linux-2.12r-AES/mount/lomount.c
---- util-linux-2.12r/mount/lomount.c	2004-12-21 00:11:04.000000000 +0200
-+++ util-linux-2.12r-AES/mount/lomount.c	2007-02-17 09:58:11.000000000 +0200
+diff --git a/mount/lomount.c b/mount/lomount.c
+index ae9eb36..432610f 100644
+--- a/mount/lomount.c
++++ b/mount/lomount.c
 @@ -1,4 +1,15 @@
 -/* Originally from Ted's losetup.c */
 +/* Taken from Ted's losetup.c - Mitch <m.dsouza at mrc-apu.cam.ac.uk> */
@@ -491,7 +460,7 @@
  
  #define LOOPMAJOR	7
  
-@@ -13,60 +24,81 @@
+@@ -13,63 +24,85 @@
  #include <errno.h>
  #include <stdlib.h>
  #include <unistd.h>
@@ -518,6 +487,8 @@
 +#include "rmd160.h"
 +#include "aes.h"
 +
++#define SIZE(a) (sizeof(a)/sizeof(a[0]))
++
 +#if !defined(BLKGETSIZE64)
 +# define BLKGETSIZE64 _IOR(0x12,114,size_t)
 +#endif
@@ -529,9 +500,37 @@
 +extern void show_all_loops(void);
 +extern int read_options_from_fstab(char *, char **);
 +extern int recompute_loop_dev_size(char *);
- 
++  
++#if !defined(LOOP_PASSWORD_MIN_LENGTH)
++# define  LOOP_PASSWORD_MIN_LENGTH   20
++#endif
++  
++char    *passFDnumber = (char *)0;
++char    *passAskTwice = (char *)0;
++char    *passSeedString = (char *)0;
++char    *passHashFuncName = (char *)0;
++char    *passIterThousands = (char *)0;
++char    *loInitValue = (char *)0;
++char    *gpgKeyFile = (char *)0;
++char    *gpgHomeDir = (char *)0;
++char    *clearTextKeyFile = (char *)0;
++char    *loopOffsetBytes = (char *)0;
++char    *loopSizeBytes = (char *)0;
++char    *loopEncryptionType = (char *)0;
++
++static int  multiKeyMode = 0;   /* 0=single-key 64=multi-key-v2 65=multi-key-v3 1000=any */
++static char *multiKeyPass[66];
++static char *loopFileName;
++static char *progname;
+ 
+-#define SIZE(a) (sizeof(a)/sizeof(a[0]))
+-
 -#ifdef LOOP_SET_FD
--
++#ifdef MAIN
++static char *
++crypt_name (int id, int *flags) {
++	int i;
+ 
 -static int
 -loop_info64_to_old(const struct loop_info64 *info64, struct loop_info *info)
 -{
@@ -558,34 +557,8 @@
 -            info->lo_inode != info64->lo_inode ||
 -            info->lo_offset != info64->lo_offset)
 -                return -EOVERFLOW;
-+#if !defined(LOOP_PASSWORD_MIN_LENGTH)
-+# define  LOOP_PASSWORD_MIN_LENGTH   20
-+#endif
- 
+-
 -        return 0;
--}
-+char    *passFDnumber = (char *)0;
-+char    *passAskTwice = (char *)0;
-+char    *passSeedString = (char *)0;
-+char    *passHashFuncName = (char *)0;
-+char    *passIterThousands = (char *)0;
-+char    *loInitValue = (char *)0;
-+char    *gpgKeyFile = (char *)0;
-+char    *gpgHomeDir = (char *)0;
-+char    *clearTextKeyFile = (char *)0;
-+char    *loopOffsetBytes = (char *)0;
-+char    *loopSizeBytes = (char *)0;
-+char    *loopEncryptionType = (char *)0;
-+
-+static int  multiKeyMode = 0;   /* 0=single-key 64=multi-key-v2 65=multi-key-v3 1000=any */
-+static char *multiKeyPass[66];
-+static char *loopFileName;
- 
- #ifdef MAIN
-+static char *
-+crypt_name (int id, int *flags) {
-+	int i;
-+
 +	for (i = 0; loop_crypt_type_tbl[i].id != -1; i++)
 +		if(id == loop_crypt_type_tbl[i].id) {
 +			*flags = loop_crypt_type_tbl[i].flags;
@@ -595,23 +568,26 @@
 +	if(id == 18)
 +		return "CryptoAPI";
 +	return "undefined";
-+}
- 
+ }
+ 
+-#ifdef MAIN
+-
  static int
  show_loop(char *device) {
 -	struct loop_info loopinfo;
 -	struct loop_info64 loopinfo64;
 -	int fd, errsv;
+-
 +	struct loop_info64 loopinfo;
 +	int fd;
- 
++  
  	if ((fd = open(device, O_RDONLY)) < 0) {
  		int errsv = errno;
-@@ -74,73 +106,64 @@
- 			device, strerror (errsv));
+ 		fprintf(stderr, _("loop: can't open device %s: %s\n"),
+@@ -77,58 +110,60 @@ show_loop(char *device) {
  		return 2;
  	}
--
+ 
 -	if (ioctl(fd, LOOP_GET_STATUS64, &loopinfo64) == 0) {
 -
 -		loopinfo64.lo_file_name[LO_NAME_SIZE-2] = '*';
@@ -646,7 +622,7 @@
 -		return 0;
 +		return 1;
  	}
--
+ 
 -	if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) == 0) {
 -		printf ("%s: [%04x]:%ld (%s)",
 -			device, loopinfo.lo_device, loopinfo.lo_inode,
@@ -654,14 +630,6 @@
 -
 -		if (loopinfo.lo_offset)
 -			printf(_(", offset %d"), loopinfo.lo_offset);
--
--		if (loopinfo.lo_encrypt_type)
--			printf(_(", encryption type %d\n"),
--			       loopinfo.lo_encrypt_type);
--
--		printf("\n");
--		close (fd);
--		return 0;
 +	loopinfo.lo_file_name[LO_NAME_SIZE-1] = 0;
 +	loopinfo.lo_crypt_name[LO_NAME_SIZE-1] = 0;
 +	printf("%s: [%04llx]:%llu (%s)", device, (unsigned long long)loopinfo.lo_device,
@@ -672,17 +640,20 @@
 +		} else {
 +			printf(_(" offset=%llu"), (unsigned long long)loopinfo.lo_offset);
 +		}
- 	}
--
--	errsv = errno;
--	fprintf(stderr, _("loop: can't get info on device %s: %s\n"),
--		device, strerror (errsv));
++	}
+ 
+-		if (loopinfo.lo_encrypt_type)
+-			printf(_(", encryption type %d\n"),
+-			       loopinfo.lo_encrypt_type);
 +	if (loopinfo.lo_sizelimit)
 +		printf(_(" sizelimit=%llu"), (unsigned long long)loopinfo.lo_sizelimit);
 +	if (loopinfo.lo_encrypt_type) {
 +		int flags;
 +		char *s = crypt_name (loopinfo.lo_encrypt_type, &flags);
-+
+ 
+-		printf("\n");
+-		close (fd);
+-		return 0;
 +		printf(_(" encryption=%s"), s);
 +		/* type 18 == LO_CRYPT_CRYPTOAPI */
 +		if (loopinfo.lo_encrypt_type == 18) {
@@ -693,7 +664,11 @@
 +			if(flags & 1)
 +				printf("%u", (unsigned int)loopinfo.lo_encrypt_key_size << 3);
 +		}
-+	}
+ 	}
+-
+-	errsv = errno;
+-	fprintf(stderr, _("loop: can't get info on device %s: %s\n"),
+-		device, strerror (errsv));
 +	switch(loopinfo.lo_flags & 0x180000) {
 +	case 0x180000:
 +		printf(_(" multi-key-v3"));
@@ -710,8 +685,14 @@
 +	printf("\n");
  	close (fd);
 -	return 1;
--}
--#endif
++
++	return 0;
+ }
+ 
+ static int
+@@ -167,15 +202,6 @@ show_used_loop_devices (void) {
+ 
+ #endif
  
 -int
 -is_loop_device (const char *device) {
@@ -720,17 +701,12 @@
 -	return (stat(device, &statbuf) == 0 &&
 -		S_ISBLK(statbuf.st_mode) &&
 -		major(statbuf.st_rdev) == LOOPMAJOR);
-+	return 0;
- }
-+#endif
- 
- #define SIZE(a) (sizeof(a)/sizeof(a[0]))
- 
-+#if !defined(MAIN)
+-}
+-
  char *
  find_unused_loop_device (void) {
  	/* Just creating a device, say in /tmp, is probably a bad idea -
-@@ -148,9 +171,8 @@
+@@ -183,9 +209,8 @@ find_unused_loop_device (void) {
  	   So, we just try /dev/loop[0-7]. */
  	char dev[20];
  	char *loop_formats[] = { "/dev/loop%d", "/dev/loop/%d" };
@@ -741,7 +717,7 @@
  
  	for (j = 0; j < SIZE(loop_formats); j++) {
  	    for(i = 0; i < 256; i++) {
-@@ -159,16 +181,14 @@
+@@ -194,16 +219,14 @@ find_unused_loop_device (void) {
  			somedev++;
  			fd = open (dev, O_RDONLY);
  			if (fd >= 0) {
@@ -760,7 +736,7 @@
  			continue;/* continue trying as long as devices exist */
  		}
  		break;
-@@ -176,75 +196,626 @@
+@@ -211,75 +234,625 @@ find_unused_loop_device (void) {
  	}
  
  	if (!somedev)
@@ -808,10 +784,6 @@
 -				error("Out of memory while reading passphrase");
 -				pass = tmppass; /* the old buffer hasn't changed */
 -				break;
--			}
--		}
--		if (read(pfd, pass+i, 1) != 1 ||
--		    pass[i] == '\n' || pass[i] == 0)
 +int is_loop_active(const char *dev, const char *backdev)
 +{
 +	int fd;
@@ -832,7 +804,6 @@
 +	}
 +	return ret;
 +}
-+#endif
 +
 +static int rd_wr_retry(int fd, char *buf, int cnt, int w)
 +{
@@ -1014,10 +985,12 @@
 +				fclose(f);
 +				close(x);
 +				goto nomem3;
-+			}
+ 			}
 +			if(cnt2 != cnt3) break;
 +			cnt -= cnt3;
-+		}
+ 		}
+-		if (read(pfd, pass+i, 1) != 1 ||
+-		    pass[i] == '\n' || pass[i] == 0)
 +		if(fflush(f)) goto tmpWrErr;
 +		close(x);
 +		x = dup(fileno(f));
@@ -1092,7 +1065,7 @@
 +		}
 +		if(strlen(multiKeyPass[x]) < LOOP_PASSWORD_MIN_LENGTH) break;
 +		x++;
-+	}
+ 	}
 +	warnAboutBadKeyData(x);
 +	if(x >= 65)
 +		multiKeyMode = 65;
@@ -1103,7 +1076,9 @@
 +	if(!multiKeyPass[0]) goto nomem1;
 +	return multiKeyPass[0];
 +}
-+
+ 
+-	if (pass == NULL)
+-		return "";
 +static char *sGetPass(int minLen, int warnLen)
 +{
 +	char *p, *s, *seed;
@@ -1182,7 +1157,7 @@
 +		nomem:
 +		fprintf(stderr, _("Error: Unable to allocate memory\n"));
 +		return(NULL);
- 	}
++	}
 +	strcpy(s, p);
 +	memset(p, 0, i);
 +	if(ask2) {
@@ -1202,16 +1177,14 @@
 +	return(s);
 +}
  
--	if (pass == NULL)
--		return "";
+-	pass[i] = 0;
+-	return pass;
 +/* this is for compatibility with historic loop-AES version */
 +static void unhashed1_key_setup(unsigned char *keyStr, int ile, unsigned char *keyBuf, int bufSize)
 +{
 +	register int    x, y, z, cnt = ile;
 +	unsigned char   *kp;
- 
--	pass[i] = 0;
--	return pass;
++
 +	memset(keyBuf, 0, bufSize);
 +	kp = keyStr;
 +	for(x = 0; x < (bufSize * 8); x += 6) {
@@ -1277,8 +1250,8 @@
 +	} else {
 +		return llseek(fd, offset, whence);
 +	}
- }
- 
++}
++
 +static int loop_create_random_keys(char *partition, long long offset, long long sizelimit, int loopro, unsigned char *k)
 +{
 +	int x, y, fd;
@@ -1418,9 +1391,9 @@
 +		return 1;
 +	}
 +	return 0;
-+}
+ }
 +#endif
-+
+ 
  int
 -set_loop(const char *device, const char *file, unsigned long long offset,
 -	 const char *encryption, int pfd, int *loopro) {
@@ -1429,23 +1402,24 @@
 +	struct loop_info64 loopinfo;
  	int fd, ffd, mode, i;
 -	char *pass;
+-
 +	char *pass, *apiName = NULL;
 +	void (*hashFunc)(unsigned char *, int, unsigned char *, int);
 +	unsigned char multiKeyBits[65][32];
 +	int minPassLen = LOOP_PASSWORD_MIN_LENGTH;
 +	int run_mkfs_command = 0;
- 
++
 +	loopFileName = (char *)file;
 +	multiKeyMode = 0;
  	mode = (*loopro ? O_RDONLY : O_RDWR);
  	if ((ffd = open(file, mode)) < 0) {
  		if (!*loopro && errno == EROFS)
-@@ -256,32 +827,25 @@
+@@ -291,32 +864,26 @@ set_loop(const char *device, const char *file, unsigned long long offset,
  	}
  	if ((fd = open(device, mode)) < 0) {
  		perror (device);
--		return 1;
-+		goto close_ffd_return1;
++		close(ffd);
+ 		return 1;
  	}
  	*loopro = (mode == O_RDONLY);
  
@@ -1464,6 +1438,7 @@
 -	}
 -
 -	loopinfo64.lo_offset = offset;
+-
 +	memset (&loopinfo, 0, sizeof (loopinfo));
 +	xstrncpy ((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE);
 +	if (loopEncryptionType)
@@ -1472,19 +1447,18 @@
 +		loopinfo.lo_offset = mystrtoull(loopOffsetBytes, 1);
 +	if (loopSizeBytes)
 +		loopinfo.lo_sizelimit = mystrtoull(loopSizeBytes, 0);
- 
--#ifdef MCL_FUTURE  
-+#ifdef MCL_FUTURE
++  
+ #ifdef MCL_FUTURE
  	/*
  	 * Oh-oh, sensitive data coming up. Better lock into memory to prevent
  	 * passwd etc being swapped out and left somewhere on disk.
  	 */
--                                                
-+
- 	if(mlockall(MCL_CURRENT | MCL_FUTURE)) {
- 		perror("memlock");
- 		fprintf(stderr, _("Couldn't lock into memory, exiting.\n"));
-@@ -289,126 +853,224 @@
+-	if (loopinfo64.lo_encrypt_type != LO_CRYPT_NONE) {
++	if (loopinfo.lo_encrypt_type != LO_CRYPT_NONE) {
+ 		if(mlockall(MCL_CURRENT | MCL_FUTURE)) {
+ 			perror("memlock");
+ 			fprintf(stderr, _("Couldn't lock into memory, exiting.\n"));
+@@ -325,25 +892,152 @@ set_loop(const char *device, const char *file, unsigned long long offset,
  	}
  #endif
  
@@ -1498,7 +1472,15 @@
 -		pass = getpass(_("Password: "));
 -		goto gotpass;
 +		pass = sGetPass (1, 0);
-+		if(!pass) goto close_fd_ffd_return1;
++		if(!pass) {
++keyclean_close_fd_ffd_return1:
++			memset(loopinfo.lo_encrypt_key, 0, sizeof(loopinfo.lo_encrypt_key));
++			memset(&multiKeyBits[0][0], 0, sizeof(multiKeyBits));
++close_fd_ffd_return1:
++			close(fd);
++			close(ffd);
++			return 1;
++		}
 +		xstrncpy ((char *)loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE);
 +		loopinfo.lo_encrypt_key_size = strlen((char*)loopinfo.lo_encrypt_key);
 +		break;
@@ -1632,15 +1614,18 @@
  	}
  
  	if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
- 		perror("ioctl: LOOP_SET_FD");
-+keyclean_close_fd_ffd_return1:
+-		close(fd);
+-		close(ffd);
 +		memset(loopinfo.lo_encrypt_key, 0, sizeof(loopinfo.lo_encrypt_key));
 +		memset(&multiKeyBits[0][0], 0, sizeof(multiKeyBits));
-+close_fd_ffd_return1:
 +		close (fd);
-+close_ffd_return1:
 +		close (ffd);
- 		return 1;
+ 		if (errno == EBUSY) {
+ 			if (verbose)
+ 				printf(_("ioctl LOOP_SET_FD failed: %s\n"), strerror(errno));
+@@ -353,117 +1047,84 @@ set_loop(const char *device, const char *file, unsigned long long offset,
+ 			return 1;
+ 		}
  	}
 -	close (ffd);
  
@@ -1669,7 +1654,7 @@
 -		memset(&loopinfo, 0, sizeof(loopinfo));
  	}
 -	memset(&loopinfo64, 0, sizeof(loopinfo64));
--
+ 
 -	if (i) {
 -		ioctl (fd, LOOP_CLR_FD, 0);
 -		close (fd);
@@ -1694,11 +1679,15 @@
 -		       device, file, offset);
 -	return 0;
 -}
--
++	memset(loopinfo.lo_encrypt_key, 0, sizeof(loopinfo.lo_encrypt_key));
++	memset(&multiKeyBits[0][0], 0, sizeof(multiKeyBits));
+ 
 -int 
 -del_loop (const char *device) {
 -	int fd;
--
++	close (fd);
++	close (ffd);
+ 
 -	if ((fd = open (device, O_RDONLY)) < 0) {
 -		int errsv = errno;
 -		fprintf(stderr, _("loop: can't delete device %s: %s\n"),
@@ -1708,11 +1697,26 @@
 -	if (ioctl (fd, LOOP_CLR_FD, 0) < 0) {
 -		perror ("ioctl: LOOP_CLR_FD");
 -		return 1;
--	}
-+	memset(loopinfo.lo_encrypt_key, 0, sizeof(loopinfo.lo_encrypt_key));
-+	memset(&multiKeyBits[0][0], 0, sizeof(multiKeyBits));
- 	close (fd);
--	if (verbose > 1)
++#if !defined(MAIN)
++	if(run_mkfs_command && fstype && *fstype && **fstype && (getuid() == 0)) {
++		if(!loop_fork_mkfs_command((char *)device, (char *)(*fstype))) {
++			/* !strncasecmp(passHashFuncName, "random", 6) test matched */
++			/* This reads octal mode for newly created file system root */
++			/* directory node from '-o phash=random/1777' mount option. */
++			/*                          octal mode--^^^^                */
++			sscanf(passHashFuncName + 6, "/%o", AutoChmodPtr);
++		} else {
++			if((fd = open(device, mode)) >= 0) {
++				ioctl(fd, LOOP_CLR_FD, 0);
++				close(fd);
++				return 1;
++			}
++		}
+ 	}
+-	close (fd);
++#endif
++  
+ 	if (verbose > 1)
 -		printf(_("del_loop(%s): success\n"), device);
 -	return 0;
 -}
@@ -1731,41 +1735,23 @@
 -	mutter();
 -	return 1;
 -}
-+	close (ffd);
- 
+-
 -int
 -del_loop (const char *device) {
 -	mutter();
 -	return 1;
 -}
-+#if !defined(MAIN)
-+	if(run_mkfs_command && fstype && *fstype && **fstype && (getuid() == 0)) {
-+		if(!loop_fork_mkfs_command((char *)device, (char *)(*fstype))) {
-+			/* !strncasecmp(passHashFuncName, "random", 6) test matched */
-+			/* This reads octal mode for newly created file system root */
-+			/* directory node from '-o phash=random/1777' mount option. */
-+			/*                          octal mode--^^^^                */
-+			sscanf(passHashFuncName + 6, "/%o", AutoChmodPtr);
-+		} else {
-+			if((fd = open(device, mode)) >= 0) {
-+				ioctl(fd, LOOP_CLR_FD, 0);
-+				close(fd);
-+				return 1;
-+			}
-+		}
-+	}
-+#endif
- 
+-
 -char *
 -find_unused_loop_device (void) {
 -	mutter();
-+	if (verbose > 1)
 +		printf(_("set_loop(%s,%s): success\n"), device, file);
  	return 0;
  }
- 
+-
 -#endif
 -
++  
  #ifdef MAIN
  
 -#ifdef LOOP_SET_FD
@@ -1779,26 +1765,38 @@
  
  static void
  usage(void) {
- 	fprintf(stderr, _("usage:\n\
--  %s loop_device                                       # give info\n\
--  %s -d loop_device                                    # delete\n\
--  %s -f                                                # find unused\n\
--  %s [-e encryption] [-o offset] {-f|loop_device} file # setup\n"),
--		progname, progname, progname, progname);
-+  %s [options] loop_device file        # setup\n\
-+  %s -F [options] loop_device [file]   # setup, read /etc/fstab\n\
-+  %s loop_device                       # give info\n\
-+  %s -a                                # give info of all loops\n\
-+  %s -d loop_device                    # delete\n\
-+  %s -R loop_device                    # resize\n\
+-	fprintf(stderr, _("\nUsage:\n"
+-  " %1$s loop_device                                  # give info\n"
+-  " %1$s -a | --all                                   # list all used\n"
+-  " %1$s -d | --detach loop_device                    # delete\n"
+-  " %1$s -f | --find                                  # find unused\n"
+-  " %1$s [ options ] {-f|--find|loop_device} file     # setup\n"
+-  "\nOptions:\n"
+-  " -e | --encryption <type> enable data encryption with specified <name/num>\n"
+-  " -h | --help              this help\n"
+-  " -o | --offset <num>      start at offset <num> into file\n"
+-  " -p | --pass-fd <num>     read passphrase from file descriptor <num>\n"
+-  " -r | --read-only         setup read-only loop device\n"
+-  " -s | --show              print device name (with -f <file>)\n"
+-  " -v | --verbose           verbose mode\n\n"),
++	fprintf(stderr, _("\nUsage:\n\
++  %1$s [options] loop_device file        # setup\n\
++  %1$s -F [options] loop_device [file]   # setup, read /etc/fstab\n\
++  %1$s loop_device                       # give info\n\
++  %1$s -a                                # give info of all loops\n\
++  %1$s -d loop_device                    # delete\n\
++  %1$s -R loop_device                    # resize\n\
 +options:  -e encryption  -o offset  -s sizelimit  -p passwdfd  -T  -S pseed\n\
 +          -H phash  -I loinit  -K gpgkey  -G gpghome  -C itercountk  -v  -r\n\
 +          -P cleartextkey\n"),
-+		progname, progname, progname, progname, progname, progname);
+ 		progname);
  	exit(1);
- }
- 
-@@ -439,107 +1101,252 @@
+- }
++}
+ 
+ char *
+ xstrdup (const char *s) {
+@@ -492,16 +1153,147 @@ error (const char *fmt, ...) {
  	fprintf (stderr, "\n");
  }
  
@@ -1934,40 +1932,50 @@
 +	return err2;
 +}
 +
+ 
  int
  main(int argc, char **argv) {
 -	char *p, *offset, *encryption, *passfd, *device, *file;
--	int delete, find, c;
+-	int delete, find, c, all;
 +	char *partitionName = NULL;
 +	int delete,c,option_a=0,option_F=0,option_R=0,setup_o=0;
  	int res = 0;
+ 	int showdev = 0;
  	int ro = 0;
 -	int pfd = -1;
 -	unsigned long long off;
- 
- 	setlocale(LC_ALL, "");
++	char *p;
+ 	struct option longopts[] = {
+ 		{ "all", 0, 0, 'a' },
+ 		{ "detach", 0, 0, 'd' },
+@@ -520,44 +1312,79 @@ main(int argc, char **argv) {
  	bindtextdomain(PACKAGE, LOCALEDIR);
  	textdomain(PACKAGE);
  
--	delete = find = 0;
+-	delete = find = all = 0;
 -	off = 0;
 -	offset = encryption = passfd = NULL;
 -
 +	delete = 0;
  	progname = argv[0];
--	if ((p = strrchr(progname, '/')) != NULL)
--		progname = p+1;
--
--	while ((c = getopt(argc, argv, "de:E:fo:p:v")) != -1) {
+ 	if ((p = strrchr(progname, '/')) != NULL)
+ 		progname = p+1;
+ 
+-	while ((c = getopt_long(argc, argv, "ade:E:fho:p:rsv",
+-				longopts, NULL)) != -1) {
 +	while ((c = getopt(argc,argv,"aC:de:FG:H:I:K:o:p:rRs:S:Tv")) != -1) {
  		switch (c) {
+-		case 'a':
+-			all = 1;
 +		case 'a':		/* show status of all loops */
 +			option_a = 1;
-+			break;
+ 			break;
+-		case 'r':
+-			ro = 1;
 +		case 'C':
 +			passIterThousands = optarg;
 +			setup_o = 1;
-+			break;
+ 			break;
  		case 'd':
  			delete = 1;
  			break;
@@ -1980,13 +1988,13 @@
 +		case 'F':		/* read loop related options from /etc/fstab */
 +			option_F = 1;
 +			setup_o = 1;
-+			break;
+ 			break;
+-		case 'f':
+-			find = 1;
 +		case 'G':               /* GnuPG home dir */
 +			gpgHomeDir = optarg;
 +			setup_o = 1;
  			break;
--		case 'f':
--			find = 1;
 +		case 'H':               /* passphrase hash function name */
 +			passHashFuncName = optarg;
 +			setup_o = 1;
@@ -1998,7 +2006,7 @@
 +		case 'K':               /* GnuPG key file name */
 +			gpgKeyFile = optarg;
 +			setup_o = 1;
- 			break;
++  			break;
  		case 'o':
 -			offset = optarg;
 +			loopOffsetBytes = optarg;
@@ -2007,7 +2015,9 @@
 +		case 'p':               /* read passphrase from given fd */
 +			passFDnumber = optarg;
 +			setup_o = 1;
-+			break;
+ 			break;
+-		case 'p':
+-			passfd = optarg;
 +		case 'P':               /* read passphrase from given file */
 +			clearTextKeyFile = optarg;
 +			setup_o = 1;
@@ -2015,16 +2025,15 @@
 +		case 'r':               /* read-only */
 +			ro = 1;
 +			setup_o = 1;
- 			break;
--		case 'p':
--			passfd = optarg;
++			break;
 +		case 'R':               /* recompute loop dev size */
 +			option_R = 1;
-+			break;
-+		case 's':
+ 			break;
+ 		case 's':
+-			showdev = 1;
 +			loopSizeBytes = optarg;
 +			setup_o = 1;
-+			break;
+ 			break;
 +		case 'S':               /* optional seed for passphrase */
 +			passSeedString = optarg;
 +			setup_o = 1;
@@ -2032,29 +2041,31 @@
 +		case 'T':               /* ask passphrase _twice_ */
 +			passAskTwice = "T";
 +			setup_o = 1;
- 			break;
  		case 'v':
 -			verbose = 1;
 +			verbose++;
  			break;
  		default:
  			usage();
- 		}
- 	}
--
--	if (argc == 1) {
--		usage();
-+	if (option_a + delete + option_R + setup_o > 1) usage();
-+	if (option_a) {
+@@ -566,79 +1393,35 @@ main(int argc, char **argv) {
+ 
+ 	if (argc == 1) {
+ 		usage();
++	} else if (option_a + delete + option_R + setup_o > 1) {
++		usage();
++	} else if (option_a) {
 +		/* show all loops */
 +		if (argc != optind) usage();
 +		show_all_loops();
 +		res = 0;
  	} else if (delete) {
--		if (argc != optind+1 || encryption || offset || find)
+-		if (argc != optind+1 || encryption || offset || find || all || showdev)
 -			usage();
 -	} else if (find) {
--		if (argc < optind || argc > optind+1)
+-		if (all || argc < optind || argc > optind+1)
+-			usage();
+-	} else if (all) {
+-		if (argc > 2)
 -			usage();
 +		/* delete loop */
 +		if (argc != optind+1) usage();
@@ -2068,18 +2079,18 @@
 +		res = show_loop(argv[optind]);
  	} else {
 -		if (argc < optind+1 || argc > optind+2)
-+		/* set up new loop */
-+		if ((argc < optind+1) || ((argc == optind+1) && !option_F) || (argc > optind+2))
- 			usage();
+-			usage();
 -	}
 -
--	if (find) {
+-	if (all)
+-		return show_used_loop_devices();
+-	else if (find) {
 -		device = find_unused_loop_device();
 -		if (device == NULL)
 -			return -1;
--		if (verbose)
--			printf("Loop device is %s\n", device);
 -		if (argc == optind) {
+-			if (verbose)
+-				printf("Loop device is %s\n", device);
 -			printf("%s\n", device);
 -			return 0;
 -		}
@@ -2100,8 +2111,26 @@
 -		if (offset && sscanf(offset, "%llu", &off) != 1)
 -			usage();
 -		if (passfd && sscanf(passfd, "%d", &pfd) != 1)
--			usage();
--		res = set_loop(device, file, off, encryption, pfd, &ro);
++		/* set up new loop */
++		if ((argc < optind+1) || ((argc == optind+1) && !option_F) || (argc > optind+2))
+ 			usage();
+-		do {
+-			res = set_loop(device, file, off, encryption, pfd, &ro);
+-			if (res == 2 && find) {
+-				if (verbose)
+-					printf("stolen loop=%s...trying again\n",
+-						device);
+-				free(device);
+-				if (!(device = find_unused_loop_device()))
+-					return -1;
+-			}
+-		} while (find && res == 2);
+-
+-		if (verbose && res == 0)
+-			printf("Loop device is %s\n", device);
+-
+-		if (res == 0 && showdev && find)
+-			printf("%s\n", device);
 +		if (argc > optind+1)
 +			partitionName = argv[optind+1];
 +		if (option_F && (read_options_from_fstab(argv[optind], &partitionName) != 1))
@@ -2110,7 +2139,7 @@
  	}
  	return res;
  }
--
+ 
 -#else /* LOOP_SET_FD not defined */
 -
 -int
@@ -2122,9 +2151,10 @@
 -}
 -#endif
  #endif
-diff -urN util-linux-2.12r/mount/lomount.h util-linux-2.12r-AES/mount/lomount.h
---- util-linux-2.12r/mount/lomount.h	2004-07-11 20:23:46.000000000 +0300
-+++ util-linux-2.12r-AES/mount/lomount.h	2007-02-17 09:58:11.000000000 +0200
+diff --git a/mount/lomount.h b/mount/lomount.h
+index 89695cd..7748cf5 100644
+--- a/mount/lomount.h
++++ b/mount/lomount.h
 @@ -1,6 +1,19 @@
  extern int verbose;
 -extern int set_loop(const char *, const char *, unsigned long long,
@@ -2147,9 +2177,11 @@
 +extern char *loopOffsetBytes;
 +extern char *loopSizeBytes;
 +extern char *loopEncryptionType;
-diff -urN util-linux-2.12r/mount/loop.c util-linux-2.12r-AES/mount/loop.c
---- util-linux-2.12r/mount/loop.c	1970-01-01 02:00:00.000000000 +0200
-+++ util-linux-2.12r-AES/mount/loop.c	2005-09-24 14:48:53.000000000 +0300
+diff --git a/mount/loop.c b/mount/loop.c
+new file mode 100644
+index 0000000..1e95d42
+--- /dev/null
++++ b/mount/loop.c
 @@ -0,0 +1,221 @@
 +/*
 + *  loop.c
@@ -2372,9 +2404,10 @@
 +	loopinfo->lo_encrypt_type = 18; /* LO_CRYPT_CRYPTOAPI */
 +	return(loop_set_status64_ioctl(fd, loopinfo));
 +}
-diff -urN util-linux-2.12r/mount/loop.h util-linux-2.12r-AES/mount/loop.h
---- util-linux-2.12r/mount/loop.h	2003-07-16 23:06:02.000000000 +0300
-+++ util-linux-2.12r-AES/mount/loop.h	2005-09-24 14:48:53.000000000 +0300
+diff --git a/mount/loop.h b/mount/loop.h
+index 951a5d1..cc9097b 100644
+--- a/mount/loop.h
++++ b/mount/loop.h
 @@ -1,6 +1,20 @@
 -#define LO_CRYPT_NONE	0
 -#define LO_CRYPT_XOR	1
@@ -2432,7 +2465,7 @@
  	int		lo_offset;
  	int		lo_encrypt_type;
  	int		lo_encrypt_key_size;
-@@ -30,22 +53,35 @@
+@@ -30,22 +53,35 @@ struct loop_info {
  	char		reserved[4];
  };
  
@@ -2485,10 +2518,11 @@
 +extern int try_cryptoapi_loop_interface(int, struct loop_info64 *, char *);
 +
 +#endif
-diff -urN util-linux-2.12r/mount/losetup.8 util-linux-2.12r-AES/mount/losetup.8
---- util-linux-2.12r/mount/losetup.8	2004-12-05 03:35:54.000000000 +0200
-+++ util-linux-2.12r-AES/mount/losetup.8	2007-02-17 09:58:11.000000000 +0200
-@@ -1,42 +1,29 @@
+diff --git a/mount/losetup.8 b/mount/losetup.8
+index db2929f..5260436 100644
+--- a/mount/losetup.8
++++ b/mount/losetup.8
+@@ -1,45 +1,29 @@
 -.TH LOSETUP 8 "2003-07-01" "Linux" "MAINTENANCE COMMANDS"
 +.TH LOSETUP 8 "2007-02-17" "Linux" "MAINTENANCE COMMANDS"
  .SH NAME
@@ -2502,6 +2536,8 @@
 +[options]
  .I loop_device
 -.sp
+-.B losetup -a
+-.sp
 -.in -5
 -Delete loop:
 -.sp
@@ -2511,19 +2547,6 @@
 +.br
 +.B losetup -F
 +[options]
-+.I loop_device
-+[file]
-+.br
-+.B losetup
-+[
-+.B \-d
-+]
-+.I loop_device
-+.br
-+.B losetup -a
-+.br
-+.B losetup
-+.B \-R
  .I loop_device
 -.sp
 -.in -5
@@ -2536,21 +2559,34 @@
 -Setup loop device:
 -.sp
 -.in +5
--.B losetup
++[file]
++.br
+ .B losetup
 -.RB [{\-e | \-E}
 -.IR encryption ]
 -.RB [ \-o
 -.IR offset ]
 -.RB [ \-p
 -.IR pfd ]
+-.RB [ \-r ]
 -.in +8
--.RB { \-f | \fIloop_device\fP }
+-.RB { \-f [ \-s ] | \fIloop_device\fP }
 -.I file
 -.in -13
++[
++.B \-d
++]
++.I loop_device
++.br
++.B losetup -a
++.br
++.B losetup
++.B \-R
++.I loop_device
  .ad b
  .SH DESCRIPTION
  .B losetup
-@@ -44,45 +31,135 @@
+@@ -47,53 +31,135 @@ is used to associate loop devices with regular files or block devices,
  to detach loop devices and to query the status of a loop device. If only the
  \fIloop_device\fP argument is given, the status of the corresponding loop
  device is shown.
@@ -2568,15 +2604,22 @@
 -number, probably by patching the kernel. Standard numbers that are
 -always present are 0 (no encryption) and 1 (XOR encryption).
 -When the cryptoloop module is loaded (or compiled in), it uses number 18.
--This cryptoloop module wil take the name of an arbitrary encryption type
+-This cryptoloop module will take the name of an arbitrary encryption type
 -and finds the module that knows how to perform that encryption.
--(Thus, either one uses a number different from 18 with the
--.B \-E
--option, or one uses a name with the
--.B \-e
--option.)
  .SH OPTIONS
--.IP \fB\-d\fP
+-.IP "\fB\-a, \-\-all\fP"
+-show status of all loop devices
+-.IP "\fB\-d, \-\-detach\fP"
+-detach the file or device associated with the specified loop device
+-.IP "\fB\-e, \-E, \-\-encryption \fIencryption_type\fP"
+-enable data encryption with specified name or number
+-.IP "\fB\-f, \-\-find\fP"
+-find the first unused loop device. If a
+-.I file
+-argument is present, use this device. Otherwise, print its name.
+-.IP "\fB\-h, \-\-help\fP"
+-print help
+-.IP "\fB\-o, \-\-offset \fIoffset\fP"
 +.IP \fB\-a\fP
 +Show status of all loop devices.
 +.IP "\fB\-C \fIitercountk\fP"
@@ -2585,15 +2628,7 @@
 +loop setup/mount time but not thereafter. In combination with passphrase seed
 +this slows down dictionary attacks. Iteration is not done in multi-key mode.
 +.IP "\fB\-d\fP"
- Detach the file or device associated with the specified loop device.
--.IP "\fB\-E \fIencryption_type\fP"
--Enable data encryption with specified number.
--.IP "\fB\-e \fIencryption_name\fP"
--Enable data encryption with specified name.
--.IP "\fB\-f\fP"
--Find the first unused loop device. If a
--.I file
--argument is present, use this device. Otherwise, print its name.
++Detach the file or device associated with the specified loop device.
 +.IP "\fB\-e \fIencryption\fP"
 +.RS
 +Enable data encryption. Following encryption types are recognized:
@@ -2656,13 +2691,23 @@
 +or 65 keys, then loop device is put to multi-key mode. In multi-key mode
 +first key is used for first sector, second key for second sector, and so on.
 +65th key, if present, is used as additional input to MD5 IV computation.
- .IP "\fB\-o \fIoffset\fP"
++.IP "\fB\-o \fIoffset\fP"
  The data start is moved \fIoffset\fP bytes into the specified file or
 -device.
--.IP "\fB\-p \fInum\fP"
+-.IP "\fB\-p, \-\-pass-fd \fInum\fP"
 -Read the passphrase from file descriptor with number
 -.I num
--instead of from the terminal.
+-instead of from the terminal
+-.IP "\fB\-r, \-\-read-only\fP"
+-setup read-only loop device
+-.IP "\fB\-s, \-\-show\fP"
+-print device name if the
+-.I -f
+-option and a
+-.I file
+-argument are present
+-.IP "\fB\-v, \-\-verbose\fP"
+-verbose mode
 +device. Normally offset is included in IV (initialization vector)
 +computations. If offset is prefixed with @ character, then offset is not
 +included in IV computations. @ prefix functionality may not be supported on
@@ -2675,7 +2720,7 @@
 +keys, then loop device is put to multi-key mode. If losetup encounters
 +end-of-file before 64 keys are read, then only first key is used in
 +single-key mode.
-+
+ 
 +echo SecretPassphraseHere | losetup -p0 -K foo.gpg -e AES128 ...
 +
 +In above example, losetup reads passphrase from file descriptor 0 (stdin).
@@ -2721,7 +2766,7 @@
  .SH RETURN VALUE
  .B losetup
  returns 0 on success, nonzero on failure. When
-@@ -94,43 +171,26 @@
+@@ -105,49 +171,26 @@ from determining the status of the device.
  
  .SH FILES
  .nf
@@ -2770,6 +2815,12 @@
  .fi
  .SH RESTRICTION
 -DES encryption is painfully slow. On the other hand, XOR is terribly weak.
+-
+-Cryptoloop is deprecated in favor of dm-crypt. For more details see
+-.B cryptsetup(8).
+-.SH AVAILABILITY
+-The losetup command is part of the util-linux-ng package and is available from
+-ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
 -.\" .SH AUTHORS
 -.\" .nf
 -.\" Original version: Theodore Ts'o <tytso at athena.mit.edu>
@@ -2781,9 +2832,11 @@
 +Original version: Theodore Ts'o <tytso at athena.mit.edu>
 +AES support: Jari Ruusu
 +.fi
-diff -urN util-linux-2.12r/mount/loumount.c util-linux-2.12r-AES/mount/loumount.c
---- util-linux-2.12r/mount/loumount.c	1970-01-01 02:00:00.000000000 +0200
-+++ util-linux-2.12r-AES/mount/loumount.c	2005-09-24 14:48:53.000000000 +0300
+diff --git a/mount/loumount.c b/mount/loumount.c
+new file mode 100644
+index 0000000..3301ce2
+--- /dev/null
++++ b/mount/loumount.c
 @@ -0,0 +1,60 @@
 +/*
 + *  loumount.c
@@ -2845,10 +2898,11 @@
 +		printf(_("del_loop(%s): success\n"), device);
 +	return 0;
 +}
-diff -urN util-linux-2.12r/mount/mount.8 util-linux-2.12r-AES/mount/mount.8
---- util-linux-2.12r/mount/mount.8	2004-12-20 00:30:14.000000000 +0200
-+++ util-linux-2.12r-AES/mount/mount.8	2007-02-17 09:58:11.000000000 +0200
-@@ -281,6 +281,16 @@
+diff --git a/mount/mount.8 b/mount/mount.8
+index 01001ad..4d8b2a5 100644
+--- a/mount/mount.8
++++ b/mount/mount.8
+@@ -316,6 +316,16 @@ Print a help message.
  .B \-v
  Verbose mode.
  .TP
@@ -2865,7 +2919,7 @@
  .B \-a
  Mount all filesystems (of the given types) mentioned in
  .IR fstab .
-@@ -328,12 +338,6 @@
+@@ -365,12 +375,6 @@ This is necessary for example when
  .I /etc
  is on a read-only file system.
  .TP
@@ -2878,7 +2932,7 @@
  .B \-s
  Tolerate sloppy mount options rather than failing. This will ignore
  mount options not supported by a filesystem type. Not all filesystems
-@@ -1841,13 +1845,19 @@
+@@ -1999,13 +2003,19 @@ to correspond to the file
  and then mount this device on
  .IR /mnt .
  
@@ -2900,9 +2954,10 @@
  If no explicit loop device is mentioned
  (but just an option `\fB\-o loop\fP' is given), then
  .B mount
-diff -urN util-linux-2.12r/mount/mount.c util-linux-2.12r-AES/mount/mount.c
---- util-linux-2.12r/mount/mount.c	2004-12-22 00:00:36.000000000 +0200
-+++ util-linux-2.12r-AES/mount/mount.c	2007-02-17 09:58:11.000000000 +0200
+diff --git a/mount/mount.c b/mount/mount.c
+index d09fd5e..bd01f43 100644
+--- a/mount/mount.c
++++ b/mount/mount.c
 @@ -11,6 +11,7 @@
  #include <string.h>
  #include <getopt.h>
@@ -2911,7 +2966,7 @@
  
  #include <pwd.h>
  #include <grp.h>
-@@ -80,9 +81,6 @@
+@@ -90,9 +91,6 @@ static int mounttype = 0;
  /* True if ruid != euid.  */
  static int suid = 0;
  
@@ -2921,16 +2976,16 @@
  /* Map from -o and fstab option strings to the flag argument to mount(2).  */
  struct opt_map {
    const char *opt;		/* option name */
-@@ -167,7 +165,7 @@
+@@ -185,7 +183,7 @@ static const struct opt_map opt_map[] = {
    { NULL,	0, 0, 0		}
  };
  
 -static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption,
 +static const char *opt_loopdev, *opt_vfstype,
- 	*opt_speed, *opt_comment;
- 
- static struct string_opt_map {
-@@ -177,8 +175,16 @@
+ 	*opt_speed, *opt_comment, *opt_uhelper;
+ 
+ static int mounted (const char *spec0, const char *node0);
+@@ -199,8 +197,16 @@ static struct string_opt_map {
  } string_opt_map[] = {
    { "loop=",	0, &opt_loopdev },
    { "vfs=",	1, &opt_vfstype },
@@ -2948,8 +3003,8 @@
 +  { "encryption=", 0, (const char **)&loopEncryptionType },
    { "speed=", 0, &opt_speed },
    { "comment=", 1, &opt_comment },
-   { NULL, 0, NULL }
-@@ -580,9 +586,8 @@
+   { "uhelper=", 0, &opt_uhelper },
+@@ -826,9 +832,8 @@ suid_check(const char *spec, const char *node, int *flags, char **user) {
  
  static int
  loop_check(const char **spec, const char **type, int *flags,
@@ -2960,7 +3015,7 @@
  
    /*
     * In the case of a loop mount, either type is of the form lo@/dev/loop5
-@@ -607,7 +612,7 @@
+@@ -853,7 +858,7 @@ loop_check(const char **spec, const char **type, int *flags,
        *type = opt_vfstype;
    }
  
@@ -2969,7 +3024,7 @@
    *loopfile = *spec;
  
    if (*loop) {
-@@ -615,6 +620,10 @@
+@@ -861,12 +866,14 @@ loop_check(const char **spec, const char **type, int *flags,
      if (fake) {
        if (verbose)
  	printf(_("mount: skipping the setup of a loop device\n"));
@@ -2979,19 +3034,24 @@
 +      *spec = *loopdev;
      } else {
        int loopro = (*flags & MS_RDONLY);
- 
-@@ -624,9 +633,7 @@
- 	return EX_SYSERR;	/* no more loop devices */
-       if (verbose)
- 	printf(_("mount: going to use the loop device %s\n"), *loopdev);
+       int res;
+ 
 -      offset = opt_offset ? strtoull(opt_offset, NULL, 0) : 0;
--      if (set_loop(*loopdev, *loopfile, offset,
--		   opt_encryption, pfd, &loopro)) {
-+      if (set_loop (*loopdev, *loopfile, &loopro, type, AutoChmodPtr)) {
+-
+       do {
+         if (!*loopdev || !**loopdev)
+ 	  *loopdev = find_unused_loop_device();
+@@ -875,8 +882,7 @@ loop_check(const char **spec, const char **type, int *flags,
  	if (verbose)
- 	  printf(_("mount: failed setting up loop device\n"));
- 	return EX_FAIL;
-@@ -687,14 +694,6 @@
+ 	  printf(_("mount: going to use the loop device %s\n"), *loopdev);
+ 
+-	if ((res = set_loop(*loopdev, *loopfile, offset,
+-			    opt_encryption, pfd, &loopro))) {
++	if ((res = set_loop(*loopdev, *loopfile, &loopro, type, AutoChmodPtr))) {
+ 	  if (res == 2) {
+ 	     /* loop dev has been grabbed by some other process,
+ 	        try again, if not given explicitly */
+@@ -960,14 +966,6 @@ update_mtab_entry(const char *spec, const char *node, const char *type,
  }
  
  static void
@@ -3006,15 +3066,15 @@
  cdrom_setspeed(const char *spec) {
  #define CDROM_SELECT_SPEED      0x5322  /* Set the CD-ROM speed */
  	if (opt_speed) {
-@@ -788,6 +787,7 @@
+@@ -1006,6 +1004,7 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
    const char *opts, *spec, *node, *types;
    char *user = 0;
    int loop = 0;
 +  unsigned int LoopMountAutomaticChmod = 0;
    const char *loopdev = 0, *loopfile = 0;
    struct stat statbuf;
-   int nfs_mount_version = 0;	/* any version */
-@@ -820,7 +820,7 @@
+ 
+@@ -1052,7 +1051,7 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
         * stale assignments of files to loop devices. Nasty when used for
         * encryption.
         */
@@ -3023,14 +3083,10 @@
        if (res)
  	  goto out;
    }
-@@ -855,9 +855,20 @@
- 
-   block_signals (SIG_BLOCK);
- 
--  if (!fake)
-+  if (!fake) {
+@@ -1076,6 +1075,16 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
      mnt5_res = guess_fstype_and_mount (spec, node, &types, flags & ~MS_NOSYS,
- 				       mount_opts);
+ 				       mount_opts, &special, &status);
+ 
 +    if(!mnt5_res && LoopMountAutomaticChmod && (getuid() == 0)) {
 +      /*
 +       * If loop was set up using random keys and new file system
@@ -3041,13 +3097,12 @@
 +        error (_("Error: encrypted file system chmod() failed"));
 +      }
 +    }
-+  }
- 
-   if (fake || mnt5_res == 0) {
-       /* Mount succeeded, report this (if verbose) and write mtab entry.  */
-@@ -1530,8 +1541,8 @@
- 			else
- 				test_opts = xstrdup(optarg);
+     if (special) {
+       block_signals (SIG_UNBLOCK);
+       res = status;
+@@ -1836,8 +1845,8 @@ main(int argc, char *argv[]) {
+ 		case 'O':		/* with -t: mount only if (not) opt */
+ 			test_opts = append_opt(test_opts, optarg, NULL);
  			break;
 -		case 'p':		/* fd on which to read passwd */
 -			set_pfd(optarg);
@@ -3056,21 +3111,11 @@
  			break;
  		case 'r':		/* mount readonly */
  			readonly = 1;
-diff -urN util-linux-2.12r/mount/mount_by_label.c util-linux-2.12r-AES/mount/mount_by_label.c
---- util-linux-2.12r/mount/mount_by_label.c	2004-12-22 01:15:33.000000000 +0200
-+++ util-linux-2.12r-AES/mount/mount_by_label.c	2005-09-24 14:48:54.000000000 +0300
-@@ -189,7 +189,7 @@
- 	if (!procpt) {
- 		static int warn = 0;
- 		if (!warn++)
--		    error (_("%s: could not open %s, so UUID and LABEL "
-+		    fprintf(stderr, _("%s: could not open %s, so UUID and LABEL "
- 			     "conversion cannot be done.\n"),
- 			   progname, PROC_PARTITIONS);
- 		return;
-diff -urN util-linux-2.12r/mount/rmd160.c util-linux-2.12r-AES/mount/rmd160.c
---- util-linux-2.12r/mount/rmd160.c	1970-01-01 02:00:00.000000000 +0200
-+++ util-linux-2.12r-AES/mount/rmd160.c	2005-09-24 14:48:54.000000000 +0300
+diff --git a/mount/rmd160.c b/mount/rmd160.c
+new file mode 100644
+index 0000000..930e61e
+--- /dev/null
++++ b/mount/rmd160.c
 @@ -0,0 +1,532 @@
 +/* rmd160.c  -	RIPE-MD160
 + *	Copyright (C) 1998 Free Software Foundation, Inc.
@@ -3604,9 +3649,11 @@
 +    rmd160_final( &hd );
 +    memcpy( outbuf, hd.buf, 20 );
 +}
-diff -urN util-linux-2.12r/mount/rmd160.h util-linux-2.12r-AES/mount/rmd160.h
---- util-linux-2.12r/mount/rmd160.h	1970-01-01 02:00:00.000000000 +0200
-+++ util-linux-2.12r-AES/mount/rmd160.h	2005-09-24 14:48:54.000000000 +0300
+diff --git a/mount/rmd160.h b/mount/rmd160.h
+new file mode 100644
+index 0000000..dab329e
+--- /dev/null
++++ b/mount/rmd160.h
 @@ -0,0 +1,9 @@
 +#ifndef RMD160_H
 +#define RMD160_H
@@ -3617,9 +3664,11 @@
 +#endif /*RMD160_H*/
 +
 +
-diff -urN util-linux-2.12r/mount/sha512.c util-linux-2.12r-AES/mount/sha512.c
---- util-linux-2.12r/mount/sha512.c	1970-01-01 02:00:00.000000000 +0200
-+++ util-linux-2.12r-AES/mount/sha512.c	2005-09-24 14:48:54.000000000 +0300
+diff --git a/mount/sha512.c b/mount/sha512.c
+new file mode 100644
+index 0000000..a795228
+--- /dev/null
++++ b/mount/sha512.c
 @@ -0,0 +1,432 @@
 +/*
 + *  sha512.c
@@ -4053,9 +4102,11 @@
 +    memset(&ctx, 0, sizeof(ctx));
 +}
 +#endif
-diff -urN util-linux-2.12r/mount/sha512.h util-linux-2.12r-AES/mount/sha512.h
---- util-linux-2.12r/mount/sha512.h	1970-01-01 02:00:00.000000000 +0200
-+++ util-linux-2.12r-AES/mount/sha512.h	2005-09-24 14:48:54.000000000 +0300
+diff --git a/mount/sha512.h b/mount/sha512.h
+new file mode 100644
+index 0000000..817dc26
+--- /dev/null
++++ b/mount/sha512.h
 @@ -0,0 +1,45 @@
 +/*
 + *  sha512.h
@@ -4102,10 +4153,11 @@
 +/* no sha384_write(), use sha512_write() */
 +/* no sha384_final(), use sha512_final(), result in ctx->sha_out[0...47]  */
 +extern void sha384_hash_buffer(unsigned char *, int, unsigned char *, int);
-diff -urN util-linux-2.12r/mount/swapon.8 util-linux-2.12r-AES/mount/swapon.8
---- util-linux-2.12r/mount/swapon.8	2004-12-21 22:59:42.000000000 +0200
-+++ util-linux-2.12r-AES/mount/swapon.8	2005-09-24 14:48:54.000000000 +0300
-@@ -142,6 +142,22 @@
+diff --git a/mount/swapon.8 b/mount/swapon.8
+index 138b819..6f3b652 100644
+--- a/mount/swapon.8
++++ b/mount/swapon.8
+@@ -142,6 +142,22 @@ flag is given, swapping is disabled on all known swap devices and files
  .I /proc/swaps
  or
  .IR /etc/fstab ).
@@ -4128,17 +4180,17 @@
  .SH NOTE
  You should not use
  .B swapon
-diff -urN util-linux-2.12r/mount/swapon.c util-linux-2.12r-AES/mount/swapon.c
---- util-linux-2.12r/mount/swapon.c	2004-12-22 11:50:19.000000000 +0200
-+++ util-linux-2.12r-AES/mount/swapon.c	2006-07-21 20:33:56.000000000 +0300
-@@ -1,22 +1,45 @@
+diff --git a/mount/swapon.c b/mount/swapon.c
+index ed91afc..8155b60 100644
+--- a/mount/swapon.c
++++ b/mount/swapon.c
+@@ -1,18 +1,41 @@
  /*
   * A swapon(8)/swapoff(8) for Linux 0.99.
-  * swapon.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp
 + *
 + * 1997-02-xx <Vincent.Renardias at waw.com>
 + * - added '-s' (summary option)
-+ * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek at pld.ORG.PL>
++ * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek at pld.ORG.PL>
 + * - added Native Language Support
 + * 1999-03-21 Arnaldo Carvalho de Melo <acme at conectiva.com.br>
 + * - fixed strerr(errno) in gettext calls
@@ -4148,7 +4200,6 @@
 + * 2002-04-14 Jari Ruusu
 + * - added encrypted swap support
   */
- 
  #include <ctype.h>
  #include <stdlib.h>
  #include <stdio.h>
@@ -4165,19 +4216,17 @@
 +#include <sys/utsname.h>
 +#include <sys/time.h>
 +#include <asm/page.h>
+ #include <unistd.h>
  #include "xmalloc.h"
  #include "swap_constants.h"
- #include "swapargs.h"
  #include "nls.h"
- #include "mount_blkid.h"
- #include "mount_by_label.h"
 +#include "loop.h"
 +#include "xstrncpy.h"
 +#include "sha512.h"
- 
- #define streq(s, t)	(strcmp ((s), (t)) == 0)
- 
-@@ -297,6 +320,262 @@
+ #include "fsprobe.h"
+ #include "realpath.h"
+ #include "mount_paths.h"
+@@ -288,6 +311,262 @@ swapoff_by_uuid(const char *uuid, int quiet) {
  }
  
  static int
@@ -4440,7 +4489,7 @@
  swapon_all(void) {
  	FILE *fp;
  	struct mntent *fstab;
-@@ -317,6 +596,8 @@
+@@ -307,6 +586,8 @@ swapon_all(void) {
  		const char *special;
  		int skip = 0;
  		int pri = priority;
@@ -4449,7 +4498,7 @@
  
  		if (!streq(fstab->mnt_type, MNTTYPE_SWAP))
  			continue;
-@@ -325,23 +606,39 @@
+@@ -315,23 +596,39 @@ swapon_all(void) {
  		if (!special)
  			continue;
  
@@ -4457,13 +4506,16 @@
 -		    (!ifexists || !access(special, R_OK))) {
 -			/* parse mount options; */
 -			char *opt, *opts = strdup(fstab->mnt_opts);
--	   
+-
 -			for (opt = strtok(opts, ","); opt != NULL;
 -			     opt = strtok(NULL, ",")) {
 -				if (strncmp(opt, "pri=", 4) == 0)
 -					pri = atoi(opt+4);
 -				if (strcmp(opt, "noauto") == 0)
 -					skip = 1;
+-			}
+-			if (!skip)
+-				status |= do_swapon(special, pri, CANONIC);
 +		/* parse mount options; */
 +		opts = strdup(fstab->mnt_opts);
 +		if (!opts) {
@@ -4488,14 +4540,12 @@
 +					status |= -1;
 +					continue;
 +				}
-+				status |= do_swapon(loop, pri);
- 			}
--			if (!skip)
--				status |= do_swapon(special, pri);
++				status |= do_swapon(loop, pri, CANONIC);
++  			}
 +			continue;
 +		}
 +		if (!is_in_proc_swaps(special) && (!ifexists || !access(special, R_OK))) {
-+			status |= do_swapon(special, pri);
++			status |= do_swapon(special, pri, CANONIC);
  		}
  	}
 -	fclose(fp);
@@ -4503,26 +4553,25 @@
  
  	return status;
  }
-@@ -504,11 +801,49 @@
+@@ -494,19 +791,49 @@ main_swapoff(int argc, char *argv[]) {
  			exit(2);
  		}
  		while ((fstab = getmntent(fp)) != NULL) {
--			if (streq(fstab->mnt_type, MNTTYPE_SWAP) &&
--			    !is_in_proc_swaps(fstab->mnt_fsname))
--				do_swapoff(fstab->mnt_fsname, QUIET);
 +			const char *orig_special = fstab->mnt_fsname;
-+			const char *special;
+ 			const char *special;
 +			int skip = 0;
 +			char *opt, *opts;
 +			char *loop = NULL, *encryption = NULL;
-+
-+			if (!streq(fstab->mnt_type, MNTTYPE_SWAP))
-+				continue;
-+
-+			special = mount_get_devname(orig_special);
-+			if (!special)
-+				continue;
-+
+ 
+ 			if (!streq(fstab->mnt_type, MNTTYPE_SWAP))
+ 				continue;
+ 
+-			special = fsprobe_get_devname(fstab->mnt_fsname);
++			special = fsprobe_get_devname(orig_special);
+ 			if (!special)
+ 				continue;
+ 
+-			if (!is_in_proc_swaps(special))
 +			/* parse mount options; */
 +			opts = strdup(fstab->mnt_opts);
 +			if (!opts) {
@@ -4541,7 +4590,7 @@
 +				if (!is_in_proc_swaps(loop)) {
 +					if(skip)
 +						continue;
-+					do_swapoff(loop, QUIET);
++					do_swapoff(loop, QUIET, CANONIC);
 +				}
 +				shutdown_encrypted_swap(loop);
 +				continue;
@@ -4549,7 +4598,7 @@
 +			if(skip)
 +				continue;
 +			if (!is_in_proc_swaps(special)) {
-+				do_swapoff(special, QUIET);
+ 				do_swapoff(special, QUIET, CANONIC);
 +			}
  		}
 -		fclose(fp);




More information about the Pkg-loop-aes-commits mailing list