--- ../x/cryptoloop/cryptoloop.c	Tue Jul 23 23:25:47 2002
+++ cryptoloop.c	Wed Aug  7 17:40:35 2002
@@ -52,18 +52,14 @@
 # error crypto api v0.1.0 or better required
 #endif
 
-#if !defined(LOOP_IV_SECTOR_SIZE)
-# error ******************************************************************
-# error ******************************************************************
-# error ******************************************************************
-# error ******************************************************************
-# error ****                                                          ****
-# error ****         you need to to patch your loop.c driver          ****
-# error ****                                                          ****
-# error ******************************************************************
-# error ******************************************************************
-# error ******************************************************************
-# error ******************************************************************
+#if !defined(LOOP_IV_SECTOR_BITS) && !defined(LOOP_IV_SECTOR_SIZE)
+# define LOOP_IV_SECTOR_BITS 9
+# define LOOP_IV_SECTOR_SIZE (1 << LOOP_IV_SECTOR_BITS)
+# warning *** LOOP_IV_SECTOR_BITS not defined
+# warning *** You do not have a fixed 512-byte metric for IV calculation in loop.c
+# warning *** Do not worry, applying workaround
+# define THERP_IV_HACK
+typedef int loop_iv_t;		// This is likely to be missing
 #endif
 
 #if !defined(LO_CRYPT_CRYPTOAPI)
@@ -187,7 +183,19 @@
 		out = raw_buf;
 	}
 
-	IV /= blocksize / LOOP_IV_SECTOR_SIZE;
+#ifdef THERP_IV_HACK
+	/* Expand IV to 512 byte metric */
+
+	IV = IV*(loop_get_bs(lo) >> LOOP_IV_SECTOR_BITS);
+
+	/* 
+	 * Too bad offset information is lost, but we use a dirty trick
+	 * to recover it from the raw_buf address (ab)using the page 
+	 * alignments and the blocksize alignments
+	 */
+
+	IV = IV + (((unsigned long)raw_buf&(loop_get_bs(lo)-1)) >> LOOP_IV_SECTOR_BITS);
+#endif
 
 #if defined(CONFIG_CRYPTOLOOP_DEBUG)
 	if (lx->debug)
@@ -233,12 +241,8 @@
 	switch (cmd) {
 	case CRYPTOLOOP_SET_BLKSIZE:
 		printk (KERN_DEBUG
-			"cryptoloop: switch to blocksize %d requested\n",
+			"cryptoloop: switch to blocksize %d ignored (unsupported)\n",
 			arg_int);
-		if (arg_int >= 0 && (arg_int % LOOP_IV_SECTOR_SIZE == 0)) {
-			lx->blocksize = arg_int;
-			err = 0;
-		}
 		break;
 
 	case CRYPTOLOOP_SET_DEBUG:
