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.
This commit is contained in:
mrg 2010-09-19 07:11:42 +00:00
parent 6489048a39
commit 94bc17b82c
2 changed files with 25 additions and 20 deletions

View File

@ -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 @@ struct vnd_user50 {
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 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
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 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
/* 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 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
}
switch (cmd) {
#ifdef VNDIOOCSET
case VNDIOOCSET:
#ifdef VNDIOCSET50
case VNDIOCSET50:
#endif
case VNDIOCSET:
if (vnd->sc_flags & VNF_INITED)
@ -1313,8 +1324,8 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
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 @@ unlock_and_exit:
vndunlock(vnd);
return error;
#ifdef VNDIOOCCLR
case VNDIOOCCLR:
#ifdef VNDIOCCLR50
case VNDIOCCLR50:
#endif
case VNDIOCCLR:
part = DISKPART(dev);

View File

@ -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 @@ struct vnd_user {
#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_ */