Project

General

Profile

Bug #2674 ยป installer-gpt.patch

pascii, 12/28/2015 02:44 PM

View differences:

etc/defaults/uuids
37 37
#
38 38
a19d880f-05fc-4d3b-a006-743f0f84911e	"Linux Raid"
39 39
0657fd6d-a4ab-43c4-84e5-0933c84b4f4f	"Linux Swap"
40
0fc63daf-8483-4772-8e79-3d69d8477de4	"Linux Filesystem Data"
40 41
e6d6d379-f507-44c2-a23c-238f2a3df928	"Linux LVM"
41 42
48465300-0000-11aa-aa11-00306543ecac	"Apple HFS"
share/installer/cmdnames.conf
28 28
DISKLABEL64=sbin/disklabel64
29 29
DUMPON=sbin/dumpon
30 30
FDISK=sbin/fdisk
31
GPT=sbin/gpt
31 32
HAMMER=sbin/hammer
32 33
IFCONFIG=sbin/ifconfig
33 34
MOUNT=sbin/mount
usr.sbin/installer/dfuibe_installer/flow.c
1105 1105
		    slice_get_number(storage_get_selected_slice(a->s)),
1106 1106
		    slice_get_desc(storage_get_selected_slice(a->s)),
1107 1107
		    disk_get_desc(storage_get_selected_disk(a->s)))) {
1108
			if (!format_slice(a)) {
1108
			if (disk_get_gptsliced(storage_get_selected_disk(a->s))) {
1109
				inform(a->c, _("You must set the type of this GPT partition"
1110
					" to DragonFly Label64 yourself if not already done."
1111
					" Also, GPT booting is not supported yet."));
1112
				state = state_ask_fs;
1113
			} else if (!format_slice(a)) {
1109 1114
				inform(a->c, _("Primary partition #%d was "
1110 1115
				    "not correctly formatted, and may "
1111 1116
				    "now be in an inconsistent state. "
usr.sbin/installer/libinstaller/diskutil.c
159 159
	d->desc = NULL;
160 160
	d->serno = NULL;
161 161
	d->we_formatted = 0;
162
	d->gpt_sliced = 0;
162 163
	d->capacity = 0;
163 164

  
164 165
	d->cylinders = -1;	/* -1 indicates "we don't know" */
......
304 305
}
305 306

  
306 307
void
308
disk_set_gptsliced(struct disk *d, int gptsliced)
309
{
310
	d->gpt_sliced = gptsliced;
311
}
312

  
313
int
314
disk_get_gptsliced(const struct disk *d)
315
{
316
	return(d->gpt_sliced);
317
}
318

  
319
void
307 320
disk_set_geometry(struct disk *d, int cyl, int hd, int sec)
308 321
{
309 322
	d->cylinders = cyl;
......
345 358
 */
346 359
struct slice *
347 360
slice_new(struct disk *d, int number, int type, int flags,
348
	  unsigned long start, unsigned long size)
361
	  unsigned long start, unsigned long size, char *desc)
349 362
{
350 363
	struct slice *s;
351 364
	const char *sysid_desc = NULL;
......
368 381
	s->start = start;
369 382
	s->size = size;
370 383

  
371
	for (i = 0; ; i++) {
372
		if (part_types[i].type == type) {
373
			sysid_desc = part_types[i].name;
374
			break;
384
	if (disk_get_gptsliced(d)) {
385
		sysid_desc = strdup(desc);
386
	} else {
387
		for (i = 0; ; i++) {
388
			if (part_types[i].type == type) {
389
				sysid_desc = part_types[i].name;
390
				break;
391
			}
392
			if (part_types[i].type == 255)
393
				break;
394
		}
395
		if (sysid_desc == NULL) {
396
			snprintf(unknown, 256, "??? Unknown, sysid = %d", type);
397
			sysid_desc = unknown;
375 398
		}
376
		if (part_types[i].type == 255)
377
			break;
378
	}
379
	if (sysid_desc == NULL) {
380
		snprintf(unknown, 256, "??? Unknown, sysid = %d", type);
381
		sysid_desc = unknown;
382 399
	}
383 400

  
384 401
	asprintf(&s->desc, "%ldM - %ldM: %s",
usr.sbin/installer/libinstaller/diskutil.h
77 77
	int sectors;			/* (sectors per track) */
78 78
	long capacity;			/* capacity in megabytes */
79 79
	int we_formatted;		/* did we format it ourselves? */
80
	int gpt_sliced;			/* slices are of gpt type */
80 81
};
81 82

  
82 83
struct slice {
......
140 141
struct slice		*disk_slice_first(const struct disk *);
141 142
void			 disk_set_formatted(struct disk *, int);
142 143
int			 disk_get_formatted(const struct disk *);
144
void			 disk_set_gptsliced(struct disk *, int);
145
int			 disk_get_gptsliced(const struct disk *);
143 146
void			 disk_set_geometry(struct disk *, int, int, int);
144 147
void			 disk_get_geometry(const struct disk *, int *, int *, int *);
145 148

  
146 149
struct slice		*slice_new(struct disk *, int, int, int,
147
				   unsigned long, unsigned long);
150
				   unsigned long, unsigned long, char *);
148 151
struct slice		*slice_find(const struct disk *, int);
149 152
struct slice		*slice_next(const struct slice *);
150 153
int			 slice_get_number(const struct slice *);
usr.sbin/installer/libinstaller/survey.c
39 39

  
40 40
#include <sys/types.h>
41 41
#include <sys/sysctl.h>
42
#include <ctype.h>
42 43

  
43 44
#include <stdio.h>
44 45
#include <string.h>
......
258 259
		    a->os_root, cmd_name(a, "ECHO"), a->tmp);
259 260
		command_set_log_mode(cmd, COMMAND_LOG_SILENT);
260 261

  
262
		/*
263
		 * Probe the disk with gpt.
264
		 */
265
		cmd = command_add(cmds, "%s%s '@GPT_SLICES' >>%ssurvey.txt",
266
		    a->os_root, cmd_name(a, "ECHO"), a->tmp);
267
		command_set_log_mode(cmd, COMMAND_LOG_SILENT);
268
		cmd = command_add(cmds, "%s%s show %s 2>/dev/null >>%ssurvey.txt || %s%s '' >>%ssurvey.txt",
269
		    a->os_root, cmd_name(a, "GPT"),
270
		    disk,
271
		    a->tmp,
272
		    a->os_root, cmd_name(a, "ECHO"),
273
		    a->tmp);
274
		cmd = command_add(cmds, "%s%s '@END' >>%ssurvey.txt",
275
		    a->os_root, cmd_name(a, "ECHO"), a->tmp);
276
		command_set_log_mode(cmd, COMMAND_LOG_SILENT);
277

  
261 278
		aura_dict_next(di);
262 279
	}
263 280

  
......
318 335
						fprintfo(log, "| Found slice #%d, sysid %d, "
319 336
						    "start %ld, size %ld\n", sliceno, type, start, size);
320 337
						*/
321
						slice_new(d, sliceno, type, flags, start, size);
338
						if (type == 0xee)
339
							disk_set_gptsliced(d, 1);
340
						else if (!disk_get_gptsliced(d))
341
							slice_new(d, sliceno, type, flags, start, size, NULL);
322 342
					}
323 343
				}
324 344
			}
345
		} else if (strcmp(line, "@GPT_SLICES") == 0) {
346
			/*
347
			 *    start       size  index  contents
348
			 *        0          1      -  PMBR
349
			 *        1          1      -  Pri GPT header
350
			 *        2         32      -  Pri GPT table
351
			 *       34       2014      -
352
			 *     2048     974848      0  GPT part - EFI System
353
			 */
354
			while (d != NULL && strcmp(line, "@END") != 0 && fgets_chomp(line, 255, f)) {
355
				if (strstr(line, "start") && strstr(line, "contents")) {
356
					/* ignore it */
357
				} else if (disk_get_gptsliced(d)) {
358
					char *s = line;
359
					unsigned long start, size;
360
					int sliceno;
361

  
362
					start = strtoul(s, &s, 10);
363
					if (!s || !start) continue;
364
					size = strtoul(s, &s, 10);
365
					if (!s || !size) continue;
366
					while (isspace(*s)) s++;
367
					if (!isdigit(*s)) continue;
368
					sliceno = (int)strtol(s, &s, 10);
369
					if (!s) continue;
370
					while (isspace(*s)) s++;
371
					if (!strncmp(s, "GPT part - ", 11)) s += 11;
372
					slice_new(d, sliceno, 0, 0, start, size, s);
373
				}
374
			}
325 375
		}
326 376
	}
327 377

  
    (1-1/1)