Source-Changes-HG archive

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

[src/trunk]: src/sys/dev fix the vnd_osize changes on 32 bit platforms with 6...



details:   https://anonhg.NetBSD.org/src/rev/acf401cf653d
branches:  trunk
changeset: 757723:acf401cf653d
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Sep 19 07:11:42 2010 +0000

description:
fix the vnd_osize changes on 32 bit platforms with 64 bit alignment for
64 bit integers (eg, sparc).  the problem was that the new 64 bit
element on the end was used for the offsetof() (aka size) for the old
structure, but this includes the padding required, thus the ioctl number
was set wrongly.

move all the supporting code for this inside COMPAT_50, with some renaming
to suit, and kill all the external definitions related to it.


tested on i386, amd64 and sparc.

diffstat:

 sys/dev/vnd.c    |  37 ++++++++++++++++++++++++-------------
 sys/dev/vndvar.h |   8 +-------
 2 files changed, 25 insertions(+), 20 deletions(-)

diffs (113 lines):

diff -r 7c42d060edc3 -r acf401cf653d sys/dev/vnd.c
--- a/sys/dev/vnd.c     Sun Sep 19 05:50:28 2010 +0000
+++ b/sys/dev/vnd.c     Sun Sep 19 07:11:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vnd.c,v 1.211 2010/09/19 05:50:28 mrg Exp $    */
+/*     $NetBSD: vnd.c,v 1.212 2010/09/19 07:11:42 mrg Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.211 2010/09/19 05:50:28 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.212 2010/09/19 07:11:42 mrg Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -211,6 +211,15 @@
        ino_t           vnu_ino;        /* ...at this inode */
 };
 #define VNDIOCGET50    _IOWR('F', 3, struct vnd_user50)        /* get list */
+
+struct vnd_ioctl50 {
+       char            *vnd_file;      /* pathname of file to mount */
+       int             vnd_flags;      /* flags; see below */
+       struct vndgeom  vnd_geom;       /* geometry to emulate */
+       unsigned int    vnd_size;       /* (returned) size of disk */
+};
+#define VNDIOCSET50    _IOWR('F', 0, struct vnd_ioctl50)
+#define VNDIOCCLR50    _IOW('F', 1, struct vnd_ioctl50)
 #endif
 
 /* called by main() at boot time */
@@ -1064,9 +1073,11 @@
        switch (cmd) {
        case VNDIOCSET:
        case VNDIOCCLR:
-#ifdef VNDIOOCSET
-       case VNDIOOCSET:
-       case VNDIOOCCLR:
+#ifdef VNDIOCSET50
+       case VNDIOCSET50:
+#endif
+#ifdef VNDIOCCLR50
+       case VNDIOCCLR50:
 #endif
        case DIOCSDINFO:
        case DIOCWDINFO:
@@ -1083,8 +1094,8 @@
        /* Must be initialized for these... */
        switch (cmd) {
        case VNDIOCCLR:
-#ifdef VNDIOOCCLR
-       case VNDIOOCCLR:
+#ifdef VNDIOCCLR50
+       case VNDIOCCLR50:
 #endif
        case DIOCGDINFO:
        case DIOCSDINFO:
@@ -1105,8 +1116,8 @@
        }
 
        switch (cmd) {
-#ifdef VNDIOOCSET
-       case VNDIOOCSET:
+#ifdef VNDIOCSET50
+       case VNDIOCSET50:
 #endif
        case VNDIOCSET:
                if (vnd->sc_flags & VNF_INITED)
@@ -1313,8 +1324,8 @@
 
                vndthrottle(vnd, vnd->sc_vp);
                vio->vnd_osize = dbtob(vnd->sc_size);
-#ifdef VNDIOOCSET
-               if (cmd != VNDIOOCSET)
+#ifdef VNDIOCSET50
+               if (cmd != VNDIOCSET50)
 #endif
                        vio->vnd_size = dbtob(vnd->sc_size);
                vnd->sc_flags |= VNF_INITED;
@@ -1373,8 +1384,8 @@
                vndunlock(vnd);
                return error;
 
-#ifdef VNDIOOCCLR
-       case VNDIOOCCLR:
+#ifdef VNDIOCCLR50
+       case VNDIOCCLR50:
 #endif
        case VNDIOCCLR:
                part = DISKPART(dev);
diff -r 7c42d060edc3 -r acf401cf653d sys/dev/vndvar.h
--- a/sys/dev/vndvar.h  Sun Sep 19 05:50:28 2010 +0000
+++ b/sys/dev/vndvar.h  Sun Sep 19 07:11:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vndvar.h,v 1.27 2010/09/19 05:50:28 mrg Exp $  */
+/*     $NetBSD: vndvar.h,v 1.28 2010/09/19 07:11:42 mrg Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -210,10 +210,4 @@
 #define VNDIOCCLR      _IOW('F', 1, struct vnd_ioctl)  /* disable disk */
 #define VNDIOCGET      _IOWR('F', 3, struct vnd_user)  /* get list */
 
-/* These only have the 32bit vnd_osize field */
-#define VNDIOOCSET     _IOC(IOC_INOUT, 'F', 0, \
-                               offsetof(struct vnd_ioctl, vnd_size))
-#define VNDIOOCCLR     _IOC(IOC_IN, 'F', 1, \
-                               offsetof(struct vnd_ioctl, vnd_size))
-
 #endif /* _SYS_DEV_VNDVAR_H_ */



Home | Main Index | Thread Index | Old Index