(dosdp->dp_typ == DOSPTYP_386BSD ||
(dosdp->dp_typ == DOSPTYP_OPENBSD ||
writelabel(f, boot, lp)	int f;	char *boot;	struct disklabel *lp;{	int writeable;	off_t sectoffset = 0;	if (nwflag) {		warnx("DANGER! The disklabel was not found at the correct location!");		warnx("To repair this situation, use `disklabel %s > file' to",		    dkname);		warnx("save it, then use `disklabel -R %s file' to replace it.",		    dkname);		warnx("A new disklabel is not being installed now.");		return(0); /* Actually 1 but we want to exit */	}#if NUMBOOT > 0	setbootflag(lp);#endif	lp->d_magic = DISKMAGIC;	lp->d_magic2 = DISKMAGIC;	lp->d_checksum = 0;	lp->d_checksum = dkcksum(lp);	if (rflag) {#ifdef DOSLABEL		struct partition *pp = &lp->d_partitions[2];		/*		 * If OpenBSD DOS partition is missing, or if 		 * the label to be written is not within partition,		 * prompt first. Need to allow this in case operator		 * wants to convert the drive for dedicated use.		 * In this case, partition 'a' had better start at 0,		 * otherwise we reject the request as meaningless. -wfj		 */		if (dosdp && pp->p_size &&		    (dosdp->dp_typ == DOSPTYP_386BSD ||		    dosdp->dp_typ == DOSPTYP_386BSD)) {		        sectoffset = dosdp->dp_start * lp->d_secsize;		} else {			if (dosdp) {				int first, ch;				printf("Erase the previous contents of the disk? [n]: ");				fflush(stdout);				first = ch = getchar();				while (ch != '\n' && ch != EOF)					ch = getchar();				if (first != 'y' && first != 'Y')					exit(0);			}			sectoffset = 0;		}#if NUMBOOT > 0		/*		 * If we are not installing a boot program		 * we must read the current bootarea so we don't		 * clobber the existing boot.		 */		if (!installboot) {			struct disklabel tlab;			if (lseek(f, sectoffset, SEEK_SET) < 0) {				perror("lseek");				return (1);			}			tlab = *lp;			if (read(f, boot, tlab.d_bbsize) != tlab.d_bbsize) {				perror("read");				return (1);			}			*lp =tlab;		}#endif#endif		/*		 * First set the kernel disk label,		 * then write a label to the raw disk.		 * If the SDINFO ioctl fails because it is unimplemented,		 * keep going; otherwise, the kernel consistency checks		 * may prevent us from changing the current (in-core)		 * label.		 */		if (!donothing) {			if (ioctl(f, DIOCSDINFO, lp) < 0 &&			    errno != ENODEV && errno != ENOTTY) {				l_perror("ioctl DIOCSDINFO");				return (1);			}		}		if (verbose)			printf("writing label to block %d (0x%x)\n",			    (int)sectoffset/DEV_BSIZE,			    (int)sectoffset/DEV_BSIZE);		if (!donothing) {			if (lseek(f, sectoffset, SEEK_SET) < 0) {				perror("lseek");				return (1);			}			/*			 * write enable label sector before write (if necessary),			 * disable after writing.			 */			writeable = 1;						if (ioctl(f, DIOCWLABEL, &writeable) < 0)				perror("ioctl DIOCWLABEL");#ifdef __alpha__			/*			 * The Alpha requires that the boot block be checksummed.			 * The first 63 8-byte quantites are summed into the 64th.			 */			{				int i;				u_int64_t *dp, sum;				dp = (u_int64_t *)boot;				sum = 0;				for (i = 0; i < 63; i++)					sum += dp[i];				dp[63] = sum;			}#endif			if (write(f, boot, lp->d_bbsize) != lp->d_bbsize) {				perror("write");				return (1);			}		}#if NUMBOOT > 0		/*		 * Output the remainder of the disklabel		 */		if (bootbuf && write(f, bootbuf, bootsize) != bootsize) {			perror("write");			return(1);		}#endif		writeable = 0;		if (!donothing)			if (ioctl(f, DIOCWLABEL, &writeable) < 0)				perror("ioctl DIOCWLABEL");	} else {		if (!donothing) {			if (ioctl(f, DIOCWDINFO, lp) < 0) {				l_perror("ioctl DIOCWDINFO");				return (1);			}		}	}#ifdef vax	if (lp->d_type == DTYPE_SMD && lp->d_flags & D_BADSECT) {		daddr_t alt;		int i;		alt = lp->d_ncylinders * lp->d_secpercyl - lp->d_nsectors;		for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) {			(void)lseek(f, (off_t)((alt + i) * lp->d_secsize),			    SEEK_SET);			if (!donothing)				if (write(f, boot, lp->d_secsize) < lp->d_secsize)					warn("alternate label %d write", i/2);		}	}#endif	return (0);}