From: ukai@kmc.kyoto-u.ac.jp (Ukai Fumitoshi)
Subject: Re: [386BSD] 386BSD(98) release 
Reply-To: ukai@kuamp.kyoto-u.ac.jp
Organization: Kyoto University Microcomputer Club, Kyoto, Japan
	<ISHII.92Oct4114529@kuro.kmc.kyoto-u.ac.jp>
Distribution: fj
Date: Sun, 4 Oct 1992 13:54:52 GMT


$@$&$+$$!w5~Bg%^%$%3%s%/%i%V$G$9!#(J

In article <ISHII.92Oct4114529@kuro.kmc.kyoto-u.ac.jp> ishii@kmc.kyoto-u.ac.jp (Ishii Masahiro) writes:

>  3) disklabel $@$N(JPC98$@MQ$N%Q%C%A$r$$$l$k$N$rK:$l$F$7$^(J$@$$$^$7$?!#(J
>
>    src01.* $@$rE83+$9$k$H(J /usr/src/sbin/disklabel/ $@$K(JIBM-PC$@MQ$N%=!<%9$,E8(J
>  $@3+$5$l$^$9$,(J$@!"$=$l$r(Jre-compile$@$7$F<B9T$7$J$$$G2<$5$$!#(Jdisk$@$,2u$l$^$9!#(J

/sbin/disklabel $@$N(J PC98 $@MQ$N(J patch $@$G$9!#(J
/sbin/disklabel $@$r%3%s%Q%$%k$9$k;~$O(J

	# cd /usr/src/sbin/disklabel
	# patch -p1 < $@$3$N%Q%C%A(J

$@$H$7$F(J$@$+$i!"(Jmake $@$7$F$/$@$5$$!#(J

----------------------------------------------------------------
*** disklabel.c-orig	Mon Aug 10 04:30:07 1992
--- disklabel.c	Sun Oct  4 17:52:38 1992
***************
*** 96,101 ****
--- 96,102 ----
  #if defined(vax) || defined(i386)
  #define	BOOT				/* also have bootstrap in "boot area" */
  #define	BOOTDIR	_PATH_BOOTDIR		/* source of boot binaries */
+ #define	PC98 /* for PC9801 */
  #else
  #ifdef lint
  #define	BOOT
***************
*** 381,388 ****
--- 382,404 ----
  		 * otherwise we reject the request as meaningless. -wfj
  		 */
  
+ #ifdef PC98
+ #define DPBLKNO(cyl,hd,sect) \
+ 	((cyl)*lp->d_secpercyl+(hd)*lp->d_nsectors+(sect))
+ 
+ #ifdef DEBUG	/* ukai */
+ printf("secpercyl = %d, nsectors = %d\n",
+ 	lp->d_secpercyl, lp->d_nsectors );
+ #endif
+ 		if (dosdp && dosdp->dp_mid == DOSMID_386BSD
+ 		    && dosdp->dp_sid == DOSSID_386BSD &&
+ 		    pp->p_size &&
+ 		    DPBLKNO(dosdp->dp_scyl,dosdp->dp_shd,dosdp->dp_ssect)
+ 		    	<= pp->p_offset) {	/* XXX ukai */
+ #else /* IBMPC */
  		if (dosdp && dosdp->dp_typ == DOSPTYP_386BSD && pp->p_size &&
  			dosdp->dp_start == pp->p_offset) {
+ #endif		    
  			lbl_off = pp->p_offset;
  		} else {
  			if (dosdp) {
***************
*** 399,404 ****
--- 415,423 ----
  			}
  			lbl_off = 0;
  		}
+ #ifdef DEBUG	/* ukai */
+ printf("lseek %x\n", lbl_off * lp->d_secsize);
+ #endif
  		(void)lseek(f, (off_t)(lbl_off * lp->d_secsize), L_SET);
  #endif
  		/*
***************
*** 501,507 ****
--- 520,530 ----
  	char mbr[DEV_BSIZE];
  	int i, npart, nboot, njunk;
  
+ #ifdef PC98
+ 	(void)lseek(f, (off_t)DOSLABELSECTOR*DEV_BSIZE, L_SET);
+ #else
  	(void)lseek(f, (off_t)DOSBBSECTOR, L_SET);
+ #endif
  	if (read(f, mbr, sizeof(mbr)) < sizeof(mbr))
  		Perror("can't read master boot record");
  		
***************
*** 515,520 ****
--- 538,555 ----
  	dp = dos_partitions;
  	npart = njunk = nboot = 0;
  	for (i = 0; i < NDOSPART; i++, dp++) {
+ #ifdef PC98
+ 	    	if (dp->dp_mid == 0 && dp->dp_sid == 0) {
+ 		    break;
+ 		}
+ 		if (dp->dp_mid & 0x80) {
+ 		    nboot = 1;
+ 		}
+ 		npart++;
+ 		if (dp->dp_mid == DOSMID_386BSD &&
+ 		    dp->dp_sid == DOSSID_386BSD)
+ 			bsdp = dp;
+ #else /* IBMPC */
  		if (dp->dp_flag != 0x80 && dp->dp_flag != 0) njunk++;
  		else
  			if (dp->dp_size > 0) npart++;
***************
*** 521,526 ****
--- 556,562 ----
  		if (dp->dp_flag == 0x80) nboot++;
  		if (dp->dp_size && dp->dp_typ == DOSPTYP_386BSD)
  			bsdp = dp;
+ #endif
  	}
  
  	/* valid partition table? */
***************
*** 549,561 ****
  #ifdef __386BSD__
  		off_t sectoffset;
  
  		if (dosdp && dosdp->dp_size && dosdp->dp_typ == DOSPTYP_386BSD)
  			sectoffset = dosdp->dp_start * DEV_BSIZE;
  		else
  			sectoffset = 0;
  		(void)lseek(f, sectoffset, L_SET);
  #endif
- 			
  		if (read(f, bootarea, BBSIZE) < BBSIZE)
  			Perror(specname);
  		for (lp = (struct disklabel *)bootarea;
--- 585,616 ----
  #ifdef __386BSD__
  		off_t sectoffset;
  
+ #ifdef PC98
+ 		struct disklabel dklbl;
+ 		ioctl(f, DIOCGDINFO, &dklbl);	/* XXX */
+ 		lp = &dklbl;			/* XXX */
+ #ifdef DEBUG	/* ukai */
+ printf("start cyl = %d, hd = %d, sect = %d\n",
+ 	dosdp->dp_scyl, dosdp->dp_shd, dosdp->dp_ssect);
+ printf("secpercyl = %d, nsectors = %d\n",
+ 	lp->d_secpercyl, lp->d_nsectors );
+ #endif
+ 		if (dosdp && dosdp->dp_mid == DOSMID_386BSD &&
+ 		    dosdp->dp_sid == DOSSID_386BSD)
+ 			sectoffset =
+ 			  DPBLKNO(dosdp->dp_scyl,dosdp->dp_shd,
+ 				  dosdp->dp_ssect) * DEV_BSIZE;
+ #else
  		if (dosdp && dosdp->dp_size && dosdp->dp_typ == DOSPTYP_386BSD)
  			sectoffset = dosdp->dp_start * DEV_BSIZE;
+ #endif
  		else
  			sectoffset = 0;
+ #ifdef DEBUG	/* ukai */
+ printf("sectoffset = %x\n", sectoffset);
+ #endif		
  		(void)lseek(f, sectoffset, L_SET);
  #endif
  		if (read(f, bootarea, BBSIZE) < BBSIZE)
  			Perror(specname);
  		for (lp = (struct disklabel *)bootarea;
***************
*** 1183,1188 ****
--- 1238,1256 ----
  	if (lp->d_secperunit == 0)
  		lp->d_secperunit = lp->d_secpercyl * lp->d_ncylinders;
  #ifdef __386BSD__notyet
+ #ifdef PC98
+ 	if (dosdp && dosdp->dp_mid == DOSMID_386BSD &&
+ 	    dosdp->dp_sid == DOSPTYP_386BSD
+ 		&& lp->d_secperunit >
+ 			DPBLKNO(dosdp->dp_scyl,dosdp->dp_shd,dosdp->dp_ssect)
+ 	    			+ dosdp->dp_size) {
+ 		fprintf(stderr, "exceeds DOS partition size\n");
+ 		errors++;
+ 		lp->d_secperunit =
+ 			DPBLKNO(dosdp->dp_scyl,dosdp->dp_shd,dosdp->dp_ssect)
+ 				+ dosdp->dp_size;
+ 	}
+ #else /* IBMPC */
  	if (dosdp && dosdp->dp_size && dosdp->dp_typ == DOSPTYP_386BSD
  		&& lp->d_secperunit > dosdp->dp_start + dosdp->dp_size) {
  		fprintf(stderr, "exceeds DOS partition size\n");
***************
*** 1189,1194 ****
--- 1257,1263 ----
  		errors++;
  		lp->d_secperunit = dosdp->dp_start + dosdp->dp_size;
  	}
+ #endif
  	/* XXX should also check geometry against BIOS's idea */
  #endif
  	if (lp->d_bbsize == 0) {
----------------------------------------------------------------
---
$@1-;tJ8IR(J
$@5~ETBg3XBg3X1!9)3X8&5f2J1~MQ2J3X%7%9%F%`@l96D9C+@n8&(J ukai@kuamp.kyoto-u.ac.jp
$@5~Bg%^%$%3%s%/%i%V(J                                     ukai@kmc.kyoto-u.ac.jp