if (!resolve) {
if (resolve != 1) {
has_overlap(lp, freep, resolve)	struct disklabel *lp;	u_int32_t *freep;	int resolve;{	struct partition **spp;	u_int16_t npartitions;	int c, i, j, rval = 0;	/* Get a sorted list of the partitions */	spp = sort_partitions(lp, &npartitions);	if (npartitions < 2) {		(void)free(spp);		return(0);			/* nothing to do */	}	/* Now that we have things sorted by starting sector check overlap */	for (i = 0; i < npartitions; i++) {		for (j = i + 1; j < npartitions; j++) {			/* `if last_sec_in_part + 1 > first_sec_in_next_part' */			if (spp[i]->p_offset + spp[i]->p_size > spp[j]->p_offset) {				/* Overlap!  Convert to real part numbers. */				i = ((char *)spp[i] - (char *)lp->d_partitions)				    / sizeof(**spp);				j = ((char *)spp[j] - (char *)lp->d_partitions)				    / sizeof(**spp);				printf("\nError, partitions %c and %c overlap:\n",				    'a' + i, 'a' + j);				puts("         size   offset    fstype   [fsize bsize   cpg]");				display_partition(stdout, lp, i, 0);				display_partition(stdout, lp, j, 0);				/* Did they ask us to resolve it ourselves? */				if (!resolve) {					(void)free(spp);					return(1);				}				printf("Disable which one? [%c %c] ",				    'a' + i, 'a' + j);				/* XXX - make less gross */				while ((c = getchar()) != EOF && c != '\n') {					c -= 'a';					if (c == i || c == j)						break;				}				putchar('\n');				/* Mark the selected one as unused or... */				if (c == i || c == j) {					lp->d_partitions[c].p_fstype = FS_UNUSED;					*freep += lp->d_partitions[c].p_size;				} else					rval = 1;	/* still has overlap */			    }		}	}	(void)free(spp);	return(rval);}