pp->p_cpg = ui;
editor_modify(lp, mp, freep, p)	struct disklabel *lp;	char **mp;	u_int32_t *freep;	char *p;{	struct partition origpart, *pp;	u_int32_t ui;	int partno;	/* Change which partition? */	if (p == NULL) {		p = getstring(lp, "partition to modify",		    "The letter of the partition to modify, a - p.", NULL);	}	if (p == NULL) {		fputs("Command aborted\n", stderr);		return;	}	partno = p[0] - 'a';	pp = &lp->d_partitions[partno];	origpart = lp->d_partitions[partno];	if (partno < 0 || partno >= lp->d_npartitions) {		fprintf(stderr, "Partition must be between 'a' and '%c'.\n",		    'a' + lp->d_npartitions - 1);		return;	} else if (partno >= lp->d_npartitions ||	    (pp->p_fstype == FS_UNUSED && pp->p_size == 0)) {		fprintf(stderr, "Partition '%c' is not in use.\n", 'a' + partno);		return;	}		/* Get filesystem type */	if (pp->p_fstype < FSMAXTYPES) {		p = getstring(lp, "FS type",		    "Filesystem type (usually 4.2BSD or swap)",		    fstypenames[pp->p_fstype]);		if (p == NULL) {			fputs("Command aborted\n", stderr);			pp->p_size = 0;		/* effective delete */			return;		}		for (ui = 0; ui < FSMAXTYPES; ui++) {			if (!strcasecmp(p, fstypenames[ui])) {				pp->p_fstype = ui;				break;			}		}		if (ui >= FSMAXTYPES) {			printf("Unrecognized filesystem type '%s', treating as 'unknown'\n", p);			pp->p_fstype = FS_OTHER;		}	} else {		for (;;) {			ui = getuint(lp, partno, "FS type (decimal)",			    "Filesystem type as a decimal number; usually 7 (4.2BSD) or 1 (swap).",			    pp->p_fstype, pp->p_fstype, 0, 0);			if (ui == UINT_MAX - 1) {				fputs("Command aborted\n", stderr);				pp->p_size = 0;		/* effective delete */				return;			} else if (ui == UINT_MAX)				fputs("Invalid entry\n", stderr);			else				break;		}		pp->p_fstype = ui;	}	/* Did they disable/enable the partition? */	if ((pp->p_fstype == FS_UNUSED || pp->p_fstype == FS_BOOT) &&	    origpart.p_fstype != FS_UNUSED && origpart.p_fstype != FS_BOOT)		*freep += origpart.p_size;	else if (pp->p_fstype != FS_UNUSED && pp->p_fstype != FS_BOOT &&	    (origpart.p_fstype == FS_UNUSED || origpart.p_fstype == FS_BOOT)) {		if (pp->p_size > *freep) {			fprintf(stderr,			    "Warning, need %u sectors but there are only %u "			    "free.  Setting size to %u.\n", pp->p_size, *freep,			    *freep);			pp->p_fstype = *freep;			*freep = 0;		} else			*freep -= pp->p_size;		/* have enough space */	}getoff2:	/* Get offset */	for (;;) {		ui = getuint(lp, partno, "offset",		    "Starting sector for this partition.", pp->p_offset,		    pp->p_offset, 0, DO_CONVERSIONS |		    (pp->p_fstype == FS_BSDFFS ? DO_ROUNDING : 0));		if (ui == UINT_MAX - 1) {			fputs("Command aborted\n", stderr);			*pp = origpart;		/* undo changes */			return;		} else if (ui == UINT_MAX)			fputs("Invalid entry\n", stderr);		else if (partno != 2 && ui + ui < starting_sector) {			fprintf(stderr, "The OpenBSD portion of the disk starts"			    " at sector %u, you tried to start at %u."			    "  You can use the 'b' command to change the size "			    "of the OpenBSD portion.\n", starting_sector, ui);		} else			break;	}	pp->p_offset = ui;	/* Get size */	/* XXX - this loop sucks */	for (;;) {		ui = getuint(lp, partno, "size", "Size of the partition.",		    pp->p_size, *freep, pp->p_offset, DO_CONVERSIONS |		    ((pp->p_fstype == FS_BSDFFS || pp->p_fstype == FS_SWAP)		    ? DO_ROUNDING : 0));		if (ui == pp->p_size)			break;			/* no change */		if (ui == UINT_MAX - 1) {			fputs("Command aborted\n", stderr);			*pp = origpart;		/* undo changes */			return;		} else if (ui == UINT_MAX) {			fputs("Invalid entry\n", stderr);			continue;		} else if (partno == 2 && ui + pp->p_offset > lp->d_secperunit) {			fputs("'c' partition may not be larger than the disk\n",			    stderr);			continue;		}		if (pp->p_fstype == FS_UNUSED || pp->p_fstype == FS_BOOT) {			pp->p_size = ui;	/* don't care what's free */			break;		} else {			if (ui > pp->p_size + *freep)				/* XXX - prompt user to steal space from another partition */				fprintf(stderr,				    "Size may not be larger than %u sectors\n",				    pp->p_size + *freep);			else {				*freep += pp->p_size - ui;				pp->p_size = ui;				break;			}		}	}	/* XXX - if (ui % lp->d_secpercyl == 0) make ui + offset on cyl bound */	pp->p_size = ui;	if (pp->p_size == 0)		return;	/* Check for overlap and restore if not resolved */	if (has_overlap(lp, freep, 0)) {		puts("\nPlease re-enter an offset and size");		pp->p_offset = origpart.p_offset;		pp->p_size = origpart.p_size;		goto getoff2;		/* Yeah, I know... */	}	if (pp->p_fstype == FS_BSDFFS || pp->p_fstype == FS_UNUSED) {		/* get fsize */		for (;;) {			ui = getuint(lp, partno, "fragment size",			    "Size of fs block fragments.  Usually 1024 or 512.",			    pp->p_fsize ? pp->p_fsize : 1024, 1024, 0, 0);			if (ui == UINT_MAX - 1) {				fputs("Command aborted\n", stderr);				*pp = origpart;		/* undo changes */				return;			} else if (ui == UINT_MAX)				fputs("Invalid entry\n", stderr);			else				break;		}		pp->p_fsize = ui;		if (pp->p_fsize == 0)			puts("Zero fragment size implies zero block size");		/* get bsize */		for (; pp->p_fsize > 0;) {			ui = getuint(lp, partno, "block size",			    "Size of filesystem blocks.  Usually 8192 or 4096.",			    pp->p_frag ? pp->p_fsize * pp->p_frag : 8192,			    8192, 0, 0);			/* sanity check */			if (ui == UINT_MAX - 1) {				fputs("Command aborted\n", stderr);				*pp = origpart;		/* undo changes */				return;			} else if (ui == UINT_MAX)				fputs("Invalid entry\n", stderr);			else if (ui % pp->p_fsize != 0)				puts("Error: block size must be a multiple of the fragment size.");			else if (ui / pp->p_fsize < 1)				puts("Error: block size must be at least as big as fragment size.");			else {				pp->p_frag = ui / pp->p_fsize;				break;			}		}		if (pp->p_fstype == FS_BSDFFS) {			/* get cpg */			for (;;) {				ui = getuint(lp, partno, "cpg",				    "Number of filesystem cylinders per group."				    "  Usually 16 or 8.",				    pp->p_cpg ? pp->p_cpg : 16, 16, 0, 0);				if (ui == UINT_MAX - 1) {					fputs("Command aborted\n", stderr);					*pp = origpart;	/* undo changes */					return;				} else if (ui == UINT_MAX)					fputs("Invalid entry\n", stderr);				else					break;			}			pp->p_cpg = ui;		}	}	if (mp != NULL && pp->p_fstype != FS_UNUSED &&	    pp->p_fstype != FS_SWAP && pp->p_fstype != FS_BOOT &&	    pp->p_fstype != FS_OTHER) {		/* get mount point */		p = getstring(lp, "mount point",		    "Where to mount this filesystem (ie: / /var /usr)",		    mp[partno] ? mp[partno] : "none");		if (p == NULL) {			fputs("Command aborted\n", stderr);			pp->p_size = 0;		/* effective delete */			return;		}		if (mp[partno] != NULL) {			free(mp[partno]);			mp[partno] = NULL;		}		if (strcasecmp(p, "none") != 0) {			/* XXX - check that it starts with '/' */			if ((mp[partno] = strdup(p)) == NULL)				errx(4, "out of memory");		}	}	/* Make sure things stay contiguous. */	if (pp->p_size + pp->p_offset > ending_sector ||	    has_overlap(lp, freep, -1))		make_contiguous(lp);}