Treat it just like a file. Use open/close/lseek/etc... to write the
supreblock, inodes, bitmaps, etc...
example:
int fd = open("/dev/loop0", O_RDWR);
//lseek to block 1
//write superblock
//lseek to block X
//write contents of inode X
//lseek to block Y
//write contents . and .. for root directory
// and so on and so forth
close(fd);
Tom
Bao zhao wrote:
hi,usually loopback device can be used according to the following step.
dd if=/dev/zero of=plaintext.img bs=1M count=20
Second, associate the newly created le with a loopback device:
losetup /dev/loop0 plaintext.img
Next, create a lesystem within the le, using the newly associated
loop device:
mkfs -t ext2 /dev/loop0
Finally, mount the lesystem and use it as if it were any other
mounted volume:
but i want to create a new file system such as:
mkmyfs /dev/loop0,
but I don't know how to controll /dev/loop in applictions to
implement mkmyfs, any hint welcome!
TIA!
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/