svn commit: r232710 - in projects/bigbb: sbin/bsdlabel sbin/newfs sys/geom sys/geom/part sys/sys usr.sbin/makefs/ffs

Jung-uk Kim jkim at FreeBSD.org
Fri Mar 9 00:28:29 UTC 2012


Author: jkim
Date: Fri Mar  9 00:28:28 2012
New Revision: 232710
URL: http://svn.freebsd.org/changeset/base/232710

Log:
  Increase BBSIZE to 16KB and add compat shims.

Modified:
  projects/bigbb/sbin/bsdlabel/bsdlabel.c
  projects/bigbb/sbin/newfs/newfs.c
  projects/bigbb/sys/geom/geom_bsd.c
  projects/bigbb/sys/geom/geom_pc98.c
  projects/bigbb/sys/geom/part/g_part_bsd.c
  projects/bigbb/sys/sys/disklabel.h
  projects/bigbb/sys/sys/diskpc98.h
  projects/bigbb/usr.sbin/makefs/ffs/mkfs.c

Modified: projects/bigbb/sbin/bsdlabel/bsdlabel.c
==============================================================================
--- projects/bigbb/sbin/bsdlabel/bsdlabel.c	Fri Mar  9 00:12:05 2012	(r232709)
+++ projects/bigbb/sbin/bsdlabel/bsdlabel.c	Fri Mar  9 00:28:28 2012	(r232710)
@@ -163,16 +163,12 @@ main(int argc, char *argv[])
 				is_file=1;
 				break;
 			case 'm':
-				if (!strcmp(optarg, "i386") ||
-				    !strcmp(optarg, "amd64") ||
-				    !strcmp(optarg, "ia64") ||
-				    !strcmp(optarg, "pc98")) {
-					labelsoffset = 1;
-					labeloffset = 0;
-					bbsize = 8192;
-				} else {
+				if (strcmp(optarg, "amd64") != 0 &&
+				    strcmp(optarg, "i386") != 0 &&
+				    strcmp(optarg, "pc98") != 0)
 					errx(1, "Unsupported architecture");
-				}
+				labelsoffset = 1;
+				labeloffset = 0;
 				break;
 			case 'n':
 				disable_write = 1;
@@ -311,7 +307,7 @@ fixlabel(struct disklabel *lp)
 	}
 
 	dp = &lp->d_partitions[0];
-	dp->p_offset = BBSIZE / secsize;
+	dp->p_offset = lp->d_bbsize / secsize;
 	dp->p_size = lp->d_secperunit - dp->p_offset;
 }
 
@@ -447,7 +443,7 @@ writelabel(void)
 			gctl_ro_param(grq, "verb", -1, "write bootcode");
 			gctl_ro_param(grq, "class", -1, "BSD");
 			gctl_ro_param(grq, "geom", -1, pname);
-			gctl_ro_param(grq, "bootcode", BBSIZE, bootarea);
+			gctl_ro_param(grq, "bootcode", lab.d_bbsize, bootarea);
 			errstr = gctl_issue(grq);
 			if (errstr != NULL) {
 				warnx("%s", errstr);
@@ -457,7 +453,7 @@ writelabel(void)
 			gctl_free(grq);
 		}
 	} else {
-		if (write(fd, bootarea, bbsize) != bbsize) {
+		if (write(fd, bootarea, lab.d_bbsize) != lab.d_bbsize) {
 			warn("write %s", specname);
 			close (fd);
 			return (1);
@@ -508,11 +504,11 @@ readlabel(int flag)
 		errx(1,
 		    "disks with more than 2^32-1 sectors are not supported");
 	(void)lseek(f, (off_t)0, SEEK_SET);
-	nbytes = read(f, bootarea, BBSIZE);
+	nbytes = read(f, bootarea, bbsize);
 	if (nbytes == -1)
 		err(4, "%s read", specname);
-	if (nbytes != BBSIZE)
-		errx(4, "couldn't read %d bytes from %s", BBSIZE, specname);
+	if (nbytes != bbsize)
+		errx(4, "couldn't read %d bytes from %s", bbsize, specname);
 	close (f);
 	error = bsd_disklabel_le_dec(
 	    bootarea + (labeloffset + labelsoffset * secsize),
@@ -778,7 +774,7 @@ getasciilabel(FILE *f, struct disklabel 
 	bzero(&part_set, sizeof(part_set));
 	bzero(&part_size_type, sizeof(part_size_type));
 	bzero(&part_offset_type, sizeof(part_offset_type));
-	lp->d_bbsize = BBSIZE;				/* XXX */
+	lp->d_bbsize = bbsize;				/* XXX */
 	lp->d_sbsize = 0;				/* XXX */
 	while (fgets(line, sizeof(line) - 1, f)) {
 		lineno++;
@@ -1275,7 +1271,7 @@ checklabel(struct disklabel *lp)
 	}
 
 	/* Find out the total free space, excluding the boot block area. */
-	base_offset = BBSIZE / secsize;
+	base_offset = lp->d_bbsize / secsize;
 	free_space = 0;
 	for (i = 0; i < lp->d_npartitions; i++) {
 		pp = &lp->d_partitions[i];
@@ -1325,7 +1321,7 @@ checklabel(struct disklabel *lp)
 		 * the hog partition and how much space they need.
 		 */
 		needed = 0;
-		base_offset = BBSIZE / secsize;
+		base_offset = lp->d_bbsize / secsize;
 		for (i = hog_part - 1; i >= 0; i--) {
 			pp = &lp->d_partitions[i];
 			if (!part_set[i] || i == RAW_PART)
@@ -1365,7 +1361,7 @@ checklabel(struct disklabel *lp)
 	}
 
 	/* Now set the offsets for each partition */
-	current_offset = BBSIZE / secsize; /* in sectors */
+	current_offset = lp->d_bbsize / secsize; /* in sectors */
 	seen_default_offset = 0;
 	for (i = 0; i < lp->d_npartitions; i++) {
 		part = 'a' + i;
@@ -1535,7 +1531,7 @@ getvirginlabel(void)
 
 	/* Various (unneeded) compat stuff */
 	loclab.d_rpm = 3600;
-	loclab.d_bbsize = BBSIZE;
+	loclab.d_bbsize = bbsize;
 	loclab.d_interleave = 1;
 	strncpy(loclab.d_typename, "amnesiac",
 	    sizeof(loclab.d_typename));

Modified: projects/bigbb/sbin/newfs/newfs.c
==============================================================================
--- projects/bigbb/sbin/newfs/newfs.c	Fri Mar  9 00:12:05 2012	(r232709)
+++ projects/bigbb/sbin/newfs/newfs.c	Fri Mar  9 00:28:28 2012	(r232710)
@@ -465,7 +465,7 @@ rewritelabel(char *s, struct disklabel *
 		bsd_disklabel_le_enc(bootarea + 0 /* labeloffset */ +
 			1 /* labelsoffset */ * sectorsize, lp);
 		lseek(disk.d_fd, 0, SEEK_SET);
-		if (write(disk.d_fd, bootarea, BBSIZE) != BBSIZE)
+		if (write(disk.d_fd, bootarea, lp->d_bbsize) != lp->d_bbsize)
 			errx(1, "cannot write label");
 		return;
 	}

Modified: projects/bigbb/sys/geom/geom_bsd.c
==============================================================================
--- projects/bigbb/sys/geom/geom_bsd.c	Fri Mar  9 00:12:05 2012	(r232709)
+++ projects/bigbb/sys/geom/geom_bsd.c	Fri Mar  9 00:28:28 2012	(r232710)
@@ -332,8 +332,10 @@ g_bsd_ioctl(struct g_provider *pp, u_lon
 	struct g_bsd_softc *ms;
 	struct g_slicer *gsp;
 	u_char *label;
+	size_t bbsize;
 	int error;
 
+	bbsize = BBSIZE;
 	gp = pp->geom;
 	gsp = gp->softc;
 	ms = gsp->softc;
@@ -343,6 +345,11 @@ g_bsd_ioctl(struct g_provider *pp, u_lon
 		/* Return a copy of the disklabel to userland. */
 		bsd_disklabel_le_dec(ms->label, data, MAXPARTITIONS);
 		return(0);
+#ifndef BURN_BRIDGES
+	case 0x8008646e:
+		bbsize = 8192;
+		/* FALLTHROUGH */
+#endif
 	case DIOCBSDBB: {
 		struct g_consumer *cp;
 		u_char *buf;
@@ -355,7 +362,7 @@ g_bsd_ioctl(struct g_provider *pp, u_lon
 		/* The disklabel to set is the ioctl argument. */
 		buf = g_malloc(BBSIZE, M_WAITOK);
 		p = *(void **)data;
-		error = copyin(p, buf, BBSIZE);
+		error = copyin(p, buf, bbsize);
 		if (!error) {
 			/* XXX: Rude, but supposedly safe */
 			DROP_GIANT();
@@ -370,7 +377,7 @@ g_bsd_ioctl(struct g_provider *pp, u_lon
 						sum += le64dec(buf + i * 8);
 					le64enc(buf + 504, sum);
 				}
-				error = g_write_data(cp, 0, buf, BBSIZE);
+				error = g_write_data(cp, 0, buf, bbsize);
 			}
 			g_topology_unlock();
 			PICKUP_GIANT();

Modified: projects/bigbb/sys/geom/geom_pc98.c
==============================================================================
--- projects/bigbb/sys/geom/geom_pc98.c	Fri Mar  9 00:12:05 2012	(r232709)
+++ projects/bigbb/sys/geom/geom_pc98.c	Fri Mar  9 00:28:28 2012	(r232710)
@@ -57,7 +57,7 @@ FEATURE(geom_pc98, "GEOM NEC PC9800 part
 struct g_pc98_softc {
 	u_int fwsectors, fwheads, sectorsize;
 	int type[NDOSPART];
-	u_char sec[8192];
+	u_char sec[16384];
 };
 
 static void
@@ -164,8 +164,10 @@ g_pc98_ioctl(struct g_provider *pp, u_lo
 	struct g_pc98_softc *ms;
 	struct g_slicer *gsp;
 	struct g_consumer *cp;
+	size_t bbsize;
 	int error, opened;
 
+	bbsize = 16384;
 	gp = pp->geom;
 	gsp = gp->softc;
 	ms = gsp->softc;
@@ -173,6 +175,11 @@ g_pc98_ioctl(struct g_provider *pp, u_lo
 	opened = 0;
 	error = 0;
 	switch(cmd) {
+#ifndef BURN_BRIDGES
+	case 0x80004d81:
+		bbsize = 8192;
+		/* FALLTHROUGH */
+#endif
 	case DIOCSPC98: {
 		if (!(fflag & FWRITE))
 			return (EPERM);
@@ -185,9 +192,9 @@ g_pc98_ioctl(struct g_provider *pp, u_lo
 				opened = 1;
 		}
 		if (!error)
-			error = g_pc98_modify(gp, ms, data, 8192);
+			error = g_pc98_modify(gp, ms, data, bbsize);
 		if (!error)
-			error = g_write_data(cp, 0, data, 8192);
+			error = g_write_data(cp, 0, data, bbsize);
 		if (opened)
 			g_access(cp, 0, -1 , 0);
 		g_topology_unlock();
@@ -293,14 +300,14 @@ g_pc98_taste(struct g_class *mp, struct 
 		sectorsize = cp->provider->sectorsize;
 		if (sectorsize % 512 != 0)
 			break;
-		buf = g_read_data(cp, 0, 8192, NULL);
+		buf = g_read_data(cp, 0, 16384, NULL);
 		if (buf == NULL)
 			break;
 		ms->fwsectors = fwsectors;
 		ms->fwheads = fwheads;
 		ms->sectorsize = sectorsize;
 		g_topology_lock();
-		g_pc98_modify(gp, ms, buf, 8192);
+		g_pc98_modify(gp, ms, buf, 16384);
 		g_topology_unlock();
 		g_free(buf);
 		break;
@@ -338,7 +345,11 @@ g_pc98_config(struct gctl_req *req, stru
 	data = gctl_get_param(req, "data", &len);
 	if (data == NULL)
 		return;
+#ifndef BURN_BRIDGES
 	if (len < 8192 || (len % 512)) {
+#else
+	if (len < 16384 || (len % 512)) {
+#endif
 		gctl_error(req, "Wrong request length");
 		return;
 	}

Modified: projects/bigbb/sys/geom/part/g_part_bsd.c
==============================================================================
--- projects/bigbb/sys/geom/part/g_part_bsd.c	Fri Mar  9 00:12:05 2012	(r232709)
+++ projects/bigbb/sys/geom/part/g_part_bsd.c	Fri Mar  9 00:28:28 2012	(r232710)
@@ -176,7 +176,12 @@ g_part_bsd_bootcode(struct g_part_table 
 	struct g_part_bsd_table *table;
 	const u_char *codeptr;
 
+#ifndef BURN_BRIDGES
+	if (gpp->gpp_codesize != BOOT1_SIZE && gpp->gpp_codesize != BBSIZE
+	    gpp->gpp_codesize != 8192)
+#else
 	if (gpp->gpp_codesize != BOOT1_SIZE && gpp->gpp_codesize != BBSIZE)
+#endif
 		return (ENODEV);
 
 	table = (struct g_part_bsd_table *)basetable;
@@ -185,6 +190,11 @@ g_part_bsd_bootcode(struct g_part_table 
 	if (gpp->gpp_codesize == BBSIZE)
 		bcopy(codeptr + BOOT2_OFF, table->bbarea + BOOT2_OFF,
 		    BOOT2_SIZE);
+#ifndef BURN_BRIDGES
+	elif (gpp->gpp_codesize == 8192)
+		bcopy(codeptr + BOOT2_OFF, table->bbarea + BOOT2_OFF,
+		    8192 - BOOT2_OFF);
+#endif
 	return (0);
 }
 

Modified: projects/bigbb/sys/sys/disklabel.h
==============================================================================
--- projects/bigbb/sys/sys/disklabel.h	Fri Mar  9 00:12:05 2012	(r232709)
+++ projects/bigbb/sys/sys/disklabel.h	Fri Mar  9 00:28:28 2012	(r232710)
@@ -63,7 +63,7 @@
 #endif
 
 /* Size of bootblock area in sector-size neutral bytes */
-#define BBSIZE		8192
+#define BBSIZE		16384
 
 #define	LABEL_PART	2		/* partition containing label */
 #define	RAW_PART	2		/* partition containing whole disk */
@@ -286,7 +286,7 @@ static const char *fstypenames[] = {
 #define DIOCGDINFO	_IOR('d', 101, struct disklabel)/* get */
 #define DIOCSDINFO	_IOW('d', 102, struct disklabel)/* set */
 #define DIOCWDINFO	_IOW('d', 103, struct disklabel)/* set, update disk */
-#define DIOCBSDBB	_IOW('d', 110, void *)	/* write bootblocks */
+#define DIOCBSDBB	_IOW('d', 111, void *)	/* write bootblocks */
 
 /*
  * Functions for proper encoding/decoding of struct disklabel into/from

Modified: projects/bigbb/sys/sys/diskpc98.h
==============================================================================
--- projects/bigbb/sys/sys/diskpc98.h	Fri Mar  9 00:12:05 2012	(r232709)
+++ projects/bigbb/sys/sys/diskpc98.h	Fri Mar  9 00:28:28 2012	(r232710)
@@ -81,6 +81,6 @@ CTASSERT(sizeof (struct pc98_partition) 
 void pc98_partition_dec(void const *pp, struct pc98_partition *d);
 void pc98_partition_enc(void *pp, struct pc98_partition *d);
 
-#define DIOCSPC98	_IOW('M', 129, u_char[8192])
+#define DIOCSPC98	_IOW('M', 130, u_char[16384])
 
 #endif /* !_SYS_DISKPC98_H_ */

Modified: projects/bigbb/usr.sbin/makefs/ffs/mkfs.c
==============================================================================
--- projects/bigbb/usr.sbin/makefs/ffs/mkfs.c	Fri Mar  9 00:12:05 2012	(r232709)
+++ projects/bigbb/usr.sbin/makefs/ffs/mkfs.c	Fri Mar  9 00:28:28 2012	(r232710)
@@ -41,6 +41,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/disklabel.h>
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/resource.h>
@@ -62,10 +63,6 @@ __FBSDID("$FreeBSD$");
 #include "ffs/ffs_extern.h"
 #include "ffs/newfs_extern.h"
 
-#ifndef BBSIZE
-#define	BBSIZE	8192			/* size of boot area, with label */
-#endif
-
 static void initcg(int, time_t, const fsinfo_t *);
 static int ilog2(int);
 


More information about the svn-src-projects mailing list