Subject: Patch to specify memory disk root image at kernel compile time
To: None <tech-kern@netbsd.org>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 03/06/2003 16:52:48
--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Folks...
I have the need to specify a memory disk image (root the root fs) at
kernel compile time. The following patch does that by allowing you
to specify:
makeoptions MEMORY_DISK_IMAGE="/path/to/image.fs"
in your kernel configuration file.
I'm planning on cleaning it up a little (e.g. making hexdump a host
tool) and checking it in.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=md-root-image-patch
Index: dev/md_root.c
===================================================================
RCS file: /cvsroot/src/sys/dev/md_root.c,v
retrieving revision 1.8
diff -c -r1.8 md_root.c
*** dev/md_root.c 2003/02/05 15:20:29 1.8
--- dev/md_root.c 2003/03/07 00:48:39
***************
*** 50,59 ****
--- 50,73 ----
extern int boothowto;
#ifdef MEMORY_DISK_DYNAMIC
+ #ifdef MEMORY_DISK_IMAGE
+ #error MEMORY_DISK_DYNAMIC is not compatible with MEMORY_DISK_IMAGE
+ #endif
size_t md_root_size;
char *md_root_image;
#else /* MEMORY_DISK_DYNAMIC */
+ #ifdef MEMORY_DISK_IMAGE
+ #ifdef MEMORY_DISK_ROOT_SIZE
+ #error MEMORY_DISK_ROOT_SIZE is not compatible with MEMORY_DISK_IMAGE
+ #endif
+ char md_root_image[] = {
+ #include "md_root_image.h"
+ };
+ u_int32_t md_root_size = sizeof(md_root_image) & ~(DEV_BSIZE - 1);
+
+ #else /* MEMORY_DISK_IMAGE */
+
#ifndef MEMORY_DISK_ROOT_SIZE
#define MEMORY_DISK_ROOT_SIZE 512
#endif
***************
*** 65,70 ****
--- 79,85 ----
*/
u_int32_t md_root_size = ROOTBYTES;
char md_root_image[ROOTBYTES] = "|This is the root ramdisk!\n";
+ #endif /* MEMORY_DISK_IMAGE */
#endif /* MEMORY_DISK_DYNAMIC */
#ifndef MEMORY_RBFLAGS
Index: conf/Makefile.kern.inc
===================================================================
RCS file: /cvsroot/src/sys/conf/Makefile.kern.inc,v
retrieving revision 1.32
diff -c -r1.32 Makefile.kern.inc
*** conf/Makefile.kern.inc 2003/02/05 18:07:46 1.32
--- conf/Makefile.kern.inc 2003/03/07 00:48:40
***************
*** 197,202 ****
--- 197,214 ----
cp config_time.src config_time.h
.endif
+ .if defined(MEMORY_DISK_IMAGE)
+ md_root_image.h: ${MEMORY_DISK_IMAGE}
+ hexdump -v -e '"\t" 8/1 "0x%02x, " "\n"' ${.ALLSRC} > ${.TARGET}
+
+ # XXX This is only needed when building md_root.o
+ CPPFLAGS+= -DMEMORY_DISK_IMAGE
+ md_root.o: md_root_image.h
+ .endif
+
+ # depend on MEMORY_DISK_IMAGE configuration
+ md_root.o: Makefile
+
# depend on root or device configuration
autoconf.o conf.o: Makefile
--0OAP2g/MAC+5xKAE--