[test registering loop device
timo.lindfors@iki.fi**20080605100622] {
hunk ./src/crcloop.c 1
-/*
- *  hello-1.c - The simplest kernel module.
- */
-#include <linux/module.h>/* Needed by all modules */
-#include <linux/kernel.h>/* Needed for KERN_INFO */
+#include <asm/checksum.h>
+#include <linux/loop.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
hunk ./src/crcloop.c 6
-int init_module(void)
-{
-    printk(KERN_INFO "Hello world 1.\n");
+#define LOOP_CRYPT_CRC 7
hunk ./src/crcloop.c 8
-    /*
-     * A non 0 return means init_module failed; module can't be loaded.
-     */
+#define FLOW(fmt,args...) printk(KERN_INFO "%s:%d: " fmt "\n", __FUNCTION__, __LINE__, ##args)
+
+static int crcloop_init(struct loop_device *lo, const struct loop_info64 *info) {
+    FLOW();
hunk ./src/crcloop.c 15
-void cleanup_module(void)
+static int crcloop_transfer(struct loop_device *lo, int cmd,
+		 struct page *raw_page, unsigned raw_off,
+		 struct page *loop_page, unsigned loop_off,
+		 int size, sector_t real_block)
hunk ./src/crcloop.c 20
+    FLOW();
+    return 0;
+}
+
+static int crcloop_release(struct loop_device *lo) {
+    FLOW();
+    return 0;
+}
+
+static struct loop_func_table crcloop_funcs = {
+    .number = LOOP_CRYPT_CRC,
+    .init = crcloop_init,
+    .transfer = crcloop_transfer,
+    .release = crcloop_release,
+    .owner = THIS_MODULE
+};
+
+int init_module(void) {
+    int ret;
+
+    FLOW();
+    printk(KERN_INFO "Hello world 1.\n");
+    ret = loop_register_transfer(&crcloop_funcs);
+
+    if (ret) {
+	printk(KERN_ERR "crcloop: loop_register_transfer failed\n");
+    }
+    return ret;
+}
+
+void cleanup_module(void) {
+    FLOW();
hunk ./src/crcloop.c 53
+    if (loop_unregister_transfer(LOOP_CRYPT_CRC)) {
+	printk(KERN_ERR
+	       "crcloop: loop_unregister_transfer failed\n");
+    }
}
