Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev add support for COMPAT_50 ioctls. struct vnd_user h...



details:   https://anonhg.NetBSD.org/src/rev/7c42d060edc3
branches:  trunk
changeset: 757722:7c42d060edc3
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Sep 19 05:50:28 2010 +0000

description:
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.)

diffstat:

 sys/dev/vnd.c    |  58 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 sys/dev/vndvar.h |  10 +--------
 2 files changed, 53 insertions(+), 15 deletions(-)

diffs (128 lines):

diff -r d0951f399cbc -r 7c42d060edc3 sys/dev/vnd.c
--- a/sys/dev/vnd.c     Sun Sep 19 05:42:10 2010 +0000
+++ b/sys/dev/vnd.c     Sun Sep 19 05:50:28 2010 +0000
@@ -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,10 @@
                break;
 
 #ifdef COMPAT_30
-       case VNDIOOCGET: {
-               struct vnd_ouser *vnu;
+       case VNDIOCGET30: {
+               struct vnd_user30 *vnu;
                struct vattr va;
-               vnu = (struct vnd_ouser *)data;
+               vnu = (struct vnd_user30 *)data;
                KASSERT(l);
                switch (error = vnd_cget(l, unit, &vnu->vnu_unit, &va)) {
                case 0:
@@ -1386,6 +1408,30 @@
                break;
        }
 #endif
+
+#ifdef COMPAT_50
+       case VNDIOCGET50: {
+               struct vnd_user50 *vnu;
+               struct vattr va;
+               vnu = (struct vnd_user50 *)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
+
        case VNDIOCGET: {
                struct vnd_user *vnu;
                struct vattr va;
diff -r d0951f399cbc -r 7c42d060edc3 sys/dev/vndvar.h
--- a/sys/dev/vndvar.h  Sun Sep 19 05:42:10 2010 +0000
+++ b/sys/dev/vndvar.h  Sun Sep 19 05:50:28 2010 +0000
@@ -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 */



Home | Main Index | Thread Index | Old Index