diff -urN linux/Documentation/Configure.help linux-cibd/Documentation/Configure.help --- linux/Documentation/Configure.help Wed Apr 3 13:44:35 2002 +++ linux-cibd/Documentation/Configure.help Wed Mar 27 11:23:56 2002 @@ -440,6 +440,13 @@ "real" root file system, etc. See for details. +Compiled-in block device support +CONFIG_BLK_DEV_CIBD + Set this to have the contents of drivers/block/cibd.h copied into + the ramdisk. The cibd.h file is generated using the makeh script and + the file2hex program in the drivers/block/ directory. This is useful + if you don't have any real device to boot from. + Loopback device support CONFIG_BLK_DEV_LOOP Saying Y here will allow you to use a regular file as a block diff -urN linux/drivers/block/Config.in linux-cibd/drivers/block/Config.in --- linux/drivers/block/Config.in Wed Apr 3 13:44:35 2002 +++ linux-cibd/drivers/block/Config.in Wed Mar 27 11:03:46 2002 @@ -45,6 +45,8 @@ int ' Default RAM disk size' CONFIG_BLK_DEV_RAM_SIZE 4096 fi dep_bool ' Initial RAM disk (initrd) support' CONFIG_BLK_DEV_INITRD $CONFIG_BLK_DEV_RAM +dep_bool ' CIBD support' CONFIG_BLK_DEV_CIBD $CONFIG_BLK_DEV_RAM + dep_tristate ' Non-volatile ram disk (nvrd) support (EXPERIMENTAL)' CONFIG_NVRD $CONFIG_EXPERIMENTAL endmenu diff -urN linux/drivers/block/cibd.h linux-cibd/drivers/block/cibd.h --- linux/drivers/block/cibd.h Thu Jan 1 01:00:00 1970 +++ linux-cibd/drivers/block/cibd.h Wed Apr 3 14:04:39 2002 @@ -0,0 +1,4 @@ +static unsigned char cibd_fs[]= +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + + diff -urN linux/drivers/block/file2hex.c linux-cibd/drivers/block/file2hex.c --- linux/drivers/block/file2hex.c Thu Jan 1 01:00:00 1970 +++ linux-cibd/drivers/block/file2hex.c Wed Apr 3 14:04:54 2002 @@ -0,0 +1,22 @@ +/* file2hex.c - output a C-parsable representation of binary data + * (C) 2002 Jacek Lipkowski + */ + +#include +#include + +main() +{ +int i; +int len; +unsigned char buf[16]; + +while ((len=read(0,&buf,16))&&(len>0)) +{ +printf("\n\""); +for(i=0;i (rd_length[unit] >> BLOCK_SIZE_BITS)) + { + printk ("CIBD: image too big! (%d/%ld blocks)\n", + nblocks, rd_length[unit] >> BLOCK_SIZE_BITS); + goto done; + } + +/* copy in CIBD_BLOCK_SIZE blocks, since i don't know + * if i can just write the whole image at once + */ + + for (i = 0; i < nblocks; i++) + { + outfile.f_op->write (&outfile, cibd_fs + CIBD_BLOCK_SIZE * i, + CIBD_BLOCK_SIZE, &outfile.f_pos); + if (!(i % 16)) + printk ("."); + + } + printk ("ok\n"); + + ROOT_DEV = MKDEV (MAJOR_NR, unit); + if (ROOT_DEVICE_NAME != NULL) + strcpy (ROOT_DEVICE_NAME, "rd/0"); +done: + blkdev_close (out_inode, &outfile); + iput (out_inode); + set_fs (fs); + printk ("cibd_load_image() done\n"); + return; + free_inodes: /* free inodes on error */ + iput (out_inode); + + printk ("cibd_load_image() end\n"); +} +#endif /* CONFIG_BLK_DEV_CIBD */ + + /* * This routine tries to find a RAM disk image to load, and returns the * number of blocks to read for a non-compressed image, 0 if the image @@ -883,6 +970,15 @@ void __init initrd_load(void) { rd_load_image(MKDEV(MAJOR_NR, INITRD_MINOR),rd_image_start,0); +} +#endif + +#ifdef CONFIG_BLK_DEV_CIBD +void __init +cibd_load (void) +{ + printk("CIBD - Compiled-in block device \n"); + cibd_load_image (MKDEV (MAJOR_NR, INITRD_MINOR), rd_image_start, 0); } #endif diff -urN linux/init/main.c linux-cibd/init/main.c --- linux/init/main.c Wed Apr 3 13:44:37 2002 +++ linux-cibd/init/main.c Wed Mar 27 11:19:33 2002 @@ -7,6 +7,9 @@ * Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96 * Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96 * Simplified starting of init: Michael A. Griffith + * + * Added CIBD ramdisk support: Jacek Lipkowski , Mar 2002 + * */ #define __KERNEL_SYSCALLS__ @@ -758,6 +761,7 @@ extern void rd_load(void); extern void initrd_load(void); +extern void cibd_load(void); /* * Prepare the namespace - decide what/where to mount, load ramdisks, etc. @@ -780,6 +784,10 @@ else #endif rd_load(); +#endif + +#ifdef CONFIG_BLK_DEV_CIBD +cibd_load(); #endif /* Mount the root filesystem.. */