Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161022095
D6232.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D6232.diff
View Options
Index: usr.sbin/bsdinstall/partedit/gpart_ops.c
===================================================================
--- usr.sbin/bsdinstall/partedit/gpart_ops.c
+++ usr.sbin/bsdinstall/partedit/gpart_ops.c
@@ -38,8 +38,6 @@
#include "partedit.h"
-#define GPART_FLAGS "x" /* Do not commit changes by default */
-
static void
gpart_show_error(const char *title, const char *explanation, const char *errstr)
{
@@ -430,10 +428,10 @@
gpart_partcode(struct gprovider *pp, const char *fstype)
{
struct gconfig *gc;
- const char *scheme;
- const char *indexstr;
+ const char *scheme, *indexstr, *typestr;
char message[255], command[255];
+ typestr = NULL;
LIST_FOREACH(gc, &pp->lg_geom->lg_config, lg_config) {
if (strcmp(gc->lg_name, "scheme") == 0) {
scheme = gc->lg_val;
@@ -441,20 +439,23 @@
}
}
- /* Make sure this partition scheme needs partcode on this platform */
- if (partcode_path(scheme, fstype) == NULL)
- return;
-
LIST_FOREACH(gc, &pp->lg_config, lg_config) {
if (strcmp(gc->lg_name, "index") == 0) {
indexstr = gc->lg_val;
- break;
+ }
+ if (strcmp(gc->lg_name, "type") == 0) {
+ typestr = gc->lg_val;
}
}
+ /* Make sure this partition scheme needs partcode on this platform */
+ if (partcode_path(scheme, fstype, typestr) == NULL)
+ return;
+
/* Shell out to gpart for partcode for now */
sprintf(command, "gpart bootcode -p %s -i %s %s",
- partcode_path(scheme, fstype), indexstr, pp->lg_geom->lg_name);
+ partcode_path(scheme, fstype, typestr),
+ indexstr, pp->lg_geom->lg_name);
if (system(command) != 0) {
sprintf(message, "Error installing partcode on partition %s",
pp->lg_name);
Index: usr.sbin/bsdinstall/partedit/part_wizard.c
===================================================================
--- usr.sbin/bsdinstall/partedit/part_wizard.c
+++ usr.sbin/bsdinstall/partedit/part_wizard.c
@@ -301,7 +301,9 @@
struct gclass *classp;
struct ggeom *gp;
struct gprovider *pp;
- intmax_t swapsize, available;
+ struct gconfig *gc;
+ intmax_t swapsize, available, start;
+ const char *scheme;
char swapsizestr[10], rootsizestr[10], *fsname;
char *fsnames[] = {"freebsd-ufs", "freebsd-zfs"};
int retval;
@@ -321,6 +323,24 @@
if (strcmp(gp->lg_name, disk) == 0)
break;
+ /* Now get the partition scheme */
+ scheme = NULL;
+ LIST_FOREACH(gc, &gp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "scheme") == 0) {
+ scheme = gc->lg_val;
+ break;
+ }
+ }
+
+ /* Now get the first available sector */
+ start = 0;
+ LIST_FOREACH(gc, &gp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "first") == 0) {
+ start = strtoimax(gc->lg_val, NULL, 0);
+ break;
+ }
+ }
+
pp = provider_for_name(mesh, disk);
available = gpart_max_free(gp, NULL)*pp->lg_sectorsize;
@@ -347,18 +367,32 @@
swapsize = SWAP_SIZE(available);
humanize_number(swapsizestr, 7, swapsize, "B", HN_AUTOSCALE,
HN_NOSPACE | HN_DECIMAL);
- humanize_number(rootsizestr, 7, available - swapsize - 1024*1024,
+ humanize_number(rootsizestr, 7, available - swapsize - 2048*1024,
"B", HN_AUTOSCALE, HN_NOSPACE | HN_DECIMAL);
- geom_gettree(&submesh);
- pp = provider_for_name(&submesh, disk);
- gpart_create(pp, fsname, rootsizestr, "/", NULL, 0);
- geom_deletetree(&submesh);
-
- geom_gettree(&submesh);
- pp = provider_for_name(&submesh, disk);
- gpart_create(pp, "freebsd-swap", swapsizestr, NULL, NULL, 0);
- geom_deletetree(&submesh);
+ if (scheme != NULL && strcmp(scheme, "GPT") == 0) {
+ create_bootpart(gp, scheme, start, pp->lg_sectorsize);
+
+ geom_gettree(&submesh);
+ pp = provider_for_name(&submesh, disk);
+ gpart_create(pp, "freebsd-swap", swapsizestr, NULL, NULL, 0);
+ geom_deletetree(&submesh);
+
+ geom_gettree(&submesh);
+ pp = provider_for_name(&submesh, disk);
+ gpart_create(pp, fsname, rootsizestr, "/", NULL, 0);
+ geom_deletetree(&submesh);
+ } else {
+ geom_gettree(&submesh);
+ pp = provider_for_name(&submesh, disk);
+ gpart_create(pp, fsname, rootsizestr, "/", NULL, 0);
+ geom_deletetree(&submesh);
+
+ geom_gettree(&submesh);
+ pp = provider_for_name(&submesh, disk);
+ gpart_create(pp, "freebsd-swap", swapsizestr, NULL, NULL, 0);
+ geom_deletetree(&submesh);
+ }
return (0);
}
Index: usr.sbin/bsdinstall/partedit/partedit.h
===================================================================
--- usr.sbin/bsdinstall/partedit/partedit.h
+++ usr.sbin/bsdinstall/partedit/partedit.h
@@ -32,6 +32,9 @@
#include <sys/queue.h>
#include <inttypes.h>
#include <fstab.h>
+#include <stdio.h>
+
+#define GPART_FLAGS "x" /* Do not commit changes by default */
struct gprovider;
struct gmesh;
@@ -82,6 +85,9 @@
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);
+const char *partcode_path(const char *scheme, const char *fs_type,
+ const char *part_type);
+intmax_t create_bootpart(struct ggeom *geom, const char *scheme, intmax_t start,
+ intmax_t sector);
#endif
Index: usr.sbin/bsdinstall/partedit/partedit_generic.c
===================================================================
--- usr.sbin/bsdinstall/partedit/partedit_generic.c
+++ usr.sbin/bsdinstall/partedit/partedit_generic.c
@@ -73,7 +73,12 @@
}
const char *
-partcode_path(const char *part_type, const char *fs_type) {
+partcode_path(const char *scheme, const char *fs_type, const char *part_type) {
return (NULL);
}
+intmax_t
+create_bootpart(struct ggeom *geom, const char *scheme) {
+
+ return (0);
+}
Index: usr.sbin/bsdinstall/partedit/partedit_pc98.c
===================================================================
--- usr.sbin/bsdinstall/partedit/partedit_pc98.c
+++ usr.sbin/bsdinstall/partedit/partedit_pc98.c
@@ -76,8 +76,13 @@
}
const char *
-partcode_path(const char *part_type, const char *fs_type) {
+partcode_path(const char *scheme, const char *fs_type, const char *part_type) {
/* No partcode */
return (NULL);
}
+intmax_t
+create_bootpart(struct ggeom *geom, const char *scheme) {
+
+ return (0);
+}
Index: usr.sbin/bsdinstall/partedit/partedit_powerpc.c
===================================================================
--- usr.sbin/bsdinstall/partedit/partedit_powerpc.c
+++ usr.sbin/bsdinstall/partedit/partedit_powerpc.c
@@ -109,16 +109,22 @@
}
const char *
-partcode_path(const char *part_type, const char *fs_type) {
+partcode_path(const char *scheme, const char *fs_type, 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)
+ if (strcmp(scheme, "APM") == 0)
return ("/boot/boot1.hfs");
- if (strcmp(part_type, "MBR") == 0 ||
- (strcmp(platform, "chrp") == 0 && strcmp(part_type, "GPT") == 0))
+ if (strcmp(scheme, "MBR") == 0 ||
+ (strcmp(platform, "chrp") == 0 && strcmp(scheme, "GPT") == 0))
return ("/boot/boot1.elf");
return (NULL);
}
+intmax_t
+create_bootpart(struct ggeom *geom, const char *scheme, intmax_t start,
+ intmax_t sector) {
+
+ return (0);
+}
Index: usr.sbin/bsdinstall/partedit/partedit_sparc64.c
===================================================================
--- usr.sbin/bsdinstall/partedit/partedit_sparc64.c
+++ usr.sbin/bsdinstall/partedit/partedit_sparc64.c
@@ -69,8 +69,8 @@
}
const char *
-partcode_path(const char *part_type, const char *fs_type) {
- if (strcmp(part_type, "VTOC8") == 0) {
+partcode_path(const char *scheme, const char *fs_type, const char *part_type) {
+ if (strcmp(scheme, "VTOC8") == 0) {
if (strcmp(fs_type, "ufs") == 0) {
return ("/boot/boot1");
} else if (strcmp(fs_type, "zfs") == 0) {
@@ -80,3 +80,8 @@
return (NULL);
}
+intmax_t
+create_bootpart(struct ggeom *geom, const char *scheme) {
+
+ return (0);
+}
Index: usr.sbin/bsdinstall/partedit/partedit_x86.c
===================================================================
--- usr.sbin/bsdinstall/partedit/partedit_x86.c
+++ usr.sbin/bsdinstall/partedit/partedit_x86.c
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#include <string.h>
+#include <libgeom.h>
#include "partedit.h"
@@ -118,9 +119,6 @@
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)
@@ -130,13 +128,13 @@
return (NULL);
}
-
+
const char *
-partcode_path(const char *part_type, const char *fs_type)
+partcode_path(const char *scheme, const char *fs_type, const char *part_type)
{
- if (strcmp(part_type, "GPT") == 0) {
- if (strcmp(x86_bootmethod(), "UEFI") == 0)
+ if (strcmp(scheme, "GPT") == 0) {
+ if (part_type != NULL && strcmp(part_type, "efi") == 0)
return ("/boot/boot1.efifat");
else if (strcmp(fs_type, "zfs") == 0)
return ("/boot/gptzfsboot");
@@ -148,3 +146,70 @@
return (NULL);
}
+intmax_t
+create_bootpart(struct ggeom *geom, const char *scheme, intmax_t start,
+ intmax_t sector) {
+ struct gctl_req *r;
+ const char *errstr;
+ char sizestr[32], startstr[32], output[64];
+ intmax_t size, totalsize;
+ int err;
+
+ err = 0;
+ totalsize = 0;
+
+ /* Create the EFI boot partition */
+ size = 800*1024 / sector;
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ 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, "efi");
+ snprintf(sizestr, sizeof(sizestr), "%jd", size);
+ gctl_ro_param(r, "size", -1, sizestr);
+ snprintf(startstr, sizeof(startstr), "%jd", start);
+ gctl_ro_param(r, "start", -1, startstr);
+ gctl_rw_param(r, "output", sizeof(output), output);
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0') {
+ printf("Error: %s\n", errstr);
+ err = 1;
+ }
+ gctl_free(r);
+ totalsize += size;
+ start += size;
+
+ if (err > 0) {
+ return (0); /* XXX need error handlingg */
+ }
+
+ /* Create the GPT (BIOS) boot partition */
+ size = 512*1024 / sector;
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ 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");
+ snprintf(sizestr, sizeof(sizestr), "%jd", size);
+ gctl_ro_param(r, "size", -1, sizestr);
+ snprintf(startstr, sizeof(startstr), "%jd", start);
+ gctl_ro_param(r, "start", -1, startstr);
+ gctl_rw_param(r, "output", sizeof(output), output);
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0') {
+ printf("Error: %s\n", errstr);
+ err = 1;
+ }
+ gctl_free(r);
+ totalsize += size;
+
+ get_part_metadata(strtok(output, " "), 1)->bootcode = 1;
+
+ if (err > 0) {
+ return (0); /* XXX need error handlingg */
+ }
+
+ return (totalsize);
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jun 30, 10:20 PM (20 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34526633
Default Alt Text
D6232.diff (10 KB)
Attached To
Mode
D6232: Make bsdinstall/autopart put swap before the root filesystem in GPT configurations
Attached
Detach File
Event Timeline
Log In to Comment