Module Name:    src
Committed By:   mrg
Date:           Sun Sep 19 05:50:28 UTC 2010

Modified Files:
        src/sys/dev: vnd.c vndvar.h

Log Message:
add support for COMPAT_50 ioctls.  struct vnd_user has a dev_t component
which grew since netbsd 5.0 (hi christos!)

fix a few issues/problems:
- the COMPAT_30 code wasn't used since opt_compat_netbsd.h wasn't included
- move 'struct vnd_ouser' (for COMPAT_30) into vnd.c itself, and call it
  'struct vnd_user30'
- same for VNDIOOCGET -> VNDIOCGET30

now 'vnconfig -l' works on -current with a netbsd-5 binary, using i386.

XXX: there is still a potential problem with the old VNDIOOCSET and
VNDIOOCCLR macros on some platforms like sparc.  there is padding
between the old vnd_osize member and the new vnd_size member on
platforms that want 64 bit values 64 bit aligned, but are 32 bit
otherwise (like sparc.)  64 bit systems already end up with this
member 64 bit aligned, and should be fine.

this most likely results in the old ioctl numbers being wrong and
the code won't match/run ever (ENOTTY.)


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/sys/dev/vnd.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/vndvar.h

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

Modified files:

Index: src/sys/dev/vnd.c
diff -u src/sys/dev/vnd.c:1.210 src/sys/dev/vnd.c:1.211
--- src/sys/dev/vnd.c:1.210	Thu Jun 24 21:20:23 2010
+++ src/sys/dev/vnd.c	Sun Sep 19 05:50:28 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.210 2010/06/24 21:20:23 riz Exp $	*/
+/*	$NetBSD: vnd.c,v 1.211 2010/09/19 05:50:28 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -130,10 +130,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.210 2010/06/24 21:20:23 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.211 2010/09/19 05:50:28 mrg Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
+#include "opt_compat_netbsd.h"
 #endif
 
 #include <sys/param.h>
@@ -194,6 +195,24 @@
 #define VNDLABELDEV(dev) \
     (MAKEDISKDEV(major((dev)), vndunit((dev)), RAW_PART))
 
+#ifdef COMPAT_30
+struct vnd_user30 {
+	int		vnu_unit;	/* which vnd unit */
+	uint32_t	vnu_dev;	/* file is on this device... */
+	uint32_t	vnu_ino;	/* ...at this inode */
+};
+#define VNDIOCGET30	_IOWR('F', 2, struct vnd_user30)	/* get list */
+#endif
+
+#ifdef COMPAT_50
+struct vnd_user50 {
+	int		vnu_unit;	/* which vnd unit */
+	uint32_t	vnu_dev;	/* file is on this device... */
+	ino_t		vnu_ino;	/* ...at this inode */
+};
+#define VNDIOCGET50	_IOWR('F', 3, struct vnd_user50)	/* get list */
+#endif
+
 /* called by main() at boot time */
 void	vndattach(int);
 
@@ -1032,7 +1051,10 @@
 	vnd = device_lookup_private(&vnd_cd, unit);
 	if (vnd == NULL &&
 #ifdef COMPAT_30
-	    cmd != VNDIOOCGET &&
+	    cmd != VNDIOCGET30 &&
+#endif
+#ifdef COMPAT_50
+	    cmd != VNDIOCGET50 &&
 #endif
 	    cmd != VNDIOCGET)
 		return ENXIO;
@@ -1365,10 +1387,33 @@
 		break;
 
 #ifdef COMPAT_30
-	case VNDIOOCGET: {
-		struct vnd_ouser *vnu;
+	case VNDIOCGET30: {
+		struct vnd_user30 *vnu;
+		struct vattr va;
+		vnu = (struct vnd_user30 *)data;
+		KASSERT(l);
+		switch (error = vnd_cget(l, unit, &vnu->vnu_unit, &va)) {
+		case 0:
+			vnu->vnu_dev = va.va_fsid;
+			vnu->vnu_ino = va.va_fileid;
+			break;
+		case -1:
+			/* unused is not an error */
+			vnu->vnu_dev = 0;
+			vnu->vnu_ino = 0;
+			break;
+		default:
+			return error;
+		}
+		break;
+	}
+#endif
+
+#ifdef COMPAT_50
+	case VNDIOCGET50: {
+		struct vnd_user50 *vnu;
 		struct vattr va;
-		vnu = (struct vnd_ouser *)data;
+		vnu = (struct vnd_user50 *)data;
 		KASSERT(l);
 		switch (error = vnd_cget(l, unit, &vnu->vnu_unit, &va)) {
 		case 0:
@@ -1386,6 +1431,7 @@
 		break;
 	}
 #endif
+
 	case VNDIOCGET: {
 		struct vnd_user *vnu;
 		struct vattr va;

Index: src/sys/dev/vndvar.h
diff -u src/sys/dev/vndvar.h:1.26 src/sys/dev/vndvar.h:1.27
--- src/sys/dev/vndvar.h:1.26	Mon Dec 14 03:11:22 2009
+++ src/sys/dev/vndvar.h	Sun Sep 19 05:50:28 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vndvar.h,v 1.26 2009/12/14 03:11:22 uebayasi Exp $	*/
+/*	$NetBSD: vndvar.h,v 1.27 2010/09/19 05:50:28 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -193,14 +193,6 @@
 /*
  * A simple structure for describing which vnd units are in use.
  */
-#ifdef COMPAT_30
-struct vnd_ouser {
-	int		vnu_unit;	/* which vnd unit */
-	dev_t		vnu_dev;	/* file is on this device... */
-	uint32_t	vnu_ino;	/* ...at this inode */
-};
-#define VNDIOOCGET	_IOWR('F', 2, struct vnd_ouser)	/* get list */
-#endif
 
 struct vnd_user {
 	int		vnu_unit;	/* which vnd unit */

Reply via email to