Hello, everyone, I have a problem when I use the
loop device. I recompiled and built the losetup.o and loop.o. Then I used the
insmod loop.o to load it into the kernel. Then I use the following command to
connect the loop0 with the floppy disk.
losetup -e xor /dev/loop0 /dev/fd0
It succeeded. Up to now it seemed that everything
is OK. Then I used the "mke2fs /dev/loop0" and "mount /dev/loop0 /floppy" to
format and mount the loop device. Then I copied some files to the loop device.
Then I used the "umount /floppy" and "losetup -d /dev/loop0" to unmount the
floppy and disconnected that with the loop device. Then I found that the data on
the floppy disk was never encrypted. It is just the normal ext2 format. In
loop.o it always call the transfer_none() function rather than the
transfer_xor().
After tracing the code I found the exact reason.
Both the lomount.c and the loop.c include the loop.h header file. In this header
file there is a loop_info structure. And this structure contains two
parameters: 'dev_t lo_device' and 'dev_t lo_rdevice'. I printed the size of the
loop_info structure and the size of the dev_t variable type in losetup and loop.
The following are the output.
In losetup:
The sizeof(loop_info) is 148.
The sizeof(dev_t) is 8.
In loop:
The sizeof(loop_info) is 136.
The sizeof(dev_t) is 2.
You see the difference. It seemed that the definition of the dev_t is
different in losetup and loop. What is wrong? After I omited these 2 parameters
from the loop_info structure, then everything is OK. It works very fine. I know
that the losetup runs in user space while loop runs in kernel space. That is the
reason for this?
Anyone has the same problem?
Michael |