diff -rNu ../linux-2.4.17/Documentation/Configure.help ./Documentation/Configure.help --- ../linux-2.4.17/Documentation/Configure.help Sat Dec 29 10:48:48 2001 +++ ./Documentation/Configure.help Sat Dec 29 11:05:14 2001 @@ -440,6 +440,31 @@ "real" root file system, etc. See for details. +Initial virtual memory filesystem support +CONFIG_TMPFS_INITTAR + Using a tmpfs initrd allows you to deliver a tar (or tar.gz) + archive in place of the usual (possibly compressed) ramdisk + filesystem. Instead of using /dev/ram0, tmpfs initrd mounts a + tmpfs filesystem on root and extracts the archive there, bypassing + use of ramdisks. + + You can pass the kernel a command-line option + "inittar=[0|1][,(tmpfs options)]"; where '0' disables inittar, + '1' enables it, and 'tmpfs options', if specified, are passed + directly to the tmpfs mount (max size, etc.). Per default, inittar + is enabled if and only if the kernel contains no regular initrd + support (CONFIG_BLK_DEV_INITRD). + + Another option is "tar_verbose". If this is passed on the + commandline, all filenames from the inittar will be printed + during extraction. + + Similar to initrd, the /proc/sys/kernel/real-root-dev contains + the root device either set by a 'root=...' commandline option + or the value written to the kernel image (see rdev(8)). Unlike + initrd, the kernel will not run /linuxrc but instead starts the + normal /sbin/init. + Loopback device support CONFIG_BLK_DEV_LOOP Saying Y here will allow you to use a regular file as a block diff -rNu ../linux-2.4.17/arch/alpha/kernel/setup.c ./arch/alpha/kernel/setup.c --- ../linux-2.4.17/arch/alpha/kernel/setup.c Tue Nov 27 18:28:39 2001 +++ ./arch/alpha/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -32,7 +32,7 @@ #include #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif @@ -363,7 +363,7 @@ reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size); printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size)); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER initrd_start = INITRD_START; if (initrd_start) { initrd_end = initrd_start+INITRD_SIZE; @@ -381,7 +381,7 @@ INITRD_SIZE); } } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ } #else extern void setup_memory(void *); diff -rNu ../linux-2.4.17/arch/alpha/mm/init.c ./arch/alpha/mm/init.c --- ../linux-2.4.17/arch/alpha/mm/init.c Wed Oct 10 18:15:18 2001 +++ ./arch/alpha/mm/init.c Sat Dec 29 11:05:14 2001 @@ -20,7 +20,7 @@ #include #include /* max_low_pfn */ #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif @@ -384,7 +384,7 @@ (&__init_end - &__init_begin) >> 10); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { diff -rNu ../linux-2.4.17/arch/alpha/mm/numa.c ./arch/alpha/mm/numa.c --- ../linux-2.4.17/arch/alpha/mm/numa.c Wed Oct 10 18:14:51 2001 +++ ./arch/alpha/mm/numa.c Sat Dec 29 11:05:14 2001 @@ -12,7 +12,7 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif @@ -246,7 +246,7 @@ for (nid = 0; nid < MAX_NUMNODES; nid++) setup_memory_node(nid, kernel_end); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER initrd_start = INITRD_START; if (initrd_start) { initrd_end = initrd_start+INITRD_SIZE; @@ -265,7 +265,7 @@ INITRD_SIZE); } } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ } void __init paging_init(void) diff -rNu ../linux-2.4.17/arch/arm/kernel/setup.c ./arch/arm/kernel/setup.c --- ../linux-2.4.17/arch/arm/kernel/setup.c Tue Nov 27 18:28:39 2001 +++ ./arch/arm/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -247,7 +247,7 @@ */ void __init setup_initrd(unsigned int start, unsigned int size) { -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (start == 0) size = 0; initrd_start = start; diff -rNu ../linux-2.4.17/arch/arm/mm/init.c ./arch/arm/mm/init.c --- ../linux-2.4.17/arch/arm/mm/init.c Wed Oct 24 14:02:10 2001 +++ ./arch/arm/mm/init.c Sat Dec 29 11:05:14 2001 @@ -301,7 +301,7 @@ { int initrd_node = -2; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* * Make sure that the initrd is within a valid area of * memory. @@ -468,7 +468,7 @@ } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (initrd_node >= 0) reserve_bootmem_node(NODE_DATA(initrd_node), __pa(initrd_start), initrd_end - initrd_start); @@ -660,7 +660,7 @@ } } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER static int keep_initrd; diff -rNu ../linux-2.4.17/arch/i386/defconfig ./arch/i386/defconfig --- ../linux-2.4.17/arch/i386/defconfig Tue Nov 27 18:28:40 2001 +++ ./arch/i386/defconfig Sat Dec 29 11:05:14 2001 @@ -135,6 +135,7 @@ # CONFIG_BLK_DEV_NBD is not set # CONFIG_BLK_DEV_RAM is not set # CONFIG_BLK_DEV_INITRD is not set +# CONFIG_TMPFS_INITTAR is not set # # Multi-device support (RAID and LVM) diff -rNu ../linux-2.4.17/arch/i386/kernel/setup.c ./arch/i386/kernel/setup.c --- ../linux-2.4.17/arch/i386/kernel/setup.c Sat Dec 29 10:48:48 2001 +++ ./arch/i386/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -93,7 +93,7 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_RAM +#ifdef CONFIG_IRD_LOADER #include #endif #include @@ -959,7 +959,7 @@ */ find_smp_config(); #endif -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (LOADER_TYPE && INITRD_START) { if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { reserve_bootmem(INITRD_START, INITRD_SIZE); diff -rNu ../linux-2.4.17/arch/i386/mm/init.c ./arch/i386/mm/init.c --- ../linux-2.4.17/arch/i386/mm/init.c Sat Dec 29 10:48:48 2001 +++ ./arch/i386/mm/init.c Sat Dec 29 11:05:14 2001 @@ -19,7 +19,7 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif #include @@ -572,7 +572,7 @@ printk ("Freeing unused kernel memory: %dk freed\n", (&__init_end - &__init_begin) >> 10); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { if (start < end) diff -rNu ../linux-2.4.17/arch/ia64/kernel/setup.c ./arch/ia64/kernel/setup.c --- ../linux-2.4.17/arch/ia64/kernel/setup.c Tue Nov 27 18:28:40 2001 +++ ./arch/ia64/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -228,7 +228,7 @@ rsvd_region[n].end = KERNEL_END; n++; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (ia64_boot_param->initrd_start) { rsvd_region[n].start = (unsigned long)__va(ia64_boot_param->initrd_start); rsvd_region[n].end = rsvd_region[n].start + ia64_boot_param->initrd_size; @@ -264,7 +264,7 @@ efi_memmap_walk(free_available_memory, 0); reserve_bootmem(bootmap_start, bootmap_size); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (ia64_boot_param->initrd_start) { initrd_start = (unsigned long)__va(ia64_boot_param->initrd_start); initrd_end = initrd_start+ia64_boot_param->initrd_size; diff -rNu ../linux-2.4.17/arch/m68k/kernel/setup.c ./arch/m68k/kernel/setup.c --- ../linux-2.4.17/arch/m68k/kernel/setup.c Mon Aug 6 16:26:16 2001 +++ ./arch/m68k/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -39,7 +39,7 @@ extern void sun_serial_setup(void); #endif -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif @@ -361,7 +361,7 @@ reserve_bootmem(m68k_memory[0].addr, availmem - m68k_memory[0].addr); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (m68k_ramdisk.size) { reserve_bootmem(m68k_ramdisk.addr, m68k_ramdisk.size); initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr); diff -rNu ../linux-2.4.17/arch/m68k/mm/init.c ./arch/m68k/mm/init.c --- ../linux-2.4.17/arch/m68k/mm/init.c Wed Oct 10 18:15:19 2001 +++ ./arch/m68k/mm/init.c Sat Dec 29 11:05:14 2001 @@ -159,7 +159,7 @@ } #if 0 set_page_count(virt_to_page(tmp), 1); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (!initrd_start || (tmp < (initrd_start & PAGE_MASK) || tmp >= initrd_end)) #endif @@ -188,7 +188,7 @@ initpages << (PAGE_SHIFT-10)); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { int pages = 0; diff -rNu ../linux-2.4.17/arch/mips/au1000/common/Makefile ./arch/mips/au1000/common/Makefile --- ../linux-2.4.17/arch/mips/au1000/common/Makefile Wed Oct 10 18:15:19 2001 +++ ./arch/mips/au1000/common/Makefile Sat Dec 29 11:05:14 2001 @@ -23,7 +23,7 @@ obj-$(CONFIG_AU1000_UART) += serial.o obj-$(CONFIG_REMOTE_DEBUG) += dbg_io.o -obj-$(CONFIG_BLK_DEV_INITRD) += ramdisk.o +obj-$(CONFIG_IRD_LOADER) += ramdisk.o ramdisk.o: mkramobj ramdisk ramdisk.o diff -rNu ../linux-2.4.17/arch/mips/au1000/pb1000/setup.c ./arch/mips/au1000/pb1000/setup.c --- ../linux-2.4.17/arch/mips/au1000/pb1000/setup.c Wed Oct 10 18:15:19 2001 +++ ./arch/mips/au1000/pb1000/setup.c Sat Dec 29 11:05:14 2001 @@ -103,7 +103,7 @@ ioport_resource.start = au1000_resources.io.start; ioport_resource.end = au1000_resources.lcd.end; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); #endif diff -rNu ../linux-2.4.17/arch/mips/ddb5xxx/ddb5477/Makefile ./arch/mips/ddb5xxx/ddb5477/Makefile --- ../linux-2.4.17/arch/mips/ddb5xxx/ddb5477/Makefile Wed Oct 10 18:15:19 2001 +++ ./arch/mips/ddb5xxx/ddb5477/Makefile Sat Dec 29 11:05:14 2001 @@ -17,6 +17,6 @@ obj-$(CONFIG_LL_DEBUG) += debug.o obj-$(CONFIG_REMOTE_DEBUG) += kgdb_io.o -obj-$(CONFIG_BLK_DEV_INITRD) += ramdisk.o +obj-$(CONFIG_IRD_LOADER) += ramdisk.o include $(TOPDIR)/Rules.make diff -rNu ../linux-2.4.17/arch/mips/ddb5xxx/ddb5477/setup.c ./arch/mips/ddb5xxx/ddb5477/setup.c --- ../linux-2.4.17/arch/mips/ddb5xxx/ddb5477/setup.c Wed Oct 10 18:15:19 2001 +++ ./arch/mips/ddb5xxx/ddb5477/setup.c Sat Dec 29 11:05:14 2001 @@ -123,7 +123,7 @@ static void ddb5477_board_init(void); extern void ddb5477_irq_setup(void); -#if defined(CONFIG_BLK_DEV_INITRD) +#if defined(CONFIG_IRD_LOADER) extern unsigned long __rd_start, __rd_end, initrd_start, initrd_end; #endif @@ -151,7 +151,7 @@ /* initialize board - we don't trust the loader */ ddb5477_board_init(); -#if defined(CONFIG_BLK_DEV_INITRD) +#if defined(CONFIG_IRD_LOADER) ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); initrd_start = (unsigned long)&__rd_start; initrd_end = (unsigned long)&__rd_end; diff -rNu ../linux-2.4.17/arch/mips/dec/boot/decstation.c ./arch/mips/dec/boot/decstation.c --- ../linux-2.4.17/arch/mips/dec/boot/decstation.c Mon Dec 13 22:30:26 1999 +++ ./arch/mips/dec/boot/decstation.c Sat Dec 29 11:05:14 2001 @@ -81,7 +81,7 @@ rex_clear_cache(); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER LOADER_TYPE = 1; INITRD_START = (long)&__rd_start; INITRD_SIZE = (long)&__rd_end - (long)&__rd_start; diff -rNu ../linux-2.4.17/arch/mips/ite-boards/generic/it8172_setup.c ./arch/mips/ite-boards/generic/it8172_setup.c --- ../linux-2.4.17/arch/mips/ite-boards/generic/it8172_setup.c Wed Oct 10 18:15:20 2001 +++ ./arch/mips/ite-boards/generic/it8172_setup.c Sat Dec 29 11:05:14 2001 @@ -148,7 +148,7 @@ iomem_resource.end = it8172_resources.pci_mem3.end; #endif -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); #endif diff -rNu ../linux-2.4.17/arch/mips/ite-boards/ivr/Makefile ./arch/mips/ite-boards/ivr/Makefile --- ../linux-2.4.17/arch/mips/ite-boards/ivr/Makefile Wed Oct 10 18:15:20 2001 +++ ./arch/mips/ite-boards/ivr/Makefile Sat Dec 29 11:05:14 2001 @@ -23,6 +23,6 @@ obj-y := init.o obj-CONFIG_PCI += pci_fixup.o -obj-CONFIG_BLK_DEV_INITRD += le_ramdisk.o +obj-CONFIG_IRD_LOADER += le_ramdisk.o include $(TOPDIR)/Rules.make diff -rNu ../linux-2.4.17/arch/mips/ite-boards/qed-4n-s01b/Makefile ./arch/mips/ite-boards/qed-4n-s01b/Makefile --- ../linux-2.4.17/arch/mips/ite-boards/qed-4n-s01b/Makefile Wed Oct 10 18:15:20 2001 +++ ./arch/mips/ite-boards/qed-4n-s01b/Makefile Sat Dec 29 11:05:14 2001 @@ -26,7 +26,7 @@ obj-y += pci_fixup.o endif -ifdef CONFIG_BLK_DEV_INITRD +ifdef CONFIG_IRD_LOADER obj-y += le_ramdisk.o endif diff -rNu ../linux-2.4.17/arch/mips/kernel/setup.c ./arch/mips/kernel/setup.c --- ../linux-2.4.17/arch/mips/kernel/setup.c Wed Oct 10 18:15:20 2001 +++ ./arch/mips/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -722,7 +722,7 @@ /* Reserve the bootmap memory. */ reserve_bootmem(PFN_PHYS(first_usable_pfn), bootmap_size); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* Board specific code should have set up initrd_start and initrd_end */ ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); if( __rd_start != __rd_end ) { @@ -743,7 +743,7 @@ initrd_start = initrd_end = 0; } } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ paging_init(); diff -rNu ../linux-2.4.17/arch/mips/mm/init.c ./arch/mips/mm/init.c --- ../linux-2.4.17/arch/mips/mm/init.c Mon Aug 6 16:27:00 2001 +++ ./arch/mips/mm/init.c Sat Dec 29 11:05:14 2001 @@ -25,7 +25,7 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif @@ -229,7 +229,7 @@ initsize >> 10); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { if (start < end) diff -rNu ../linux-2.4.17/arch/mips/philips/nino/Makefile ./arch/mips/philips/nino/Makefile --- ../linux-2.4.17/arch/mips/philips/nino/Makefile Wed Oct 10 18:15:20 2001 +++ ./arch/mips/philips/nino/Makefile Sat Dec 29 11:05:14 2001 @@ -21,7 +21,7 @@ obj-$(CONFIG_REMOTE_DEBUG) += kgdb.o -obj-$(CONFIG_BLK_DEV_INITRD) += ramdisk.o +obj-$(CONFIG_IRD_LOADER) += ramdisk.o ramdisk.o: $(MAKE) -C ramdisk diff -rNu ../linux-2.4.17/arch/mips64/mm/init.c ./arch/mips64/mm/init.c --- ../linux-2.4.17/arch/mips64/mm/init.c Mon Aug 6 16:27:01 2001 +++ ./arch/mips64/mm/init.c Sat Dec 29 11:05:14 2001 @@ -22,7 +22,7 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif @@ -205,7 +205,7 @@ } void bootmem_init(void) { -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER unsigned long tmp; unsigned long *initrd_header; #endif @@ -289,7 +289,7 @@ /* Reserve the bootmap memory. */ reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #error "Initrd is broken, please fit it." tmp = (((unsigned long)&_end + PAGE_SIZE-1) & PAGE_MASK) - 8; if (tmp < (unsigned long)&_end) @@ -423,7 +423,7 @@ } #endif /* !CONFIG_DISCONTIGMEM */ -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { for (; start < end; start += PAGE_SIZE) { diff -rNu ../linux-2.4.17/arch/parisc/kernel/setup.c ./arch/parisc/kernel/setup.c --- ../linux-2.4.17/arch/parisc/kernel/setup.c Sun Feb 25 22:20:11 2001 +++ ./arch/parisc/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -456,7 +456,7 @@ printk("PALO command line: '%s'\nPALO initrd %x-%x\n", saved_command_line, arg2, arg3); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (arg2 != 0) /* did palo pass us a ramdisk? */ { initrd_start = (unsigned long)__va(arg2); @@ -533,7 +533,7 @@ (unsigned long)mem_free); free_bootmem(mem_start, mem_free); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER printk("initrd: %08x-%08x\n", (int) initrd_start, (int) initrd_end); if (initrd_end != 0) { diff -rNu ../linux-2.4.17/arch/parisc/mm/init.c ./arch/parisc/mm/init.c --- ../linux-2.4.17/arch/parisc/mm/init.c Mon Dec 18 20:57:41 2000 +++ ./arch/parisc/mm/init.c Sat Dec 29 11:05:14 2001 @@ -437,7 +437,7 @@ free_space_ids++; } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { #if 0 diff -rNu ../linux-2.4.17/arch/ppc/kernel/apus_setup.c ./arch/ppc/kernel/apus_setup.c --- ../linux-2.4.17/arch/ppc/kernel/apus_setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/ppc/kernel/apus_setup.c Sat Dec 29 11:05:14 2001 @@ -1052,7 +1052,7 @@ /* Parse bootinfo. The bootinfo is located right after the kernel bss */ parse_bootinfo((const struct bi_record *)&_end); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* Take care of initrd if we have one. Use data from bootinfo to avoid the need to initialize PPC registers when kernel is booted via a PPC reset. */ @@ -1061,7 +1061,7 @@ initrd_end = (unsigned long) __va(ramdisk.size + ramdisk.addr); } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ ISA_DMA_THRESHOLD = 0x00ffffff; diff -rNu ../linux-2.4.17/arch/ppc/kernel/chrp_setup.c ./arch/ppc/kernel/chrp_setup.c --- ../linux-2.4.17/arch/ppc/kernel/chrp_setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/ppc/kernel/chrp_setup.c Sat Dec 29 11:05:14 2001 @@ -233,7 +233,7 @@ /* init to some ~sane value until calibrate_delay() runs */ loops_per_jiffy = 50000000/HZ; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* this is fine for chrp */ initrd_below_start_ok = 1; @@ -494,14 +494,14 @@ chrp_init(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7) { -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* take care of initrd if we have one */ if ( r6 ) { initrd_start = r6 + KERNELBASE; initrd_end = r6 + r7 + KERNELBASE; } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ ISA_DMA_THRESHOLD = ~0L; DMA_MODE_READ = 0x44; diff -rNu ../linux-2.4.17/arch/ppc/kernel/gemini_setup.c ./arch/ppc/kernel/gemini_setup.c --- ../linux-2.4.17/arch/ppc/kernel/gemini_setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/ppc/kernel/gemini_setup.c Sat Dec 29 11:05:14 2001 @@ -170,7 +170,7 @@ loops_per_jiffy = 50000000/HZ; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* bootable off CDROM */ if (initrd_start) ROOT_DEV = MKDEV(SCSI_CDROM_MAJOR, 0); @@ -541,7 +541,7 @@ DMA_MODE_READ = 0; DMA_MODE_WRITE = 0; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if ( r4 ) { initrd_start = r4 + KERNELBASE; diff -rNu ../linux-2.4.17/arch/ppc/kernel/m8260_setup.c ./arch/ppc/kernel/m8260_setup.c --- ../linux-2.4.17/arch/ppc/kernel/m8260_setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/ppc/kernel/m8260_setup.c Sat Dec 29 11:05:14 2001 @@ -223,14 +223,14 @@ if ( r3 ) memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) ); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* take care of initrd if we have one */ if ( r4 ) { initrd_start = r4 + KERNELBASE; initrd_end = r5 + KERNELBASE; } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ /* take care of cmd line */ if ( r6 ) { diff -rNu ../linux-2.4.17/arch/ppc/kernel/m8xx_setup.c ./arch/ppc/kernel/m8xx_setup.c --- ../linux-2.4.17/arch/ppc/kernel/m8xx_setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/ppc/kernel/m8xx_setup.c Sat Dec 29 11:05:14 2001 @@ -79,7 +79,7 @@ ROOT_DEV = to_kdev_t(0x0301); /* hda1 */ #endif -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #if 0 ROOT_DEV = to_kdev_t(0x0200); /* floppy */ rd_prompt = 1; @@ -356,14 +356,14 @@ m8xx_setup_pci_ptrs(); #endif -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* take care of initrd if we have one */ if ( r4 ) { initrd_start = r4 + KERNELBASE; initrd_end = r5 + KERNELBASE; } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ /* take care of cmd line */ if ( r6 ) { diff -rNu ../linux-2.4.17/arch/ppc/kernel/oak_setup.c ./arch/ppc/kernel/oak_setup.c --- ../linux-2.4.17/arch/ppc/kernel/oak_setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/ppc/kernel/oak_setup.c Sat Dec 29 11:05:14 2001 @@ -86,7 +86,7 @@ memcpy((void *)__res, (void *)(r3 + KERNELBASE), sizeof(bd_t)); } -#if defined(CONFIG_BLK_DEV_INITRD) +#if defined(CONFIG_IRD_LOADER) /* * If the init RAM disk has been configured in, and there's a valid * starting address for it, set it up. @@ -95,7 +95,7 @@ initrd_start = r4 + KERNELBASE; initrd_end = r5 + KERNELBASE; } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ /* Copy the kernel command line arguments to a safe place. */ diff -rNu ../linux-2.4.17/arch/ppc/kernel/pmac_setup.c ./arch/ppc/kernel/pmac_setup.c --- ../linux-2.4.17/arch/ppc/kernel/pmac_setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/ppc/kernel/pmac_setup.c Sat Dec 29 11:05:14 2001 @@ -383,7 +383,7 @@ #ifdef CONFIG_VT kd_mksound = pmac_mksound; #endif -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (initrd_start) ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); else diff -rNu ../linux-2.4.17/arch/ppc/kernel/prep_setup.c ./arch/ppc/kernel/prep_setup.c --- ../linux-2.4.17/arch/ppc/kernel/prep_setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/ppc/kernel/prep_setup.c Sat Dec 29 11:05:14 2001 @@ -266,7 +266,7 @@ case _PREP_Motorola: /* Enable L2. Assume we don't need to flush -- Cort*/ *(unsigned char *)(0x8000081c) |= 3; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (initrd_start) ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); /* /dev/ram */ else @@ -840,13 +840,13 @@ } #endif -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if ( r4 ) { initrd_start = r4 + KERNELBASE; initrd_end = r5 + KERNELBASE; } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ /* Copy cmd_line parameters */ if ( r6 ) diff -rNu ../linux-2.4.17/arch/ppc/kernel/setup.c ./arch/ppc/kernel/setup.c --- ../linux-2.4.17/arch/ppc/kernel/setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/ppc/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -396,7 +396,7 @@ strncpy(cmd_line, (char *) boot_infos + boot_infos->kernelParamsOffset, sizeof(cmd_line)); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (boot_infos->ramDisk) { initrd_start = (unsigned long) boot_infos + boot_infos->ramDisk; @@ -408,7 +408,7 @@ struct device_node *chosen; char *p; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (r3 && r4 && r4 != 0xdeadbeef) { if (r3 < KERNELBASE) @@ -470,12 +470,12 @@ (data[0]+KERNELBASE)); sysmap_size = data[1]; break; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER case BI_INITRD: initrd_start = data[0] + KERNELBASE; initrd_end = data[0] + data[1] + KERNELBASE; break; -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ #ifdef CONFIG_ALL_PPC case BI_MACHTYPE: _machine = data[0]; diff -rNu ../linux-2.4.17/arch/ppc/kernel/walnut_setup.c ./arch/ppc/kernel/walnut_setup.c --- ../linux-2.4.17/arch/ppc/kernel/walnut_setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/ppc/kernel/walnut_setup.c Sat Dec 29 11:05:14 2001 @@ -81,7 +81,7 @@ memcpy((void *)__res, (void *)(r3 + KERNELBASE), sizeof(bd_t)); } -#if defined(CONFIG_BLK_DEV_INITRD) +#if defined(CONFIG_IRD_LOADER) /* * If the init RAM disk has been configured in, and there's a valid * starting address for it, set it up. @@ -90,7 +90,7 @@ initrd_start = r4 + KERNELBASE; initrd_end = r5 + KERNELBASE; } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ /* Copy the kernel command line arguments to a safe place. */ diff -rNu ../linux-2.4.17/arch/ppc/mm/init.c ./arch/ppc/mm/init.c --- ../linux-2.4.17/arch/ppc/mm/init.c Wed Oct 10 23:35:18 2001 +++ ./arch/ppc/mm/init.c Sat Dec 29 11:05:14 2001 @@ -31,7 +31,7 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include /* for initrd_* */ #endif @@ -245,7 +245,7 @@ #undef FREESEC } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10); @@ -465,14 +465,14 @@ totalram_pages += free_all_bootmem(); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* if we are booted from BootX with an initial ramdisk, make sure the ramdisk pages aren't reserved. */ if (initrd_start) { for (addr = initrd_start; addr < initrd_end; addr += PAGE_SIZE) ClearPageReserved(virt_to_page(addr)); } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ #if defined(CONFIG_ALL_PPC) /* mark the RTAS pages as reserved */ @@ -558,13 +558,13 @@ mem_pieces_remove(&phys_avail, kstart, ksize, 0); mem_pieces_remove(&phys_avail, 0, 0x4000, 0); -#if defined(CONFIG_BLK_DEV_INITRD) +#if defined(CONFIG_IRD_LOADER) /* Remove the init RAM disk from the available memory. */ if (initrd_start) { mem_pieces_remove(&phys_avail, __pa(initrd_start), initrd_end - initrd_start, 1); } -#endif /* CONFIG_BLK_DEV_INITRD */ +#endif /* CONFIG_IRD_LOADER */ #ifdef CONFIG_ALL_PPC /* remove the RTAS pages from the available memory */ if (rtas_data) diff -rNu ../linux-2.4.17/arch/s390/kernel/setup.c ./arch/s390/kernel/setup.c --- ../linux-2.4.17/arch/s390/kernel/setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/s390/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -402,7 +402,7 @@ */ reserve_bootmem(start_pfn << PAGE_SHIFT, bootmap_size); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (INITRD_START) { if (INITRD_START + INITRD_SIZE <= memory_end) { reserve_bootmem(INITRD_START, INITRD_SIZE); diff -rNu ../linux-2.4.17/arch/s390/mm/init.c ./arch/s390/mm/init.c --- ../linux-2.4.17/arch/s390/mm/init.c Wed Oct 24 14:02:11 2001 +++ ./arch/s390/mm/init.c Sat Dec 29 11:05:14 2001 @@ -22,7 +22,7 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif #include @@ -218,7 +218,7 @@ (&__init_end - &__init_begin) >> 10); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { if (start < end) diff -rNu ../linux-2.4.17/arch/s390x/kernel/setup.c ./arch/s390x/kernel/setup.c --- ../linux-2.4.17/arch/s390x/kernel/setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/s390x/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -391,7 +391,7 @@ */ reserve_bootmem(start_pfn << PAGE_SHIFT, bootmap_size); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (INITRD_START) { if (INITRD_START + INITRD_SIZE <= memory_end) { reserve_bootmem(INITRD_START, INITRD_SIZE); diff -rNu ../linux-2.4.17/arch/s390x/mm/init.c ./arch/s390x/mm/init.c --- ../linux-2.4.17/arch/s390x/mm/init.c Tue Nov 27 18:28:41 2001 +++ ./arch/s390x/mm/init.c Sat Dec 29 11:05:14 2001 @@ -22,7 +22,7 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif #include @@ -230,7 +230,7 @@ (&__init_end - &__init_begin) >> 10); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { if (start < end) diff -rNu ../linux-2.4.17/arch/sh/kernel/setup.c ./arch/sh/kernel/setup.c --- ../linux-2.4.17/arch/sh/kernel/setup.c Tue Nov 27 18:28:41 2001 +++ ./arch/sh/kernel/setup.c Sat Dec 29 11:05:14 2001 @@ -437,7 +437,7 @@ */ reserve_bootmem_node(NODE_DATA(0), __MEMORY_START, PAGE_SIZE); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (LOADER_TYPE && INITRD_START) { if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { reserve_bootmem_node(NODE_DATA(0), INITRD_START+__MEMORY_START, INITRD_SIZE); diff -rNu ../linux-2.4.17/arch/sh/mm/init.c ./arch/sh/mm/init.c --- ../linux-2.4.17/arch/sh/mm/init.c Wed Oct 24 14:02:11 2001 +++ ./arch/sh/mm/init.c Sat Dec 29 11:05:14 2001 @@ -21,7 +21,7 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif #include @@ -190,7 +190,7 @@ printk ("Freeing unused kernel memory: %dk freed\n", (&__init_end - &__init_begin) >> 10); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { unsigned long p; diff -rNu ../linux-2.4.17/arch/sparc/mm/init.c ./arch/sparc/mm/init.c --- ../linux-2.4.17/arch/sparc/mm/init.c Sat Dec 29 10:48:48 2001 +++ ./arch/sparc/mm/init.c Sat Dec 29 11:05:14 2001 @@ -19,7 +19,7 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #include #endif #include @@ -214,7 +214,7 @@ printk(KERN_NOTICE "%ldMB HIGHMEM available.\n", calc_highpages()); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* Now have to check initial ramdisk, so that bootmap does not overwrite it */ if (sparc_ramdisk_image) { if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE) @@ -274,7 +274,7 @@ size); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (initrd_start) { size = initrd_end - initrd_start; #ifdef DEBUG_BOOTMEM @@ -489,7 +489,7 @@ printk ("Freeing unused kernel memory: %dk freed\n", (&__init_end - &__init_begin) >> 10); } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { if (start < end) diff -rNu ../linux-2.4.17/arch/sparc64/mm/init.c ./arch/sparc64/mm/init.c --- ../linux-2.4.17/arch/sparc64/mm/init.c Sat Dec 29 10:48:48 2001 +++ ./arch/sparc64/mm/init.c Sat Dec 29 11:06:30 2001 @@ -1220,7 +1220,7 @@ end_pfn = end_of_phys_memory >> PAGE_SHIFT; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER /* Now have to check initial ramdisk, so that bootmap does not overwrite it */ if (sparc_ramdisk_image) { if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE) @@ -1250,7 +1250,7 @@ free_bootmem(sp_banks[i].base_addr, sp_banks[i].num_bytes); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (initrd_start) { size = initrd_end - initrd_start; @@ -1301,7 +1301,7 @@ real_end = (unsigned long)&_end; if ((real_end > ((unsigned long)KERNBASE + 0x400000))) bigkernel = 1; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (sparc_ramdisk_image) real_end = (PAGE_ALIGN(real_end) + PAGE_ALIGN(sparc_ramdisk_size)); #endif @@ -1675,7 +1675,7 @@ } } -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER void free_initrd_mem(unsigned long start, unsigned long end) { if (start < end) diff -rNu ../linux-2.4.17/drivers/block/Config.in ./drivers/block/Config.in --- ../linux-2.4.17/drivers/block/Config.in Wed Oct 10 18:15:31 2001 +++ ./drivers/block/Config.in Sat Dec 29 11:05:14 2001 @@ -44,6 +44,13 @@ if [ "$CONFIG_BLK_DEV_RAM" = "y" -o "$CONFIG_BLK_DEV_RAM" = "m" ]; then int ' Default RAM disk size' CONFIG_BLK_DEV_RAM_SIZE 4096 fi +if [ "$CONFIG_BLK_DEV_RAM" = "y" ]; then + define_bool CONFIG_RD_LOADER y + define_bool CONFIG_CRD_LOADER y +fi dep_bool ' Initial RAM disk (initrd) support' CONFIG_BLK_DEV_INITRD $CONFIG_BLK_DEV_RAM +if [ "$CONFIG_BLK_DEV_INITRD" = "y"]; then + define_bool CONFIG_IRD_LOADER y +fi endmenu diff -rNu ../linux-2.4.17/drivers/block/Makefile ./drivers/block/Makefile --- ../linux-2.4.17/drivers/block/Makefile Wed Oct 10 18:15:31 2001 +++ ./drivers/block/Makefile Sat Dec 29 11:05:14 2001 @@ -23,6 +23,10 @@ obj-$(CONFIG_ATARI_SLM) += acsi_slm.o obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o obj-$(CONFIG_BLK_DEV_RAM) += rd.o +obj-$(CONFIG_RD_LOADER) += rdload.o +obj-$(CONFIG_CRD_LOADER) += crdload.o +obj-$(CONFIG_IRD_LOADER) += irdload.o +obj-$(CONFIG_TMPFS_INITTAR) += tar.o obj-$(CONFIG_BLK_DEV_LOOP) += loop.o obj-$(CONFIG_BLK_DEV_PS2) += ps2esdi.o obj-$(CONFIG_BLK_DEV_XD) += xd.o diff -rNu ../linux-2.4.17/drivers/block/crdload.c ./drivers/block/crdload.c --- ../linux-2.4.17/drivers/block/crdload.c Thu Jan 1 01:00:00 1970 +++ ./drivers/block/crdload.c Sat Dec 29 11:05:14 2001 @@ -0,0 +1,161 @@ +/* + * crdload.c - Load a compressed ramdisk, initrd or inittar. + * + * (C) Chad Page, Theodore Ts'o, et. al, 1995. + * + * Splitup into rd.c, rdload.c, crdload.c and irdload.c for support + * of tmpfs+inittar, Matthias Kilian , inspired by + * David L. Parseley , 10/28/2001 + */ + +#include +#include +#include +#include +#include +#include + +/* + * gzip declarations + */ + +#define OF(args) args + +#ifndef memzero +#define memzero(s, n) memset ((s), 0, (n)) +#endif + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + +#define INBUFSIZ 4096 +#define WSIZE 0x8000 /* window size--must be a power of two, and */ + /* at least 32K for zip's deflate method */ + +static uch *inbuf; +static uch *window; + +static unsigned insize; /* valid bytes in inbuf */ +static unsigned inptr; /* index of next byte to be processed in inbuf */ +static unsigned outcnt; /* bytes in output buffer */ +static int exit_code; +static long bytes_out; +static struct file *crd_infp, *crd_outfp; + +#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) + +/* Diagnostic functions (stubbed out) */ +#define Assert(cond,msg) +#define Trace(x) +#define Tracev(x) +#define Tracevv(x) +#define Tracec(c,x) +#define Tracecv(c,x) + +#define STATIC static + +static int fill_inbuf(void); +static void flush_window(void); +static void *malloc(int size); +static void free(void *where); +static void error(char *m); +static void gzip_mark(void **); +static void gzip_release(void **); + +#include "../../lib/inflate.c" + +static void __init *malloc(int size) +{ + return kmalloc(size, GFP_KERNEL); +} + +static void __init free(void *where) +{ + kfree(where); +} + +static void __init gzip_mark(void **ptr) +{ +} + +static void __init gzip_release(void **ptr) +{ +} + + +/* =========================================================================== + * Fill the input buffer. This is called only when the buffer is empty + * and at least one byte is really needed. + */ +static int __init fill_inbuf(void) +{ + if (exit_code) return -1; + + insize = crd_infp->f_op->read(crd_infp, inbuf, INBUFSIZ, + &crd_infp->f_pos); + if (insize == 0) return -1; + + inptr = 1; + + return inbuf[0]; +} + +/* =========================================================================== + * Write the output window window[0..outcnt-1] and update crc and bytes_out. + * (Used for the decompressed data only.) + */ +static void __init flush_window(void) +{ + ulg c = crc; /* temporary variable */ + unsigned n; + uch *in, ch; + + crd_outfp->f_op->write(crd_outfp, window, outcnt, &crd_outfp->f_pos); + in = window; + for (n = 0; n < outcnt; n++) { + ch = *in++; + c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); + } + crc = c; + bytes_out += (ulg)outcnt; + outcnt = 0; +} + +static void __init error(char *x) +{ + printk(KERN_ERR "%s", x); + exit_code = 1; +} + +int __init +crd_load(struct file * fp, struct file *outfp) +{ + int result; + + insize = 0; /* valid bytes in inbuf */ + inptr = 0; /* index of next byte to be processed in inbuf */ + outcnt = 0; /* bytes in output buffer */ + exit_code = 0; + bytes_out = 0; + crc = (ulg)0xffffffffL; /* shift register contents */ + + crd_infp = fp; + crd_outfp = outfp; + inbuf = kmalloc(INBUFSIZ, GFP_KERNEL); + if (inbuf == 0) { + printk(KERN_ERR "RAMDISK: Couldn't allocate gzip buffer\n"); + return -1; + } + window = kmalloc(WSIZE, GFP_KERNEL); + if (window == 0) { + printk(KERN_ERR "RAMDISK: Couldn't allocate gzip window\n"); + kfree(inbuf); + return -1; + } + makecrc(); + result = gunzip(); + kfree(inbuf); + kfree(window); + return result; +} diff -rNu ../linux-2.4.17/drivers/block/irdload.c ./drivers/block/irdload.c --- ../linux-2.4.17/drivers/block/irdload.c Thu Jan 1 01:00:00 1970 +++ ./drivers/block/irdload.c Sat Dec 29 11:05:14 2001 @@ -0,0 +1,270 @@ +/* + * irdload.c - Load an initrd or inittar. + * + * (C) Chad Page, Theodore Ts'o, et. al, 1995. + * + * Added support for tar.gz -> tmpfs initrd loading. + * David L. Parsley + * based on work by Dave Cinege + * + * Splitup into rd.c, rdload.c, crdload.c and irdload.c for support + * of tmpfs+inittar, Matthias Kilian , inspired by + * David L. Parseley , 10/28/2001 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + + +int mount_initrd = 1; /* zero if initrd/inittar should not be mounted */ + +unsigned long initrd_start, initrd_end; +int initrd_below_start_ok; +int initrd_users = 0; + + +static int __init no_initrd(char *str) +{ + mount_initrd = 0; + return 1; +} + +__setup("noinitrd", no_initrd); + + +#if !defined(CONFIG_BLK_DEV_INITRD) && defined(CONFIG_TMPFS_INITTAR) +static int use_inittar = 1; +#else +static int use_inittar = 0; +#endif + +#ifdef CONFIG_TMPFS_INITTAR +static char tmpfs_options[64]; /* options passed to tmpfs */ + +char* __init get_tmpfs_inittar_options(void) +{ + return tmpfs_options; +} + +static int __init inittar_options(char *str) +{ + char *options; + tmpfs_options[0] = 0; + options = strchr(str, ','); + if (options++ != NULL){ + strncpy(tmpfs_options,options,63); + tmpfs_options[63] = 0; + options--; + *options = 0; + } + use_inittar = simple_strtol(str,NULL,0); + return 1; +} + +__setup("inittar=", inittar_options); +#endif + + +static ssize_t __init initrd_read(struct file *file, char *buf, + size_t count, loff_t *ppos) +{ + int left; + + left = initrd_end - initrd_start - *ppos; + if (count > left) count = left; + if (count == 0) return 0; + copy_to_user(buf, (char *)initrd_start + *ppos, count); + *ppos += count; + return count; +} + + +static int __init initrd_release(struct inode *inode,struct file *file) +{ + extern void free_initrd_mem(unsigned long, unsigned long); + + lock_kernel(); + if (!--initrd_users) { + free_initrd_mem(initrd_start, initrd_end); + initrd_start = 0; + } + unlock_kernel(); + if(inode) { + blkdev_put(inode->i_bdev, BDEV_FILE); + } + return 0; +} + + +struct file_operations initrd_fops = { + read: initrd_read, + release: initrd_release, +}; + +#ifdef CONFIG_TMPFS_INITTAR +extern struct file_operations tar_fops; + +/* + * Check what type of image we have. Return 0 for a compressed image, 1 for a + * tar file and -1 for everything else. + */ +static int __init identify_inittar_image(struct file *fp) +{ + const int size = 512; + unsigned char *buf; + int result; + + if(!(buf = kmalloc(size, GFP_KERNEL))) { + return -1; + } + + /* + * Read block 0 to test for gzipped kernel + */ + if (fp->f_op->llseek) { + fp->f_op->llseek(fp, 0, 0); + } + fp->f_pos = 0; + fp->f_op->read(fp, buf, size, &fp->f_pos); + + if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) { + /* If it matches the gzip magic numbers, return -1 */ + printk(KERN_NOTICE "INITTAR: Compressed image found\n"); + result = 0; + } else if (!strncmp(buf + 257, "ustar", 5)) { + /* Tar files have 'ustar' at 257 */ + printk(KERN_NOTICE "INITTAR: Tar image found\n"); + result = 1; + } else { + printk(KERN_NOTICE "INITTAR: No valid image found\n"); + result = -1; + } + + if (fp->f_op->llseek) { + fp->f_op->llseek(fp, 0, 0); + } + + fp->f_pos = 0; + + kfree(buf); + + return result; +} + + +extern int __init crd_load(struct file * fp, struct file *outfp); +extern int __init mount_tmpfs_root(void); +extern void __init rd_load_initrd(void); + + +/* + * Mount a root tmpfs and then load and propagate the (optionally compressed) + * inittar onto it. Return 0 on success, -1 on failure. + */ +static int __init inittar_load(void) +{ + struct file in, out; + void *buf; + ssize_t count; + mm_segment_t fs; + int result; + + /* Try to mount tmpfs */ + if(mount_tmpfs_root()) { + return -1; + } + + /* Setup file descriptors for reading the image and for writing + * to the tar extractor. Note the neither of this two files make + * any use of inode. + */ + memset(&in, 0, sizeof(in)); + in.f_mode = 1; /* read only */ + in.f_op = &initrd_fops; + + memset(&out, 0, sizeof(out)); + out.f_mode = 3; /* read/write */ + out.f_op = &tar_fops; + + /* Note: This is only used to make initrd_release() + * work. initrd_users is only used by the nomal initrd, not by + * inittar. + */ + initrd_users++; + + fs = get_fs(); + set_fs(KERNEL_DS); + + switch(identify_inittar_image(&in)) { + case 0: /* compressed */ + result = crd_load(&in, &out); + break; + case 1: /* tar file */ + /* Simply read blocks from the image and pass them to the untar + * code + */ + result = 0; + if(!(buf = kmalloc(BLOCK_SIZE, GFP_KERNEL))) { + printk(KERN_ERR "INITTAR: could not allocate buffer\n"); + result = -1; + } + while((count = in.f_op->read(&in, buf, BLOCK_SIZE, &in.f_pos)) > 0) { + out.f_op->write(&out, buf, count, &out.f_pos); + } + kfree(buf); + break; + default: /* unknown */ + result = -1; + break; + } + + in.f_op->release(NULL, &in); + out.f_op->release(NULL, &out); + + set_fs(fs); + + return result; +} +#endif + + +/* + * Load the initrd/inittar, located at initrd_start up to initrd_end. + * + * Depending on the configured Features resp. the selected + * boot type (initrd or inittar), either the conventional initrd loader or the + * new tar loader will be called. The latter will also mount a tmpfs as root. + * + * Return code is 0 for successfull inittar load, -1 for failed inittar load, + * 1 for conventional initrd load (successful or not). + */ +int __init initrd_load(void) +{ +#ifdef CONFIG_TMPFS_INITTAR + if(use_inittar) { + return inittar_load(); + } +#endif + +#ifdef CONFIG_BLK_DEV_INITRD + rd_load_initrd(); +#endif + + return 1; +} diff -rNu ../linux-2.4.17/drivers/block/rd.c ./drivers/block/rd.c --- ../linux-2.4.17/drivers/block/rd.c Sat Dec 29 10:48:49 2001 +++ ./drivers/block/rd.c Sat Dec 29 11:05:14 2001 @@ -40,13 +40,14 @@ * * Make block size and block size shift for RAM disks a global macro * and set blk_size for -ENOSPC, Werner Fink , Apr '99 + * + * Splitup into rd.c, rdload.c, crdload.c and irdload.c for support + * of tmpfs+inittar, Matthias Kilian , inspired by + * David L. Parseley , 10/28/2001 */ #include #include -#include -#include -#include #include #include #include @@ -79,23 +80,11 @@ /* The RAM disk size is now a parameter */ #define NUM_RAMDISKS 16 /* This cannot be overridden (yet) */ -#ifndef MODULE -/* We don't have to load RAM disks or gunzip them in a module. */ -#define RD_LOADER -#define BUILD_CRAMDISK - -void rd_load(void); -static int crd_load(struct file *fp, struct file *outfp); - -#ifdef CONFIG_BLK_DEV_INITRD -static int initrd_users; -#endif -#endif /* Various static variables go here. Most are used only in the RAM disk code. */ -static unsigned long rd_length[NUM_RAMDISKS]; /* Size of RAM disks in bytes */ +unsigned long rd_length[NUM_RAMDISKS]; /* Size of RAM disks in bytes */ static int rd_hardsec[NUM_RAMDISKS]; /* Size of real blocks in bytes */ static int rd_blocksizes[NUM_RAMDISKS]; /* Size of 1024 byte blocks :) */ static int rd_kbsize[NUM_RAMDISKS]; /* Size in blocks of 1024 bytes */ @@ -124,41 +113,11 @@ #ifndef MODULE -int rd_doload; /* 1 = load RAM disk, 0 = don't load */ -int rd_prompt = 1; /* 1 = prompt for RAM disk, 0 = don't prompt */ -int rd_image_start; /* starting block # of image */ #ifdef CONFIG_BLK_DEV_INITRD -unsigned long initrd_start, initrd_end; -int mount_initrd = 1; /* zero if initrd should not be mounted */ -int initrd_below_start_ok; - -static int __init no_initrd(char *str) -{ - mount_initrd = 0; - return 1; -} - -__setup("noinitrd", no_initrd); - +extern unsigned long initrd_start, initrd_end; +extern int initrd_below_start_ok; #endif -static int __init ramdisk_start_setup(char *str) -{ - rd_image_start = simple_strtol(str,NULL,0); - return 1; -} - -static int __init load_ramdisk(char *str) -{ - rd_doload = simple_strtol(str,NULL,0) & 3; - return 1; -} - -static int __init prompt_ramdisk(char *str) -{ - rd_prompt = simple_strtol(str,NULL,0) & 1; - return 1; -} static int __init ramdisk_size(char *str) { @@ -177,9 +136,6 @@ return 1; } -__setup("ramdisk_start=", ramdisk_start_setup); -__setup("load_ramdisk=", load_ramdisk); -__setup("prompt_ramdisk=", prompt_ramdisk); __setup("ramdisk=", ramdisk_size); __setup("ramdisk_size=", ramdisk_size2); __setup("ramdisk_blocksize=", ramdisk_blocksize); @@ -388,50 +344,14 @@ } -#ifdef CONFIG_BLK_DEV_INITRD - -static ssize_t initrd_read(struct file *file, char *buf, - size_t count, loff_t *ppos) -{ - int left; - - left = initrd_end - initrd_start - *ppos; - if (count > left) count = left; - if (count == 0) return 0; - copy_to_user(buf, (char *)initrd_start + *ppos, count); - *ppos += count; - return count; -} - - -static int initrd_release(struct inode *inode,struct file *file) -{ - extern void free_initrd_mem(unsigned long, unsigned long); - - lock_kernel(); - if (!--initrd_users) { - free_initrd_mem(initrd_start, initrd_end); - initrd_start = 0; - } - unlock_kernel(); - blkdev_put(inode->i_bdev, BDEV_FILE); - return 0; -} - - -static struct file_operations initrd_fops = { - read: initrd_read, - release: initrd_release, -}; - -#endif - - static int rd_open(struct inode * inode, struct file * filp) { int unit = DEVICE_NR(inode->i_rdev); #ifdef CONFIG_BLK_DEV_INITRD + extern struct file_operations initrd_fops; + extern int initrd_users; + if (unit == INITRD_MINOR) { if (!initrd_start) return -ENODEV; initrd_users++; @@ -548,462 +468,3 @@ MODULE_PARM_DESC(rd_blocksize, "Blocksize of each RAM disk in bytes."); MODULE_LICENSE("GPL"); - -/* End of non-loading portions of the RAM disk driver */ - -#ifdef RD_LOADER -/* - * 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 - * is a compressed image, and -1 if an image with the right magic - * numbers could not be found. - * - * We currently check for the following magic numbers: - * minix - * ext2 - * romfs - * gzip - */ -static int __init -identify_ramdisk_image(kdev_t device, struct file *fp, int start_block) -{ - const int size = 512; - struct minix_super_block *minixsb; - struct ext2_super_block *ext2sb; - struct romfs_super_block *romfsb; - int nblocks = -1; - unsigned char *buf; - - buf = kmalloc(size, GFP_KERNEL); - if (buf == 0) - return -1; - - minixsb = (struct minix_super_block *) buf; - ext2sb = (struct ext2_super_block *) buf; - romfsb = (struct romfs_super_block *) buf; - memset(buf, 0xe5, size); - - /* - * Read block 0 to test for gzipped kernel - */ - if (fp->f_op->llseek) - fp->f_op->llseek(fp, start_block * BLOCK_SIZE, 0); - fp->f_pos = start_block * BLOCK_SIZE; - - fp->f_op->read(fp, buf, size, &fp->f_pos); - - /* - * If it matches the gzip magic numbers, return -1 - */ - if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) { - printk(KERN_NOTICE - "RAMDISK: Compressed image found at block %d\n", - start_block); - nblocks = 0; - goto done; - } - - /* romfs is at block zero too */ - if (romfsb->word0 == ROMSB_WORD0 && - romfsb->word1 == ROMSB_WORD1) { - printk(KERN_NOTICE - "RAMDISK: romfs filesystem found at block %d\n", - start_block); - nblocks = (ntohl(romfsb->size)+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS; - goto done; - } - - /* - * Read block 1 to test for minix and ext2 superblock - */ - if (fp->f_op->llseek) - fp->f_op->llseek(fp, (start_block+1) * BLOCK_SIZE, 0); - fp->f_pos = (start_block+1) * BLOCK_SIZE; - - fp->f_op->read(fp, buf, size, &fp->f_pos); - - /* Try minix */ - if (minixsb->s_magic == MINIX_SUPER_MAGIC || - minixsb->s_magic == MINIX_SUPER_MAGIC2) { - printk(KERN_NOTICE - "RAMDISK: Minix filesystem found at block %d\n", - start_block); - nblocks = minixsb->s_nzones << minixsb->s_log_zone_size; - goto done; - } - - /* Try ext2 */ - if (ext2sb->s_magic == cpu_to_le16(EXT2_SUPER_MAGIC)) { - printk(KERN_NOTICE - "RAMDISK: ext2 filesystem found at block %d\n", - start_block); - nblocks = le32_to_cpu(ext2sb->s_blocks_count); - goto done; - } - - printk(KERN_NOTICE - "RAMDISK: Couldn't find valid RAM disk image starting at %d.\n", - start_block); - -done: - if (fp->f_op->llseek) - fp->f_op->llseek(fp, start_block * BLOCK_SIZE, 0); - fp->f_pos = start_block * BLOCK_SIZE; - - kfree(buf); - return nblocks; -} - -/* - * This routine loads in the RAM disk image. - */ -static void __init rd_load_image(kdev_t device, int offset, int unit) -{ - struct inode *inode, *out_inode; - struct file infile, outfile; - struct dentry in_dentry, out_dentry; - mm_segment_t fs; - kdev_t ram_device; - int nblocks, i; - char *buf; - unsigned short rotate = 0; - unsigned short devblocks = 0; -#if !defined(CONFIG_ARCH_S390) && !defined(CONFIG_PPC_ISERIES) - char rotator[4] = { '|' , '/' , '-' , '\\' }; -#endif - ram_device = MKDEV(MAJOR_NR, unit); - - if ((inode = get_empty_inode()) == NULL) - return; - memset(&infile, 0, sizeof(infile)); - memset(&in_dentry, 0, sizeof(in_dentry)); - infile.f_mode = 1; /* read only */ - infile.f_dentry = &in_dentry; - in_dentry.d_inode = inode; - infile.f_op = &def_blk_fops; - init_special_inode(inode, S_IFBLK | S_IRUSR, kdev_t_to_nr(device)); - - if ((out_inode = get_empty_inode()) == NULL) - goto free_inode; - memset(&outfile, 0, sizeof(outfile)); - memset(&out_dentry, 0, sizeof(out_dentry)); - outfile.f_mode = 3; /* read/write */ - outfile.f_dentry = &out_dentry; - out_dentry.d_inode = out_inode; - outfile.f_op = &def_blk_fops; - init_special_inode(out_inode, S_IFBLK | S_IRUSR | S_IWUSR, kdev_t_to_nr(ram_device)); - - if (blkdev_open(inode, &infile) != 0) { - iput(out_inode); - goto free_inode; - } - if (blkdev_open(out_inode, &outfile) != 0) - goto free_inodes; - - fs = get_fs(); - set_fs(KERNEL_DS); - - nblocks = identify_ramdisk_image(device, &infile, offset); - if (nblocks < 0) - goto done; - - if (nblocks == 0) { -#ifdef BUILD_CRAMDISK - if (crd_load(&infile, &outfile) == 0) - goto successful_load; -#else - printk(KERN_NOTICE - "RAMDISK: Kernel does not support compressed " - "RAM disk images\n"); -#endif - goto done; - } - - /* - * NOTE NOTE: nblocks suppose that the blocksize is BLOCK_SIZE, so - * rd_load_image will work only with filesystem BLOCK_SIZE wide! - * So make sure to use 1k blocksize while generating ext2fs - * ramdisk-images. - */ - if (nblocks > (rd_length[unit] >> BLOCK_SIZE_BITS)) { - printk("RAMDISK: image too big! (%d/%ld blocks)\n", - nblocks, rd_length[unit] >> BLOCK_SIZE_BITS); - goto done; - } - - /* - * OK, time to copy in the data - */ - buf = kmalloc(BLOCK_SIZE, GFP_KERNEL); - if (buf == 0) { - printk(KERN_ERR "RAMDISK: could not allocate buffer\n"); - goto done; - } - - if (blk_size[MAJOR(device)]) - devblocks = blk_size[MAJOR(device)][MINOR(device)]; - -#ifdef CONFIG_BLK_DEV_INITRD - if (MAJOR(device) == MAJOR_NR && MINOR(device) == INITRD_MINOR) - devblocks = nblocks; -#endif - - if (devblocks == 0) { - printk(KERN_ERR "RAMDISK: could not determine device size\n"); - goto done; - } - - printk(KERN_NOTICE "RAMDISK: Loading %d blocks [%d disk%s] into ram disk... ", - nblocks, ((nblocks-1)/devblocks)+1, nblocks>devblocks ? "s" : ""); - for (i=0; i < nblocks; i++) { - if (i && (i % devblocks == 0)) { - printk("done disk #%d.\n", i/devblocks); - rotate = 0; - if (infile.f_op->release(inode, &infile) != 0) { - printk("Error closing the disk.\n"); - goto noclose_input; - } - printk("Please insert disk #%d and press ENTER\n", i/devblocks+1); - wait_for_keypress(); - if (blkdev_open(inode, &infile) != 0) { - printk("Error opening disk.\n"); - goto noclose_input; - } - infile.f_pos = 0; - printk("Loading disk #%d... ", i/devblocks+1); - } - infile.f_op->read(&infile, buf, BLOCK_SIZE, &infile.f_pos); - outfile.f_op->write(&outfile, buf, BLOCK_SIZE, &outfile.f_pos); -#if !defined(CONFIG_ARCH_S390) && !defined(CONFIG_PPC_ISERIES) - if (!(i % 16)) { - printk("%c\b", rotator[rotate & 0x3]); - rotate++; - } -#endif - } - printk("done.\n"); - kfree(buf); - -successful_load: - ROOT_DEV = MKDEV(MAJOR_NR, unit); - if (ROOT_DEVICE_NAME != NULL) strcpy (ROOT_DEVICE_NAME, "rd/0"); - -done: - infile.f_op->release(inode, &infile); -noclose_input: - blkdev_close(out_inode, &outfile); - iput(inode); - iput(out_inode); - set_fs(fs); - return; -free_inodes: /* free inodes on error */ - iput(out_inode); - infile.f_op->release(inode, &infile); -free_inode: - iput(inode); -} - -#ifdef CONFIG_MAC_FLOPPY -int swim3_fd_eject(int devnum); -#endif - -static void __init rd_load_disk(int n) -{ - - if (rd_doload == 0) - return; - - if (MAJOR(ROOT_DEV) != FLOPPY_MAJOR -#ifdef CONFIG_BLK_DEV_INITRD - && MAJOR(real_root_dev) != FLOPPY_MAJOR -#endif - ) - return; - - if (rd_prompt) { -#ifdef CONFIG_BLK_DEV_FD - floppy_eject(); -#endif -#ifdef CONFIG_MAC_FLOPPY - if(MAJOR(ROOT_DEV) == FLOPPY_MAJOR) - swim3_fd_eject(MINOR(ROOT_DEV)); - else if(MAJOR(real_root_dev) == FLOPPY_MAJOR) - swim3_fd_eject(MINOR(real_root_dev)); -#endif - printk(KERN_NOTICE - "VFS: Insert root floppy disk to be loaded into RAM disk and press ENTER\n"); - wait_for_keypress(); - } - - rd_load_image(ROOT_DEV,rd_image_start, n); - -} - -void __init rd_load(void) -{ - rd_load_disk(0); -} - -void __init rd_load_secondary(void) -{ - rd_load_disk(1); -} - -#ifdef CONFIG_BLK_DEV_INITRD -void __init initrd_load(void) -{ - rd_load_image(MKDEV(MAJOR_NR, INITRD_MINOR),rd_image_start,0); -} -#endif - -#endif /* RD_LOADER */ - -#ifdef BUILD_CRAMDISK - -/* - * gzip declarations - */ - -#define OF(args) args - -#ifndef memzero -#define memzero(s, n) memset ((s), 0, (n)) -#endif - -typedef unsigned char uch; -typedef unsigned short ush; -typedef unsigned long ulg; - -#define INBUFSIZ 4096 -#define WSIZE 0x8000 /* window size--must be a power of two, and */ - /* at least 32K for zip's deflate method */ - -static uch *inbuf; -static uch *window; - -static unsigned insize; /* valid bytes in inbuf */ -static unsigned inptr; /* index of next byte to be processed in inbuf */ -static unsigned outcnt; /* bytes in output buffer */ -static int exit_code; -static long bytes_out; -static struct file *crd_infp, *crd_outfp; - -#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) - -/* Diagnostic functions (stubbed out) */ -#define Assert(cond,msg) -#define Trace(x) -#define Tracev(x) -#define Tracevv(x) -#define Tracec(c,x) -#define Tracecv(c,x) - -#define STATIC static - -static int fill_inbuf(void); -static void flush_window(void); -static void *malloc(int size); -static void free(void *where); -static void error(char *m); -static void gzip_mark(void **); -static void gzip_release(void **); - -#include "../../lib/inflate.c" - -static void __init *malloc(int size) -{ - return kmalloc(size, GFP_KERNEL); -} - -static void __init free(void *where) -{ - kfree(where); -} - -static void __init gzip_mark(void **ptr) -{ -} - -static void __init gzip_release(void **ptr) -{ -} - - -/* =========================================================================== - * Fill the input buffer. This is called only when the buffer is empty - * and at least one byte is really needed. - */ -static int __init fill_inbuf(void) -{ - if (exit_code) return -1; - - insize = crd_infp->f_op->read(crd_infp, inbuf, INBUFSIZ, - &crd_infp->f_pos); - if (insize == 0) return -1; - - inptr = 1; - - return inbuf[0]; -} - -/* =========================================================================== - * Write the output window window[0..outcnt-1] and update crc and bytes_out. - * (Used for the decompressed data only.) - */ -static void __init flush_window(void) -{ - ulg c = crc; /* temporary variable */ - unsigned n; - uch *in, ch; - - crd_outfp->f_op->write(crd_outfp, window, outcnt, &crd_outfp->f_pos); - in = window; - for (n = 0; n < outcnt; n++) { - ch = *in++; - c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); - } - crc = c; - bytes_out += (ulg)outcnt; - outcnt = 0; -} - -static void __init error(char *x) -{ - printk(KERN_ERR "%s", x); - exit_code = 1; -} - -static int __init -crd_load(struct file * fp, struct file *outfp) -{ - int result; - - insize = 0; /* valid bytes in inbuf */ - inptr = 0; /* index of next byte to be processed in inbuf */ - outcnt = 0; /* bytes in output buffer */ - exit_code = 0; - bytes_out = 0; - crc = (ulg)0xffffffffL; /* shift register contents */ - - crd_infp = fp; - crd_outfp = outfp; - inbuf = kmalloc(INBUFSIZ, GFP_KERNEL); - if (inbuf == 0) { - printk(KERN_ERR "RAMDISK: Couldn't allocate gzip buffer\n"); - return -1; - } - window = kmalloc(WSIZE, GFP_KERNEL); - if (window == 0) { - printk(KERN_ERR "RAMDISK: Couldn't allocate gzip window\n"); - kfree(inbuf); - return -1; - } - makecrc(); - result = gunzip(); - kfree(inbuf); - kfree(window); - return result; -} - -#endif /* BUILD_CRAMDISK */ - diff -rNu ../linux-2.4.17/drivers/block/rdload.c ./drivers/block/rdload.c --- ../linux-2.4.17/drivers/block/rdload.c Thu Jan 1 01:00:00 1970 +++ ./drivers/block/rdload.c Sat Dec 29 11:05:14 2001 @@ -0,0 +1,353 @@ +/* + * rdload.c - Load a ramdisk. + * + * (C) Chad Page, Theodore Ts'o, et. al, 1995. + * + * Splitup into rd.c, rdload.c, crdload.c and irdload.c for support + * of tmpfs+inittar, Matthias Kilian , inspired by + * David L. Parseley , 10/28/2001 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +extern void wait_for_keypress(void); + +/* + * 35 has been officially registered as the RAMDISK major number, but + * so is the original MAJOR number of 1. We're using 1 in + * include/linux/major.h for now + */ +#define MAJOR_NR RAMDISK_MAJOR +#include +#include + + +extern unsigned long rd_length[]; /* Size of RAM disks in bytes */ + + +int rd_doload; /* 1 = load RAM disk, 0 = don't load */ +int rd_prompt = 1; /* 1 = prompt for RAM disk, 0 = don't prompt */ +int rd_image_start; /* starting block # of image */ + + +/* + * 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 + * is a compressed image, and -1 if an image with the right magic + * numbers could not be found. + * + * We currently check for the following magic numbers: + * minix + * ext2 + * romfs + * gzip + */ +static int __init +identify_ramdisk_image(kdev_t device, struct file *fp, int start_block) +{ + const int size = 512; + struct minix_super_block *minixsb; + struct ext2_super_block *ext2sb; + struct romfs_super_block *romfsb; + int nblocks = -1; + unsigned char *buf; + + buf = kmalloc(size, GFP_KERNEL); + if (buf == 0) + return -1; + + minixsb = (struct minix_super_block *) buf; + ext2sb = (struct ext2_super_block *) buf; + romfsb = (struct romfs_super_block *) buf; + memset(buf, 0xe5, size); + + /* + * Read block 0 to test for gzipped kernel + */ + if (fp->f_op->llseek) + fp->f_op->llseek(fp, start_block * BLOCK_SIZE, 0); + fp->f_pos = start_block * BLOCK_SIZE; + + fp->f_op->read(fp, buf, size, &fp->f_pos); + + /* + * If it matches the gzip magic numbers, return -1 + */ + if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) { + printk(KERN_NOTICE + "RAMDISK: Compressed image found at block %d\n", + start_block); + nblocks = 0; + goto done; + } + + /* romfs is at block zero too */ + if (romfsb->word0 == ROMSB_WORD0 && + romfsb->word1 == ROMSB_WORD1) { + printk(KERN_NOTICE + "RAMDISK: romfs filesystem found at block %d\n", + start_block); + nblocks = (ntohl(romfsb->size)+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS; + goto done; + } + + /* + * Read block 1 to test for minix and ext2 superblock + */ + if (fp->f_op->llseek) + fp->f_op->llseek(fp, (start_block+1) * BLOCK_SIZE, 0); + fp->f_pos = (start_block+1) * BLOCK_SIZE; + + fp->f_op->read(fp, buf, size, &fp->f_pos); + + /* Try minix */ + if (minixsb->s_magic == MINIX_SUPER_MAGIC || + minixsb->s_magic == MINIX_SUPER_MAGIC2) { + printk(KERN_NOTICE + "RAMDISK: Minix filesystem found at block %d\n", + start_block); + nblocks = minixsb->s_nzones << minixsb->s_log_zone_size; + goto done; + } + + /* Try ext2 */ + if (ext2sb->s_magic == cpu_to_le16(EXT2_SUPER_MAGIC)) { + printk(KERN_NOTICE + "RAMDISK: ext2 filesystem found at block %d\n", + start_block); + nblocks = le32_to_cpu(ext2sb->s_blocks_count); + goto done; + } + + printk(KERN_NOTICE + "RAMDISK: Couldn't find valid RAM disk image starting at %d.\n", + start_block); + +done: + if (fp->f_op->llseek) + fp->f_op->llseek(fp, start_block * BLOCK_SIZE, 0); + fp->f_pos = start_block * BLOCK_SIZE; + + kfree(buf); + return nblocks; +} + +extern int __init crd_load(struct file * fp, struct file *outfp); + +/* + * This routine loads in the RAM disk image. 'device' is where to load from + * (usually a floppy). + * 'unit' is the ramdisk (/dev/ramX, where X=unit) to store it in. + */ +static void __init rd_load_image(kdev_t device, int offset, int unit) +{ + struct inode *inode, *out_inode; + struct file infile, outfile; + struct dentry in_dentry, out_dentry; + mm_segment_t fs; + kdev_t ram_device; + int nblocks, i; + char *buf; + unsigned short rotate = 0; + unsigned short devblocks = 0; +#if !defined(CONFIG_ARCH_S390) && !defined(CONFIG_PPC_ISERIES) + char rotator[4] = { '|' , '/' , '-' , '\\' }; +#endif + ram_device = MKDEV(MAJOR_NR, unit); + + if ((inode = get_empty_inode()) == NULL) + return; + memset(&infile, 0, sizeof(infile)); + memset(&in_dentry, 0, sizeof(in_dentry)); + infile.f_mode = 1; /* read only */ + infile.f_dentry = &in_dentry; + in_dentry.d_inode = inode; + infile.f_op = &def_blk_fops; + init_special_inode(inode, S_IFBLK | S_IRUSR, kdev_t_to_nr(device)); + + if ((out_inode = get_empty_inode()) == NULL) + goto free_inode; + memset(&outfile, 0, sizeof(outfile)); + memset(&out_dentry, 0, sizeof(out_dentry)); + outfile.f_mode = 3; /* read/write */ + outfile.f_dentry = &out_dentry; + out_dentry.d_inode = out_inode; + outfile.f_op = &def_blk_fops; + init_special_inode(out_inode, S_IFBLK | S_IRUSR | S_IWUSR, kdev_t_to_nr(ram_device)); + + if (blkdev_open(inode, &infile) != 0) { + iput(out_inode); + goto free_inode; + } + if (blkdev_open(out_inode, &outfile) != 0) + goto free_inodes; + + fs = get_fs(); + set_fs(KERNEL_DS); + + nblocks = identify_ramdisk_image(device, &infile, offset); + if (nblocks < 0) + goto done; + + if (nblocks == 0) { + if (crd_load(&infile, &outfile) == 0) + goto successful_load; + goto done; + } + + /* + * NOTE NOTE: nblocks suppose that the blocksize is BLOCK_SIZE, so + * rd_load_image will work only with filesystem BLOCK_SIZE wide! + * So make sure to use 1k blocksize while generating ext2fs + * ramdisk-images. + */ + if (nblocks > (rd_length[unit] >> BLOCK_SIZE_BITS)) { + printk("RAMDISK: image too big! (%d/%ld blocks)\n", + nblocks, rd_length[unit] >> BLOCK_SIZE_BITS); + goto done; + } + + /* + * OK, time to copy in the data + */ + buf = kmalloc(BLOCK_SIZE, GFP_KERNEL); + if (buf == 0) { + printk(KERN_ERR "RAMDISK: could not allocate buffer\n"); + goto done; + } + + if (blk_size[MAJOR(device)]) + devblocks = blk_size[MAJOR(device)][MINOR(device)]; + +#ifdef CONFIG_BLK_DEV_INITRD + if (MAJOR(device) == MAJOR_NR && MINOR(device) == INITRD_MINOR) + devblocks = nblocks; +#endif + + if (devblocks == 0) { + printk(KERN_ERR "RAMDISK: could not determine device size\n"); + goto done; + } + + printk(KERN_NOTICE "RAMDISK: Loading %d blocks [%d disk%s] into ram disk... ", + nblocks, ((nblocks-1)/devblocks)+1, nblocks>devblocks ? "s" : ""); + for (i=0; i < nblocks; i++) { + if (i && (i % devblocks == 0)) { + printk("done disk #%d.\n", i/devblocks); + rotate = 0; + if (infile.f_op->release(inode, &infile) != 0) { + printk("Error closing the disk.\n"); + goto noclose_input; + } + printk("Please insert disk #%d and press ENTER\n", i/devblocks+1); + wait_for_keypress(); + if (blkdev_open(inode, &infile) != 0) { + printk("Error opening disk.\n"); + goto noclose_input; + } + infile.f_pos = 0; + printk("Loading disk #%d... ", i/devblocks+1); + } + infile.f_op->read(&infile, buf, BLOCK_SIZE, &infile.f_pos); + outfile.f_op->write(&outfile, buf, BLOCK_SIZE, &outfile.f_pos); +#if !defined(CONFIG_ARCH_S390) && !defined(CONFIG_PPC_ISERIES) + if (!(i % 16)) { + printk("%c\b", rotator[rotate & 0x3]); + rotate++; + } +#endif + } + printk("done.\n"); + kfree(buf); + +successful_load: + ROOT_DEV = MKDEV(MAJOR_NR, unit); + if (ROOT_DEVICE_NAME != NULL) strcpy (ROOT_DEVICE_NAME, "rd/0"); + +done: + infile.f_op->release(inode, &infile); +noclose_input: + outfile.f_op->release(out_inode, &outfile); + iput(inode); + iput(out_inode); + set_fs(fs); + return; +free_inodes: /* free inodes on error */ + iput(out_inode); + infile.f_op->release(inode, &infile); +free_inode: + iput(inode); +} + +#ifdef CONFIG_MAC_FLOPPY +int swim3_fd_eject(int devnum); +#endif + +static void __init rd_load_disk(int n) +{ + if (rd_doload == 0) + return; + + if (MAJOR(ROOT_DEV) != FLOPPY_MAJOR +#ifdef CONFIG_BLK_DEV_INITRD + && MAJOR(real_root_dev) != FLOPPY_MAJOR +#endif + ) + return; + + if (rd_prompt) { +#ifdef CONFIG_BLK_DEV_FD + floppy_eject(); +#endif +#ifdef CONFIG_MAC_FLOPPY + if(MAJOR(ROOT_DEV) == FLOPPY_MAJOR) + swim3_fd_eject(MINOR(ROOT_DEV)); + else if(MAJOR(real_root_dev) == FLOPPY_MAJOR) + swim3_fd_eject(MINOR(real_root_dev)); +#endif + printk(KERN_NOTICE + "VFS: Insert root floppy disk to be loaded into RAM disk and press ENTER\n"); + wait_for_keypress(); + } + + rd_load_image(ROOT_DEV,rd_image_start, n); + +} + +void __init rd_load(void) +{ + rd_load_disk(0); +} + +void __init rd_load_secondary(void) +{ + rd_load_disk(1); +} + +#ifdef CONFIG_BLK_DEV_INITRD +void __init rd_load_initrd(void) +{ + rd_load_image(MKDEV(MAJOR_NR, INITRD_MINOR),rd_image_start,0); +} +#endif diff -rNu ../linux-2.4.17/drivers/block/tar.c ./drivers/block/tar.c --- ../linux-2.4.17/drivers/block/tar.c Thu Jan 1 01:00:00 1970 +++ ./drivers/block/tar.c Sat Dec 29 11:05:14 2001 @@ -0,0 +1,360 @@ +/* + * tar.c - extract a tar image + * + * (C) 2001 Matthias Kilian + * + * Tar extraction by Matthias Kilian + * Idea of faked file ops by David L. Parsley + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Some syscalls not defined in linux/unistd.h */ +extern ssize_t sys_write(unsigned int fd, const char * buf,unsigned int count); +extern long sys_chmod(const char * filename, mode_t mode); +extern long sys_fchmod(unsigned int fd, mode_t mode); +extern long sys_chown(const char * filename, uid_t user, gid_t group); +extern long sys_mknod(const char * filename, int mode, dev_t dev); +extern long sys_mkdir(const char * pathname, int mode); +extern long sys_chdir(const char * filename); +extern long sys_link(const char * oldname, const char * newname); +extern long sys_symlink(const char * oldname, const char * newname); +extern long sys_utime(char * filename, struct utimbuf * times); +extern long sys_creat(const char * pathname, int mode); +extern long sys_creat(const char * pathname, int mode); +extern long sys_fchown(unsigned int fd, uid_t user, gid_t group); +extern long sys_fchown(unsigned int fd, uid_t user, gid_t group); +extern long sys_lchown(const char * filename, uid_t user, gid_t group); + + +/* Configuration */ +static int verbose = 0; + +static int __init tar_verbose(char *str) +{ + verbose = 1; + return 1; +} + +__setup("tar_verbose", tar_verbose); + + +/* perror() replacement */ +static void __init perror(const char *msg) +{ + if(msg) { + printk(KERN_ERR "TAR: %s: error %d\n", msg, errno); + } else { + printk(KERN_ERR "TAR: %d\n", errno); + } +} + +struct posix_header +{ /* byte offset */ + char name[100]; /* 0 */ + char mode[8]; /* 100 */ + char uid[8]; /* 108 */ + char gid[8]; /* 116 */ + char size[12]; /* 124 */ + char mtime[12]; /* 136 */ + char chksum[8]; /* 148 */ + char typeflag; /* 156 */ + char linkname[100]; /* 157 */ + char magic[6]; /* 257 */ + char version[2]; /* 263 */ + char uname[32]; /* 265 */ + char gname[32]; /* 297 */ + char devmajor[8]; /* 329 */ + char devminor[8]; /* 337 */ + char prefix[155]; /* 345 */ + /* 500 */ +}; + +#define REGTYPE '0' /* regular file */ +#define AREGTYPE '\0' /* regular file */ +#define LNKTYPE '1' /* link */ +#define SYMTYPE '2' /* reserved */ +#define CHRTYPE '3' /* character special */ +#define BLKTYPE '4' /* block special */ +#define DIRTYPE '5' /* directory */ +#define FIFOTYPE '6' /* FIFO special */ + +#define BLOCKSIZE 512 + + +static unsigned long block = 0; + +static int __init all_null(const char *b) +{ + int s = BLOCKSIZE; + while(s--) { + if(*b++) { + return 0; + } + } + return 1; +} + + +static int __init extract(const void *b) +{ + static int fd = -1; + static long size = 0; + static long mtime; + static char name[102]; + static int touch; + + if(b == NULL) { + if(fd >= 0) { + printk(KERN_ERR + "TAR: block %lu: unexpected end of file.\n", + block); + return 1; + } + } else if(fd >= 0) { + if(size > 0) { + long wsize = size > BLOCKSIZE ? BLOCKSIZE : size; + if(sys_write(fd, b, wsize) != wsize) { + perror(name); + return 1; + } + size -= BLOCKSIZE; + } + if(size > 0) { + return 0; + } else { + sys_close(fd); + fd = -1; + } + } else { + struct posix_header *h = (struct posix_header *)b; + char linkname[101]; + unsigned int imode; + mode_t mode; + uid_t uid; + gid_t gid; + int major = 0; + int minor = 0; + + if(all_null(b)) { + return 0; + } + + touch = 1; + + if(sscanf(h->size, "%12lo", &size) != 1) { + printk(KERN_ERR + "TAR: block %lu: illegal size \"%.12s\"\n", + block, h->size); + return 1; + } + + if(sscanf(h->mtime, "%12lo", &mtime) != 1) { + printk(KERN_ERR + "TAR: block %lu: illegal mtime \"%.12s\"\n", + block, h->mtime); + return 1; + } + + if(sscanf(h->mode, "%8o", &imode) != 1) { + printk(KERN_ERR + "TAR: block %lu: illegal mode \"%.8s\"\n", + block, h->mode); + return 1; + } else { + mode = imode; + } + + if(sscanf(h->uid, "%8o", &uid) != 1) { + printk(KERN_ERR + "TAR: block %lu: illegal uid \"%.8s\"\n", + block, h->uid); + return 1; + } + + if(sscanf(h->gid, "%8o", &gid) != 1) { + printk(KERN_ERR + "TAR: block %lu: illegal gid \"%.8s\"\n", + block, h->gid); + return 1; + } + + /* we always extract relative to / */ + if(h->name[0] != '/') { + name[0] = '/'; + strncpy(name + 1, h->name, 100); + } else { + strncpy(name, h->name, 100); + } + name[101] = 0; + + if(verbose) { + printk(KERN_NOTICE "TAR: extract %s\n", name); + } + + strncpy(linkname, h->linkname, 100); + linkname[100] = 0; + + switch(h->typeflag) { + case REGTYPE: + case AREGTYPE: + /* Regular file */ + if((fd = sys_creat(name, mode)) < 0) { + perror(name); + return 1; + } + if(sys_fchown(fd, uid, gid)) { + perror(name); + return 1; + } + if(sys_fchmod(fd, mode)) { + perror(name); + return 1; + } + if(size > 0) { + return 0; + } else { + sys_close(fd); + fd = -1; + } + break; + case LNKTYPE: + /* Hardlink */ + if(sys_link(linkname, name)) { + perror(name); + return 1; + } + touch = 0; + break; + case SYMTYPE: + /* Symlink */ + if(sys_symlink(linkname, name)) { + perror(name); + return 1; + } + if(sys_lchown(name, uid, gid)) { + perror(name); + return 1; + } + touch = 0; + break; + case CHRTYPE: + /* Character special */ + case BLKTYPE: + /* Block special */ + if(sscanf(h->devmajor, "%8o", &major) != 1) { + printk(KERN_ERR + "TAR: block %lu: illegal major \"%.8s\"\n", + block, h->devmajor); + return 1; + } + if(sscanf(h->devminor, "%8o", &minor) != 1) { + printk(KERN_ERR + "TAR: block %lu: illegal minor \"%.8s\"\n", + block, h->devminor); + return 1; + } + /* Fall through */ + case FIFOTYPE: + /* Fifo */ + + if(sys_mknod(name, mode, MKDEV(major, minor)) || + sys_chown(name, uid, gid) || + sys_chmod(name, mode)) { + perror(name); + return 1; + } + break; + case DIRTYPE: + /* Directory */ + switch(sys_mkdir(name, mode)) { + case -EEXIST: + case 0: + if(sys_chown(name, uid, gid)) { + perror(name); + return 1; + } + if(sys_chmod(name, mode)) { + perror(name); + return 1; + } + break; + default: + perror(name); + return 1; + } + break; + default: + errno = EINVAL; + printk(KERN_ERR "TAR: block %lu: unknown type `%c`\n", + block, h->typeflag); + return 1; + } + } + + if(touch) { + struct utimbuf ut; + ut.actime = ut.modtime = mtime; + if(sys_utime(name, &ut)) { + perror(name); + return 1; + } + } + + return 0; +} + + +/* Build a fake set of fops for the fake file 'untar', which crd_load + * will need to write to. + */ + +static int __init tar_open(struct inode *inode, struct file *file) +{ + /* This funktion does -- just noting */ + return 0; +} + +static int __init tar_release(struct inode *inode, struct file *file) +{ + if(extract(NULL)) { + return -1; + } + return 0; +} + +/* This is called by flush_window to flush the gzip output + * buffer (containing part of a tar image). + */ +static ssize_t __init tar_write(struct file *fp, const char *buf, + size_t count, loff_t *fpos) +{ + while(count >= BLOCKSIZE) { + if(extract(buf)) { + return -1; + } + buf += BLOCKSIZE; + count -= BLOCKSIZE; + block++; + } + if(count) { + printk(KERN_ERR "TAR: count is not multiple of %d\n", BLOCKSIZE); + return -1; + } + return 0; +} + + +struct file_operations tar_fops = { + open: tar_open, + write: tar_write, + release: tar_release, +}; diff -rNu ../linux-2.4.17/fs/Config.in ./fs/Config.in --- ../linux-2.4.17/fs/Config.in Tue Nov 27 18:28:50 2001 +++ ./fs/Config.in Sat Dec 29 11:05:14 2001 @@ -45,6 +45,11 @@ fi tristate 'Compressed ROM file system support' CONFIG_CRAMFS bool 'Virtual memory file system support (former shm fs)' CONFIG_TMPFS +dep_bool ' Initial virtual memory filesystem support (EXPERIMENTAL)' CONFIG_TMPFS_INITTAR $CONFIG_TMPFS $CONFIG_EXPERIMENTAL +if [ "$CONFIG_TMPFS_INITTAR" = "y" ]; then + define_bool CONFIG_IRD_LOADER y + define_bool CONFIG_CRD_LOADER y +fi tristate 'Simple RAM-based file system support' CONFIG_RAMFS tristate 'ISO 9660 CDROM file system support' CONFIG_ISO9660_FS diff -rNu ../linux-2.4.17/fs/super.c ./fs/super.c --- ../linux-2.4.17/fs/super.c Sat Dec 29 10:48:58 2001 +++ ./fs/super.c Sat Dec 29 11:05:14 2001 @@ -1082,3 +1082,43 @@ mntput(vfsmnt); } + + +#ifdef CONFIG_TMPFS_INITTAR +extern char *get_tmpfs_inittar_options(void); + +/* + * Mount a root tmpfs. Return 0 on success, -1 on failure. + * TODO: should we do some devfs stuff here? + */ +int __init mount_tmpfs_root(void) +{ + struct nameidata root_nd; + struct vfsmount *vfsmnt; + + root_mountflags |= MS_VERBOSE; + + vfsmnt = do_kern_mount("tmpfs", root_mountflags, "tmpfs", + get_tmpfs_inittar_options()); + + if (IS_ERR(vfsmnt)) { + printk(KERN_ERR "VFS: unable to mount tmpfs root filesystem.\n"); + return -1; + } + + printk ("VFS: Mounted root (tmpfs filesystem).\n"); + + ROOT_DEV = vfsmnt->mnt_sb->s_dev; + + root_nd.mnt = root_vfsmnt; + root_nd.dentry = root_vfsmnt->mnt_sb->s_root; + graft_tree(vfsmnt, &root_nd); + + set_fs_root(current->fs, vfsmnt, vfsmnt->mnt_root); + set_fs_pwd(current->fs, vfsmnt, vfsmnt->mnt_root); + + mntput(vfsmnt); + + return 0; +} +#endif diff -rNu ../linux-2.4.17/include/linux/blk.h ./include/linux/blk.h --- ../linux-2.4.17/include/linux/blk.h Tue Nov 27 18:28:54 2001 +++ ./include/linux/blk.h Sat Dec 29 11:05:14 2001 @@ -65,7 +65,7 @@ extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */ extern int rd_image_start; /* starting block # of image */ -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER #define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */ diff -rNu ../linux-2.4.17/include/linux/devfs_fs_kernel.h ./include/linux/devfs_fs_kernel.h --- ../linux-2.4.17/include/linux/devfs_fs_kernel.h Sat Dec 29 10:48:58 2001 +++ ./include/linux/devfs_fs_kernel.h Sat Dec 29 11:05:14 2001 @@ -47,7 +47,7 @@ typedef struct devfs_entry * devfs_handle_t; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER # define ROOT_DEVICE_NAME ((real_root_dev ==ROOT_DEV) ? root_device_name:NULL) #else # define ROOT_DEVICE_NAME root_device_name diff -rNu ../linux-2.4.17/include/linux/fs.h ./include/linux/fs.h --- ../linux-2.4.17/include/linux/fs.h Sat Dec 29 10:48:58 2001 +++ ./include/linux/fs.h Sat Dec 29 11:05:14 2001 @@ -1435,8 +1435,10 @@ extern void show_buffers(void); extern void mount_root(void); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER extern unsigned int real_root_dev; +#endif +#ifdef CONFIG_BLK_DEV_INITRD extern int change_root(kdev_t, const char *); #endif diff -rNu ../linux-2.4.17/init/main.c ./init/main.c --- ../linux-2.4.17/init/main.c Sat Dec 29 10:48:59 2001 +++ ./init/main.c Sat Dec 29 11:05:14 2001 @@ -118,7 +118,7 @@ int rows, cols; -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER unsigned int real_root_dev; /* do_proc_dointvec cannot handle kdev_t */ #endif @@ -581,7 +581,7 @@ kmem_cache_init(); sti(); calibrate_delay(); -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (initrd_start && !initrd_below_start_ok && initrd_start < min_low_pfn << PAGE_SHIFT) { printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - " @@ -741,14 +741,17 @@ } extern void rd_load(void); -extern void initrd_load(void); +extern int initrd_load(void); +extern unsigned long initrd_start; +extern int mount_initrd; /* * Prepare the namespace - decide what/where to mount, load ramdisks, etc. */ static void prepare_namespace(void) { -#ifdef CONFIG_BLK_DEV_INITRD + int root_mounted = 0; +#ifdef CONFIG_IRD_LOADER int real_root_mountflags = root_mountflags; if (!initrd_start) mount_initrd = 0; @@ -757,17 +760,18 @@ real_root_dev = ROOT_DEV; #endif -#ifdef CONFIG_BLK_DEV_RAM -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER if (mount_initrd) - initrd_load(); + root_mounted = !initrd_load(); +#ifdef CONFIG_BLK_DEV_RAM else -#endif rd_load(); #endif +#endif /* Mount the root filesystem.. */ - mount_root(); + if(!root_mounted) + mount_root(); mount_devfs_fs (); diff -rNu ../linux-2.4.17/kernel/sysctl.c ./kernel/sysctl.c --- ../linux-2.4.17/kernel/sysctl.c Sat Dec 29 10:48:59 2001 +++ ./kernel/sysctl.c Sat Dec 29 11:05:14 2001 @@ -175,7 +175,7 @@ 0644, NULL, &proc_dointvec}, {KERN_CAP_BSET, "cap-bound", &cap_bset, sizeof(kernel_cap_t), 0600, NULL, &proc_dointvec_bset}, -#ifdef CONFIG_BLK_DEV_INITRD +#ifdef CONFIG_IRD_LOADER {KERN_REALROOTDEV, "real-root-dev", &real_root_dev, sizeof(int), 0644, NULL, &proc_dointvec}, #endif