summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/bsdinstall/partedit/gpart_ops.c9
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit.h9
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_generic.c5
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_pc98.c5
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_powerpc.c5
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_sparc64.c5
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_x86.c64
7 files changed, 85 insertions, 17 deletions
diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c
index 289ac98..27feb57 100644
--- a/usr.sbin/bsdinstall/partedit/gpart_ops.c
+++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c
@@ -584,7 +584,7 @@ set_default_part_metadata(const char *name, const char *scheme,
if (strcmp(type, "freebsd-swap") == 0)
mountpoint = "none";
- if (strcmp(type, "freebsd-boot") == 0)
+ if (strcmp(type, bootpart_type(scheme)) == 0)
md->bootcode = 1;
/* VTOC8 needs partcode in UFS partitions */
@@ -949,7 +949,8 @@ addpartform:
LIST_FOREACH(gc, &pp->lg_config, lg_config)
if (strcmp(gc->lg_name, "type") == 0)
break;
- if (gc != NULL && strcmp(gc->lg_val, "freebsd-boot") == 0)
+ if (gc != NULL && strcmp(gc->lg_val,
+ bootpart_type(scheme)) == 0)
break;
}
@@ -971,7 +972,7 @@ addpartform:
gctl_ro_param(r, "arg0", -1, geom->lg_name);
gctl_ro_param(r, "flags", -1, GPART_FLAGS);
gctl_ro_param(r, "verb", -1, "add");
- gctl_ro_param(r, "type", -1, "freebsd-boot");
+ gctl_ro_param(r, "type", -1, bootpart_type(scheme));
snprintf(sizestr, sizeof(sizestr), "%jd",
bootpart_size(scheme) / sector);
gctl_ro_param(r, "size", -1, sizestr);
@@ -1031,7 +1032,7 @@ addpartform:
gctl_issue(r); /* Error usually expected and non-fatal */
gctl_free(r);
- if (strcmp(items[0].text, "freebsd-boot") == 0)
+ if (strcmp(items[0].text, bootpart_type(scheme)) == 0)
get_part_metadata(newpartname, 1)->bootcode = 1;
else if (strcmp(items[0].text, "freebsd") == 0)
gpart_partition(newpartname, "BSD");
diff --git a/usr.sbin/bsdinstall/partedit/partedit.h b/usr.sbin/bsdinstall/partedit/partedit.h
index 121e3a2..32e3a36 100644
--- a/usr.sbin/bsdinstall/partedit/partedit.h
+++ b/usr.sbin/bsdinstall/partedit/partedit.h
@@ -74,9 +74,10 @@ void set_default_part_metadata(const char *name, const char *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);
+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);
#endif
diff --git a/usr.sbin/bsdinstall/partedit/partedit_generic.c b/usr.sbin/bsdinstall/partedit/partedit_generic.c
index 96faafa..8498a78 100644
--- a/usr.sbin/bsdinstall/partedit/partedit_generic.c
+++ b/usr.sbin/bsdinstall/partedit/partedit_generic.c
@@ -58,6 +58,11 @@ bootpart_size(const char *part_type) {
}
const char *
+bootpart_type(const char *scheme) {
+ return ("freebsd-boot");
+}
+
+const char *
bootcode_path(const char *part_type) {
return (NULL);
}
diff --git a/usr.sbin/bsdinstall/partedit/partedit_pc98.c b/usr.sbin/bsdinstall/partedit/partedit_pc98.c
index ec438f6..dd075a1 100644
--- a/usr.sbin/bsdinstall/partedit/partedit_pc98.c
+++ b/usr.sbin/bsdinstall/partedit/partedit_pc98.c
@@ -52,6 +52,11 @@ bootpart_size(const char *part_type) {
}
const char *
+bootpart_type(const char *scheme) {
+ return ("freebsd-boot");
+}
+
+const char *
bootcode_path(const char *part_type) {
if (strcmp(part_type, "PC98") == 0)
return ("/boot/pc98boot");
diff --git a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
index 06129c7..4fa2e05 100644
--- a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
+++ b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
@@ -74,6 +74,11 @@ bootpart_size(const char *part_type) {
}
const char *
+bootpart_type(const char *scheme) {
+ return ("freebsd-boot");
+}
+
+const char *
bootcode_path(const char *part_type) {
return (NULL);
}
diff --git a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c
index b8ee052..8232c55 100644
--- a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c
+++ b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c
@@ -50,6 +50,11 @@ bootpart_size(const char *part_type) {
}
const char *
+bootpart_type(const char *scheme) {
+ return ("freebsd-boot");
+}
+
+const char *
bootcode_path(const char *part_type) {
return (NULL);
}
diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c
index a03a7a7..c9eda5d 100644
--- a/usr.sbin/bsdinstall/partedit/partedit_x86.c
+++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c
@@ -26,10 +26,15 @@
* $FreeBSD$
*/
+#include <sys/types.h>
+#include <sys/sysctl.h>
#include <string.h>
#include "partedit.h"
+static char platform[255] = "BIOS"; /* XXX once sysctl exists, make this an empty string */
+static const char *platform_sysctl = "hw.platform";
+
const char *
default_scheme(void) {
return ("GPT");
@@ -37,27 +42,60 @@ default_scheme(void) {
int
is_scheme_bootable(const char *part_type) {
- if (strcmp(part_type, "BSD") == 0)
- return (1);
+ size_t platlen = sizeof(platform);
+ if (strlen(platform) == 0)
+ sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1);
+
if (strcmp(part_type, "GPT") == 0)
return (1);
- if (strcmp(part_type, "MBR") == 0)
- return (1);
+ if (strcmp(platform, "BIOS") == 0) {
+ if (strcmp(part_type, "BSD") == 0)
+ return (1);
+ if (strcmp(part_type, "MBR") == 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) {
+ size_t platlen = sizeof(platform);
+ if (strlen(platform) == 0)
+ sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1);
/* No partcode except for GPT */
+ if (strcmp(scheme, "GPT") != 0)
+ return (0);
+
+ if (strcmp(platform, "BIOS") == 0)
+ return (64*1024);
+ else
+ return (800*1024);
+
return (0);
}
const char *
+bootpart_type(const char *scheme) {
+ size_t platlen = sizeof(platform);
+ if (strlen(platform) == 0)
+ sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1);
+
+ if (strcmp(platform, "EFI") == 0)
+ return ("efi");
+
+ return ("freebsd-boot");
+}
+
+const char *
bootcode_path(const char *part_type) {
+ size_t platlen = sizeof(platform);
+ if (strlen(platform) == 0)
+ sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1);
+ if (strcmp(platform, "EFI") == 0)
+ return (NULL);
+
if (strcmp(part_type, "GPT") == 0)
return ("/boot/pmbr");
if (strcmp(part_type, "MBR") == 0)
@@ -70,8 +108,16 @@ bootcode_path(const char *part_type) {
const char *
partcode_path(const char *part_type) {
- if (strcmp(part_type, "GPT") == 0)
- return ("/boot/gptboot");
+ size_t platlen = sizeof(platform);
+ if (strlen(platform) == 0)
+ sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1);
+
+ if (strcmp(part_type, "GPT") == 0) {
+ if (strcmp(platform, "EFI") == 0)
+ return ("/boot/boot1.efifat");
+ else
+ return ("/boot/gptboot");
+ }
/* No partcode except for GPT */
return (NULL);
OpenPOWER on IntegriCloud