RE: linux 2.6 driver (patch included)
"Leisner, Martin" <[email protected]>
| Newsgroups | gmane.linux.cryptography |
|---|---|
| Message-ID | <556445368AFA1C438794ABDA8901891C07844404@USA0300MS03.na.xerox.net> |
1) there's no loop.c-2.6.original available -- that's my major complaint
-- so I can't see where it came from (with all the kernel changes).
There were some api changes I saw, but there seemed to be some "other
changes" -- for example:
@@ -709,6 +734,9 @@
sector_t IV;
struct page *pg;
+ if(!bio->bi_size)
+ return 0;
+
pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset;
buf = page_address(LDE_lo_bio_free0->bi_io_vec[0].bv_page);
IV = bio->bi_sector;
I'm not sure if that's a reason to upgrade or not...
2) Some stuff had to be cleaned up -- this was just a feeler to see if
anyone had a use for this...
I'm not sure about the future of loopAES with all the other methods
of encryption in the kernel (I started working on this several months
ago -- and since we used loopAES in 2.4 machines, I was asked to get it
working on 2.6). Note I'm new to this...
Another advantage is I had a framework to load multiple loopAES drivers
at the same time (which does different things -- for example, to compare
the
C code and the assembler code on x86).
Just replacing should compile it as device loop/major 7 -- but this can
be
changed at compile and or runtime...
Here's the patch with the extraneous stuff -- against 2.3a...feel free
to
use/comment/flush (I didn't see any patches on sourceforge in the
patchmanager,
so I wasn't sure if that was a place to put patches...)
marty
-----Original Message-----
From: Jari Ruusu [mailto:[email protected]]
Sent: Wednesday, November 14, 2007 9:46 AM
To: Leisner, Martin
Subject: Re: linux 2.6 driver
"Leisner, Martin" wrote:
> There's no loop.c-2.6.original in the 3.2a/3.2b distributions.
>
> I'm using 3.2a and made some mods to the driver.
>
> Looking at linus's git tree, there were substantial changes made to
> loop.c since May.
>
> FYI:
> diff -u loop-AES-v3.2a/loop.c-2.6.patched
> loop-AES-v3.2b/loop.c-2.6.patched | diffstat
> loop.c-2.6.patched | 89
> +++++++++++++++++++++++++++++++++++++++++++++--------
> 1 files changed, 77 insertions(+), 12 deletions(-)
>
> I've modified the loop driver so it can run alongside the standard
loop
> driver in the kernel (this was when systems had them build in instead
of
> modulized).
>
> I had the ability to:
> default to another name besides /dev/loop* (I used loopAES)
> runtime assignment of major numbers (so there's no conflict with
> the
> standard loop)
>
> This was easier than to recompile/modify all the kernels I was using
> (and tell everyone I was supporting they "had to run a new kernel".
[ This is private email, but feel free to CC a public mailing list
on your possible reply. ]
I'm not sure how to interpret your message. It could mean:
1) You are unhappy with amount of changes to loop.c-2.6.patched file?
- Most of those changes are needed because of block layer interface
changes on linux-2.6.24-rc and later kernels. It would be cool if
interfaces didn't change, but they did.
2) You wanted me and/or others to look at your changes?
- Your email didn't include a patch.
3) You are making public statement that you can hack code?
- Fine. Nothing wrong with that.
--
Jari Ruusu 1024R/3A220F51 5B 4B F9 BB D3 3F 52 E9 DB 1D EB E3 24 0E A9
DD
loop.c.diff
(application/octet-stream, 4 KB)
--- loop.c 2007/10/03 19:40:09 1.1 +++ loop.c 2007/10/05 19:14:35 @@ -62,6 +62,16 @@ * Added support for removing offset from IV computations. * Jari Ruusu, September 21 2003 * + * Added a way to have a seperate loop driver (if the kernel has on built-in). + * Also you can run multiple implementation of the loop driver. + * Added a option: + * loopname (default to loop) + * major (default to 7, if 0, use dynamic) + * Added a compile time option: + * NO_EXPORT_SYMBOLS + * to negate export symbols. + * Marty Leisner <[email protected]> + * * * Still To Fix: * - Advisory locking is ignored here. @@ -105,6 +115,11 @@ #include <asm/uaccess.h> +#ifdef NO_EXPORT_SYMBOLS +#undef EXPORT_SYMBOL +#define EXPORT_SYMBOL(x) +#endif + #if !defined(LO_FLAGS_DO_BMAP) # define LO_FLAGS_DO_BMAP 0x20000 #endif @@ -145,6 +160,25 @@ module_param(max_loop, int, 0); MODULE_PARM_DESC(max_loop, "Maximum number of loop devices (1-256)"); + +#ifndef DEFAULT_LOOP_DEVICE +#define DEFAULT_LOOP_DEVICE 7 +#endif + +static int loop_major = DEFAULT_LOOP_DEVICE; +module_param(loop_major, int, 0); +MODULE_PARM_DESC(loop_major, "Default loop device major number, 0 to autospecify"); + +#ifndef DEFAULT_LOOP_NAME +#define DEFAULT_LOOP_NAME "loop" +#endif + +static char *loop_name = DEFAULT_LOOP_NAME; +module_param(loop_name, charp, 0); +MODULE_PARM_DESC(loop_name, "loop device name"); + + + static struct gendisk **disks; /* @@ -234,6 +268,7 @@ module_param(lo_nice, int, 0); MODULE_PARM_DESC(lo_nice, "Loop thread scheduler nice (0 ... -20)"); + struct loop_bio_extension { struct bio *bioext_merge; struct loop_device *bioext_loop; @@ -1323,6 +1358,7 @@ if (S_ISBLK(inode->i_mode)) { lo_device = inode->i_bdev; if (lo_device == bdev) { + printk("EBUSY at %d\n", __LINE__); error = -EBUSY; goto out_putf; } @@ -1436,7 +1472,7 @@ /* 2.6.19 and newer kernels */ { struct task_struct *t; - t = kthread_create(loop_thread, lo, "loop%d", lo->lo_number); + t = kthread_create(loop_thread, lo, "%s%d", loop_name, lo->lo_number); if (IS_ERR(t)) { error = PTR_ERR(t); goto out_mapping; @@ -1938,12 +1974,16 @@ * And now the modules code and kernel interface. */ MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("loopAES driver, hacked marty leisner"); + +#if 0 #if (LINUX_VERSION_CODE >= 0x20601) || !defined(OLD_REQUEST_MODULE_INTERFACE) MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR); #else MODULE_ALIAS("block-major-7"); #endif +#endif int loop_register_transfer(struct loop_func_table *funcs) { @@ -1978,9 +2018,11 @@ EXPORT_SYMBOL(loop_register_transfer); EXPORT_SYMBOL(loop_unregister_transfer); + int __init loop_init(void) { int i; + int num; if ((max_loop < 1) || (max_loop > 256)) { printk(KERN_WARNING "loop: invalid max_loop (must be between" @@ -1988,8 +2030,14 @@ max_loop = 8; } - if (register_blkdev(LOOP_MAJOR, "loop")) + num = register_blkdev(loop_major, loop_name); + if(num < 0) return -EIO; + if(loop_major == 0) + loop_major = num; + + // printk("loop major = %d\n", loop_major); + loop_dev_ptr_arr = kmalloc(max_loop * sizeof(struct loop_device *), GFP_KERNEL); if (!loop_dev_ptr_arr) @@ -2047,10 +2095,10 @@ lo->lo_queue = disk->queue; spin_lock_init(&LDE_lo_ioctl_spin); init_waitqueue_head(&LDE_lo_ioctl_wait); - disk->major = LOOP_MAJOR; + disk->major = loop_major; disk->first_minor = i; disk->fops = &lo_fops; - sprintf(disk->disk_name, "loop%d", i); + sprintf(disk->disk_name, "%s%d", loop_name, i); #ifdef CONFIG_DEVFS_FS sprintf(disk->devfs_name, "loop/%d", i); #endif @@ -2076,7 +2124,7 @@ out_mem2: kfree(loop_dev_ptr_arr); out_mem1: - unregister_blkdev(LOOP_MAJOR, "loop"); + unregister_blkdev(loop_major, loop_name); printk(KERN_ERR "loop: ran out of memory\n"); return -ENOMEM; } @@ -2095,7 +2143,7 @@ #ifdef CONFIG_DEVFS_FS devfs_remove("loop"); #endif - unregister_blkdev(LOOP_MAJOR, "loop"); + unregister_blkdev(loop_major, loop_name); kfree(disks); kfree(loop_dev_ptr_arr);