Lines Matching +full:partition +full:-

35  * This program reads the partition table on the specified device and
90 /* XXX - should be in fdisk.h, used by sd as well */
113 #define VTOC_NOTSUP 2 /* operation not supported - EFI label */
151 /* Maximum number of digits for a valid partition size */
154 /* Minimum partition size in cylinders */
159 "[ -A id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect ]\n"
160 "[ -b masterboot ]\n"
161 "[ -D id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect ]\n"
162 "[ -F fdisk_file ] [ -h ] [ -o offset ] [ -P fill_patt ] [ -s size ]\n"
163 "[ -S geom_file ] [ [ -v ] -W { creat_fdisk_file | - } ]\n"
164 "[ -w | r | d | n | I | B | E | g | G | R | t | T ] rdevice";
166 static char Usage1[] = " Partition options:\n"
167 " -A id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect\n"
168 " Create a partition with specific attributes:\n"
169 " id = system id number (fdisk.h) for the partition type\n"
170 " act = active partition flag (0 is off and 128 is on)\n"
171 " bhead = beginning head for start of partition\n"
172 " bsect = beginning sector for start of partition\n"
173 " bcyl = beginning cylinder for start of partition\n"
174 " ehead = ending head for end of partition\n"
175 " esect = ending sector for end of partition\n"
176 " ecyl = ending cylinder for end of partition\n"
178 " start of partition\n"
179 " numsect = partition size in sectors\n"
180 " -b master_boot\n"
182 " -B Create one Solaris partition that uses the entire disk.\n"
183 " -E Create one EFI partition that uses the entire disk.\n"
184 " -D id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect\n"
185 " Delete a partition. See attribute definitions for -A.\n"
186 " -F fdisk_file\n"
187 " Use fdisk_file to initialize on-line fdisk table.\n"
188 " -I Forego device checks. Generate a file image of what would go\n"
189 " on a disk using the geometry specified with the -S option.\n"
190 " -n Do not run in interactive mode.\n"
191 " -R Open the disk device as read-only.\n"
192 " -t Check and adjust VTOC to be consistent with fdisk table.\n"
193 " VTOC slices exceeding the partition size will be truncated.\n"
194 " -T Check and adjust VTOC to be consistent with fdisk table.\n"
195 " VTOC slices exceeding the partition size will be removed.\n"
196 " -W fdisk_file\n"
197 " Write on-disk table to fdisk_file.\n"
198 " -W - Write on-disk table to standard output.\n"
199 " -v Display virtual geometry. Must be used with the -W option.\n"
201 " -d Activate debug information about progress.\n"
202 " -g Write label geometry to standard output:\n"
210 " -G Write physical geometry to standard output (see -g).\n"
211 " -h Issue this verbose help message.\n"
212 " -o offset\n"
214 " -P # specified.\n"
215 " -P fill_patt\n"
220 " and fills each block (see -o and -s).\n"
221 " -r Read from a disk to stdout (see -o and -s).\n"
222 " -s size Number of blocks on which to perform operation (see -o).\n"
223 " -S geom_file\n"
224 " Use geom_file to set the label geometry (see -g).\n"
225 " -w Write to a disk from stdin (see -o and -s).";
230 static char DDstr[] = "DOS-DATA";
231 static char EDstr[] = "EXT-DOS";
232 static char DBstr[] = "DOS-BIG";
272 static int io_wrt = 0; /* write stdin to disk (-w) */
273 static int io_rd = 0; /* read disk and write stdout (-r) */
274 static char *io_fatt; /* user supplied pattern (-P pattern) */
275 static int io_patt = 0; /* write pattern to disk (-P pattern) */
276 static int io_lgeom = 0; /* get label geometry (-g) */
277 static int io_pgeom = 0; /* get drive physical geometry (-G) */
278 static char *io_sgeom = 0; /* set label geometry (-S geom_file) */
279 static int io_readonly = 0; /* do not write to disk (-R) */
281 /* The -o offset and -s size options specify the area of the disk on */
282 /* which to perform the particular operation; i.e., -P, -r, or -w. */
283 static off_t io_offset = 0; /* offset sector (-o offset) */
284 static off_t io_size = 0; /* size in sectors (-s size) */
286 /* Partition table flags */
287 static int v_flag = 0; /* virtual geometry-HBA flag (-v) */
288 static int stdo_flag = 0; /* stdout flag (-W -) */
290 static int io_ifdisk = 0; /* interactive partition */
291 static int io_nifdisk = 0; /* non-interactive partition (-n) */
293 static int io_adjt = 0; /* check/adjust VTOC (truncate (-t)) */
294 static int io_ADJT = 0; /* check/adjust VTOC (delete (-T)) */
295 static char *io_ffdisk = 0; /* input fdisk file name (-F file) */
296 static char *io_Wfdisk = 0; /* output fdisk file name (-W file) */
297 static char *io_Afdisk = 0; /* add entry to partition table (-A) */
298 static char *io_Dfdisk = 0; /* delete entry from part. table (-D) */
300 static char *io_mboot = 0; /* master boot record (-b boot_file) */
304 static int io_wholedisk = 0; /* use whole disk for Solaris (-B) */
305 static int io_EFIdisk = 0; /* use whole disk for EFI (-E) */
306 static int io_debug = 0; /* activate verbose mode (-d) */
307 static int io_image = 0; /* create image using geometry (-I) */
356 * Complete list of all the 255 partition types. Some are unknown types
359 * Courtesy of http://www.win.tue.nl/~aeb/partitions/partition_types-1.html
386 "AST SmartSleep Partition", /* 24 */
430 "GoBack partition", /* 68 */
431 "Boot-US boot manager", /* 69 */
438 "Oberon partition", /* 76 */
447 "EZ-Drive", /* 85 */
448 "Golden Bow VFeature/AT&T MS-DOS", /* 86 */
462 "PC-ARMOUR, Netware 286", /* 100 */
474 "DiskSecure Multi-Boot", /* 112 */
478 "Scramdisk partition", /* 116 */
500 "Linux Kernel Partition", /* 138 */
504 "Linux LVM partition", /* 142 */
530 "Mac OS-X", /* 168 */
533 "Mac OS-X Boot", /* 171 */
578 "CP/M-86", /* 216 */
580 "Non-FS Data", /* 218 */
587 "SpeedStor 12-bit FAT EXT", /* 225 */
590 "SpeedStor 16-bit FAT EXT", /* 228 */
602 "Linux/PA-RISC boot loader", /* 240 */
607 "Prologue multi-volume", /* 245 */
620 /* Allowed extended partition menu options */
624 * Structure holding all information about the extended partition
626 * known systems allow only one extended dos partition per disk.
714 * This function is called only during the non-interactive mode.
716 * mounted logical drives, changes to the partition table
761 * Process command-line options.
852 * If '-' is the -W argument, then write
856 if (strncmp(optarg, "-", 1) == 0)
904 "\nDetailed help is available with the -h option.\n");
917 if ((Dev = open(Dfltdev, openmode, 0666)) == -1) {
939 * turn off flag to print out virtual geometry (-v),
1019 * turn off flag to print out virtual geometry (-v)
1074 (void) printf(" %-8d %-8d %-8d %-8d %-5d %-5d %-6d\n",
1094 (void) printf(" %-8d %-8d %-8d %-8d %-5d %-5d %-6d\n",
1176 * Read extended partition only when the fdisk table is not
1219 /* Load fdisk table from specified file (-F fdisk_file) */
1221 /* Load and verify user-specified table parameters */
1239 " partition for the disk is:\n\n"
1241 "partition\n\n"
1243 "partition, otherwise type \"n\" to "
1244 "edit the\n partition table.\n");
1248 " than 2TB. Solaris partition will"
1252 /* Edit the partition table as directed */
1257 /* now set up UNIX System partition */
1262 LE_32((ulong_t)((Numcyl_usable - 1) *
1271 /* create an EFI partition for the whole disk */
1275 (dev_capacity - 1), 0);
1278 "Error creating EFI partition\n");
1288 (void) fprintf(stderr, "Partition Table Entry Values:\n");
1320 * Read geometry from specified file (-S).
1337 while (fgets(line, sizeof (line) - 1, fp)) {
1357 } /* while (fgets(line, sizeof (line) - 1, fp)) */
1388 if (lseek(Dev, 0, SEEK_SET) == -1) {
1390 "fdisk: Error seeking to partition table on %s.\n",
1397 "fdisk: Error reading partition table from %s.\n",
1412 int clr_efi = -1;
1454 /* Did a solaris partition change location or size? */
1474 /* look to see if a EFI partition changed in relsect/numsect */
1489 * if EFI partition changed, set the flag to clear
1513 if ((ioctl(Dev, DKIOCSMBOOT, buff) == -1) && (errno != ENOTTY)) {
1522 if (lseek(Dev, sect, SEEK_SET) == -1) {
1555 * and installed in a non-platform-dependent
1564 if ((mDev = open(io_mboot, O_RDONLY, 0666)) == -1) {
1628 while (io_size--) {
1637 SEEK_SET) == -1) {
1647 } /* while (--io_size); */
1653 * io_size blocks. Write the data to standard ouput (-r).
1660 while (io_size--) {
1662 SEEK_SET) == -1) {
1688 } /* while (--io_size); */
1695 * absolute relative block io_offset for io_size blocks (-w).
1702 while (io_size--) {
1728 SEEK_SET) == -1) {
1740 } /* while (--io_size); */
1748 * delete an entry (-A, -D, -F).
1787 * force it to be updated on disk later (-F
1795 "fdisk: Cannot open prototype partition file %s.\n",
1801 while (fgets(line, sizeof (line) - 1, fp)) {
1812 "Extended partition"
1820 * If the existing extended partition's start
1822 * initialize the extended partition EBR
1864 * extended partition matches the new one and
1874 begsec = rsect - offset;
1895 * from the given start of partition.
1912 "Invalid partition ID\n");
1918 endsec = rsect + numsect - 1;
1925 "partition\n");
1940 * Validate the partition. It cannot start at sector
1952 startindex)) != -1) {
1966 * cylinder size (virtual made-up cylinder
1968 * and sectors in partition table fields).
1985 * partition with the -F option that contains
1986 * a partition that runs off the end of the
2006 } /* while (fgets(line, sizeof (line) - 1, fp)) */
2010 "fdisk: Cannot create partition table\n");
2019 /* Parse the user-supplied deletion line (-D) */
2056 temp = temp->next) {
2057 relsect = temp->abs_secnum + temp->logdrive_offset;
2058 if (temp->parts[0].systid == id &&
2059 temp->parts[0].bootid == act &&
2060 temp->parts[0].beghead == bhead &&
2061 temp->parts[0].begsect == ((bsect & 0x3f) |
2063 temp->parts[0].begcyl == (uchar_t)(bcyl & 0xff) &&
2064 temp->parts[0].endhead == ehead &&
2065 temp->parts[0].endsect == ((esect & 0x3f) |
2067 temp->parts[0].endcyl == (uchar_t)(ecyl & 0xff) &&
2069 temp->parts[0].numsect == LE_32(numsect)) {
2078 "fdisk: Entry does not match any existing partition:\n"
2086 /* Parse the user-supplied addition line (-A) */
2094 /* Validate the partition. It cannot start at sector 0 */
2097 "fdisk: New partition cannot start at sector 0:\n"
2104 * if the user wishes to add an EFI partition, we need
2106 * numsect should equal the entire disk capacity - 1
2123 "(input numsect: %u - max: %llu)\n",
2127 } else if (numsect != dev_capacity - 1) {
2131 "(input numsect: %u - avail: %llu)\n",
2133 dev_capacity - 1);
2140 (void) printf("Invalid partition ID\n");
2147 "Extended partition already exists.\n");
2166 begsec = rsect - offset;
2173 * from the given start of partition.
2190 "fdisk: Partition size cannot be zero:\n"
2195 endsec = rsect + numsect - 1;
2224 "fdisk: Cannot create partition \"%s\"\n", file);
2234 * for a single partition table entry (ti) based on the relsect
2269 lba = (uint32_t)(Table[ti].relsect + Table[ti].numsect - 1);
2286 * Insert entry into fdisk table. Check all user-supplied values
2299 /* validate partition size */
2302 "fdisk: Partition table exceeds the size of the disk.\n");
2303 return (-1);
2307 /* find UNUSED partition table entry */
2314 (void) fprintf(stderr, "fdisk: Partition table is full.\n");
2315 return (-1);
2333 * valid means non-zero values that fit in the BIOS fields
2355 * return partition index
2376 return (-1);
2390 /* find UNUSED partition table entry */
2400 return (-1);
2404 return (-1);
2409 * Verify that no partition entries overlap or exceed the size of
2420 for (i = 0; i < FD_NUMPART - 1; i++) {
2427 return (-1);
2432 * EFI_PMBR partition must be the only
2433 * partition
2440 "for EFI_PMBR partition:\n"
2445 return (-1);
2450 (dev_capacity - 1))) {
2453 "EFI_PMBR partition must "
2459 "numsect %u - "
2466 "disk.\n numsect %u - "
2469 dev_capacity - 1);
2471 return (-1);
2475 /* make sure the partition isn't larger than the disk */
2482 return (-1);
2494 "Cannot add partition to "
2501 "partition:\t"
2505 "partition:\t\t"
2530 return (-1);
2538 "current partition overlaps"
2539 " following partition\n");
2541 return (-1);
2549 return (-1);
2555 return (-1);
2564 * Parse user-supplied data to set up fdisk partitions
2565 * (-A, -D, -F).
2621 * Validate that a new partition does not start at sector 0. Only UNUSED
2636 "New partition cannot start at sector 0\n");
2637 return (-1);
2641 (void) fprintf(stderr, "Invalid partition ID\n");
2642 return (-1);
2674 "Enter a one-digit number between 1 and 7.");
2677 "Enter a one-digit number between 1 and 6.");
2687 if (pcreate() == -1)
2691 if (pchange() == -1)
2695 if (pdelete() == -1)
2699 if (ppartid() == -1)
2708 (void) printf("\nNo extended partition"
2716 /* update disk partition table, if changed */
2753 /* update disk partition table, if changed */
2795 * Create partition entry in the table (interactive mode).
2813 "The partition table is full!\n"
2814 "You must delete a partition before creating"
2816 return (-1);
2830 /* Check if an extended partition already exists */
2838 " another partition.\n");
2840 "You must delete a partition before creating"
2842 return (-1);
2857 "Select the partition type to create:\n"
2872 return (-1);
2873 case '1': /* Solaris partition */
2876 case '2': /* UNIX partition */
2879 case '3': /* PCIXOS partition */
2882 case '4': /* OTHEROS System partition */
2897 "Extended partition already exists\n");
2912 case 'a': /* x86 Boot partition */
2916 case 'b': /* Diagnostic boot partition */
2928 case 'e': /* Extended partition, need extended int13 */
2935 "Extended partition already exists\n");
2961 "Upper limit is 2 TB for non-EFI partition ID\n");
2963 /* create the new partition */
2966 if (i != -1) {
2967 /* see if it should be the active partition */
2972 "Should this become the active partition? If "
2984 "Partition %d is now "
2985 "the active partition.",
2997 * If partition created is an extended partition, null
2999 * extended partition
3022 "fdisk: Cannot create EFI partition table; \n"
3023 "current partition table is invalid.\n");
3024 return (-1);
3027 "An EFI partition must be the only partition on "
3037 return (-1);
3041 /* create the table entry - i should be 0 */
3044 (dev_capacity - 1), 0);
3047 (void) printf("Error creating EFI partition!!!\n");
3048 i = -1;
3064 * Query the user to specify the size of the new partition in
3071 int i, j, percent = -1;
3076 struct ipart *partition[FD_NUMPART];
3082 * make a local copy of the partition table
3100 partition[i] = &localpart[i];
3102 for (i = 0; i < FD_NUMPART - 1; i++) {
3103 if (partition[i]->systid == UNUSED)
3106 if (partition[j]->systid == UNUSED)
3108 if (LE_32(partition[j]->relsect) <
3109 LE_32(partition[i]->relsect)) {
3110 struct ipart *temp = partition[i];
3111 partition[i] = partition[j];
3112 partition[j] = temp;
3120 "Specify the percentage of disk to use for this partition\n"
3131 return (-1);
3138 return (-1);
3146 return (-1);
3153 return (-1);
3157 cylen = Numcyl_usable - 1;
3161 /* Verify DOS12 partition doesn't exceed max size of 32MB. */
3167 (void) printf("Maximum size for a DOS partition "
3170 return (-1);
3178 * check for free space before partition i
3181 * freespace after partition 3 is unusable
3184 * freespace begins at the end of previous partition
3189 first_free = LE_32(partition[i - 1]->relsect) +
3190 LE_32(partition[i - 1]->numsect);
3196 * freespace ends before the current partition
3199 if (partition[i]->systid == UNUSED) {
3200 size_free = chs_capacity - first_free;
3203 * Partition might start before cylinder 1.
3207 (LE_32(partition[i]->relsect > first_free))
3208 ? (LE_32(partition[i]->relsect) -
3220 if (partition[i]->systid == UNUSED) {
3226 return (-1);
3233 "fdisk: Partition table is full.\n");
3234 return (-1);
3241 return (-1);
3248 if ((cyl = getcyl()) == -1) {
3251 return (-1);
3256 "New partition cannot start at cylinder 0.\n");
3257 return (-1);
3266 cyl, Numcyl_usable - 1);
3267 return (-1);
3271 (void) printf("Enter partition size in cylinders: ");
3272 if ((cylen = getcyl()) == -1) {
3275 return (-1);
3281 if (partition[i]->systid == UNUSED)
3283 t_relsect = LE_32(partition[i]->relsect);
3284 t_numsect = LE_32(partition[i]->numsect);
3293 return (-1);
3297 (cyl + cylen - 1) * cyl_size > t_relsect) {
3300 "Maximum size for partition is %u cylinders"
3302 (t_relsect - cyl * cyl_size) / cyl_size);
3303 return (-1);
3307 /* Verify partition doesn't exceed disk size or 2 TB */
3312 "Maximum size for partition is %d "
3314 Numcyl_usable - cyl);
3317 "Maximum size for partition is %d "
3319 Numcyl_usable - cyl);
3321 return (-1);
3324 /* Verify DOS12 partition doesn't exceed max size of 32MB. */
3329 "Maximum size for a %s partition is %ld cylinders;"
3332 return (-1);
3339 return (-1);
3343 (void) printf("fdisk: Cannot create partition table\n");
3344 return (-1);
3362 " 1. Create a partition\n"
3363 " 2. Specify the active partition\n"
3364 " 3. Delete a partition\n"
3365 " 4. Change between Solaris and Solaris2 Partition IDs\n"
3372 " 1. Create a partition\n"
3373 " 2. Specify the active partition\n"
3374 " 3. Delete a partition\n"
3375 " 4. Change between Solaris and Solaris2 Partition IDs\n"
3383 * Change the ACTIVE designation of a partition.
3395 "Specify the partition number to boot from"
3418 "No partition is currently marked as active.");
3420 } else { /* User has selected a partition to be active */
3422 i = s[0] - '1';
3426 (void) printf("Partition does not exist.");
3427 return (-1);
3429 /* a DOS-DATA or EXT-DOS partition cannot be active */
3435 "DOS-DATA, EXT_DOS and EXT_DOS_LBA partitions "
3437 (void) printf("Select another partition.");
3438 return (-1);
3449 "Partition %d is now active. The system will start up"
3451 (void) printf("partition after the next reboot.");
3457 * Change between SOLARIS and SOLARIS2 partition id
3467 (void) printf("Specify the partition number to change"
3486 i -= 1;
3495 "Partition %d is not a Solaris partition.",
3501 (void) printf("Partition %d has been changed.", i + 1);
3508 * Remove partition entry from the table (interactive mode).
3518 (void) printf("Specify the partition number to delete"
3533 --i; /* Structure begins with element 0 */
3538 (void) printf("Partition %d does not exist.", i + 1);
3539 return (-1);
3548 " extended partition\n");
3570 (void) printf("Are you sure you want to delete partition %d?"
3572 (void) printf("programs in this partition inaccessible (type"
3592 (void) printf("Partition %d has been deleted.", i + 1);
3595 (void) printf(" This was the active partition.");
3614 /* Found first non-blank character of the string */
3627 * Take the user-specified cylinder number and convert it from a
3638 if (s[slen - 1] == '\n')
3639 slen--;
3642 for (i = slen - 1; i >= 0; i--) {
3644 return (-1);
3646 cyl += (j * (s[i] - '0'));
3655 * of the disk used for each partition.
3680 " Partition Status Type Start End Length"
3816 endcyl = Numcyl - 1;
3817 length = endcyl - startcyl + 1;
3824 endcyl = startcyl + length - 1;
3839 "\n %d %s %-12.12s %4d %4d %4d"
3855 "Upper limit is 2 TB for non-EFI partition ID\n");
3874 (void) fprintf(stderr, " %-5d ", Table[i].systid);
3875 (void) fprintf(stderr, "%-3d ", Table[i].bootid);
3876 (void) fprintf(stderr, "%-5d ", Table[i].beghead);
3877 (void) fprintf(stderr, "%-5d ", Table[i].begsect & 0x3f);
3878 (void) fprintf(stderr, "%-8d ",
3881 (void) fprintf(stderr, "%-5d ", Table[i].endhead);
3882 (void) fprintf(stderr, "%-5d ", Table[i].endsect & 0x3f);
3883 (void) fprintf(stderr, "%-8d ",
3885 (void) fprintf(stderr, "%-10u ", LE_32(Table[i].relsect));
3886 (void) fprintf(stderr, "%-10u\n", LE_32(Table[i].numsect));
3937 /* Get an aligned copy of the partition tables */
3938 (void) memcpy(iparts, Bootblk->parts, sizeof (iparts));
3939 bootptr = (char *)iparts; /* Points to start of partition table */
3940 if (LE_16(Bootblk->signature) != MBB_MAGIC) {
3943 (void) memcpy(Bootblk->bootinst, &BootCod, BOOTSZ);
3947 * When the DOS fdisk command deletes a partition, it is not
3963 (void) memcpy(Bootblk->bootinst, &BootCod, BOOTSZ);
3976 partp->bootid = getbyte(&bootptr);
3977 partp->beghead = getbyte(&bootptr);
3978 partp->begsect = getbyte(&bootptr);
3979 partp->begcyl = getbyte(&bootptr);
3980 partp->systid = getbyte(&bootptr);
3981 partp->endhead = getbyte(&bootptr);
3982 partp->endsect = getbyte(&bootptr);
3983 partp->endcyl = getbyte(&bootptr);
3984 partp->relsect = (int32_t)getlong(&bootptr);
3985 partp->numsect = (int32_t)getlong(&bootptr);
4033 boot_ptr = (struct ipart *)Bootblk->parts;
4037 if (tbl_ptr->systid == UNUSED)
4042 Bootblk->signature = LE_16(MBB_MAGIC);
4047 * Check for any changes in the partition table.
4057 /* Partition table changed, write back to disk */
4067 * Display contents of partition table to standard output or
4068 * another file name without writing it to the disk (-W file).
4154 " %-5d %-4d %-6d %-6d %-7d %-6d %-6d %-7d %-10u"
4155 " %-10u\n",
4175 temp = temp->next) {
4176 ext_tab = temp->parts[0];
4180 tempsect = LE_32(temp->parts[1].relsect);
4182 " %-5d %-4d %-6d %-6d %-7d %-6d %-6d "
4183 "%-7d %-8u %-8u\n",
4206 * Read the VTOC table on the Solaris partition and check that no
4207 * slices exist that extend past the end of the Solaris partition.
4208 * If no Solaris partition exists, nothing is done.
4225 * the partition.
4235 "fdisk: No Solaris partition found - VTOC not"
4250 " start of partition",
4265 " complete partition",
4300 " is larger than the partition",
4326 "partition", i, disk_vtoc.v_part[i].p_start);
4347 " than the partition",
4363 /* Make the VTOC look sane - ha ha */
4404 * Read the VTOC from the Solaris partition of the device.
4418 (void) fprintf(stderr, "fdisk: partition may have EFI "
4431 * Write the VTOC to the Solaris partition on the device.
4445 (void) fprintf(stderr, "fdisk: partition may have EFI "
4464 void *data = dk_ioc->dki_data;
4467 dk_ioc->dki_data_64 = (uintptr_t)data;
4475 * Clear EFI labels from the EFI_PMBR partition on the device
4495 dk_ioc.dki_length = EFI_MIN_ARRAY_SIZE + efi_vtoc->efi_lbasize;
4510 if (efi_ioctl(Dev, DKIOCSETEFI, &dk_ioc) == -1) {
4523 * clear the backup partition table
4525 dk_ioc.dki_lba = efi_vtoc->efi_last_u_lba + 1;
4526 dk_ioc.dki_length -= efi_vtoc->efi_lbasize;
4528 efi_vtoc->efi_lbasize);
4531 "\tClearing backup partition table at block %lld\n",
4535 if (efi_ioctl(Dev, DKIOCSETEFI, &dk_ioc) == -1) {
4537 "block %llu; errno %d\n", efi_vtoc->efi_last_u_lba + 1,
4544 dk_ioc.dki_lba = efi_vtoc->efi_last_lba;
4545 dk_ioc.dki_length = efi_vtoc->efi_lbasize;
4546 dk_ioc.dki_data = (efi_gpt_t *)((char *)dk_ioc.dki_data -
4547 efi_vtoc->efi_lbasize);
4553 if (efi_ioctl(Dev, DKIOCSETEFI, &dk_ioc) == -1) {
4557 efi_vtoc->efi_last_lba,
4569 * Clear the VTOC from the current or previous Solaris partition on the
4597 seek_byte = (off_t)(LE_32(clr_table->relsect) + VTOC_OFFSET) * sectsiz;
4603 (uint64_t)(LE_32(clr_table->relsect) + VTOC_OFFSET));
4606 if (lseek(Dev, seek_byte, SEEK_SET) == -1) {
4623 if (lseek(Dev, seek_byte, SEEK_SET) == -1) {
4659 pcyl = LE_32(clr_table->numsect) / (heads * sectors);
4660 solaris_offset = LE_32(clr_table->relsect);
4661 ncyl = pcyl - acyl;
4663 backup_block = ((ncyl + acyl - 1) *
4664 (heads * sectors)) + ((heads - 1) * sectors) + 1;
4669 if (lseek(Dev, seek_byte, SEEK_SET) == -1) {
4697 if (lseek(Dev, seek_byte, SEEK_SET) == -1) {
4770 * non-interactive mode or read-only mode.
4794 int idx = -1;
4798 * to tell if they've specified the full disk partition by checking
4799 * to see if they've specified a partition that starts at sector 0.
4801 if (ioctl(fd, DKIOCEXTPARTINFO, &extpi) != -1) {
4809 } else if (ioctl(fd, DKIOCPARTINFO, &pi) != -1) {
4826 if (ioctl(fd, DKIOCGGEOM, &d) == -1) {
4867 if (stat(node, (struct stat *)&statbuf) == -1) {
4882 space -= strlen(DEFAULT_PATH);
4886 if (stat(node, (struct stat *)&statbuf) == -1) {
4917 * Convert a given partition ID to an descriptive string.
4918 * Just an index into the partition types table.
4927 * Procedure to check the validity of the extended partition menu option
4957 * Procedure to read and validate the user option at the extended partition menu
4965 return (-1);
4971 * Procedure to print the list of known partition types and their IDs
4987 * partition IDs being printed.
4989 rowmax = ws.ws_row - 5;
4998 (void) printf("List of known partition types : \n");
4999 (void) printf("PartID Partition Type\n");
5002 (void) printf("%-3d %s\n", i, fdisk_part_types[i]);
5007 * printing the partition IDs, but one.
5009 rowmax = ws.ws_row - 1;
5028 (void) printf("Enter the partition number : ");
5038 /* Check if there is a non-digit in the input */
5039 for (i = 0; i < len-1; i++) {
5054 (void) printf("Invalid partition number\n");
5067 "partition IDs ) : ");
5072 (void) printf("Invalid partition ID\n");
5081 /* Check if there is a non-digit in the input */
5082 for (i = 0; i < len-1; i++) {
5084 (void) printf("Invalid partition ID\n");
5089 if (i < len - 1) {
5095 (void) printf("Invalid partition ID\n");
5108 /* Disallow EFI partitions within extended partition */
5111 "partition is not allowed\n");
5115 return; /* Valid partition ID is in partid */
5132 (void) printf("Partition %d deleted\n", pno);
5151 (void) printf("Enter the beginning cylinder (Default - %d) : ",
5165 /* Check if there is a non-digit in the input */
5166 for (i = 0; i < len - 1; i++) {
5173 if (i < len - 1) {
5188 (void) printf("Partition boundary overlaps "
5210 * 2. If not, check if there are any non-digits
5218 * b) If no, Check if the size is within endcyl - begcyl
5243 "Cylinder -");
5258 copy_len = len - 1;
5261 copy_len--;
5262 if ((ch = toupper(buf[len - 2])) == 'B') {
5263 ch = toupper(buf[len - 3]);
5264 copy_len--;
5268 (void) printf("Invalid partition size\n");
5272 copy_len--;
5280 (void) printf("Invalid partition size\n");
5294 (void) printf("Invalid partition size\n");
5302 (void) printf("Invalid partition size\n");
5310 if (size > (last_free_sec - begsec + 1)) {
5314 (void) printf("Invalid partition size\n");
5324 poss_end = begsec + size - 1;
5326 poss_end += spc - remdr - 1;
5337 * 1. Get the starting and ending sectors/cylinder of the extended partition.
5339 * 3. Allow the user to specify the beginning cylinder of the new partition
5341 * a) If it is non-numeric
5342 * b) If it is beyond the extended partition limits
5346 * a) If it is non-numeric
5347 * b) If it is beyond the extended partition limits
5350 * 7. Request partition ID for the new partition.
5380 "partition\n");
5390 (void) printf("New partition with ID %d added\n", partid);
5409 (void) printf("Partition ID of partition %d changed to %d\n", pno,
5429 for (temp = head, pno = 5; temp != NULL; temp = temp->next, pno++) {
5431 id_to_name(temp->parts[0].systid, namebuff);
5434 LE_32(temp->parts[0].relsect),
5435 LE_32(temp->parts[0].numsect),
5436 temp->abs_secnum,
5437 temp->abs_secnum + temp->numsect - 1 +
5443 * partition.
5445 id_to_name(temp->parts[1].systid, namebuff);
5448 LE_32(temp->parts[1].relsect),
5449 LE_32(temp->parts[1].numsect),
5481 (void) printf("Beginning cylinder of extended partition : %u\n",
5483 (void) printf("Ending cylinder of extended partition : %u\n",
5491 temp = temp->next, pno++) {
5493 fpart = &temp->parts[0];
5494 sysid = fpart->systid;
5496 * Check if partition id 0x82 is Solaris
5501 part_start = temp->abs_secnum +
5502 temp->logdrive_offset;
5511 startcyl = temp->begcyl;
5512 endcyl = temp->endcyl;
5516 length = endcyl - startcyl + 1;
5530 (void) printf("%-5d %-8u %-8u %-7u %-3d "
5531 "%-3d (%-.28s)\n",
5583 (void) printf("Extended partition menu\n");