Index: usr.sbin/bsdinstall/partedit/gpart_ops.c =================================================================== --- usr.sbin/bsdinstall/partedit/gpart_ops.c +++ usr.sbin/bsdinstall/partedit/gpart_ops.c @@ -341,7 +341,7 @@ gctl_ro_param(r, "index", sizeof(idx), &idx); errstr = gctl_issue(r); - if (errstr != NULL && errstr[0] != '\0') + if (errstr != NULL && errstr[0] != '\0') gpart_show_error("Error", "Error marking partition active:", errstr); gctl_free(r); @@ -361,7 +361,7 @@ gctl_ro_param(r, "attrib", -1, attribute); errstr = gctl_issue(r); - if (errstr != NULL && errstr[0] != '\0') + if (errstr != NULL && errstr[0] != '\0') gpart_show_error("Error", "Error setting parameter on disk:", errstr); gctl_free(r); @@ -390,7 +390,7 @@ } bootcode = bootcode_path(scheme); - if (bootcode == NULL) + if (bootcode == NULL) return; bootfd = open(bootcode, O_RDONLY); @@ -415,7 +415,7 @@ gctl_ro_param(r, "bootcode", bootsize, boot); errstr = gctl_issue(r); - if (errstr != NULL && errstr[0] != '\0') + if (errstr != NULL && errstr[0] != '\0') gpart_show_error("Bootcode Error", NULL, errstr); gctl_free(r); free(boot); @@ -427,6 +427,8 @@ struct gconfig *gc; const char *scheme; const char *indexstr; + const char *partcode; + const char *fat; char message[255], command[255]; LIST_FOREACH(gc, &pp->lg_geom->lg_config, lg_config) { @@ -437,9 +439,35 @@ } /* Make sure this partition scheme needs partcode on this platform */ - if (partcode_path(scheme, fstype) == NULL) + partcode = partcode_path(scheme, fstype); + if (partcode == NULL) return; + /* Some platforms have files on FAT, check for that */ + fat = fat_bootcode_file(scheme, fstype); + if (fat != NULL) { + /* + * A case could be made for making this an external script + */ + sprintf(command, "newfs_msdos -F 12 -L EFI /dev/%s", + pp->lg_geom->lg_name); + if (system(command) != 0) { + sprintf(message, "Error newfs_msdos the partcode on partition %s", + pp->lg_name); + dialog_msgbox("Error", message, 0, 0, TRUE); + return; + } + sprintf(command, "mkdir /tmp/junk && mount -t msdos /dev/%s /tmp/junk && mkdir -p /tmp/junk/efi/boot && cp %s /tmp/junk/efi/boot/%s && umount /tmp/junk", + pp->lg_geom->lg_name, partcode, fat); + if (system(command) != 0) { + sprintf(message, "Error mounting partition %s", + pp->lg_name); + dialog_msgbox("Error", message, 0, 0, TRUE); + return; + } + return; + } + LIST_FOREACH(gc, &pp->lg_config, lg_config) { if (strcmp(gc->lg_name, "index") == 0) { indexstr = gc->lg_val; @@ -449,7 +477,7 @@ /* 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, indexstr, pp->lg_geom->lg_name); if (system(command) != 0) { sprintf(message, "Error installing partcode on partition %s", pp->lg_name); @@ -778,7 +806,7 @@ struct gprovider **b = (struct gprovider **)xb; intmax_t astart, bstart; struct gconfig *gc; - + astart = bstart = 0; LIST_FOREACH(gc, &(*a)->lg_config, lg_config) if (strcmp(gc->lg_name, "start") == 0) { @@ -939,7 +967,7 @@ /* Now get the partition scheme */ scheme = NULL; if (geom != NULL) { - LIST_FOREACH(gc, &geom->lg_config, lg_config) + LIST_FOREACH(gc, &geom->lg_config, lg_config) if (strcmp(gc->lg_name, "scheme") == 0) scheme = gc->lg_val; } @@ -1140,7 +1168,7 @@ 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') + if (errstr != NULL && errstr[0] != '\0') gpart_show_error("Error", NULL, errstr); gctl_free(r); @@ -1149,12 +1177,12 @@ /* Now adjust the part we are really adding forward */ firstfree += bootpart_size(scheme) / sector; size -= (bootpart_size(scheme) + stripe)/sector; - if (stripe > 0 && (firstfree*sector % stripe) != 0) + if (stripe > 0 && (firstfree*sector % stripe) != 0) firstfree += (stripe - ((firstfree*sector) % stripe)) / sector; } } - + r = gctl_get_handle(); gctl_ro_param(r, "class", -1, "PART"); gctl_ro_param(r, "arg0", -1, geom->lg_name); @@ -1207,7 +1235,7 @@ if (partname != NULL) *partname = strdup(newpartname); } - + void gpart_delete(struct gprovider *pp) { @@ -1381,7 +1409,7 @@ md = get_part_metadata(pp->lg_name, 0); if (md == NULL || !md->bootcode) continue; - + /* Mark this partition active if that's required */ gpart_activate(pp); @@ -1401,7 +1429,7 @@ gctl_ro_param(r, "verb", -1, "commit"); errstr = gctl_issue(r); - if (errstr != NULL && errstr[0] != '\0') + if (errstr != NULL && errstr[0] != '\0') gpart_show_error("Error", NULL, errstr); gctl_free(r); } Index: usr.sbin/bsdinstall/partedit/partedit.h =================================================================== --- usr.sbin/bsdinstall/partedit/partedit.h +++ usr.sbin/bsdinstall/partedit/partedit.h @@ -83,5 +83,6 @@ 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 *fat_bootcode_file(const char *part_type, const char *fs_type); #endif Index: usr.sbin/bsdinstall/partedit/partedit_arm64.c =================================================================== --- usr.sbin/bsdinstall/partedit/partedit_arm64.c +++ usr.sbin/bsdinstall/partedit/partedit_arm64.c @@ -36,7 +36,8 @@ /* EFI partition size in bytes */ #define EFI_BOOTPART_SIZE (200 * 1024 * 1024) -#define EFI_BOOTPART_PATH "/boot/boot1.efifat" +#define EFI_BOOTPART_PATH "/boot/boot1.efif" +#define EFI_FAT_PATH "/efi/boot/bootaa64.efi" const char * default_scheme(void) @@ -93,12 +94,17 @@ const char * partcode_path(const char *part_type, const char *fs_type) +{ + + return (NULL); +} + +const char * +fat_bootcode_file(const char *part_type, const char *fs_type) { if (strcmp(part_type, "GPT") == 0) - return (EFI_BOOTPART_PATH); + return (EFI_FAT_PATH); - /* No boot partition data for non-GPT */ return (NULL); } - Index: usr.sbin/bsdinstall/partedit/partedit_generic.c =================================================================== --- usr.sbin/bsdinstall/partedit/partedit_generic.c +++ usr.sbin/bsdinstall/partedit/partedit_generic.c @@ -77,3 +77,7 @@ return (NULL); } +const char * +fat_bootcode_file(const char *part_type, const char *fs_type) { + return (NULL); +} Index: usr.sbin/bsdinstall/partedit/partedit_powerpc.c =================================================================== --- usr.sbin/bsdinstall/partedit/partedit_powerpc.c +++ usr.sbin/bsdinstall/partedit/partedit_powerpc.c @@ -122,3 +122,8 @@ return (NULL); } +const char * +fat_bootcode_file(const char *part_type, const char *fs_type) +{ + return (NULL); +} Index: usr.sbin/bsdinstall/partedit/partedit_sparc64.c =================================================================== --- usr.sbin/bsdinstall/partedit/partedit_sparc64.c +++ usr.sbin/bsdinstall/partedit/partedit_sparc64.c @@ -80,3 +80,8 @@ return (NULL); } +const char * +fat_bootcode_file(const char *part_type, const char *fs_type) +{ + return (NULL); +} Index: usr.sbin/bsdinstall/partedit/partedit_x86.c =================================================================== --- usr.sbin/bsdinstall/partedit/partedit_x86.c +++ usr.sbin/bsdinstall/partedit/partedit_x86.c @@ -34,7 +34,8 @@ /* EFI partition size in bytes */ #define EFI_BOOTPART_SIZE (200 * 1024 * 1024) -#define EFI_BOOTPART_PATH "/boot/boot1.efifat" +#define EFI_BOOTPART_PATH "/boot/boot1.efi" +#define EFI_FAT_PATH "/efi/boot/bootx64.efi" static const char * x86_bootmethod(void) @@ -141,7 +142,7 @@ if (strcmp(part_type, "GPT") == 0) { if (strcmp(x86_bootmethod(), "UEFI") == 0) - return (EFI_BOOTPART_PATH); + return (NULL); else if (strcmp(fs_type, "zfs") == 0) return ("/boot/gptzfsboot"); else @@ -152,3 +153,13 @@ return (NULL); } +const char * +fat_bootcode_file(const char *part_type, const char *fs_type) +{ + + if (strcmp(part_type, "GPT") == 0 && + strcmp(x86_bootmethod(), "UEFI") == 0) + return (EFI_FAT_PATH); + + return (NULL); +}