[Midnightbsd-cvs] src [11303] trunk/usr.sbin/bsdinstall/partedit: update partedit

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Wed Jul 4 10:00:50 EDT 2018


Revision: 11303
          http://svnweb.midnightbsd.org/src/?rev=11303
Author:   laffer1
Date:     2018-07-04 10:00:49 -0400 (Wed, 04 Jul 2018)
Log Message:
-----------
update partedit

Modified Paths:
--------------
    trunk/usr.sbin/bsdinstall/partedit/part_wizard.c
    trunk/usr.sbin/bsdinstall/partedit/partedit.c
    trunk/usr.sbin/bsdinstall/partedit/partedit.h
    trunk/usr.sbin/bsdinstall/partedit/partedit_generic.c
    trunk/usr.sbin/bsdinstall/partedit/partedit_sparc64.c
    trunk/usr.sbin/bsdinstall/partedit/partedit_x86.c

Added Paths:
-----------
    trunk/usr.sbin/bsdinstall/partedit/partedit_pc98.c
    trunk/usr.sbin/bsdinstall/partedit/partedit_powerpc.c

Modified: trunk/usr.sbin/bsdinstall/partedit/part_wizard.c
===================================================================
--- trunk/usr.sbin/bsdinstall/partedit/part_wizard.c	2018-07-04 13:56:15 UTC (rev 11302)
+++ trunk/usr.sbin/bsdinstall/partedit/part_wizard.c	2018-07-04 14:00:49 UTC (rev 11303)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 Nathan Whitehorn
  * All rights reserved.
@@ -23,14 +24,15 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
- * $FreeBSD: src/usr.sbin/bsdinstall/partedit/part_wizard.c,v 1.6 2011/10/07 01:40:30 nwhitehorn Exp $
+ * $FreeBSD: stable/10/usr.sbin/bsdinstall/partedit/part_wizard.c 321166 2017-07-18 18:54:47Z ngie $
  */
 
 #include <sys/param.h>
+#include <sys/sysctl.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <libutil.h>
-#include <inttypes.h>
+#include <string.h>
 
 #include <libgeom.h>
 #include <dialog.h>
@@ -45,11 +47,18 @@
 static char *wizard_partition(struct gmesh *mesh, const char *disk);
 
 int
-part_wizard(void) {
+part_wizard(const char *fsreq)
+{
+	char *disk, *schemeroot;
+	const char *fstype;
+	struct gmesh mesh;
 	int error;
-	struct gmesh mesh;
-	char *disk, *schemeroot;
 
+	if (fsreq != NULL)
+		fstype = fsreq;
+	else
+		fstype = "ufs";
+
 startwizard:
 	error = geom_gettree(&mesh);
 
@@ -71,11 +80,11 @@
 	dlg_put_backtitle();
 	error = geom_gettree(&mesh);
 
-	error = wizard_makeparts(&mesh, schemeroot, 1);
+	error = wizard_makeparts(&mesh, schemeroot, fstype, 1);
 	if (error)
 		goto startwizard;
 	free(schemeroot);
-	
+
 	geom_deletetree(&mesh);
 
 	return (0);
@@ -107,9 +116,9 @@
 			LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
 				desc = type = NULL;
 				LIST_FOREACH(gc, &pp->lg_config, lg_config) {
-					if (strcmp(gc->lg_name, "type") == 0) 
+					if (strcmp(gc->lg_name, "type") == 0)
 						type = gc->lg_val;
-					if (strcmp(gc->lg_name, "descr") == 0) 
+					if (strcmp(gc->lg_name, "descr") == 0)
 						desc = gc->lg_val;
 				}
 
@@ -191,9 +200,9 @@
 	struct gclass *classp;
 	struct ggeom *gpart = NULL;
 	struct gconfig *gc;
+	char *retval = NULL;
+	const char *scheme = NULL;
 	char message[512];
-	const char *scheme = NULL;
-	char *retval = NULL;
 	int choice;
 
 	LIST_FOREACH(classp, &mesh->lg_class, lg_class)
@@ -201,7 +210,7 @@
 			break;
 
 	if (classp != NULL) {
-		LIST_FOREACH(gpart, &classp->lg_geom, lg_geom) 
+		LIST_FOREACH(gpart, &classp->lg_geom, lg_geom)
 			if (strcmp(gpart->lg_name, disk) == 0)
 				break;
 	}
@@ -249,8 +258,10 @@
 			goto query;
 
 		gpart_destroy(gpart);
-		gpart_partition(disk, default_scheme());
-		scheme = default_scheme();
+		scheme = choose_part_type(default_scheme());
+		if (scheme == NULL)
+			return NULL;
+		gpart_partition(disk, scheme);
 	}
 
 	if (scheme == NULL || choice == 0) {
@@ -264,11 +275,13 @@
 			gpart_destroy(gpart);
 		}
 
-		gpart_partition(disk, default_scheme());
-		scheme = default_scheme();
+		scheme = choose_part_type(default_scheme());
+		if (scheme == NULL)
+			return NULL;
+		gpart_partition(disk, scheme);
 	}
 
-	if (strcmp(scheme, "MBR") == 0) {
+	if (strcmp(scheme, "PC98") == 0 || strcmp(scheme, "MBR") == 0) {
 		struct gmesh submesh;
 		geom_gettree(&submesh);
 		gpart_create(provider_for_name(&submesh, disk),
@@ -283,21 +296,31 @@
 }
 
 int
-wizard_makeparts(struct gmesh *mesh, const char *disk, int interactive)
+wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype,
+    int interactive)
 {
-	struct gmesh submesh;
 	struct gclass *classp;
 	struct ggeom *gp;
 	struct gprovider *pp;
+	char *fsnames[] = {"mnbsd-ufs", "mnbsd-zfs"};
+	char *fsname;
+	struct gmesh submesh;
+	char swapsizestr[10], rootsizestr[10];
 	intmax_t swapsize, available;
-	char swapsizestr[10], rootsizestr[10];
 	int retval;
 
+	if (strcmp(fstype, "zfs") == 0) {
+		fsname = fsnames[1];
+	} else {
+		/* default to UFS */
+		fsname = fsnames[0];
+	}
+
 	LIST_FOREACH(classp, &mesh->lg_class, lg_class)
 		if (strcmp(classp->lg_name, "PART") == 0)
 			break;
 
-	LIST_FOREACH(gp, &classp->lg_geom, lg_geom) 
+	LIST_FOREACH(gp, &classp->lg_geom, lg_geom)
 		if (strcmp(gp->lg_name, disk) == 0)
 			break;
 
@@ -332,7 +355,7 @@
 
 	geom_gettree(&submesh);
 	pp = provider_for_name(&submesh, disk);
-	gpart_create(pp, "mnbsd-ufs", rootsizestr, "/", NULL, 0);
+	gpart_create(pp, fsname, rootsizestr, "/", NULL, 0);
 	geom_deletetree(&submesh);
 
 	geom_gettree(&submesh);
@@ -342,4 +365,3 @@
 
 	return (0);
 }
-

Modified: trunk/usr.sbin/bsdinstall/partedit/partedit.c
===================================================================
--- trunk/usr.sbin/bsdinstall/partedit/partedit.c	2018-07-04 13:56:15 UTC (rev 11302)
+++ trunk/usr.sbin/bsdinstall/partedit/partedit.c	2018-07-04 14:00:49 UTC (rev 11303)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 Nathan Whitehorn
  * All rights reserved.
@@ -23,8 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
- * $FreeBSD: src/usr.sbin/bsdinstall/partedit/partedit.c,v 1.5 2011/10/25 16:30:16 nwhitehorn Exp $
+ * $FreeBSD: stable/10/usr.sbin/bsdinstall/partedit/partedit.c 285769 2015-07-21 21:12:28Z allanjude $
  */
 
 #include <sys/param.h>
@@ -45,6 +45,7 @@
 static int sade_mode = 0;
 
 static int apply_changes(struct gmesh *mesh);
+static void apply_workaround(struct gmesh *mesh);
 static struct partedit_item *read_geom_mesh(struct gmesh *mesh, int *nitems);
 static void add_geom_children(struct ggeom *gp, int recurse,
     struct partedit_item **items, int *nitems);
@@ -96,7 +97,12 @@
 	if (strcmp(basename(argv[0]), "autopart") == 0) { /* Guided */
 		prompt = "Please review the disk setup. When complete, press "
 		    "the Finish button.";
-		part_wizard();
+		/* Experimental ZFS autopartition support */
+		if (argc > 1 && strcmp(argv[1], "zfs") == 0) {
+			part_wizard("zfs");
+		} else {
+			part_wizard("ufs");
+		}
 	} else if (strcmp(basename(argv[0]), "scriptedpart") == 0) {
 		error = scripted_editor(argc, argv);
 		prompt = NULL;
@@ -163,7 +169,7 @@
 			init_fstab_metadata();
 			break;
 		case 4: /* Auto */
-			part_wizard();
+			part_wizard("ufs");
 			break;
 		}
 
@@ -185,6 +191,8 @@
 
 			if (op == 0 && validate_setup()) { /* Save */
 				error = apply_changes(&mesh);
+				if (!error)
+					apply_workaround(&mesh);
 				break;
 			} else if (op == 3) { /* Quit */
 				gpart_revert_all(&mesh);
@@ -286,7 +294,7 @@
 		dialog_vars.defaultno = TRUE;
 		cancel = dialog_yesno("Warning", "The chosen root partition "
 		    "has a preexisting filesystem. If it contains an existing "
-		    "BSD system, please update it manually "
+		    "MidnightBSD system, please update it with midnightbsd-update "
 		    "instead of installing a new system on it. The partition "
 		    "can also be erased by pressing \"No\" and then deleting "
 		    "and recreating it. Are you sure you want to proceed?",
@@ -386,6 +394,43 @@
 	return (0);
 }
 
+static void
+apply_workaround(struct gmesh *mesh)
+{
+	struct gclass *classp;
+	struct ggeom *gp;
+	struct gconfig *gc;
+	const char *scheme = NULL, *modified = NULL;
+
+	LIST_FOREACH(classp, &mesh->lg_class, lg_class) {
+		if (strcmp(classp->lg_name, "PART") == 0)
+			break;
+	}
+
+	if (strcmp(classp->lg_name, "PART") != 0) {
+		dialog_msgbox("Error", "gpart not found!", 0, 0, TRUE);
+		return;
+	}
+
+	LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
+		LIST_FOREACH(gc, &gp->lg_config, lg_config) {
+			if (strcmp(gc->lg_name, "scheme") == 0) {
+				scheme = gc->lg_val;
+			} else if (strcmp(gc->lg_name, "modified") == 0) {
+				modified = gc->lg_val;
+			}
+		}
+
+		if (scheme && strcmp(scheme, "GPT") == 0 &&
+		    modified && strcmp(modified, "true") == 0) {
+			if (getenv("WORKAROUND_LENOVO"))
+				gpart_set_root(gp->lg_name, "lenovofix");
+			if (getenv("WORKAROUND_GPTACTIVE"))
+				gpart_set_root(gp->lg_name, "active");
+		}
+	}
+}
+
 static struct partedit_item *
 read_geom_mesh(struct gmesh *mesh, int *nitems)
 {

Modified: trunk/usr.sbin/bsdinstall/partedit/partedit.h
===================================================================
--- trunk/usr.sbin/bsdinstall/partedit/partedit.h	2018-07-04 13:56:15 UTC (rev 11302)
+++ trunk/usr.sbin/bsdinstall/partedit/partedit.h	2018-07-04 14:00:49 UTC (rev 11303)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 Nathan Whitehorn
  * All rights reserved.
@@ -23,8 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
- * $FreeBSD: src/usr.sbin/bsdinstall/partedit/partedit.h,v 1.3 2011/10/07 01:40:30 nwhitehorn Exp $
+ * $FreeBSD: stable/10/usr.sbin/bsdinstall/partedit/partedit.h 285769 2015-07-21 21:12:28Z allanjude $
  */
 
 #ifndef _PARTEDIT_PARTEDIT_H
@@ -55,9 +55,10 @@
 struct partition_metadata *get_part_metadata(const char *name, int create);
 void delete_part_metadata(const char *name);
 
-int part_wizard(void);
+int part_wizard(const char *fstype);
 int scripted_editor(int argc, const char **argv);
-int wizard_makeparts(struct gmesh *mesh, const char *disk, int interactive);
+int wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype,
+    int interactive);
 
 /* gpart operations */
 void gpart_delete(struct gprovider *pp);
@@ -72,12 +73,16 @@
 int gpart_partition(const char *lg_name, const char *scheme);
 void set_default_part_metadata(const char *name, const char *scheme,
     const char *type, const char *mountpoint, const char *newfs);
+void gpart_set_root(const char *lg_name, const char *attribute);
+const char *choose_part_type(const char *def_scheme);
 
 /* machine-dependent bootability checks */
 const char *default_scheme(void);
-int is_scheme_bootable(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);
+int is_scheme_bootable(const char *scheme);
+int is_fs_bootable(const char *scheme, const char *fs);
+size_t bootpart_size(const char *scheme);
+const char *bootpart_type(const char *scheme);
+const char *bootcode_path(const char *scheme);
+const char *partcode_path(const char *scheme, const char *fs_type);
 
 #endif

Modified: trunk/usr.sbin/bsdinstall/partedit/partedit_generic.c
===================================================================
--- trunk/usr.sbin/bsdinstall/partedit/partedit_generic.c	2018-07-04 13:56:15 UTC (rev 11302)
+++ trunk/usr.sbin/bsdinstall/partedit/partedit_generic.c	2018-07-04 14:00:49 UTC (rev 11303)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 Nathan Whitehorn
  * All rights reserved.
@@ -23,8 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
- * $FreeBSD: src/usr.sbin/bsdinstall/partedit/partedit_generic.c,v 1.1 2011/02/18 14:54:34 nwhitehorn Exp $
+ * $FreeBSD: stable/10/usr.sbin/bsdinstall/partedit/partedit_generic.c 273831 2014-10-29 16:48:18Z nwhitehorn $
  */
 
 #include <string.h>
@@ -51,6 +51,11 @@
 	return (1);
 }
 
+int
+is_fs_bootable(const char *part_type, const char *fs) {
+	return (1);
+}
+
 /* No clue => no boot partition, bootcode, or partcode */
 
 size_t
@@ -59,12 +64,17 @@
 }
 
 const char *
+bootpart_type(const char *scheme) {
+	return ("mnbsd-boot");
+}
+
+const char *
 bootcode_path(const char *part_type) {
 	return (NULL);
 }
 	
 const char *
-partcode_path(const char *part_type) {
+partcode_path(const char *part_type, const char *fs_type) {
 	return (NULL);
 }
 

Added: trunk/usr.sbin/bsdinstall/partedit/partedit_pc98.c
===================================================================
--- trunk/usr.sbin/bsdinstall/partedit/partedit_pc98.c	                        (rev 0)
+++ trunk/usr.sbin/bsdinstall/partedit/partedit_pc98.c	2018-07-04 14:00:49 UTC (rev 11303)
@@ -0,0 +1,84 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: stable/10/usr.sbin/bsdinstall/partedit/partedit_pc98.c 273831 2014-10-29 16:48:18Z nwhitehorn $
+ */
+
+#include <string.h>
+
+#include "partedit.h"
+
+const char *
+default_scheme(void) {
+	return ("PC98");
+}
+
+int
+is_scheme_bootable(const char *part_type) {
+	if (strcmp(part_type, "BSD") == 0)
+		return (1);
+	if (strcmp(part_type, "PC98") == 0)
+		return (1);
+
+	return (0);
+}
+
+int
+is_fs_bootable(const char *part_type, const char *fs)
+{
+	if (strcmp(fs, "mnbsd-ufs") == 0)
+		return (1);
+	
+	return (0);
+}
+
+size_t
+bootpart_size(const char *part_type) {
+	/* No boot partition */
+	return (0);
+}
+
+const char *
+bootpart_type(const char *scheme) {
+	return ("mnbsd-boot");
+}
+
+const char *
+bootcode_path(const char *part_type) {
+	if (strcmp(part_type, "PC98") == 0)
+		return ("/boot/pc98boot");
+	if (strcmp(part_type, "BSD") == 0)
+		return ("/boot/boot");
+
+	return (NULL);
+}
+	
+const char *
+partcode_path(const char *part_type, const char *fs_type) {
+	/* No partcode */
+	return (NULL);
+}
+


Property changes on: trunk/usr.sbin/bsdinstall/partedit/partedit_pc98.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
===================================================================
--- trunk/usr.sbin/bsdinstall/partedit/partedit_powerpc.c	                        (rev 0)
+++ trunk/usr.sbin/bsdinstall/partedit/partedit_powerpc.c	2018-07-04 14:00:49 UTC (rev 11303)
@@ -0,0 +1,125 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: stable/10/usr.sbin/bsdinstall/partedit/partedit_powerpc.c 273831 2014-10-29 16:48:18Z nwhitehorn $
+ */
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <string.h>
+
+#include "partedit.h"
+
+static char platform[255] = "";
+
+const char *
+default_scheme(void) {
+	size_t platlen = sizeof(platform);
+	if (strlen(platform) == 0)
+		sysctlbyname("hw.platform", platform, &platlen, NULL, -1);
+
+	if (strcmp(platform, "powermac") == 0)
+		return ("APM");
+	if (strcmp(platform, "chrp") == 0)
+		return ("MBR");
+
+	/* Pick GPT (bootable on PS3) as a generic default */
+	return ("GPT");
+}
+
+int
+is_scheme_bootable(const char *part_type) {
+	size_t platlen = sizeof(platform);
+	if (strlen(platform) == 0)
+		sysctlbyname("hw.platform", platform, &platlen, NULL, -1);
+
+	if (strcmp(platform, "powermac") == 0 && strcmp(part_type, "APM") == 0)
+		return (1);
+	if (strcmp(platform, "ps3") == 0 && strcmp(part_type, "GPT") == 0)
+		return (1);
+	if (strcmp(platform, "chrp") == 0 &&
+	    (strcmp(part_type, "MBR") == 0 || strcmp(part_type, "BSD") == 0 ||
+	     strcmp(part_type, "GPT") == 0))
+		return (1);
+
+	return (0);
+}
+
+int
+is_fs_bootable(const char *part_type, const char *fs)
+{
+	if (strcmp(fs, "mnbsd-ufs") == 0)
+		return (1);
+	
+	return (0);
+}
+
+size_t
+bootpart_size(const char *part_type) {
+	size_t platlen = sizeof(platform);
+	if (strlen(platform) == 0)
+		sysctlbyname("hw.platform", platform, &platlen, NULL, -1);
+
+	if (strcmp(part_type, "APM") == 0 || strcmp(part_type, "MBR") == 0)
+		return (800*1024);
+	if (strcmp(platform, "chrp") == 0 && strcmp(part_type, "GPT") == 0)
+		return (800*1024);
+	return (0);
+}
+
+const char *
+bootpart_type(const char *scheme) {
+	size_t platlen = sizeof(platform);
+	if (strlen(platform) == 0)
+		sysctlbyname("hw.platform", platform, &platlen, NULL, -1);
+
+	if (strcmp(platform, "chrp") == 0)
+		return ("prep-boot");
+	if (strcmp(platform, "powermac") == 0)
+		return ("apple-boot");
+
+	return ("mnbsd-boot");
+}
+
+const char *
+bootcode_path(const char *part_type) {
+	return (NULL);
+}
+	
+const char *
+partcode_path(const char *part_type, const char *fs_type) {
+	size_t platlen = sizeof(platform);
+	if (strlen(platform) == 0)
+		sysctlbyname("hw.platform", platform, &platlen, NULL, -1);
+
+	if (strcmp(part_type, "APM") == 0)
+		return ("/boot/boot1.hfs");
+	if (strcmp(part_type, "MBR") == 0 ||
+	    (strcmp(platform, "chrp") == 0 && strcmp(part_type, "GPT") == 0))
+		return ("/boot/boot1.elf");
+	return (NULL);
+}
+


Property changes on: trunk/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/usr.sbin/bsdinstall/partedit/partedit_sparc64.c
===================================================================
--- trunk/usr.sbin/bsdinstall/partedit/partedit_sparc64.c	2018-07-04 13:56:15 UTC (rev 11302)
+++ trunk/usr.sbin/bsdinstall/partedit/partedit_sparc64.c	2018-07-04 14:00:49 UTC (rev 11303)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 Nathan Whitehorn
  * All rights reserved.
@@ -23,8 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
- * $FreeBSD: src/usr.sbin/bsdinstall/partedit/partedit_sparc64.c,v 1.1 2011/02/18 14:54:34 nwhitehorn Exp $
+ * $FreeBSD: stable/10/usr.sbin/bsdinstall/partedit/partedit_sparc64.c 273831 2014-10-29 16:48:18Z nwhitehorn $
  */
 
 #include <string.h>
@@ -43,6 +43,15 @@
 	return (0);
 }
 
+int
+is_fs_bootable(const char *part_type, const char *fs)
+{
+	if (strcmp(fs, "mnbsd-ufs") == 0 || strcmp(fs, "mnbsd-zfs") == 0)
+		return (1);
+	return (0);
+}
+
+
 size_t
 bootpart_size(const char *part_type) {
 	/* No standalone boot partition */
@@ -51,14 +60,24 @@
 }
 
 const char *
+bootpart_type(const char *scheme) {
+	return ("mnbsd-boot");
+}
+
+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");
+partcode_path(const char *part_type, const char *fs_type) {
+	if (strcmp(part_type, "VTOC8") == 0) {
+		if (strcmp(fs_type, "ufs") == 0) {
+			return ("/boot/boot1");
+		} else if (strcmp(fs_type, "zfs") == 0) {
+			return ("/boot/zfsboot");
+		}
+	}
 	return (NULL);
 }
 

Modified: trunk/usr.sbin/bsdinstall/partedit/partedit_x86.c
===================================================================
--- trunk/usr.sbin/bsdinstall/partedit/partedit_x86.c	2018-07-04 13:56:15 UTC (rev 11302)
+++ trunk/usr.sbin/bsdinstall/partedit/partedit_x86.c	2018-07-04 14:00:49 UTC (rev 11303)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 Nathan Whitehorn
  * All rights reserved.
@@ -23,42 +24,105 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
- * $FreeBSD: src/usr.sbin/bsdinstall/partedit/partedit_x86.c,v 1.1 2011/02/18 14:54:34 nwhitehorn Exp $
+ * $FreeBSD: stable/10/usr.sbin/bsdinstall/partedit/partedit_x86.c 321202 2017-07-19 14:15:49Z emaste $
  */
 
+#include <sys/types.h>
+#include <sys/sysctl.h>
 #include <string.h>
 
 #include "partedit.h"
 
+/* EFI partition size in bytes */
+#define	EFI_BOOTPART_SIZE	(200 * 1024 * 1024)
+#define	EFI_BOOTPART_PATH	"/boot/boot1.efifat"
+
+static const char *
+x86_bootmethod(void)
+{
+	static char fw[255] = "";
+	size_t len = sizeof(fw);
+	int error;
+	
+	if (strlen(fw) == 0) {
+		error = sysctlbyname("machdep.bootmethod", fw, &len, NULL, -1);
+		if (error != 0)
+			return ("BIOS");
+	}
+
+	return (fw);
+}
+
 const char *
-default_scheme(void) {
+default_scheme(void)
+{
 	return ("GPT");
 }
 
 int
-is_scheme_bootable(const char *part_type) {
-	if (strcmp(part_type, "BSD") == 0)
-		return (1);
+is_scheme_bootable(const char *part_type)
+{
+
 	if (strcmp(part_type, "GPT") == 0)
 		return (1);
-	if (strcmp(part_type, "MBR") == 0)
+	if (strcmp(x86_bootmethod(), "BIOS") == 0) {
+		if (strcmp(part_type, "BSD") == 0)
+			return (1);
+		if (strcmp(part_type, "MBR") == 0)
+			return (1);
+	}
+
+	return (0);
+}
+
+int
+is_fs_bootable(const char *part_type, const char *fs)
+{
+
+	if (strcmp(fs, "mnbsd-ufs") == 0)
 		return (1);
 
+	if (strcmp(fs, "mnbsd-zfs") == 0 &&
+	    strcmp(part_type, "GPT") == 0 &&
+	    strcmp(x86_bootmethod(), "BIOS") == 0)
+		return (1);
+
 	return (0);
 }
 
 size_t
-bootpart_size(const char *part_type) {
-	if (strcmp(part_type, "GPT") == 0)
-		return (64*1024);
+bootpart_size(const char *scheme)
+{
 
 	/* No partcode except for GPT */
+	if (strcmp(scheme, "GPT") != 0)
+		return (0);
+
+	if (strcmp(x86_bootmethod(), "BIOS") == 0)
+		return (512*1024);
+	else 
+		return (EFI_BOOTPART_SIZE);
+
 	return (0);
 }
 
 const char *
-bootcode_path(const char *part_type) {
+bootpart_type(const char *scheme)
+{
+
+	if (strcmp(x86_bootmethod(), "UEFI") == 0)
+		return ("efi");
+
+	return ("mnbsd-boot");
+}
+
+const char *
+bootcode_path(const char *part_type)
+{
+
+	if (strcmp(x86_bootmethod(), "UEFI") == 0)
+		return (NULL);
+
 	if (strcmp(part_type, "GPT") == 0)
 		return ("/boot/pmbr");
 	if (strcmp(part_type, "MBR") == 0)
@@ -70,9 +134,17 @@
 }
 	
 const char *
-partcode_path(const char *part_type) {
-	if (strcmp(part_type, "GPT") == 0)
-		return ("/boot/gptboot");
+partcode_path(const char *part_type, const char *fs_type)
+{
+
+	if (strcmp(part_type, "GPT") == 0) {
+		if (strcmp(x86_bootmethod(), "UEFI") == 0)
+			return (EFI_BOOTPART_PATH);
+		else if (strcmp(fs_type, "zfs") == 0)
+			return ("/boot/gptzfsboot");
+		else
+			return ("/boot/gptboot");
+	}
 	
 	/* No partcode except for GPT */
 	return (NULL);



More information about the Midnightbsd-cvs mailing list