Index: usr.sbin/sysinstall/dispatch.c
===================================================================
RCS file: /usr/local/ncvs/src/usr.sbin/sysinstall/dispatch.c,v
retrieving revision 1.47.2.1
diff -u -r1.47.2.1 dispatch.c
--- usr.sbin/sysinstall/dispatch.c	31 Jan 2006 22:03:18 -0000	1.47.2.1
+++ usr.sbin/sysinstall/dispatch.c	10 Apr 2007 07:24:17 -0000
@@ -47,6 +47,7 @@
 static int dispatch_msgConfirm(dialogMenuItem *unused);
 static int dispatch_mediaOpen(dialogMenuItem *unused);
 static int dispatch_mediaClose(dialogMenuItem *unused);
+static int cfgModuleFire(dialogMenuItem *self);
 
 static struct _word {
     char *name;
@@ -92,6 +93,7 @@
     { "installVarDefaults",	installVarDefaults	},
     { "loadConfig",		dispatch_load_file	},
     { "loadFloppyConfig",	dispatch_load_floppy	},
+    { "loadCDROMConfig",	dispatch_load_cdrom	},
     { "mediaOpen",		dispatch_mediaOpen	},
     { "mediaClose",		dispatch_mediaClose	},
     { "mediaSetCDROM",		mediaSetCDROM		},
@@ -404,8 +406,7 @@
 
     mediaClose();
     cp = variable_get_value(VAR_INSTALL_CFG,
-			    "Specify the name of a configuration file\n"
-			    "residing on a MSDOS or UFS floppy.", 0);
+			    "Specify the name of a configuration file", 0);
     if (!cp || !*cp) {
 	variable_unset(VAR_INSTALL_CFG);
 	what |= DITEM_FAILURE;
@@ -446,3 +447,187 @@
     return what;
 }
 
+int
+dispatch_load_cdrom(dialogMenuItem *self)
+{
+    int             what = DITEM_SUCCESS;
+    extern char    *distWanted;
+    char           *cp;
+    FILE           *fp;
+    qelement	   *list;
+
+    mediaClose();
+    cp = variable_get_value(VAR_INSTALL_CFG,
+			    "Specify the name of a configuration file\n"
+			    "residing on the CDROM.", 0);
+    if (!cp || !*cp) {
+	variable_unset(VAR_INSTALL_CFG);
+	what |= DITEM_FAILURE;
+	return what;
+    }
+
+    distWanted = cp;
+    /* Try to open the CDROM drive */
+    if (DITEM_STATUS(mediaSetCDROM(NULL)) == DITEM_FAILURE) {
+	msgConfirm("Unable to set media device to CDROM.");
+	what |= DITEM_FAILURE;
+	mediaClose();
+	return what;
+    }
+
+    if (!DEVICE_INIT(mediaDevice)) {
+	msgConfirm("Unable to CDROM filesystem.");
+	what |= DITEM_FAILURE;
+	mediaClose();
+	return what;
+    }
+
+    fp = DEVICE_GET(mediaDevice, cp, TRUE);
+    if (fp) {
+	list = dispatch_load_fp(fp);
+	fclose(fp);
+	mediaClose();
+
+	what |= dispatch_execute(list);
+    }
+    else {
+	if (!variable_get(VAR_NO_ERROR))
+	    msgConfirm("Configuration file '%s' not found.", cp);
+	variable_unset(VAR_INSTALL_CFG);
+	what |= DITEM_FAILURE;
+	mediaClose();
+    }
+    return what;
+}
+
+/*
+ * Create a menu based on available disk devices
+ */
+int
+dispatch_load_menu(dialogMenuItem *self)
+{
+    DMenu	*menu;
+    Device	**devlist;
+    char	*err;
+    int		what, i, j, msize, count;
+    DeviceType	dtypes[] = {DEVICE_TYPE_FLOPPY, DEVICE_TYPE_CDROM, DEVICE_TYPE_DOS, DEVICE_TYPE_UFS};
+    
+    fprintf(stderr, "dispatch_load_menu called\n");
+    
+    msize = sizeof(DMenu) + (sizeof(dialogMenuItem) * 2);
+    count = 0;
+    err = NULL;
+    what = DITEM_SUCCESS;
+
+    if ((menu = malloc(msize)) == NULL) {
+	err = "Failed to allocate memory for menu";
+	goto errout;
+    }
+
+    bcopy(&MenuConfig, menu, sizeof(DMenu));
+	
+    bzero(&menu->items[count], sizeof(menu->items[0]));
+    menu->items[count].prompt = strdup("X Exit");
+    menu->items[count].title = strdup("Exit this menu (returning to previous)");
+    menu->items[count].fire = dmenuExit;
+    count++;
+
+    for (i = 0; i < sizeof(dtypes) / sizeof(dtypes[0]); i++) {
+	if ((devlist = deviceFind(NULL, dtypes[i])) == NULL) {
+	    fprintf(stderr, "No devices found for type %d\n", dtypes[i]);
+	    continue;
+	}
+    
+	for (j = 0; devlist[j] != NULL; j++) {
+	    fprintf(stderr, "device type %d device name %s\n", dtypes[i], devlist[j]->name);
+	    msize += sizeof(dialogMenuItem);
+	    if ((menu = realloc(menu, msize)) == NULL) {
+		err = "Failed to allocate memory for menu item";
+		goto errout;
+	    }
+	    
+	    bzero(&menu->items[count], sizeof(menu->items[0]));
+	    menu->items[count].fire = cfgModuleFire;
+
+	    menu->items[count].prompt = strdup(devlist[j]->name);
+	    menu->items[count].title = strdup(devlist[j]->description);
+	    /* XXX: dialog(3) sucks */
+	    menu->items[count].aux = (long)devlist[j];
+	    count++;
+	}
+    }
+    
+    menu->items[count].prompt = NULL;
+    menu->items[count].title = NULL;
+
+    dmenuOpenSimple(menu, FALSE);
+
+  errout:
+    for (i = 0; i < count; i++) {
+	free(menu->items[i].prompt);
+	free(menu->items[i].title);
+    }
+    
+    free(menu);
+
+    if (err != NULL) {
+	what |= DITEM_FAILURE;
+	if (!variable_get(VAR_NO_ERROR))
+	    msgConfirm(err);
+    }
+    
+    return (what);
+
+}
+
+static int
+cfgModuleFire(dialogMenuItem *self) {
+    Device	*d;
+    FILE	*fp;
+    int		what = DITEM_SUCCESS;
+    extern char *distWanted; 
+    qelement	*list;
+    char	*cp;
+    
+    d = (Device *)self->aux;
+
+    fprintf(stderr, "cfgModuleFire: User selected %s (%s)\n", self->prompt, d->devname);
+
+    mediaClose();
+
+    cp = variable_get_value(VAR_INSTALL_CFG,
+			    "Specify the name of a configuration file", 0);
+    if (!cp || !*cp) {
+	variable_unset(VAR_INSTALL_CFG);
+	what |= DITEM_FAILURE;
+	return what;
+    }
+
+    distWanted = cp;
+    
+    mediaDevice = d;
+    if (!DEVICE_INIT(mediaDevice)) {
+	msgConfirm("Unable to mount filesystem.");
+	what |= DITEM_FAILURE;
+	mediaClose();
+	return what;
+    }
+    
+    fp = DEVICE_GET(mediaDevice, cp, TRUE);
+    if (fp) {
+	list = dispatch_load_fp(fp);
+	fclose(fp);
+	mediaClose();
+	
+	what |= dispatch_execute(list);
+    } else {
+	if (!variable_get(VAR_NO_ERROR))
+	    msgConfirm("Configuration file '%s' not found.", cp);
+	variable_unset(VAR_INSTALL_CFG);
+	what |= DITEM_FAILURE;
+	mediaClose();
+    }
+    
+    return(what);
+ }
+
Index: usr.sbin/sysinstall/menus.c
===================================================================
RCS file: /usr/local/ncvs/src/usr.sbin/sysinstall/menus.c,v
retrieving revision 1.410.2.10
diff -u -r1.410.2.10 menus.c
--- usr.sbin/sysinstall/menus.c	26 May 2007 07:31:47 -0000	1.410.2.10
+++ usr.sbin/sysinstall/menus.c	30 Jul 2007 02:19:46 -0000
@@ -231,7 +231,9 @@
       { " Console settings",	"Customize system console behavior.",	NULL, dmenuSubmenu, NULL, &MenuSyscons },
 #endif
       { " Configure",		"The system configuration menu.",	NULL, dmenuSubmenu, NULL, &MenuConfigure },
-      { " Defaults, Load",	"Load default settings.",		NULL, dispatch_load_floppy },
+      { " Defaults, Load (FDD)","Load default settings from floppy.", NULL, dispatch_load_floppy },
+      { " Defaults, Load (CD)",       "Load default settings from CDROM.",    NULL, dispatch_load_cdrom },
+      { " Defaults, Load",    "Load default settings (all devices).", NULL, dispatch_load_menu },
 #ifdef WITH_MICE
       { " Device, Mouse",	"The mouse configuration menu.",	NULL, dmenuSubmenu, NULL, &MenuMouse },
 #endif
@@ -308,6 +310,7 @@
       { " Time Zone",		"Set the system's time zone.",		NULL, dmenuSystemCommand, NULL, "tzsetup" },
       { " TTYs",		"Configure system ttys.",		NULL, configEtcTtys, NULL, "ttys" },
       { " Upgrade",		"Upgrade an existing system.",		NULL, installUpgrade },
+      { "Load Config..","Load default install configuration",         NULL, dispatch_load_menu },
       { " Usage",		"Quick start - How to use this menu system.",	NULL, dmenuDisplayFile, NULL, "usage" },
       { " User Management",	"Add user and group information.",	NULL, dmenuSubmenu, NULL, &MenuUsermgmt },
       { " X.Org, Fonts",	"X.Org Font selection menu.",		NULL, dmenuSubmenu, NULL, &MenuXOrgSelectFonts },
@@ -342,7 +345,7 @@
       { "Options",	"View/Set various installation options",	NULL, optionsEditor },
       { "Fixit",	"Repair mode with CDROM/DVD/floppy or start shell",	NULL, dmenuSubmenu, NULL, &MenuFixit },
       { "Upgrade",	"Upgrade an existing system",			NULL, installUpgrade },
-      { "Load Config","Load default install configuration",		NULL, dispatch_load_floppy },
+      { "Load Config..","Load default install configuration",		NULL, dispatch_load_menu },
       { "Index",	"Glossary of functions",			NULL, dmenuSubmenu, NULL, &MenuIndex },
       { NULL } },
 };
@@ -922,6 +925,17 @@
     { { NULL } },
 };
 
+/* Prototype config file load menu */
+DMenu MenuConfig = {
+    DMENU_NORMAL_TYPE,
+    "Config Menu",
+    "Please select the device to load your configuration file from.\n"
+    "Note that a USB key will show up as daNs1.",
+    NULL,
+    NULL,
+    { { NULL } },
+};
+
 /* The media selection menu */
 DMenu MenuMedia = {
     DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
Index: usr.sbin/sysinstall/sysinstall.h
===================================================================
RCS file: /usr/local/ncvs/src/usr.sbin/sysinstall/sysinstall.h,v
retrieving revision 1.264.2.6
diff -u -r1.264.2.6 sysinstall.h
--- usr.sbin/sysinstall/sysinstall.h	29 Oct 2006 14:38:17 -0000	1.264.2.6
+++ usr.sbin/sysinstall/sysinstall.h	12 Apr 2007 07:51:38 -0000
@@ -440,6 +441,7 @@
 extern DMenu		MenuOptions;		/* Installation options				*/
 extern DMenu		MenuOptionsLanguage;	/* Language options menu			*/
 extern DMenu		MenuKLD;		/* Prototype KLD menu				*/
+extern DMenu		MenuConfig;		/* Prototype config menu				*/
 extern DMenu		MenuMedia;		/* Media type menu				*/
 #ifdef WITH_MICE
 extern DMenu		MenuMouse;		/* Mouse type menu				*/
@@ -592,8 +594,10 @@
 /* dispatch.c */
 extern int	dispatchCommand(char *command);
 extern int	dispatch_load_floppy(dialogMenuItem *self);
+extern int	dispatch_load_cdrom(dialogMenuItem *self);
 extern int	dispatch_load_file_int(int);
 extern int	dispatch_load_file(dialogMenuItem *self);
+extern int	dispatch_load_menu(dialogMenuItem *self);
 
 
 /* dist.c */
