2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
10 #include <sys/cdefs.h>
11 __FBSDID("$FreeBSD$");
18 #include <sys/types.h>
20 #include <sys/ioctl.h>
21 #include <sys/disklabel.h>
26 Fill_Disklabel(struct disklabel *dl, const struct disk *new,
27 const struct chunk *c1)
32 memset(dl, 0, sizeof *dl);
34 for (c2 = c1->part; c2; c2 = c2->next) {
35 if (c2->type == unused)
37 if (!strcmp(c2->name, "X"))
39 j = c2->name[strlen(c2->name) - 1] - 'a';
40 if (j < 0 || j >= MAXPARTITIONS || j == RAW_PART)
42 dl->d_partitions[j].p_size = c2->size;
43 dl->d_partitions[j].p_offset = c2->offset;
44 dl->d_partitions[j].p_fstype = c2->subtype;
47 dl->d_bbsize = BBSIZE;
49 * Add in defaults for superblock size, interleave, and rpms
53 strcpy(dl->d_typename, c1->name);
56 dl->d_secperunit = new->chunks->size;
58 dl->d_ncylinders = new->bios_cyl;
59 dl->d_ntracks = new->bios_hd;
60 dl->d_nsectors = new->bios_sect;
62 dl->d_secpercyl = dl->d_ntracks * dl->d_nsectors;
64 dl->d_npartitions = MAXPARTITIONS;
66 dl->d_type = new->name[0] == 's' || new->name[0] == 'd' ||
67 new->name[0] == 'o' ? DTYPE_SCSI : DTYPE_ESDI;
68 dl->d_partitions[RAW_PART].p_size = c1->size;
69 dl->d_partitions[RAW_PART].p_offset = c1->offset;
73 dl->d_magic = DISKMAGIC;
74 dl->d_magic2 = DISKMAGIC;
75 dl->d_checksum = dkcksum(dl);