116
/* default number of partitions */
117
nparts = SUN_MAXPARTITIONS;
119
115
/* sectors per cylinder (partition offset is in cylinders...) */
120
116
spc = be16_to_cpu(l->ntrks) * be16_to_cpu(l->nsect);
122
if ((be32_to_cpu(l->vtoc.sanity) == SUN_VTOC_SANITY) &&
123
(be32_to_cpu(l->vtoc.version) == SUN_VTOC_VERSION) &&
124
(be16_to_cpu(l->vtoc.nparts) <= SUN_MAXPARTITIONS)) {
126
nparts = be16_to_cpu(l->vtoc.nparts);
127
infos = l->vtoc.infos; /* for partition type */
119
printf("Sun VTOC sanity=%u version=%u nparts=%u\n",
120
be32_to_cpu(l->vtoc.sanity),
121
be32_to_cpu(l->vtoc.version),
122
be16_to_cpu(l->vtoc.nparts)));
124
/* Check to see if we can use the VTOC table */
125
use_vtoc = ((be32_to_cpu(l->vtoc.sanity) == SUN_VTOC_SANITY) &&
126
(be32_to_cpu(l->vtoc.version) == SUN_VTOC_VERSION) &&
127
(be16_to_cpu(l->vtoc.nparts) <= SUN_MAXPARTITIONS));
129
/* Use 8 partition entries if not specified in validated VTOC */
130
nparts = use_vtoc ? be16_to_cpu(l->vtoc.nparts) : SUN_MAXPARTITIONS;
133
* So that old Linux-Sun partitions continue to work,
134
* alow the VTOC to be used under the additional condition ...
136
use_vtoc = use_vtoc || !(l->vtoc.sanity || l->vtoc.version || l->vtoc.nparts);
130
138
for (i = 0, p = l->partitions; i < nparts; i++, p++) {
134
uint16_t type = infos ? be16_to_cpu(infos[i].id) : 0;
140
blkid_loff_t start, size;
141
uint16_t type = 0, flags = 0;
136
144
start = be32_to_cpu(p->start_cylinder) * spc;
137
145
size = be32_to_cpu(p->num_sectors);
147
type = be16_to_cpu(l->vtoc.infos[i].id);
148
flags = be16_to_cpu(l->vtoc.infos[i].flags);
139
if (type == SUN_TAG_WHOLEDISK || !size)
151
if (type == SUN_TAG_WHOLEDISK || !size) {
152
blkid_partlist_increment_partno(ls);
142
if (!blkid_partlist_add_partition(ls, tab, type, start, size))
155
par = blkid_partlist_add_partition(ls, tab, start, size);
160
blkid_partition_set_type(par, type);
162
blkid_partition_set_flags(par, flags);