Subject: install/20121: Make the install-disk selection become a menu
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jmmv@menta.net>
List: netbsd-bugs
Date: 01/30/2003 12:45:59
>Number:         20121
>Category:       install
>Synopsis:       Make the install-disk selection become a menu
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    install-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 30 03:40:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 1.6M
>Organization:
Julio M. Merino Vidal <jmmv@menta.net>
The NetBSD Project - http://www.NetBSD.org/
>Environment:
	
	
System: NetBSD darkstar.local 1.6M NetBSD 1.6M (DARKSTAR) #194: Wed Jan 29 16:24:37 CET 2003 jmmv@darkstar.local:/usr/obj/DARKSTAR i386
Architecture: i386
Machine: i386
>Description:
	sysinst uses menus for almost all selections. There is, although,
	a point where a menu is not used: this is the hard disk selection
	(the second question shown when installing).

	That question should be converted to show a menu with all possible
	disks and let the user choose from it, instead of having to write
	the disk name by hand.
>How-To-Repeat:
	
>Fix:
	This patch implements the menu:

Index: disks.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/disks.c,v
retrieving revision 1.49
diff -u -u -r1.49 disks.c
--- disks.c	2003/01/12 21:49:50	1.49
+++ disks.c	2003/01/30 11:32:51
@@ -75,7 +75,16 @@
 static int target_mount_with_error_menu(const char *opt, char *diskpart,
 					const char *mntpt);
 
+static menu_ent dsk_menu[MAX_DISKS];
 
+static int
+set_dsk_select(menudesc *m)
+{
+	if (m)
+		strcpy(diskdev, m->opts[m->cursel].opt_name);
+	return 0;
+}
+
 static void
 get_disks(void)
 {
@@ -99,6 +108,12 @@
 				disks[numdisks].dd_sec = l.d_nsectors;
 				disks[numdisks].dd_secsize = l.d_secsize;
 				disks[numdisks].dd_totsec = l.d_secperunit;
+				dsk_menu[numdisks].opt_name = strdup(d_name);
+				if (dsk_menu[numdisks].opt_name == NULL)
+					dsk_menu[numdisks].opt_name = "*";
+				dsk_menu[numdisks].opt_menu = OPT_NOMENU;
+				dsk_menu[numdisks].opt_flags = OPT_EXIT;
+				dsk_menu[numdisks].opt_action = set_dsk_select;
 				numdisks++;
 			}
 		}
@@ -110,9 +125,8 @@
 int
 find_disks(void)
 {
-	char *tp;
-	char defname[STRSIZE];
 	int  i;
+	int  menu_no;
 
 	/* initialize */
 	disknames[0] = 0;
@@ -140,26 +154,19 @@
 		strcpy(diskdev, disknames);
 	} else {
 		/* Multiple disks found! */
-		strcpy(defname, disknames);
-		tp = defname;
-		strsep(&tp, " ");
-		msg_prompt(MSG_askdisk, defname,  diskdev, 10, disknames);
-		tp = diskdev;
-		strsep(&tp, " ");
-		diskdev[strlen(diskdev)+1] = 0;
-		diskdev[strlen(diskdev)] = ' ';
-		while (!ISDISKSTART(*diskdev) ||
-		       strstr(disknames, diskdev) == NULL) {
-			msg_prompt(MSG_badname, defname,  diskdev, 10,
-				    disknames);
-			tp = diskdev;
-			strsep(&tp, " ");
-			diskdev[strlen(diskdev)+1] = 0;
-			diskdev[strlen(diskdev)] = ' ';
-		}
-
-		/* Remove that space we added. */
-		diskdev[strlen(diskdev)-1] = 0;
+		menu_no = new_menu("Available disks",
+		                   dsk_menu, numdisks, 32, 9, 6, 15,
+		                   MC_SCROLL | MC_NOSHORTCUT | MC_NOEXITOPT,
+		                   NULL, NULL,
+		                   "\nPlease consult the install documents.");
+		if (menu_no < 0)
+			return -1;
+		msg_display(MSG_askdisk);
+		process_menu(menu_no);
+		free_menu(menu_no);
+		for (i = 0; i < numdisks; i++)
+			free(dsk_menu[i].opt_name);
+		free(dsk_menu);
 	}
 	
 	/* Set disk. */
Index: msg.mi.en
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.en,v
retrieving revision 1.95
diff -u -u -r1.95 msg.mi.en
--- msg.mi.en	2003/01/22 05:59:07	1.95
+++ msg.mi.en	2003/01/30 11:32:55
@@ -118,13 +118,7 @@
 }
 
 message askdisk
-{I have found the following disks: %s
-\nOn which disk do you want to install NetBSD? }
-
-message badname
-{You did not choose one of the listed disks.  Please try again.
-The following disks are available: %s
-\nOn which disk do you want to install NetBSD? }
+{On which disk do you want to install NetBSD?}
 
 message disktoosmall
 {Your hard disk is too small for a standard install. You will have to enter



>Release-Note:
>Audit-Trail:
>Unformatted: