Module Name:    src
Committed By:   martin
Date:           Mon Aug 18 12:40:36 UTC 2014

Modified Files:
        src/sbin/ccdconfig [netbsd-7]: ccdconfig.c
        src/sys/dev [netbsd-7]: ccd.c ccdvar.h

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #38):
        sys/dev/ccd.c: revision 1.152
        sbin/ccdconfig/ccdconfig.c: revision 1.54
        sbin/ccdconfig/ccdconfig.c: revision 1.55
        sys/dev/ccdvar.h: revision 1.34
Switch size_t to uint64_t in appropriate places to ensure that ccd(4) works
with component and total sizes of > 2TB.
Add COMPAT_60 code for platforms where this alters userland-accessible
structures.
Make kernel print device information when a ccd configured.
Fix some typos in comments.
Don't print ccd_size with %zu; it no longer has type size_t.
Instead, cast to uintmax_t and print with %ju.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.53.6.1 src/sbin/ccdconfig/ccdconfig.c
cvs rdiff -u -r1.151 -r1.151.2.1 src/sys/dev/ccd.c
cvs rdiff -u -r1.33 -r1.33.10.1 src/sys/dev/ccdvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ccdconfig/ccdconfig.c
diff -u src/sbin/ccdconfig/ccdconfig.c:1.53 src/sbin/ccdconfig/ccdconfig.c:1.53.6.1
--- src/sbin/ccdconfig/ccdconfig.c:1.53	Fri May  3 00:01:15 2013
+++ src/sbin/ccdconfig/ccdconfig.c	Mon Aug 18 12:40:36 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ccdconfig.c,v 1.53 2013/05/03 00:01:15 christos Exp $	*/
+/*	$NetBSD: ccdconfig.c,v 1.53.6.1 2014/08/18 12:40:36 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1996, 1997\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: ccdconfig.c,v 1.53 2013/05/03 00:01:15 christos Exp $");
+__RCSID("$NetBSD: ccdconfig.c,v 1.53.6.1 2014/08/18 12:40:36 martin Exp $");
 #endif
 
 #include <sys/param.h>
@@ -271,7 +271,7 @@ do_single(int argc, char **argv, int act
 			    ui == 0 ? '(' : ' ', cp2,
 			    ui == ccio.ccio_ndisks - 1 ? ')' : ',');
 		}
-		printf(", %ld blocks ", (long)ccio.ccio_size);
+		printf(", %ju blocks ", (uintmax_t)ccio.ccio_size);
 		if (ccio.ccio_ileave != 0)
 			printf("interleaved at %d blocks\n", ccio.ccio_ileave);
 		else
@@ -445,8 +445,9 @@ print_ccd_info(int u, struct ccddiskinfo
 	}
 
 	/* Dump out softc information. */
-	printf("ccd%d\t\t%d\t0x%x\t%zu\t", u, ccd->ccd_ileave,
-	    ccd->ccd_flags & CCDF_USERMASK, ccd->ccd_size * DEV_BSIZE);
+	printf("ccd%d\t\t%d\t0x%x\t%ju\t", u, ccd->ccd_ileave,
+	    ccd->ccd_flags & CCDF_USERMASK,
+	    (uintmax_t)ccd->ccd_size * DEV_BSIZE);
 
 	/* Read component pathname and display component info. */
 	for (size_t i = 0; i < ccd->ccd_ndisks; ++i) {

Index: src/sys/dev/ccd.c
diff -u src/sys/dev/ccd.c:1.151 src/sys/dev/ccd.c:1.151.2.1
--- src/sys/dev/ccd.c:1.151	Fri Jul 25 08:10:35 2014
+++ src/sys/dev/ccd.c	Mon Aug 18 12:40:36 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ccd.c,v 1.151 2014/07/25 08:10:35 dholland Exp $	*/
+/*	$NetBSD: ccd.c,v 1.151.2.1 2014/08/18 12:40:36 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.151 2014/07/25 08:10:35 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.151.2.1 2014/08/18 12:40:36 martin Exp $");
+
+#if defined(_KERNEL_OPT)
+#include "opt_compat_netbsd.h"
+#endif
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -426,6 +430,22 @@ ccdinit(struct ccd_softc *cs, char **cpa
 	ccg->ccg_ntracks = 1;
 	ccg->ccg_nsectors = 1024 * (1024 / ccg->ccg_secsize);
 	ccg->ccg_ncylinders = cs->sc_size / ccg->ccg_nsectors;
+	
+	if (cs->sc_ileave > 0)
+	        aprint_normal("%s: Interleaving %d component%s "
+	            "(%d block interleave)\n", cs->sc_xname,
+        	    cs->sc_nccdisks, (cs->sc_nccdisks != 0 ? "s" : ""),
+        	    cs->sc_ileave);
+	else
+	        aprint_normal("%s: Concatenating %d component%s\n",
+	            cs->sc_xname,
+        	    cs->sc_nccdisks, (cs->sc_nccdisks != 0 ? "s" : ""));
+	for (ix = 0; ix < cs->sc_nccdisks; ix++) {
+		ci = &cs->sc_cinfo[ix];
+		aprint_normal("%s: %s (%ju blocks)\n", cs->sc_xname,
+		    ci->ci_path, (uintmax_t)ci->ci_size);
+	}
+	aprint_normal("%s: total %ju blocks\n", cs->sc_xname, cs->sc_size);
 
 	/*
 	 * Create thread to handle deferred I/O.
@@ -1053,6 +1073,46 @@ ccdioctl(dev_t dev, u_long cmd, void *da
 		return ENOENT;
 	uc = kauth_cred_get();
 
+/*
+ * Compat code must not be called if on a platform where
+ * sizeof (size_t) == sizeof (uint64_t) as CCDIOCSET will
+ * be the same as CCDIOCSET_60
+ */
+#if defined(COMPAT_60) && !defined(_LP64)
+	switch (cmd) {
+	case CCDIOCSET_60: {
+		struct ccd_ioctl ccionew;
+       		struct ccd_ioctl_60 *ccio60 =
+       		    (struct ccd_ioctl_60 *)data;
+		ccionew.ccio_disks = ccio->ccio_disks;
+		ccionew.ccio_ndisks = ccio->ccio_ndisks;
+		ccionew.ccio_ileave = ccio->ccio_ileave;
+		ccionew.ccio_flags = ccio->ccio_flags;
+		ccionew.ccio_unit = ccio->ccio_unit;
+		error = ccdioctl(dev, CCDIOCSET, &ccionew, flag, l);
+		if (!error) {
+			/* Copy data back, adjust types if necessary */
+			ccio60->ccio_disks = ccionew.ccio_disks;
+			ccio60->ccio_ndisks = ccionew.ccio_ndisks;
+			ccio60->ccio_ileave = ccionew.ccio_ileave;
+			ccio60->ccio_flags = ccionew.ccio_flags;
+			ccio60->ccio_unit = ccionew.ccio_unit;
+			ccio60->ccio_size = (size_t)ccionew.ccio_size;
+		}
+		return error;
+		}
+		break;
+
+	case CCDIOCCLR_60:
+		/*
+		 * ccio_size member not used, so existing struct OK
+		 * drop through to existing non-compat version
+		 */
+		cmd = CCDIOCCLR;
+		break;
+	}
+#endif /* COMPAT_60 && !_LP64*/
+
 	/* Must be open for writes for these commands... */
 	switch (cmd) {
 	case CCDIOCSET:
@@ -1120,7 +1180,7 @@ ccdioctl(dev_t dev, u_long cmd, void *da
 
 		/*
 		 * Allocate space for and copy in the array of
-		 * componet pathnames and device numbers.
+		 * component pathnames and device numbers.
 		 */
 		cpp = kmem_alloc(ccio->ccio_ndisks * sizeof(*cpp), KM_SLEEP);
 		vpp = kmem_alloc(ccio->ccio_ndisks * sizeof(*vpp), KM_SLEEP);
@@ -1259,7 +1319,9 @@ ccdioctl(dev_t dev, u_long cmd, void *da
 		kmem_free(cs->sc_itable, (cs->sc_nccdisks + 1) *
 		    sizeof(struct ccdiinfo));
 
-		/* Detatch the disk. */
+		aprint_normal("%s: detached\n", cs->sc_xname);
+
+		/* Detach the disk. */
 		disk_detach(&cs->sc_dkdev);
 		bufq_free(cs->sc_bufq);
 		ccdput(cs);
@@ -1489,15 +1551,16 @@ ccdgetdisklabel(dev_t dev)
 		 */
 		if (lp->d_secperunit != cs->sc_size)
 			printf("WARNING: %s: "
-			    "total sector size in disklabel (%d) != "
-			    "the size of ccd (%lu)\n", cs->sc_xname,
-			    lp->d_secperunit, (u_long)cs->sc_size);
+			    "total sector size in disklabel (%ju) != "
+			    "the size of ccd (%ju)\n", cs->sc_xname,
+			    (uintmax_t)lp->d_secperunit,
+			    (uintmax_t)cs->sc_size);
 		for (i = 0; i < lp->d_npartitions; i++) {
 			pp = &lp->d_partitions[i];
 			if (pp->p_offset + pp->p_size > cs->sc_size)
 				printf("WARNING: %s: end of partition `%c' "
-				    "exceeds the size of ccd (%lu)\n",
-				    cs->sc_xname, 'a' + i, (u_long)cs->sc_size);
+				    "exceeds the size of ccd (%ju)\n",
+				    cs->sc_xname, 'a' + i, (uintmax_t)cs->sc_size);
 		}
 	}
 

Index: src/sys/dev/ccdvar.h
diff -u src/sys/dev/ccdvar.h:1.33 src/sys/dev/ccdvar.h:1.33.10.1
--- src/sys/dev/ccdvar.h:1.33	Sat Apr 27 17:13:34 2013
+++ src/sys/dev/ccdvar.h	Mon Aug 18 12:40:36 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ccdvar.h,v 1.33 2013/04/27 17:13:34 christos Exp $	*/
+/*	$NetBSD: ccdvar.h,v 1.33.10.1 2014/08/18 12:40:36 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -93,9 +93,10 @@ struct ccd_ioctl {
 	int	ccio_ileave;		/* interleave (DEV_BSIZE blocks) */
 	int	ccio_flags;		/* see sc_flags below */
 	int	ccio_unit;		/* unit number: use varies */
-	size_t	ccio_size;		/* (returned) size of ccd */
+	uint64_t	ccio_size;	/* (returned) size of ccd */
 };
 
+
 /*
  * Component info table.
  * Describes a single component of a concatenated disk.
@@ -103,7 +104,7 @@ struct ccd_ioctl {
 struct ccdcinfo {
 	struct vnode	*ci_vp;			/* device's vnode */
 	dev_t		ci_dev;			/* XXX: device's dev_t */
-	size_t		ci_size; 		/* size */
+	uint64_t	ci_size; 		/* size */
 	char		*ci_path;		/* path to component */
 	size_t		ci_pathlen;		/* length of component path */
 };
@@ -160,7 +161,7 @@ struct ccdbuf;
 struct ccd_softc {
 	int		 sc_unit;
 	int		 sc_flags;		/* flags */
-	size_t		 sc_size;		/* size of ccd */
+	uint64_t	 sc_size;		/* size of ccd */
 	int		 sc_ileave;		/* interleave */
 	u_int		 sc_nccdisks;		/* number of components */
 #define	CCD_MAXNDISKS	65536
@@ -203,13 +204,29 @@ struct ccd_softc {
 #define CCDIOCSET	_IOWR('F', 16, struct ccd_ioctl)   /* enable ccd */
 #define CCDIOCCLR	_IOW('F', 17, struct ccd_ioctl)    /* disable ccd */
 
+#if defined(COMPAT_60) && !defined(_LP64)
+/*
+ * Old version with incorrect ccio_size
+ */
+struct ccd_ioctl_60 {
+	char	**ccio_disks;		/* pointer to component paths */
+	u_int	ccio_ndisks;		/* number of disks to concatenate */
+	int	ccio_ileave;		/* interleave (DEV_BSIZE blocks) */
+	int	ccio_flags;		/* see sc_flags below */
+	int	ccio_unit;		/* unit number: use varies */
+	size_t	ccio_size;		/* (returned) size of ccd */
+};
+
+#define CCDIOCSET_60	_IOWR('F', 16, struct ccd_ioctl_60)   /* enable ccd */
+#define CCDIOCCLR_60	_IOW('F', 17, struct ccd_ioctl_60)   /* disable ccd */
+#endif /* COMPAT_60 && !LP64*/
 /*
  * Sysctl information
  */
 struct ccddiskinfo {
 	int ccd_ileave;
 	u_int ccd_ndisks;
-	size_t ccd_size;
+	uint64_t ccd_size;
 	int ccd_flags;
 };
 

Reply via email to