fmthard.c revision 3f2f09c1efd66f6d2995998ea72c5df8c70c9a97
b7b6b01a0d0622181a4c28dd60401f0ab2480d00Mark Andrews * CDDL HEADER START
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * The contents of this file are subject to the terms of the
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Common Development and Distribution License (the "License").
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * You may not use this file except in compliance with the License.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * See the License for the specific language governing permissions
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * and limitations under the License.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * When distributing Covered Code, include this CDDL HEADER in each
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * If applicable, add the following below this CDDL HEADER, with the
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * fields enclosed by brackets "[]" replaced with your own identifying
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * information: Portions Copyright [yyyy] [name of copyright owner]
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * CDDL HEADER END
f80ea74e1984e0b1dbe48dd86ecdd3a2380393cbBob Halley/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence/* All Rights Reserved */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Portions of this source code were provided by International
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Computers Limited (ICL) under a development agreement with AT&T.
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson#pragma ident "%Z%%M% %I% %E% SMI"
6c8abf481df85a67c3f32f5f107b554d3ff5a3edMark Andrews * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
6c8abf481df85a67c3f32f5f107b554d3ff5a3edMark Andrews * Use is subject to license terms.
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence * Sun Microsystems version of fmthard:
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Supports the following arguments:
d88e1c30a4d4232a1a0520ad0d498b40a40cafd2Mark Andrews * -i Writes VTOC to stdout, rather than disk
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence * -q Quick check: exit code 0 if VTOC ok
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence * -d <data> Incremental changes to the VTOC
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence * -n <vname> Change volume name to <vname>
d358eea93ef0e6a70b6f43b06b3ad24f79f69cd1Andreas Gustafsson * -s <file> Read VTOC information from <file>, or stdin ("-")
ba94ff2e56ff8cafeb5a701adfbe71bf9a5932e7Mark Andrews * -u <state> Reboot after writing VTOC, according to <state>:
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence * boot: AD_BOOT (standard reboot)
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * firm: AD_IBOOT (interactive reboot)
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Note that fmthard cannot write a VTOC on an unlabeled disk.
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * You must use format or SunInstall for this purpose.
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * (NOTE: the above restriction only applies on Sparc systems).
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * The primary motivation for fmthard is to duplicate the
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * partitioning from disk to disk:
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2
ce3c351d815569455892c30dc78d8c2e85ec1076Andreas Gustafsson#endif /* SECSIZE */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * External functions.
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonextern int write_vtoc(int, struct vtoc *);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Internal functions.
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonextern int main(int, char **);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic void display(struct dk_geom *, struct vtoc *, char *);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrencestatic void display64(struct dk_gpt *, char *);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic void insert(char *, struct vtoc *);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic void insert64(char *, struct dk_gpt *);
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrencestatic void load(FILE *, struct dk_geom *, struct vtoc *);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic void load64(FILE *, int fd, struct dk_gpt **);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic void usage(void);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic void validate(struct dk_geom *, struct vtoc *);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic int vread(int, struct vtoc *, char *);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic void vread64(int, struct dk_gpt **, char *);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic void vwrite(int, struct vtoc *, char *);
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrencestatic void vwrite64(int, struct dk_gpt *, char *);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Static variables.
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic char *delta; /* Incremental update */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic short eflag; /* force write of an EFI label */
ed04318ef686581fc9a20965a5be02abfb4f1bd5Andreas Gustafssonstatic short iflag; /* Prints VTOC w/o updating */
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrencestatic short qflag; /* Check for a formatted disk */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonstatic short uflag; /* Exit to firmware after writing */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson /* new vtoc and reboot. Used during */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson /* installation of core floppies */
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellingtonstatic diskaddr_t lastlba = 0; /* last LBA on 64-bit VTOC */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson/* use installgrub(1M) to install boot blocks */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson#endif /* various platform-specific definitions */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson#endif /* defined(_SUNOS_VTOC_16) */
3a34b87c878990c6303358efd22265c2c5980c65Mark Andrews#endif /* defined(_SUNOS_VTOC_8) */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson while ((c = getopt(argc, argv, "ed:u:in:qs:")) != EOF)
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson while ((c = getopt(argc, argv, "ed:u:in:qb:p:s:")) != EOF)
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson "fmthard: -p and -b no longer supported."
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson " Use installgrub(1M) to install boot blocks\n");
f80ea74e1984e0b1dbe48dd86ecdd3a2380393cbBob Halley#endif /* defined(i386) */
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington if (stat(argv[optind], (struct stat *)&statbuf) == -1) {
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington "fmthard: Cannot stat device %s\n",
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington if ((statbuf.st_mode & S_IFMT) != S_IFCHR) {
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington "fmthard: %s must be a raw device.\n",
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington if ((fd = open(argv[optind], O_RDWR|O_NDELAY)) < 0) {
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington (void) fprintf(stderr, "fmthard: Cannot open device %s - %s\n",
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Get the geometry information for this disk from the driver
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence if (!eflag && ioctl(fd, DKIOCGGEOM, &disk_geom)) {
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence#endif /* DEBUG */
7618f0551eb745354ee695907e568b0be1f2c8f5Andreas Gustafsson /* disk has EFI labels */
7618f0551eb745354ee695907e568b0be1f2c8f5Andreas Gustafsson "%s: Cannot get disk geometry\n", argv[optind]);
e724512f2be8d3de5f2982ebba0b2cdaf8325702Mark Andrews * Read the vtoc on the disk
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington if (vread(fd, &disk_vtoc, argv[optind]) == 1)
f80ea74e1984e0b1dbe48dd86ecdd3a2380393cbBob Halley * Quick check for valid disk: 0 if ok, 1 if not
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson exit(disk_vtoc.v_sanity == VTOC_SANE ? 0 : 1);
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington exit(disk_efi->efi_version <= EFI_VERSION102 ? 0 : 1);
3a34b87c878990c6303358efd22265c2c5980c65Mark Andrews * Incremental changes to the VTOC
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Read new VTOC from stdin or data file
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington (void) fprintf(stderr, "Cannot open file %s\n",
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Print the modified VTOC, rather than updating the disk
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson display(&disk_geom, &disk_vtoc, argv[optind]);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson n = MIN(strlen(vname) + 1, LEN_DKL_VVOL);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson (void) memcpy(disk_vtoc.v_volume, vname, n);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson for (c = 0; c < disk_efi->efi_nparts; c++) {
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson (void) memcpy(&disk_efi->efi_parts[c].p_name,
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence * Write the new VTOC on the disk
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson * Shut system down after writing a new vtoc to disk
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson * This is used during installation of core floppies.
ed04318ef686581fc9a20965a5be02abfb4f1bd5Andreas Gustafsson (void) printf("fmthard: New volume table of contents now in place.\n");
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * display contents of VTOC without writing it to disk
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssondisplay(struct dk_geom *geom, struct vtoc *vtoc, char *device)
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Print out the VTOC
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson (void) printf("* %s default partition map\n", device);
f0e246e271f84c6fe960a3c36703a56d1067431cBrian Wellington for (i = 0; i < LEN_DKL_VVOL; i++) {
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence (void) printf("* %d bytes/sector\n", SECSIZE);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence (void) printf("* %d sectors/track\n", geom->dkg_nsect);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson (void) printf("* %d tracks/cylinder\n", geom->dkg_nhead);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson (void) printf("* %d cylinders\n", geom->dkg_pcyl);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson (void) printf("* %d accessible cylinders\n", geom->dkg_ncyl);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson"\n* Partition Tag Flag First Sector Sector Count\n");
9b0e18da3d5c2290f90b285d122d368173f17c63Andreas Gustafsson for (i = 0; i < V_NUMPAR; i++) {
f0e246e271f84c6fe960a3c36703a56d1067431cBrian Wellington" %d %d 0%x %ld %ld\n",
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * display64 ()
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * display64 contents of EFI partition without writing it to disk
bd703253b745aaec6e45a60108bec513bf79bd2cBrian Wellington * Print out the VTOC
f0e246e271f84c6fe960a3c36703a56d1067431cBrian Wellington (void) printf("* %s default partition map\n", device);
f0e246e271f84c6fe960a3c36703a56d1067431cBrian Wellington (void) printf("* %d bytes/sector\n", efi->efi_lbasize);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson (void) printf("* N/A tracks/cylinder\n");
8f79820c6930ee5ef6b4a54f36d2559400bdf47dAndreas Gustafsson (void) printf("* N/A accessible cylinders\n");
618a5e4923c3d064c1cc0f1866e27e8ddca90700Andreas Gustafsson"\n* Partition Tag Flag First Sector Sector Count\n");
618a5e4923c3d064c1cc0f1866e27e8ddca90700Andreas Gustafsson" %d %d 0%x %8lld %8lld\n",
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson * Insert a change into the VTOC.
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson &part, &tag, &flag, &start, &size) != 5) {
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence (void) fprintf(stderr, "Delta syntax error on \"%s\"\n", data);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence "Error in data \"%s\": No such partition %x\n",
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson vtoc->v_part[part].p_tag = (ushort_t)tag;
ce3c351d815569455892c30dc78d8c2e85ec1076Andreas Gustafsson vtoc->v_part[part].p_flag = (ushort_t)flag;
ce3c351d815569455892c30dc78d8c2e85ec1076Andreas Gustafsson * Insert a change into the VTOC.
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson &part, &tag, &flag, &start, &size) != 5) {
f80ea74e1984e0b1dbe48dd86ecdd3a2380393cbBob Halley (void) fprintf(stderr, "Delta syntax error on \"%s\"\n", data);
9b0e18da3d5c2290f90b285d122d368173f17c63Andreas Gustafsson "Error in data \"%s\": No such partition %x\n",
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson efi->efi_parts[part].p_flag = (ushort_t)flag;
7618f0551eb745354ee695907e568b0be1f2c8f5Andreas Gustafsson * Load VTOC information from a datafile.
8f79820c6930ee5ef6b4a54f36d2559400bdf47dAndreas Gustafssonload(FILE *fp, struct dk_geom *geom, struct vtoc *vtoc)
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson for (i = 0; i < V_NUMPAR; ++i) {
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * initialize partition 2, by convention it corresponds to whole
9b0e18da3d5c2290f90b285d122d368173f17c63Andreas Gustafsson * disk. It will be overwritten, if specified in the input datafile
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson fullsz = geom->dkg_ncyl * geom->dkg_nsect * geom->dkg_nhead;
3a34b87c878990c6303358efd22265c2c5980c65Mark Andrews if (line[0] == '\0' || line[0] == '\n' || line[0] == '*')
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson &part, &tag, &flag, &start, &size) != 5) {
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence (void) fprintf(stderr, "Syntax error: \"%s\"\n",
7618f0551eb745354ee695907e568b0be1f2c8f5Andreas Gustafsson "No such partition %x: \"%s\"\n",
3476dfe9d7e0a13338a16ee096f68d73c5a60bf2Mark Andrews if (!eflag && ((start % nblks) != 0 || (size % nblks) != 0)) {
9b0e18da3d5c2290f90b285d122d368173f17c63Andreas Gustafsson"Partition %d not aligned on cylinder boundary: \"%s\"\n",
a928d619170d61da40c3bff29800ff73709140daAndreas Gustafsson vtoc->v_part[part].p_tag = (ushort_t)tag;
a928d619170d61da40c3bff29800ff73709140daAndreas Gustafsson vtoc->v_part[part].p_flag = (ushort_t)flag;
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson for (part = 0; part < V_NUMPAR; part++) {
a928d619170d61da40c3bff29800ff73709140daAndreas Gustafsson * Load VTOC information from a datafile.
a928d619170d61da40c3bff29800ff73709140daAndreas Gustafsson if (line[0] == '\0' || line[0] == '\n' || line[0] == '*')
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence (void) fprintf(stderr, "Syntax error: \"%s\"\n",
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence mem = realloc(mem, sizeof (*mem) * (nlines + 1));
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence if ((i = efi_alloc_and_init(fd, max_part, efi)) < 0) {
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence "efi_alloc_and_init failed: %d\n", i);
a928d619170d61da40c3bff29800ff73709140daAndreas Gustafsson for (i = 0; i < nlines; i++) {
a928d619170d61da40c3bff29800ff73709140daAndreas Gustafsson &part, &tag, &flag, &start, &size) != 5) {
a928d619170d61da40c3bff29800ff73709140daAndreas Gustafsson (void) fprintf(stderr, "Syntax error: \"%s\"\n",
a928d619170d61da40c3bff29800ff73709140daAndreas Gustafsson "No such partition %x: \"%s\"\n",
86a292d45977f1d8400df04b04bf659d9a5d68a1Andreas Gustafsson (*efi)->efi_parts[part].p_tag = (ushort_t)tag;
86a292d45977f1d8400df04b04bf659d9a5d68a1Andreas Gustafsson (*efi)->efi_parts[part].p_flag = (ushort_t)flag;
3a34b87c878990c6303358efd22265c2c5980c65Mark Andrews"Usage: fmthard [ -i ] [ -n volumename ] [ -s datafile ] [ -d arguments] \
ce3c351d815569455892c30dc78d8c2e85ec1076Andreas Gustafssonraw-device\n");
3a34b87c878990c6303358efd22265c2c5980c65Mark Andrews"Usage: fmthard [ -i ] [ -S ] [-I geom_file] \
3a34b87c878990c6303358efd22265c2c5980c65Mark Andrews-n volumename | -s datafile [ -d arguments] raw-device\n");
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence * Validate the new VTOC.
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrencevalidate(struct dk_geom *geom, struct vtoc *vtoc)
ce3c351d815569455892c30dc78d8c2e85ec1076Andreas Gustafsson fullsz = geom->dkg_ncyl * geom->dkg_nsect * geom->dkg_nhead;
ce3c351d815569455892c30dc78d8c2e85ec1076Andreas Gustafsson /* make the vtoc look sane - ha ha */
a928d619170d61da40c3bff29800ff73709140daAndreas Gustafsson#endif /* defined(_SUNOS_VTOC_16) */
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence for (i = 0; i < V_NUMPAR; i++) {
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrencefmthard: Partition %d specifies the full disk and is not equal\n\
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrencefull size of disk. The full disk capacity is %lu sectors.\n", i, fullsz);
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence continue; /* Undefined partition */
a928d619170d61da40c3bff29800ff73709140daAndreas Gustafssonfmthard: Partition %d not aligned on cylinder boundary \n", i);
9b0e18da3d5c2290f90b285d122d368173f17c63Andreas Gustafssonfmthard: Partition %d specified as %lu sectors starting at %lu\n\
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence\tdoes not fit. The full disk contains %lu sectors.\n",
f3083bc781333f6314a44cb19fe31fe17e59f26fDavid Lawrence for (j = 0; j < V_NUMPAR; j++) {
9b0e18da3d5c2290f90b285d122d368173f17c63Andreas Gustafsson if ((i != j) &&
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrencefmthard: Partition %d overlaps partition %d. Overlap is allowed\n\
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence\tonly on partition on the full disk partition).\n",
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence * validate64()
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence * Validate the new VTOC.
9b0e18da3d5c2290f90b285d122d368173f17c63Andreas Gustafsson continue; /* Undefined partition */
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrencefmthard: Partition %d specified as %lld sectors starting at %lld\n\
dee489d6c1487c5fb450e352c48b1a37848e9b6cMark Andrews\tdoes not fit. The full disk contains %lld sectors.\n",
9b0e18da3d5c2290f90b285d122d368173f17c63Andreas Gustafsson for (j = 0; j < V_NUMPAR; j++) {
9b0e18da3d5c2290f90b285d122d368173f17c63Andreas Gustafsson if ((i != j) &&
9b0e18da3d5c2290f90b285d122d368173f17c63Andreas Gustafssonfmthard: Partition %d overlaps partition %d. Overlap is allowed\n\
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson\tonly on partition on the full disk partition).\n",
951c247f2923f667c5c97355b31dc564bd540bfeDavid Lawrence "expected one reserved partition, but found %d\n",
951c247f2923f667c5c97355b31dc564bd540bfeDavid Lawrence * Read the VTOC
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonvread(int fd, struct vtoc *vtoc, char *devname)
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson (void) fprintf(stderr, "%s: Cannot read VTOC\n",
ce3c351d815569455892c30dc78d8c2e85ec1076Andreas Gustafssonvread64(int fd, struct dk_gpt **efi_hdr, char *devname)
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence if ((i = efi_alloc_and_read(fd, efi_hdr)) < 0) {
ce3c351d815569455892c30dc78d8c2e85ec1076Andreas Gustafsson "%s: this disk must be labeled first\n",
3a34b87c878990c6303358efd22265c2c5980c65Mark Andrews "%s: read_efi failed %d\n",
ed8daea26475309e1ac8ed8556b7d4ec8ae4432cDavid Lawrence * Write the VTOC
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrencevwrite(int fd, struct vtoc *vtoc, char *devname)
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence "%s: invalid entry exists in vtoc\n",
f991461dc144794d80ff8d85e430fd8a6e6113f3David Lawrence (void) fprintf(stderr, "%s: Cannot write VTOC\n",
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrence * Write the VTOC
03609d0b8f6e458d6bd4b460f4eb3f7270f487efDavid Lawrencevwrite64(int fd, struct dk_gpt *efi, char *devname)
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson "%s: invalid entry exists in vtoc\n",
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff (void) fprintf(stderr, "%s: Cannot write EFI\n",