Lines Matching +full:slice +full:- +full:per +full:- +full:line
38 * operations from a supplied menu or from the command line. Diagnostic
101 #define VTOC_NOTSUP 2 /* operation not supported - EFI label */
147 "[ -A id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect ]\n"
148 "[ -b masterboot ]\n"
149 "[ -D id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect ]\n"
150 "[ -E [slot:active] ]\n"
151 "[ -F fdisk_file ] [ -h ] [ -o offset ] [ -P fill_patt ] [ -s size ]\n"
152 "[ -S geom_file ] [ [ -v ] -W { creat_fdisk_file | - } ]\n"
153 "[ -w | r | d | n | I | B | g | G | R | t | T ] rdevice";
156 " -A id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect\n"
169 " -b master_boot\n"
171 " -B Create one Solaris partition that uses the entire disk.\n"
172 " -D id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect\n"
173 " Delete a partition. See attribute definitions for -A.\n"
174 " -E [slot:active]\n"
176 " -F fdisk_file\n"
177 " Use fdisk_file to initialize on-line fdisk table.\n"
178 " -I Forego device checks. Generate a file image of what would go\n"
179 " on a disk using the geometry specified with the -S option.\n"
180 " -n Do not run in interactive mode.\n"
181 " -R Open the disk device as read-only.\n"
182 " -t Check and adjust VTOC to be consistent with fdisk table.\n"
184 " -T Check and adjust VTOC to be consistent with fdisk table.\n"
186 " -W fdisk_file\n"
187 " Write on-disk table to fdisk_file.\n"
188 " -W - Write on-disk table to standard output.\n"
189 " -v Display virtual geometry. Must be used with the -W option.\n"
191 " -d Activate debug information about progress.\n"
192 " -g Write label geometry to standard output:\n"
198 " NSECTORS number of sectors per track\n"
200 " -G Write physical geometry to standard output (see -g).\n"
201 " -h Issue this verbose help message.\n"
202 " -o offset\n"
204 " -P # specified.\n"
205 " -P fill_patt\n"
210 " and fills each block (see -o and -s).\n"
211 " -r Read from a disk to stdout (see -o and -s).\n"
212 " -s size Number of blocks on which to perform operation (see -o).\n"
213 " -S geom_file\n"
214 " Use geom_file to set the label geometry (see -g).\n"
215 " -w Write to a disk from stdin (see -o and -s).";
220 static char DDstr[] = "DOS-DATA";
221 static char EDstr[] = "EXT-DOS";
222 static char DBstr[] = "DOS-BIG";
262 static int io_wrt = 0; /* write stdin to disk (-w) */
263 static int io_rd = 0; /* read disk and write stdout (-r) */
264 static char *io_fatt; /* user supplied pattern (-P pattern) */
265 static int io_patt = 0; /* write pattern to disk (-P pattern) */
266 static int io_lgeom = 0; /* get label geometry (-g) */
267 static int io_pgeom = 0; /* get drive physical geometry (-G) */
268 static char *io_sgeom = 0; /* set label geometry (-S geom_file) */
269 static int io_readonly = 0; /* do not write to disk (-R) */
271 /* The -o offset and -s size options specify the area of the disk on */
272 /* which to perform the particular operation; i.e., -P, -r, or -w. */
273 static off_t io_offset = 0; /* offset sector (-o offset) */
274 static off_t io_size = 0; /* size in sectors (-s size) */
277 static int v_flag = 0; /* virtual geometry-HBA flag (-v) */
278 static int stdo_flag = 0; /* stdout flag (-W -) */
281 static int io_nifdisk = 0; /* non-interactive partition (-n) */
283 static int io_adjt = 0; /* check/adjust VTOC (truncate (-t)) */
284 static int io_ADJT = 0; /* check/adjust VTOC (delete (-T)) */
285 static char *io_ffdisk = 0; /* input fdisk file name (-F file) */
286 static char *io_Wfdisk = 0; /* output fdisk file name (-W file) */
287 static char *io_Afdisk = 0; /* add entry to partition table (-A) */
288 static char *io_Dfdisk = 0; /* delete entry from part. table (-D) */
290 static char *io_mboot = 0; /* master boot record (-b boot_file) */
294 static int io_wholedisk = 0; /* use whole disk for Solaris (-B) */
295 static int io_EFIdisk = 0; /* use whole disk for EFI (-E) */
298 static int io_debug = 0; /* activate verbose mode (-d) */
299 static int io_image = 0; /* create image using geometry (-I) */
328 static int sectors; /* number of sectors per track */
334 static int hba_sectors; /* number of sectors per track */
351 * Courtesy of http://www.win.tue.nl/~aeb/partitions/partition_types-1.html
423 "Boot-US boot manager", /* 69 */
439 "EZ-Drive", /* 85 */
440 "Golden Bow VFeature/AT&T MS-DOS", /* 86 */
454 "PC-ARMOUR, Netware 286", /* 100 */
466 "DiskSecure Multi-Boot", /* 112 */
522 "Mac OS-X", /* 168 */
525 "Mac OS-X Boot", /* 171 */
570 "CP/M-86", /* 216 */
572 "Non-FS Data", /* 218 */
579 "SpeedStor 12-bit FAT EXT", /* 225 */
582 "SpeedStor 16-bit FAT EXT", /* 228 */
594 "Linux/PA-RISC boot loader", /* 240 */
599 "Prologue multi-volume", /* 245 */
618 * known systems allow only one extended dos partition per disk.
644 static int pars_fdisk(char *line,
707 * This function is called only during the non-interactive mode.
754 * Process command-line options.
824 optind--; in main()
850 * If '-' is the -W argument, then write in main()
854 if (strncmp(optarg, "-", 1) == 0) in main()
902 "\nDetailed help is available with the -h option.\n"); in main()
914 if ((Dev = open(Dfltdev, openmode, 0666)) == -1) { in main()
936 * turn off flag to print out virtual geometry (-v), in main()
1016 * turn off flag to print out virtual geometry (-v) in main()
1071 (void) printf(" %-8d %-8d %-8d %-8d %-5d %-5d %-6d\n", in main()
1091 (void) printf(" %-8d %-8d %-8d %-8d %-5d %-5d %-6d\n", in main()
1215 /* Load fdisk table from specified file (-F fdisk_file) */ in main()
1217 /* Load and verify user-specified table parameters */ in main()
1258 LE_32((ulong_t)((Numcyl_usable - 1) * in main()
1313 * Read geometry from specified file (-S).
1319 char line[256]; in read_geom() local
1329 /* Read a line from the file */ in read_geom()
1330 while (fgets(line, sizeof (line) - 1, fp)) { in read_geom()
1331 if (line[0] == '\0' || line[0] == '\n' || line[0] == '*') { in read_geom()
1334 line[strlen(line)] = '\0'; in read_geom()
1335 if (sscanf(line, "%hu %hu %hu %hu %hu %hu %d", in read_geom()
1345 line); in read_geom()
1350 } /* while (fgets(line, sizeof (line) - 1, fp)) */ in read_geom()
1381 if (lseek(Dev, 0, SEEK_SET) == -1) { in dev_mboot_read()
1405 int clr_efi = -1; in dev_mboot_write()
1481 clr_efi = -1; in dev_mboot_write()
1511 if ((ioctl(Dev, DKIOCSMBOOT, buff) == -1) && (errno != ENOTTY)) { in dev_mboot_write()
1520 if (lseek(Dev, sect, SEEK_SET) == -1) { in dev_mboot_write()
1551 if ((mDev = open(io_mboot, O_RDONLY, 0666)) == -1) { in mboot_read()
1560 if ((mDev = open(io_mboot, O_RDONLY, 0666)) == -1) { in mboot_read()
1626 while (io_size--) { in fill_patt()
1635 SEEK_SET) == -1) { in fill_patt()
1645 } /* while (--io_size); */ in fill_patt()
1651 * io_size blocks. Write the data to standard ouput (-r).
1658 while (io_size--) { in abs_read()
1660 SEEK_SET) == -1) { in abs_read()
1686 } /* while (--io_size); */ in abs_read()
1693 * absolute relative block io_offset for io_size blocks (-w).
1700 while (io_size--) { in abs_write()
1726 SEEK_SET) == -1) { in abs_write()
1738 } /* while (--io_size); */ in abs_write()
1746 * delete an entry (-A, -D, -F).
1762 char line[256]; in load() local
1785 * force it to be updated on disk later (-F in load()
1798 /* Read a line from the file */ in load()
1799 while (fgets(line, sizeof (line) - 1, fp)) { in load()
1800 if (pars_fdisk(line, &id, &act, &bhead, &bsect, in load()
1813 " entry \"%s\".\n", line); in load()
1845 /* This line should be logical drive info */ in load()
1872 begsec = rsect - offset; in load()
1912 " entry \"%s\".\n", line); in load()
1916 endsec = rsect + numsect - 1; in load()
1931 " entry \"%s\".\n", line); in load()
1944 line); in load()
1950 startindex)) != -1) { in load()
1964 * cylinder size (virtual made-up cylinder in load()
1983 * partition with the -F option that contains in load()
2000 line); in load()
2004 } /* while (fgets(line, sizeof (line) - 1, fp)) */ in load()
2017 /* Parse the user-supplied deletion line (-D) */ in load()
2054 temp = temp->next) { in load()
2055 relsect = temp->abs_secnum + temp->logdrive_offset; in load()
2056 if (temp->parts[0].systid == id && in load()
2057 temp->parts[0].bootid == act && in load()
2058 temp->parts[0].beghead == bhead && in load()
2059 temp->parts[0].begsect == ((bsect & 0x3f) | in load()
2061 temp->parts[0].begcyl == (uchar_t)(bcyl & 0xff) && in load()
2062 temp->parts[0].endhead == ehead && in load()
2063 temp->parts[0].endsect == ((esect & 0x3f) | in load()
2065 temp->parts[0].endcyl == (uchar_t)(ecyl & 0xff) && in load()
2067 temp->parts[0].numsect == LE_32(numsect)) { in load()
2084 /* Parse the user-supplied addition line (-A) */ in load()
2104 * numsect should equal the entire disk capacity - 1 in load()
2121 "(input numsect: %u - max: %llu)\n", in load()
2125 } else if (numsect != dev_capacity - 1) { in load()
2129 "(input numsect: %u - avail: %llu)\n", in load()
2131 dev_capacity - 1); in load()
2164 begsec = rsect - offset; in load()
2193 endsec = rsect + numsect - 1; in load()
2267 lba = (uint32_t)(Table[ti].relsect + Table[ti].numsect - 1); in Set_Table_CHS_Values()
2284 * Insert entry into fdisk table. Check all user-supplied values
2301 return (-1); in insert_tbl()
2313 return (-1); in insert_tbl()
2330 * valid means non-zero values that fit in the BIOS fields in insert_tbl()
2385 return (-1); in entry_from_old_table()
2409 return (-1); in entry_from_old_table()
2413 return (-1); in entry_from_old_table()
2429 for (i = 0; i < FD_NUMPART - 1; i++) { in verify_tbl()
2436 return (-1); in verify_tbl()
2454 return (-1); in verify_tbl()
2459 (dev_capacity - 1))) { in verify_tbl()
2468 "numsect %u - " in verify_tbl()
2475 "disk.\n numsect %u - " in verify_tbl()
2478 dev_capacity - 1); in verify_tbl()
2480 return (-1); in verify_tbl()
2491 return (-1); in verify_tbl()
2539 return (-1); in verify_tbl()
2550 return (-1); in verify_tbl()
2558 return (-1); in verify_tbl()
2564 return (-1); in verify_tbl()
2573 * Parse user-supplied data to set up fdisk partitions
2574 * (-A, -D, -F).
2578 char *line, in pars_fdisk() argument
2589 if (line[0] == '\0' || line[0] == '\n' || line[0] == '*') in pars_fdisk()
2591 line[strlen(line)] = '\0'; in pars_fdisk()
2592 for (i = 0; i < strlen(line); i++) { in pars_fdisk()
2593 if (line[i] == '\0') { in pars_fdisk()
2595 } else if (line[i] == ':') { in pars_fdisk()
2596 line[i] = ' '; in pars_fdisk()
2599 (void) strncpy(buf, line, 256); in pars_fdisk()
2605 (void) printf("Invalid input %s in line %s.\n", in pars_fdisk()
2606 tok, line); in pars_fdisk()
2613 (void) printf("Invalid input %s in line %s.\n", tok, in pars_fdisk()
2614 line); in pars_fdisk()
2619 if (sscanf(line, "%d %d %d %d %d %d %d %d %u %u", in pars_fdisk()
2622 (void) fprintf(stderr, "Syntax error:\n \"%s\".\n", line); in pars_fdisk()
2646 return (-1); in validate_part()
2651 return (-1); in validate_part()
2683 "Enter a one-digit number between 1 and 7.");
2686 "Enter a one-digit number between 1 and 6.");
2696 if (pcreate() == -1)
2700 if (pchange() == -1)
2704 if (pdelete() == -1)
2708 if (ppartid() == -1)
2825 return (-1);
2851 return (-1);
2859 * at least warning line. Clearing warning line as workaround
2881 return (-1);
2970 "Upper limit is 2 TB for non-EFI partition ID\n");
2975 if (i != -1) {
3033 return (-1);
3046 return (-1);
3050 /* create the table entry - i should be 0 */
3053 (dev_capacity - 1), 0);
3057 i = -1;
3080 int i, j, percent = -1;
3111 for (i = 0; i < FD_NUMPART - 1; i++) {
3112 if (partition[i]->systid == UNUSED)
3115 if (partition[j]->systid == UNUSED)
3117 if (LE_32(partition[j]->relsect) <
3118 LE_32(partition[i]->relsect)) {
3140 return (-1);
3147 return (-1);
3155 return (-1);
3162 return (-1);
3166 cylen = Numcyl_usable - 1;
3179 return (-1);
3198 first_free = LE_32(partition[i - 1]->relsect) +
3199 LE_32(partition[i - 1]->numsect);
3208 if (partition[i]->systid == UNUSED) {
3209 size_free = chs_capacity - first_free;
3216 (LE_32(partition[i]->relsect > first_free))
3217 ? (LE_32(partition[i]->relsect) -
3229 if (partition[i]->systid == UNUSED) {
3235 return (-1);
3243 return (-1);
3250 return (-1);
3257 if ((cyl = getcyl()) == -1) {
3260 return (-1);
3266 return (-1);
3275 cyl, Numcyl_usable - 1);
3276 return (-1);
3281 if ((cylen = getcyl()) == -1) {
3284 return (-1);
3290 if (partition[i]->systid == UNUSED)
3292 t_relsect = LE_32(partition[i]->relsect);
3293 t_numsect = LE_32(partition[i]->numsect);
3302 return (-1);
3306 (cyl + cylen - 1) * cyl_size > t_relsect) {
3311 (t_relsect - cyl * cyl_size) / cyl_size);
3312 return (-1);
3323 Numcyl_usable - cyl);
3328 Numcyl_usable - cyl);
3330 return (-1);
3341 return (-1);
3348 return (-1);
3353 return (-1);
3431 i = s[0] - '1';
3436 return (-1);
3438 /* a DOS-DATA or EXT-DOS partition cannot be active */
3444 "DOS-DATA, EXT_DOS and EXT_DOS_LBA partitions "
3447 return (-1);
3495 i -= 1;
3542 --i; /* Structure begins with element 0 */
3548 return (-1);
3623 /* Found first non-blank character of the string */
3637 * Take the user-specified cylinder number and convert it from a
3648 if (s[slen - 1] == '\n')
3649 slen--;
3652 for (i = slen - 1; i >= 0; i--) {
3654 return (-1);
3656 cyl += (j * (s[i] - '0'));
3826 endcyl = Numcyl - 1;
3827 length = endcyl - startcyl + 1;
3834 endcyl = startcyl + length - 1;
3849 "\n %d %s %-12.12s %4d %4d %4d"
3859 /* Clear the warning line */
3865 "Upper limit is 2 TB for non-EFI partition ID\n");
3884 (void) fprintf(stderr, " %-5d ", Table[i].systid);
3885 (void) fprintf(stderr, "%-3d ", Table[i].bootid);
3886 (void) fprintf(stderr, "%-5d ", Table[i].beghead);
3887 (void) fprintf(stderr, "%-5d ", Table[i].begsect & 0x3f);
3888 (void) fprintf(stderr, "%-8d ",
3891 (void) fprintf(stderr, "%-5d ", Table[i].endhead);
3892 (void) fprintf(stderr, "%-5d ", Table[i].endsect & 0x3f);
3893 (void) fprintf(stderr, "%-8d ",
3895 (void) fprintf(stderr, "%-10u ", LE_32(Table[i].relsect));
3896 (void) fprintf(stderr, "%-10u\n", LE_32(Table[i].numsect));
3948 (void) memcpy(iparts, Bootblk->parts, sizeof (iparts));
3950 if (LE_16(Bootblk->signature) != MBB_MAGIC) {
3953 (void) memcpy(Bootblk->bootinst, &BootCod, BOOTSZ);
3973 (void) memcpy(Bootblk->bootinst, &BootCod, BOOTSZ);
3986 partp->bootid = getbyte(&bootptr);
3987 partp->beghead = getbyte(&bootptr);
3988 partp->begsect = getbyte(&bootptr);
3989 partp->begcyl = getbyte(&bootptr);
3990 partp->systid = getbyte(&bootptr);
3991 partp->endhead = getbyte(&bootptr);
3992 partp->endsect = getbyte(&bootptr);
3993 partp->endcyl = getbyte(&bootptr);
3994 partp->relsect = (int32_t)getlong(&bootptr);
3995 partp->numsect = (int32_t)getlong(&bootptr);
4043 boot_ptr = (struct ipart *)Bootblk->parts;
4047 if (tbl_ptr->systid == UNUSED)
4052 Bootblk->signature = LE_16(MBB_MAGIC);
4078 * another file name without writing it to the disk (-W file).
4164 " %-5d %-4d %-6d %-6d %-7d %-6d %-6d %-7d %-10u"
4165 " %-10u\n",
4185 temp = temp->next) {
4186 ext_tab = temp->parts[0];
4190 tempsect = LE_32(temp->parts[1].relsect);
4192 " %-5d %-4d %-6d %-6d %-7d %-6d %-6d "
4193 "%-7d %-8u %-8u\n",
4245 "fdisk: No Solaris partition found - VTOC not"
4255 /* Special case for slice two (entire disk) */
4259 "slice %d starts at %llu, is not at"
4274 "slice %d size %llu does not cover"
4289 "slice %d tag was %d should be %d",
4309 "slice %d (start %llu, end %llu)"
4335 "slice %d (start %llu) is larger than the "
4356 "slice %d (end %llu) is larger"
4373 /* Make the VTOC look sane - ha ha */
4474 void *data = dk_ioc->dki_data;
4477 dk_ioc->dki_data_64 = (uintptr_t)data;
4505 dk_ioc.dki_length = EFI_MIN_ARRAY_SIZE + efi_vtoc->efi_lbasize;
4520 if (efi_ioctl(Dev, DKIOCSETEFI, &dk_ioc) == -1) {
4535 dk_ioc.dki_lba = efi_vtoc->efi_last_u_lba + 1;
4536 dk_ioc.dki_length -= efi_vtoc->efi_lbasize;
4538 efi_vtoc->efi_lbasize);
4545 if (efi_ioctl(Dev, DKIOCSETEFI, &dk_ioc) == -1) {
4547 "block %llu; errno %d\n", efi_vtoc->efi_last_u_lba + 1,
4554 dk_ioc.dki_lba = efi_vtoc->efi_last_lba;
4555 dk_ioc.dki_length = efi_vtoc->efi_lbasize;
4556 dk_ioc.dki_data = (efi_gpt_t *)((char *)dk_ioc.dki_data -
4557 efi_vtoc->efi_lbasize);
4563 if (efi_ioctl(Dev, DKIOCSETEFI, &dk_ioc) == -1) {
4567 efi_vtoc->efi_last_lba,
4607 seek_byte = (off_t)(LE_32(clr_table->relsect) + VTOC_OFFSET) * sectsiz;
4613 (uint64_t)(LE_32(clr_table->relsect) + VTOC_OFFSET));
4616 if (lseek(Dev, seek_byte, SEEK_SET) == -1) {
4633 if (lseek(Dev, seek_byte, SEEK_SET) == -1) {
4669 pcyl = LE_32(clr_table->numsect) / (heads * sectors);
4670 solaris_offset = LE_32(clr_table->relsect);
4671 ncyl = pcyl - acyl;
4673 backup_block = ((ncyl + acyl - 1) *
4674 (heads * sectors)) + ((heads - 1) * sectors) + 1;
4679 if (lseek(Dev, seek_byte, SEEK_SET) == -1) {
4707 if (lseek(Dev, seek_byte, SEEK_SET) == -1) {
4780 * non-interactive mode or read-only mode.
4804 int idx = -1;
4811 if (ioctl(fd, DKIOCEXTPARTINFO, &extpi) != -1) {
4819 } else if (ioctl(fd, DKIOCPARTINFO, &pi) != -1) {
4836 if (ioctl(fd, DKIOCGGEOM, &d) == -1) {
4877 if (stat(node, (struct stat *)&statbuf) == -1) {
4892 space -= strlen(DEFAULT_PATH);
4896 if (stat(node, (struct stat *)&statbuf) == -1) {
4975 return (-1);
4999 rowmax = ws.ws_row - 5;
5012 (void) printf("%-3d %s\n", i, fdisk_part_types[i]);
5019 rowmax = ws.ws_row - 1;
5048 /* Check if there is a non-digit in the input */
5049 for (i = 0; i < len-1; i++) {
5091 /* Check if there is a non-digit in the input */
5092 for (i = 0; i < len-1; i++) {
5099 if (i < len - 1) {
5161 (void) printf("Enter the beginning cylinder (Default - %d) : ",
5175 /* Check if there is a non-digit in the input */
5176 for (i = 0; i < len - 1; i++) {
5183 if (i < len - 1) {
5220 * 2. If not, check if there are any non-digits
5228 * b) If no, Check if the size is within endcyl - begcyl
5253 "Cylinder -");
5268 copy_len = len - 1;
5271 copy_len--;
5272 if ((ch = toupper(buf[len - 2])) == 'B') {
5273 ch = toupper(buf[len - 3]);
5274 copy_len--;
5282 copy_len--;
5320 if (size > (last_free_sec - begsec + 1)) {
5334 poss_end = begsec + size - 1;
5336 poss_end += spc - remdr - 1;
5351 * a) If it is non-numeric
5356 * a) If it is non-numeric
5439 for (temp = head, pno = 5; temp != NULL; temp = temp->next, pno++) {
5441 id_to_name(temp->parts[0].systid, namebuff);
5444 LE_32(temp->parts[0].relsect),
5445 LE_32(temp->parts[0].numsect),
5446 temp->abs_secnum,
5447 temp->abs_secnum + temp->numsect - 1 +
5455 id_to_name(temp->parts[1].systid, namebuff);
5458 LE_32(temp->parts[1].relsect),
5459 LE_32(temp->parts[1].numsect),
5501 temp = temp->next, pno++) {
5503 fpart = &temp->parts[0];
5504 sysid = fpart->systid;
5511 part_start = temp->abs_secnum +
5512 temp->logdrive_offset;
5521 startcyl = temp->begcyl;
5522 endcyl = temp->endcyl;
5526 length = endcyl - startcyl + 1;
5540 (void) printf("%-5d %-8u %-8u %-7u %-3d "
5541 "%-3d (%-.28s)\n",
5667 (dev_capacity > DK_MAX_2TB) ? DK_MAX_2TB : (dev_capacity - 1),