Module Name: src Committed By: mrg Date: Sun Sep 19 07:11:43 UTC 2010
Modified Files: src/sys/dev: vnd.c vndvar.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.211 -r1.212 src/sys/dev/vnd.c cvs rdiff -u -r1.27 -r1.28 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.211 src/sys/dev/vnd.c:1.212 --- src/sys/dev/vnd.c:1.211 Sun Sep 19 05:50:28 2010 +++ src/sys/dev/vnd.c Sun Sep 19 07:11:42 2010 @@ -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); Index: src/sys/dev/vndvar.h diff -u src/sys/dev/vndvar.h:1.27 src/sys/dev/vndvar.h:1.28 --- src/sys/dev/vndvar.h:1.27 Sun Sep 19 05:50:28 2010 +++ src/sys/dev/vndvar.h Sun Sep 19 07:11:42 2010 @@ -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_ */