Lines Matching +full:partition +full:-
27 * This file contains functions that operate on partition tables.
32 #include "partition.h"
39 * Default vtoc information for non-SVr4 partitions
42 { V_ROOT, 0 }, /* a - 0 */
43 { V_SWAP, V_UNMNT }, /* b - 1 */
44 { V_BACKUP, V_UNMNT }, /* c - 2 */
45 { V_UNASSIGNED, 0 }, /* d - 3 */
46 { V_UNASSIGNED, 0 }, /* e - 4 */
47 { V_UNASSIGNED, 0 }, /* f - 5 */
48 { V_USR, 0 }, /* g - 6 */
49 { V_UNASSIGNED, 0 }, /* h - 7 */
54 { V_BOOT, V_UNMNT }, /* i - 8 */
55 { V_ALTSCTR, 0 }, /* j - 9 */
61 { V_UNASSIGNED, 0 }, /* k - 10 */
62 { V_UNASSIGNED, 0 }, /* l - 11 */
63 { V_UNASSIGNED, 0 }, /* m - 12 */
64 { V_UNASSIGNED, 0 }, /* n - 13 */
65 { V_UNASSIGNED, 0 }, /* o - 14 */
66 { V_UNASSIGNED, 0 }, /* p - 15 */
71 * This routine finds the last usable sector in the partition table.
72 * It skips the BACKUP partition.
81 for (i = 0; i < map->efi_nparts - 1; i++) {
82 start[0] = map->efi_parts[i].p_start;
83 size[0] = map->efi_parts[i].p_size;
86 start[1] = map->efi_parts[i+1].p_start;
87 size[1] = map->efi_parts[i+1].p_size;
90 if (map->efi_parts[i].p_tag == V_BACKUP) {
93 if (map->efi_parts[i+1].p_tag == V_BACKUP) {
112 * partition in the current partition map.
130 * check if there exists a partition table for the disk.
133 err_print("Current Disk has no partition table.\n");
138 if (num > cur_parts->etoc->efi_nparts - 1) {
139 err_print("Invalid partition for EFI label\n");
142 print_efi_partition(cur_parts->etoc, num, 1);
145 * Prompt for p_tag and p_flag values for this partition
147 deflt = cur_parts->etoc->efi_parts[num].p_tag;
151 (void) sprintf(msg, "Enter partition id tag");
155 deflt = cur_parts->etoc->efi_parts[num].p_flag;
156 (void) sprintf(msg, "Enter partition permission flags");
161 ioparam.io_bounds.upper = cur_parts->etoc->efi_last_u_lba;
163 efi_deflt.start_sector = maxofN(cur_parts->etoc);
164 if ((cur_parts->etoc->efi_parts[num].p_start != 0) &&
165 (cur_parts->etoc->efi_parts[num].p_size != 0)) {
167 cur_parts->etoc->efi_parts[num].p_start;
169 efi_deflt.end_sector = ioparam.io_bounds.upper -
175 ioparam.io_bounds.upper = cur_parts->etoc->efi_last_u_lba;
176 efi_deflt.end_sector = cur_parts->etoc->efi_parts[num].p_size;
178 j64 = input(FIO_EFI, "Enter partition size", ':', &ioparam,
187 if (cur_parts->pinfo_name != NULL)
190 cur_parts->etoc->efi_parts[num].p_tag = tag;
191 cur_parts->etoc->efi_parts[num].p_flag = flag;
192 cur_parts->etoc->efi_parts[num].p_start = i64;
193 cur_parts->etoc->efi_parts[num].p_size = j64;
200 * Print out the given partition so the user knows what he/she's
207 * Prompt for p_tag and p_flag values for this partition.
209 assert(cur_parts->vtoc.v_version == V_VERSION);
210 deflt = cur_parts->vtoc.v_part[num].p_tag;
211 (void) sprintf(msg, "Enter partition id tag");
215 deflt = cur_parts->vtoc.v_part[num].p_flag;
216 (void) sprintf(msg, "Enter partition permission flags");
230 * Assuming that the alternate sectors partition (slice)
232 * partition and partition sizes are expressed in multiples
235 cyl_offset = cur_parts->pinfo_map[I_PARTITION].dkl_cylno + 1;
237 if (cur_parts->pinfo_map[J_PARTITION].dkl_nblk != 0) {
239 cur_parts->pinfo_map[J_PARTITION].dkl_cylno +
240 ((cur_parts->pinfo_map[J_PARTITION].dkl_nblk +
241 (spc()-1)) / spc());
248 ioparam.io_bounds.upper = ncyl - 1;
249 deflt = max(cur_parts->pinfo_map[num].dkl_cylno,
255 ioparam.io_bounds.upper = (ncyl - i) * spc();
257 /* fill in defaults for the current partition */
260 min(cur_parts->pinfo_map[num].dkl_nblk,
264 j = (uint_t)input(FIO_ECYL, "Enter partition size", ':', &ioparam,
268 * If the current partition has a size of zero change the
287 if (i < cur_parts->pinfo_map[I_PARTITION].dkl_cylno + 1) {
288 fmt_print("\nWarning: Partition overlaps boot ");
289 fmt_print("partition. Specify different start cyl.\n");
293 * Cyl offset for alternates partition was calculated before
296 fmt_print("\nWarning: Partition overlaps alternates ");
297 fmt_print("partition. Specify different start cyl.\n");
305 * If user has entered a V_BACKUP tag then the partition
315 * V_BACKUP Tag Partition != full disk capacity.
318 fmt_print("\nWarning: Partition with V_BACKUP tag should ");
326 * If the current partition is named, we can't change it.
327 * We create a new current partition map instead.
329 if (cur_parts->pinfo_name != NULL)
334 cur_parts->pinfo_map[num].dkl_cylno = i;
335 cur_parts->pinfo_map[num].dkl_nblk = j;
338 cur_parts->vtoc.v_part[num].p_start = (daddr_t)(i * (nhead * nsect));
339 cur_parts->vtoc.v_part[num].p_size = (long)j;
343 * Install the p_tag and p_flag values for this partition
345 assert(cur_parts->vtoc.v_version == V_VERSION);
346 cur_parts->vtoc.v_part[num].p_tag = (ushort_t)tag;
347 cur_parts->vtoc.v_part[num].p_flag = (ushort_t)flag;
352 * This routine picks to closest partition table which matches the
355 * of the partition table. If no table exists, a dummy is
365 * If there are no pre-defined maps for this disk type, it's
368 parts = cur_dtype->dtype_plist;
370 err_print("No defined partition tables.\n");
372 return (-1);
375 * Loop through the pre-defined maps searching for one which match
376 * disk type. If found copy it into unmamed partition.
379 for (pptr = parts; pptr != NULL; pptr = pptr->pinfo_next) {
380 if (cur_dtype->dtype_asciilabel) {
381 if (pptr->pinfo_name != NULL && strcmp(pptr->pinfo_name,
382 cur_dtype->dtype_asciilabel) == 0) {
384 * Set current partition and name it.
386 cur_disk->disk_parts = cur_parts = pptr;
387 cur_parts->pinfo_name = pptr->pinfo_name;
395 * Set current partition and name it.
397 cur_disk->disk_parts = cur_parts = cur_dtype->dtype_plist;
398 cur_parts->pinfo_name = parts->pinfo_name;
405 * This routine creates a new partition map and sets it current. If there
424 parts = cur_dtype->dtype_plist;
426 cur_dtype->dtype_plist = pptr;
428 while (parts->pinfo_next != NULL) {
429 parts = parts->pinfo_next;
431 parts->pinfo_next = pptr;
432 pptr->pinfo_next = NULL;
442 nparts = cur_parts->etoc->efi_nparts;
445 (void) memcpy(map, cur_parts->etoc, size);
446 pptr->etoc = map;
447 cur_disk->disk_parts = cur_parts = pptr;
453 pptr->pinfo_map[i] = cur_parts->pinfo_map[i];
455 pptr->vtoc = cur_parts->vtoc;
466 cur_disk->disk_parts = cur_parts = pptr;
472 * This routine deletes a partition map from the list of maps for
483 if (cur_dtype->dtype_plist == NULL) {
484 err_print("Error: unexpected null partition list.\n");
490 if (cur_dtype->dtype_plist == parts)
491 cur_dtype->dtype_plist = parts->pinfo_next;
493 for (pptr = cur_dtype->dtype_plist; pptr->pinfo_next != parts;
494 pptr = pptr->pinfo_next)
496 pptr->pinfo_next = parts->pinfo_next;
506 * Set all partition vtoc fields to defaults
513 bzero((caddr_t)&part->vtoc, sizeof (struct dk_vtoc));
515 part->vtoc.v_version = V_VERSION;
516 part->vtoc.v_nparts = NDKMAP;
517 part->vtoc.v_sanity = VTOC_SANE;
520 part->vtoc.v_part[i].p_tag = default_vtoc_map[i].p_tag;
521 part->vtoc.v_part[i].p_flag = default_vtoc_map[i].p_flag;