diff --git a/etc/defaults/uuids b/etc/defaults/uuids index 3a9b95e..e88d885 100644 --- a/etc/defaults/uuids +++ b/etc/defaults/uuids @@ -37,5 +37,6 @@ af9b60a0-1431-4f62-bc68-3311714a69ad "MS LDM Data" # a19d880f-05fc-4d3b-a006-743f0f84911e "Linux Raid" 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f "Linux Swap" +0fc63daf-8483-4772-8e79-3d69d8477de4 "Linux Filesystem Data" e6d6d379-f507-44c2-a23c-238f2a3df928 "Linux LVM" 48465300-0000-11aa-aa11-00306543ecac "Apple HFS" diff --git a/share/installer/cmdnames.conf b/share/installer/cmdnames.conf index 1c05c93..fb863df 100644 --- a/share/installer/cmdnames.conf +++ b/share/installer/cmdnames.conf @@ -28,6 +28,7 @@ DHCLIENT=sbin/dhclient DISKLABEL64=sbin/disklabel64 DUMPON=sbin/dumpon FDISK=sbin/fdisk +GPT=sbin/gpt HAMMER=sbin/hammer IFCONFIG=sbin/ifconfig MOUNT=sbin/mount diff --git a/usr.sbin/installer/dfuibe_installer/flow.c b/usr.sbin/installer/dfuibe_installer/flow.c index eec878e..35c54f8 100644 --- a/usr.sbin/installer/dfuibe_installer/flow.c +++ b/usr.sbin/installer/dfuibe_installer/flow.c @@ -1105,7 +1105,12 @@ state_select_slice(struct i_fn_args *a) slice_get_number(storage_get_selected_slice(a->s)), slice_get_desc(storage_get_selected_slice(a->s)), disk_get_desc(storage_get_selected_disk(a->s)))) { - if (!format_slice(a)) { + if (disk_get_gptsliced(storage_get_selected_disk(a->s))) { + inform(a->c, _("You must set the type of this GPT partition" + " to DragonFly Label64 yourself if not already done." + " Also, GPT booting is not supported yet.")); + state = state_ask_fs; + } else if (!format_slice(a)) { inform(a->c, _("Primary partition #%d was " "not correctly formatted, and may " "now be in an inconsistent state. " diff --git a/usr.sbin/installer/libinstaller/diskutil.c b/usr.sbin/installer/libinstaller/diskutil.c index 6b74735..0de0af6 100644 --- a/usr.sbin/installer/libinstaller/diskutil.c +++ b/usr.sbin/installer/libinstaller/diskutil.c @@ -159,6 +159,7 @@ disk_new(struct storage *s, const char *dev_name) d->desc = NULL; d->serno = NULL; d->we_formatted = 0; + d->gpt_sliced = 0; d->capacity = 0; d->cylinders = -1; /* -1 indicates "we don't know" */ @@ -304,6 +305,18 @@ disk_get_formatted(const struct disk *d) } void +disk_set_gptsliced(struct disk *d, int gptsliced) +{ + d->gpt_sliced = gptsliced; +} + +int +disk_get_gptsliced(const struct disk *d) +{ + return(d->gpt_sliced); +} + +void disk_set_geometry(struct disk *d, int cyl, int hd, int sec) { d->cylinders = cyl; @@ -345,7 +358,7 @@ disks_free(struct storage *s) */ struct slice * slice_new(struct disk *d, int number, int type, int flags, - unsigned long start, unsigned long size) + unsigned long start, unsigned long size, char *desc) { struct slice *s; const char *sysid_desc = NULL; @@ -368,17 +381,21 @@ slice_new(struct disk *d, int number, int type, int flags, s->start = start; s->size = size; - for (i = 0; ; i++) { - if (part_types[i].type == type) { - sysid_desc = part_types[i].name; - break; + if (disk_get_gptsliced(d)) { + sysid_desc = strdup(desc); + } else { + for (i = 0; ; i++) { + if (part_types[i].type == type) { + sysid_desc = part_types[i].name; + break; + } + if (part_types[i].type == 255) + break; + } + if (sysid_desc == NULL) { + snprintf(unknown, 256, "??? Unknown, sysid = %d", type); + sysid_desc = unknown; } - if (part_types[i].type == 255) - break; - } - if (sysid_desc == NULL) { - snprintf(unknown, 256, "??? Unknown, sysid = %d", type); - sysid_desc = unknown; } asprintf(&s->desc, "%ldM - %ldM: %s", diff --git a/usr.sbin/installer/libinstaller/diskutil.h b/usr.sbin/installer/libinstaller/diskutil.h index c77f2da..d63d6a0 100644 --- a/usr.sbin/installer/libinstaller/diskutil.h +++ b/usr.sbin/installer/libinstaller/diskutil.h @@ -77,6 +77,7 @@ struct disk { int sectors; /* (sectors per track) */ long capacity; /* capacity in megabytes */ int we_formatted; /* did we format it ourselves? */ + int gpt_sliced; /* slices are of gpt type */ }; struct slice { @@ -140,11 +141,13 @@ const char *disk_get_serno(const struct disk *); struct slice *disk_slice_first(const struct disk *); void disk_set_formatted(struct disk *, int); int disk_get_formatted(const struct disk *); +void disk_set_gptsliced(struct disk *, int); +int disk_get_gptsliced(const struct disk *); void disk_set_geometry(struct disk *, int, int, int); void disk_get_geometry(const struct disk *, int *, int *, int *); struct slice *slice_new(struct disk *, int, int, int, - unsigned long, unsigned long); + unsigned long, unsigned long, char *); struct slice *slice_find(const struct disk *, int); struct slice *slice_next(const struct slice *); int slice_get_number(const struct slice *); diff --git a/usr.sbin/installer/libinstaller/survey.c b/usr.sbin/installer/libinstaller/survey.c index edbdfb4..6099d77 100644 --- a/usr.sbin/installer/libinstaller/survey.c +++ b/usr.sbin/installer/libinstaller/survey.c @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -258,6 +259,22 @@ survey_storage(struct i_fn_args *a) a->os_root, cmd_name(a, "ECHO"), a->tmp); command_set_log_mode(cmd, COMMAND_LOG_SILENT); + /* + * Probe the disk with gpt. + */ + cmd = command_add(cmds, "%s%s '@GPT_SLICES' >>%ssurvey.txt", + a->os_root, cmd_name(a, "ECHO"), a->tmp); + command_set_log_mode(cmd, COMMAND_LOG_SILENT); + cmd = command_add(cmds, "%s%s show %s 2>/dev/null >>%ssurvey.txt || %s%s '' >>%ssurvey.txt", + a->os_root, cmd_name(a, "GPT"), + disk, + a->tmp, + a->os_root, cmd_name(a, "ECHO"), + a->tmp); + cmd = command_add(cmds, "%s%s '@END' >>%ssurvey.txt", + a->os_root, cmd_name(a, "ECHO"), a->tmp); + command_set_log_mode(cmd, COMMAND_LOG_SILENT); + aura_dict_next(di); } @@ -318,10 +335,43 @@ survey_storage(struct i_fn_args *a) fprintfo(log, "| Found slice #%d, sysid %d, " "start %ld, size %ld\n", sliceno, type, start, size); */ - slice_new(d, sliceno, type, flags, start, size); + if (type == 0xee) + disk_set_gptsliced(d, 1); + else if (!disk_get_gptsliced(d)) + slice_new(d, sliceno, type, flags, start, size, NULL); } } } + } else if (strcmp(line, "@GPT_SLICES") == 0) { + /* + * start size index contents + * 0 1 - PMBR + * 1 1 - Pri GPT header + * 2 32 - Pri GPT table + * 34 2014 - + * 2048 974848 0 GPT part - EFI System + */ + while (d != NULL && strcmp(line, "@END") != 0 && fgets_chomp(line, 255, f)) { + if (strstr(line, "start") && strstr(line, "contents")) { + /* ignore it */ + } else if (disk_get_gptsliced(d)) { + char *s = line; + unsigned long start, size; + int sliceno; + + start = strtoul(s, &s, 10); + if (!s || !start) continue; + size = strtoul(s, &s, 10); + if (!s || !size) continue; + while (isspace(*s)) s++; + if (!isdigit(*s)) continue; + sliceno = (int)strtol(s, &s, 10); + if (!s) continue; + while (isspace(*s)) s++; + if (!strncmp(s, "GPT part - ", 11)) s += 11; + slice_new(d, sliceno, 0, 0, start, size, s); + } + } } }