summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2003-10-30 02:40:30 +0000
committerpeter <peter@FreeBSD.org>2003-10-30 02:40:30 +0000
commit11bf308b70fdf315f6dd687da1123fe0efa3969e (patch)
treea575dfdf8b779dbf7db20e52f5ccc5ab8a662bd2 /sys
parent3ac5936ae2d8a943a85870924dded1c08cbf2aed (diff)
downloadFreeBSD-src-11bf308b70fdf315f6dd687da1123fe0efa3969e.zip
FreeBSD-src-11bf308b70fdf315f6dd687da1123fe0efa3969e.tar.gz
Add CTASSERT()'s to check that the sizes of our replicas of the 32 bit
structures come out the right size. Fix the ones that broke. stat32 had some missing fields from the end and statfs32 was broken due to the strange definition of MNAMELEN (which is dependent on sizeof(long)) I'm not sure if this fixes any actual problems or not.
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/freebsd32/freebsd32.h8
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c21
-rw-r--r--sys/compat/ia32/ia32_signal.h2
3 files changed, 26 insertions, 5 deletions
diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h
index ced0bce..5975144 100644
--- a/sys/compat/freebsd32/freebsd32.h
+++ b/sys/compat/freebsd32/freebsd32.h
@@ -75,6 +75,8 @@ struct rusage32 {
int32_t ru_nivcsw;
};
+#define FREEBSD32_MNAMELEN (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */
+
struct statfs32 {
int32_t f_spare2;
int32_t f_bsize;
@@ -91,12 +93,12 @@ struct statfs32 {
int32_t f_syncwrites;
int32_t f_asyncwrites;
char f_fstypename[MFSNAMELEN];
- char f_mntonname[MNAMELEN];
+ char f_mntonname[FREEBSD32_MNAMELEN];
int32_t f_syncreads;
int32_t f_asyncreads;
int16_t f_spares1;
- char f_mntfromname[MNAMELEN];
- int16_t f_spares2;
+ char f_mntfromname[FREEBSD32_MNAMELEN];
+ int16_t f_spares2 __packed;
int32_t f_spare[2];
};
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 1fdde15..df5b407 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -79,6 +79,11 @@ __FBSDID("$FreeBSD$");
#include <compat/freebsd32/freebsd32.h>
#include <compat/freebsd32/freebsd32_proto.h>
+CTASSERT(sizeof(struct timeval32) == 8);
+CTASSERT(sizeof(struct timespec32) == 8);
+CTASSERT(sizeof(struct statfs32) == 256);
+CTASSERT(sizeof(struct rusage32) == 72);
+
/*
* [ taken from the linux emulator ]
* Search an alternate path before passing pathname arguments on
@@ -356,6 +361,8 @@ struct sigaltstack32 {
int ss_flags;
};
+CTASSERT(sizeof(struct sigaltstack32) == 12);
+
int
freebsd32_sigaltstack(struct thread *td,
struct freebsd32_sigaltstack_args *uap)
@@ -589,6 +596,8 @@ struct itimerval32 {
struct timeval32 it_value;
};
+CTASSERT(sizeof(struct itimerval32) == 16);
+
int
freebsd32_setitimer(struct thread *td, struct freebsd32_setitimer_args *uap)
{
@@ -668,6 +677,8 @@ struct kevent32 {
u_int32_t udata; /* opaque user data identifier */
};
+CTASSERT(sizeof(struct kevent32) == 20);
+
int
freebsd32_kevent(struct thread *td, struct freebsd32_kevent_args *uap)
{
@@ -819,6 +830,8 @@ struct iovec32 {
};
#define STACKGAPLEN 400
+CTASSERT(sizeof(struct iovec32) == 8);
+
int
freebsd32_readv(struct thread *td, struct freebsd32_readv_args *uap)
{
@@ -1198,8 +1211,14 @@ struct stat32 {
u_int32_t st_blksize;
u_int32_t st_flags;
u_int32_t st_gen;
+ struct timespec32 st_birthtimespec;
+ unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
+ unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
};
+
+CTASSERT(sizeof(struct stat32) == 96);
+
static void
copy_stat( struct stat *in, struct stat32 *out)
{
@@ -1342,6 +1361,8 @@ struct sigaction32 {
sigset_t sa_mask;
};
+CTASSERT(sizeof(struct sigaction32) == 24);
+
int
freebsd32_sigaction(struct thread *td, struct freebsd32_sigaction_args *uap)
{
diff --git a/sys/compat/ia32/ia32_signal.h b/sys/compat/ia32/ia32_signal.h
index f251e72..53f6c73 100644
--- a/sys/compat/ia32/ia32_signal.h
+++ b/sys/compat/ia32/ia32_signal.h
@@ -35,7 +35,6 @@ struct ia32_sigaltstack {
int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
};
-/* XXX should be 640 bytes long; check and see if __packed is needed */
struct ia32_mcontext {
int mc_onstack; /* XXX - sigcontext compat. */
int mc_gs; /* machine state (struct trapframe) */
@@ -69,7 +68,6 @@ struct ia32_mcontext {
int mc_spare2[8];
};
-/* XXX should be 704 bytes long; check and see if __packed is needed */
struct ia32_ucontext {
sigset_t uc_sigmask;
struct ia32_mcontext uc_mcontext;
OpenPOWER on IntegriCloud