Subject: sysinst fixes for sgimips
To: None <port-sgimips@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: port-sgimips
Date: 02/11/2003 18:24:59
--EeQfGwPcQSOJBaQU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,
The attached diff are intended to fix 2 problems with the sgimips part of
sysinst:
the size of disk is computed as cyl*head*sect, which is wrong for modern
disks. It usually is smaller (which doens't cause harm, unless you want
to use an existing partititon which goes to the real end of disk), but
I suspect it may sometimes be larger ...
The second problem is that, in the partition editor, the option "use existing
partitions" isn't handled at all, and you end up with only C and D defined.

While I'm there use get_real_geom() instead of custom code to get the
existing disklabel.

How does the patch look ?
Eventually I'd like to ask pullup for 1.6.1, so please review.

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
     NetBSD: 24 ans d'experience feront toujours la difference
--

--EeQfGwPcQSOJBaQU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/sgimips/md.c,v
retrieving revision 1.3
diff -u -r1.3 md.c
--- md.c	2002/08/02 05:11:35	1.3
+++ md.c	2003/02/11 17:20:16
@@ -47,6 +47,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <util.h>
+#include <errno.h>
 #include "defs.h"
 #include "md.h"
 #include "msg_defs.h"
@@ -55,24 +56,13 @@
 int
 md_get_info(void)
 {	struct disklabel disklabel;
-	int fd;
-	char devname[100];
 
-	snprintf(devname, 100, "/dev/r%sc", diskdev);
-
-	fd = open(devname, O_RDONLY, 0);
-	if (fd < 0) {
-		endwin();
-		fprintf (stderr, "Can't open %s\n", devname);
-		exit(1);
-	}
-	if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+	if (get_real_geom(diskdev, &disklabel) == 0) {
 		endwin();
-		fprintf (stderr, "Can't read disklabel on %s.\n", devname);
-		close(fd);
+		fprintf (stderr, "Can't get disklabel for %s: %s\n", diskdev,
+		    strerror(errno));
 		exit(1);
 	}
-	close(fd);
 
 	dlcyl = disklabel.d_ncylinders;
 	dlhead = disklabel.d_ntracks;
@@ -84,7 +74,6 @@
 	dlcyl  = disk->dd_cyl;
 	dlhead = disk->dd_head;
 	dlsec  = disk->dd_sec;
-	dlsize = dlcyl*dlhead*dlsec;
 	fsdsize = dlsize;
 	fsdmb = fsdsize / MEG;
 
@@ -126,6 +115,7 @@
 	int part, partsize, partstart, remain;
 	char isize[SSTRSIZE];
 	int maxpart = getmaxpartitions();
+	struct disklabel l;
 
 	/* Ask for layout type -- standard or special */
 	msg_display(MSG_layout,
@@ -289,6 +279,30 @@
 
 		/* Verify Partitions. */
 		process_menu(MENU_fspartok);
+		break;
+	case 4: /* use existing parts */
+		if (get_real_geom(diskdev, &l) == 0) {
+			msg_display(MSG_abort);
+			return 0;
+		}
+#define p l.d_partitions[i]
+		for (i = 0; i < getmaxpartitions(); i++) {
+			/*
+			 * Make sure to not overwrite the raw partition, or
+			 * the boot partition.
+			 */
+			if (i == 2 || i == 3)
+				continue;
+
+			bsdlabel[i].pi_size = p.p_size;
+			bsdlabel[i].pi_offset = p.p_offset;
+			bsdlabel[i].pi_fstype = p.p_fstype;
+			bsdlabel[i].pi_bsize  = p.p_fsize * p.p_frag;
+			bsdlabel[i].pi_fsize  = p.p_fsize;
+		}
+#undef p
+		msg_display(MSG_postuseexisting);
+		getchar();
 		break;
 	}
 

--EeQfGwPcQSOJBaQU--