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

cloop patch for 64-bit



Hello list,

When trying to add a 64-bit kernel to Knoppix as boot option, I noticed
that losetup from busybox was unable to attach the compressed file to
/dev/cloop. It seems there needs to be a compat_ioctl implementation for
adding 64-bit support to cloop.

Attached is a patch that solved the problem for me. The complete source
is already on debian-knoppix.alioth.debian.org. Feel free to comment,
this is still experimental. ;-)

Regards
-Klaus
--- cloop-2.636/compressed_loop.c	2010-11-06 12:02:11.000000000 +0100
+++ cloop-2.637/compressed_loop.c	2011-01-11 22:57:00.000000000 +0100
@@ -20,7 +20,7 @@
  */
 
 #define CLOOP_NAME "cloop"
-#define CLOOP_VERSION "2.636"
+#define CLOOP_VERSION "2.637"
 #define CLOOP_MAX 8
 
 #ifndef KBUILD_MODNAME
@@ -51,6 +51,7 @@
 #include <linux/zutil.h>
 #include <linux/loop.h>
 #include <linux/kthread.h>
+#include <linux/compat.h>
 #include "compressed_loop.h"
 
 /* New License scheme */
@@ -214,8 +215,8 @@
    if(size_read <= 0)
     {
      printk(KERN_ERR "%s: Read error %d at pos %Lu in file %s, "
-                     "%d bytes lost.\n", cloop_name, size_read, pos,
-		     file, size);
+                     "%d bytes lost.\n", cloop_name, (int)size_read, pos,
+		     file, (int)size);
      memset(buf + buf_len - size, 0, size);
      break;
     }
@@ -615,7 +616,7 @@
 	}
       }
      printk(KERN_INFO "%s: preloaded %d blocks into cache.\n", cloop_name,
-                      clo->preload_size);
+                      (int)clo->preload_size);
     }
    else
     {
@@ -623,7 +624,7 @@
       * fails, then we just go without cache, but we should at least
       * let the user know. */
      printk(KERN_WARNING "%s: cloop_malloc(%d) failed, continuing without preloaded buffers.\n",
-            cloop_name, clo->preload_size * sizeof(char *));
+            cloop_name, (int)(clo->preload_size * sizeof(char *)));
      clo->preload_array_size = clo->preload_size = 0;
     }
   }
@@ -875,6 +876,28 @@
  return err;
 }
 
+#ifdef CONFIG_COMPAT
+static int cloop_compat_ioctl(struct block_device *bdev, fmode_t mode,
+			   unsigned int cmd, unsigned long arg)
+{
+ switch(cmd) {
+  case LOOP_SET_CAPACITY: /* Change arg */ 
+  case LOOP_CLR_FD:       /* Change arg */ 
+  case LOOP_GET_STATUS64: /* Change arg */ 
+  case LOOP_SET_STATUS64: /* Change arg */ 
+	arg = (unsigned long) compat_ptr(arg);
+  case LOOP_SET_STATUS:   /* unchanged */
+  case LOOP_GET_STATUS:   /* unchanged */
+  case LOOP_SET_FD:       /* unchanged */
+  case LOOP_CHANGE_FD:    /* unchanged */
+	return cloop_ioctl(bdev, mode, cmd, arg);
+	break;
+ }
+ return -ENOIOCTLCMD;
+}
+#endif
+
+
 static int cloop_open(struct block_device *bdev, fmode_t mode)
 {
  int cloop_num;
@@ -907,6 +930,9 @@
         owner:		THIS_MODULE,
         open:           cloop_open,
         release:        cloop_close,
+#ifdef CONFIG_COMPAT
+	compat_ioctl:	cloop_compat_ioctl,
+#endif
 	ioctl:          cloop_ioctl
 	/* locked_ioctl ceased to exist in 2.6.36 */
 };

Reply to: