loop: auto-load crypto module [PATCH]

From: Ian Collier
Date: Wed Sep 14 2005 - 10:38:59 EST


It seems odd that "losetup -e blowfish" will auto-load the blowfish module
if it's not already loaded but it doesn't work if the cryptoloop module
isn't loaded. It's fairly simple to amend loop so that it requests
a crypto module when required - a sample patch appears below. Just put
"alias loop-encrypt-18 cryptoloop" in your modprobe.conf. This currently
fails silently if the module isn't found - I don't know whether it's
worth putting a message in there.

On an unrelated note, while looking at loop.c I noticed that loop_init
contains two calls to memset for the same block of memory (one outside
the for-loop, one inside). It seems to me that one of these isn't
necessary. :-)

imc

--- linux-2.6.13/drivers/block/loop.c.orig 2005-08-29 00:41:01.000000000 +0100
+++ linux-2.6.13/drivers/block/loop.c 2005-09-14 14:01:42.844009381 +0100
@@ -74,6 +74,7 @@
#include <linux/completion.h>
#include <linux/highmem.h>
#include <linux/gfp.h>
+#include <linux/kmod.h>

#include <asm/uaccess.h>

@@ -950,8 +951,12 @@
if (type >= MAX_LO_CRYPT)
return -EINVAL;
xfer = xfer_funcs[type];
- if (xfer == NULL)
- return -EINVAL;
+ if (xfer == NULL) {
+ request_module("loop-encrypt-%u",type);
+ xfer = xfer_funcs[type];
+ if (xfer == NULL)
+ return -EINVAL;
+ }
} else
xfer = NULL;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/