Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jan 2011 03:16:47 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r216884 - user/nwhitehorn/bsdinstall/partedit
Message-ID:  <201101020316.p023GlEX030915@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Sun Jan  2 03:16:47 2011
New Revision: 216884
URL: http://svn.freebsd.org/changeset/base/216884

Log:
  Add support for installations on sparc64 [tested] and pc98 [speculative].

Added:
  user/nwhitehorn/bsdinstall/partedit/partedit_pc98.c
  user/nwhitehorn/bsdinstall/partedit/partedit_sparc64.c
Modified:
  user/nwhitehorn/bsdinstall/partedit/Makefile
  user/nwhitehorn/bsdinstall/partedit/gpart_ops.c
  user/nwhitehorn/bsdinstall/partedit/partedit.h
  user/nwhitehorn/bsdinstall/partedit/partedit_powerpc.c
  user/nwhitehorn/bsdinstall/partedit/partedit_x86.c

Modified: user/nwhitehorn/bsdinstall/partedit/Makefile
==============================================================================
--- user/nwhitehorn/bsdinstall/partedit/Makefile	Sun Jan  2 03:16:07 2011	(r216883)
+++ user/nwhitehorn/bsdinstall/partedit/Makefile	Sun Jan  2 03:16:47 2011	(r216884)
@@ -8,6 +8,9 @@ PARTEDIT_ARCH= ${MACHINE}
 .if ${MACHINE} == "i386" || ${MACHINE} == "amd64"
 PARTEDIT_ARCH= x86
 .endif
+.if ${MACHINE} == "sun4v"
+PARTEDIT_ARCH= sparc64
+.endif
 .if !exists(partedit_${PARTEDIT_ARCH}.c)
 PARTEDIT_ARCH= generic
 .endif

Modified: user/nwhitehorn/bsdinstall/partedit/gpart_ops.c
==============================================================================
--- user/nwhitehorn/bsdinstall/partedit/gpart_ops.c	Sun Jan  2 03:16:07 2011	(r216883)
+++ user/nwhitehorn/bsdinstall/partedit/gpart_ops.c	Sun Jan  2 03:16:47 2011	(r216884)
@@ -11,8 +11,8 @@
 
 #define GPART_FLAGS "x" /* Do not commit changes by default */
 
-static void set_part_metadata(const char *name, const char *type,
-    const char *mountpoint, int newfs);
+static void set_part_metadata(const char *name, const char *scheme,
+    const char *type, const char *mountpoint, int newfs);
 
 static void
 gpart_show_error(const char *title, const char *explanation, const char *errstr)
@@ -223,6 +223,10 @@ gpart_partcode(struct gprovider *pp)
 		}
 	}
 
+	/* Make sure this partition scheme needs partcode on this platform */
+	if (partcode_path(scheme) == NULL)
+		return;
+
 	LIST_FOREACH(gc, &pp->lg_config, lg_config) {
 		if (strcmp(gc->lg_name, "index") == 0) {
 			indexstr = gc->lg_val;
@@ -248,7 +252,7 @@ gpart_edit(struct gprovider *pp)
 	struct gconsumer *cp;
 	struct gprovider *spp;
 	struct ggeom *geom;
-	const char *errstr, *oldtype;
+	const char *errstr, *oldtype, *scheme;
 	struct partition_metadata *md;
 	char sizestr[32];
 	intmax_t index;
@@ -330,6 +334,13 @@ gpart_edit(struct gprovider *pp)
 		return;
 	}
 
+	LIST_FOREACH(gc, &geom->lg_config, lg_config) {
+		if (strcmp(gc->lg_name, "scheme") == 0) {
+			scheme = gc->lg_val;
+			break;
+		}
+	}
+
 	/* Edit editable parameters of a partition */
 	hadlabel = 0;
 	LIST_FOREACH(gc, &pp->lg_config, lg_config) {
@@ -391,7 +402,7 @@ editpart:
 	}
 	gctl_free(r);
 
-	set_part_metadata(pp->lg_name, items[0].text, items[3].text,
+	set_part_metadata(pp->lg_name, scheme, items[0].text, items[3].text,
 	    strcmp(oldtype, items[0].text) != 0);
 
 	for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++)
@@ -400,8 +411,8 @@ editpart:
 }
 
 static void
-set_part_metadata(const char *name, const char *type, const char *mountpoint,
-    int newfs)
+set_part_metadata(const char *name, const char *scheme, const char *type,
+    const char *mountpoint, int newfs)
 {
 	struct partition_metadata *md;
 
@@ -424,6 +435,10 @@ set_part_metadata(const char *name, cons
 		mountpoint = "none";
 	if (strcmp(type, "freebsd-boot") == 0)
 		md->bootcode = 1;
+
+	/* VTOC8 needs partcode in UFS partitions */
+	if (strcmp(scheme, "VTOC8") == 0 && strcmp(type, "freebsd-ufs") == 0)
+		md->bootcode = 1;
 	
 	if (mountpoint != NULL && mountpoint[0] != '\0') {
 		if (md->fstab == NULL) {
@@ -571,7 +586,7 @@ gpart_create(struct gprovider *pp)
 	items[1].text = sizestr;
 
 	/* Special-case the MBR default type for nested partitions */
-	if (strcmp(scheme, "MBR") == 0)
+	if (strcmp(scheme, "MBR") == 0 || strcmp(scheme, "PC98") == 0)
 		items[0].text = "freebsd";
 
 addpartform:
@@ -602,8 +617,11 @@ addpartform:
 			goto addpartform;
 	}
 
-	/* If this is the root partition, and we need partcode, ask the user */
-	if (strcmp(items[3].text, "/") == 0 && partcode_size(scheme) > 0) {
+	/*
+	 * If this is the root partition, and we need a boot partition, ask
+	 * the user to add one.
+	 */
+	if (strcmp(items[3].text, "/") == 0 && bootpart_size(scheme) > 0) {
 		choice = dialog_yesno("Boot Partition", "This partition scheme "
 		    "requires a boot partition for the disk to be bootable. "
 		    "Would you like to make one now?", 0, 0);
@@ -616,7 +634,7 @@ addpartform:
 			gctl_ro_param(r, "verb", -1, "add");
 			gctl_ro_param(r, "type", -1, "freebsd-boot");
 			snprintf(sizestr, sizeof(sizestr), "%jd",
-			    partcode_size(scheme) / sector);
+			    bootpart_size(scheme) / sector);
 			gctl_ro_param(r, "size", -1, sizestr);
 			snprintf(startstr, sizeof(startstr), "%jd", firstfree);
 			gctl_ro_param(r, "start", -1, startstr);
@@ -629,7 +647,7 @@ addpartform:
 			get_part_metadata(strtok(output, " "), 1)->bootcode = 1;
 
 			/* Now adjust the part we are really adding forward */
-			firstfree += partcode_size(scheme) / sector;
+			firstfree += bootpart_size(scheme) / sector;
 			if (stripe > 0 && (firstfree*sector % stripe) != 0) 
 				firstfree += (stripe - ((firstfree*sector) %
 				    stripe)) / sector;
@@ -663,7 +681,7 @@ addpartform:
 	else if (strcmp(items[0].text, "freebsd") == 0)
 		gpart_partition(strtok(output, " "), "BSD");
 	else
-		set_part_metadata(strtok(output, " "), items[0].text,
+		set_part_metadata(strtok(output, " "), scheme, items[0].text,
 		    items[3].text, 1);
 
 	for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++)

Modified: user/nwhitehorn/bsdinstall/partedit/partedit.h
==============================================================================
--- user/nwhitehorn/bsdinstall/partedit/partedit.h	Sun Jan  2 03:16:07 2011	(r216883)
+++ user/nwhitehorn/bsdinstall/partedit/partedit.h	Sun Jan  2 03:16:47 2011	(r216884)
@@ -31,6 +31,6 @@ void gpart_commit(struct gmesh *mesh);
 
 /* machine-dependent bootability checks */
 int is_scheme_bootable(const char *part_type);
-size_t partcode_size(const char *part_type);
+size_t bootpart_size(const char *part_type);
 const char *bootcode_path(const char *part_type);
 const char *partcode_path(const char *part_type);

Added: user/nwhitehorn/bsdinstall/partedit/partedit_pc98.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/nwhitehorn/bsdinstall/partedit/partedit_pc98.c	Sun Jan  2 03:16:47 2011	(r216884)
@@ -0,0 +1,34 @@
+#include <string.h>
+
+#include "partedit.h"
+
+int
+is_scheme_bootable(const char *part_type) {
+	if (strcmp(part_type, "PC98") == 0)
+		return (1);
+	if (strcmp(part_type, "BSD") == 0)
+		return (1);
+
+	return (0);
+}
+
+size_t
+bootpart_size(const char *part_type) {
+	/* No boot partition */
+	return (0);
+}
+
+const char *
+bootcode_path(const char *part_type) {
+	if (strcmp(part_type, "BSD") == 0)
+		return ("/boot/boot");
+
+	return (NULL);
+}
+	
+const char *
+partcode_path(const char *part_type) {
+	/* No partcode */
+	return (NULL);
+}
+

Modified: user/nwhitehorn/bsdinstall/partedit/partedit_powerpc.c
==============================================================================
--- user/nwhitehorn/bsdinstall/partedit/partedit_powerpc.c	Sun Jan  2 03:16:07 2011	(r216883)
+++ user/nwhitehorn/bsdinstall/partedit/partedit_powerpc.c	Sun Jan  2 03:16:47 2011	(r216884)
@@ -10,7 +10,7 @@ is_scheme_bootable(const char *part_type
 }
 
 size_t
-partcode_size(const char *part_type) {
+bootpart_size(const char *part_type) {
 	if (strcmp(part_type, "APM") == 0)
 		return (800*1024);
 	return (0);

Added: user/nwhitehorn/bsdinstall/partedit/partedit_sparc64.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/nwhitehorn/bsdinstall/partedit/partedit_sparc64.c	Sun Jan  2 03:16:47 2011	(r216884)
@@ -0,0 +1,30 @@
+#include <string.h>
+
+#include "partedit.h"
+
+int
+is_scheme_bootable(const char *part_type) {
+	if (strcmp(part_type, "VTOC8") == 0)
+		return (1);
+	return (0);
+}
+
+size_t
+bootpart_size(const char *part_type) {
+	/* No standalone boot partition */
+
+	return (0);
+}
+
+const char *
+bootcode_path(const char *part_type) {
+	return (NULL);
+}
+	
+const char *
+partcode_path(const char *part_type) {
+	if (strcmp(part_type, "VTOC8") == 0)
+		return ("/boot/boot1");
+	return (NULL);
+}
+

Modified: user/nwhitehorn/bsdinstall/partedit/partedit_x86.c
==============================================================================
--- user/nwhitehorn/bsdinstall/partedit/partedit_x86.c	Sun Jan  2 03:16:07 2011	(r216883)
+++ user/nwhitehorn/bsdinstall/partedit/partedit_x86.c	Sun Jan  2 03:16:47 2011	(r216884)
@@ -15,7 +15,7 @@ is_scheme_bootable(const char *part_type
 }
 
 size_t
-partcode_size(const char *part_type) {
+bootpart_size(const char *part_type) {
 	if (strcmp(part_type, "GPT") == 0)
 		return (64*1024);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101020316.p023GlEX030915>