[PATCH] create struct compat_timex and use it everywhere

We had a copy of the compatibility version of struct timex in each 64 bit
architecture.  This patch just creates a global one and replaces all the
usages of the old ones.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kyle McMartin <kyle@parisc-linux.org>
Acked-by: Tony Luck <tony.luck@intel.com>
Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Stephen Rothwell 2006-03-26 01:37:27 -08:00 committed by Linus Torvalds
parent eb76b3fda1
commit 88959ea968
8 changed files with 38 additions and 119 deletions

View file

@ -2594,23 +2594,10 @@ sys32_setresgid(compat_gid_t rgid, compat_gid_t egid,
/* Handle adjtimex compatibility. */
struct timex32 {
u32 modes;
s32 offset, freq, maxerror, esterror;
s32 status, constant, precision, tolerance;
struct compat_timeval time;
s32 tick;
s32 ppsfreq, jitter, shift, stabil;
s32 jitcnt, calcnt, errcnt, stbcnt;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
};
extern int do_adjtimex(struct timex *);
asmlinkage long
sys32_adjtimex(struct timex32 *utp)
sys32_adjtimex(struct compat_timex *utp)
{
struct timex txc;
int ret;

View file

@ -1159,22 +1159,9 @@ asmlinkage int sys32_ustat(dev_t dev, struct ustat32 __user * ubuf32)
/* Handle adjtimex compatibility. */
struct timex32 {
u32 modes;
s32 offset, freq, maxerror, esterror;
s32 status, constant, precision, tolerance;
struct compat_timeval time;
s32 tick;
s32 ppsfreq, jitter, shift, stabil;
s32 jitcnt, calcnt, errcnt, stbcnt;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
};
extern int do_adjtimex(struct timex *);
asmlinkage int sys32_adjtimex(struct timex32 __user *utp)
asmlinkage int sys32_adjtimex(struct compat_timex __user *utp)
{
struct timex txc;
int ret;

View file

@ -567,43 +567,14 @@ asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *off
}
struct timex32 {
unsigned int modes; /* mode selector */
int offset; /* time offset (usec) */
int freq; /* frequency offset (scaled ppm) */
int maxerror; /* maximum error (usec) */
int esterror; /* estimated error (usec) */
int status; /* clock command/status */
int constant; /* pll time constant */
int precision; /* clock precision (usec) (read only) */
int tolerance; /* clock frequency tolerance (ppm)
* (read only)
*/
struct compat_timeval time; /* (read only) */
int tick; /* (modified) usecs between clock ticks */
int ppsfreq; /* pps frequency (scaled ppm) (ro) */
int jitter; /* pps jitter (us) (ro) */
int shift; /* interval duration (s) (shift) (ro) */
int stabil; /* pps stability (scaled ppm) (ro) */
int jitcnt; /* jitter limit exceeded (ro) */
int calcnt; /* calibration intervals (ro) */
int errcnt; /* calibration errors (ro) */
int stbcnt; /* stability limit exceeded (ro) */
int :32; int :32; int :32; int :32;
int :32; int :32; int :32; int :32;
int :32; int :32; int :32; int :32;
};
asmlinkage long sys32_adjtimex(struct timex32 __user *txc_p32)
asmlinkage long sys32_adjtimex(struct compat_timex __user *txc_p32)
{
struct timex txc;
struct timex32 t32;
struct compat_timex t32;
int ret;
extern int do_adjtimex(struct timex *txc);
if(copy_from_user(&t32, txc_p32, sizeof(struct timex32)))
if(copy_from_user(&t32, txc_p32, sizeof(struct compat_timex)))
return -EFAULT;
#undef CP
#define CP(x) txc.x = t32.x
@ -620,7 +591,7 @@ asmlinkage long sys32_adjtimex(struct timex32 __user *txc_p32)
CP(time.tv_sec); CP(time.tv_usec); CP(tick); CP(ppsfreq); CP(jitter);
CP(shift); CP(stabil); CP(jitcnt); CP(calcnt); CP(errcnt);
CP(stbcnt);
return copy_to_user(txc_p32, &t32, sizeof(struct timex32)) ? -EFAULT : ret;
return copy_to_user(txc_p32, &t32, sizeof(struct compat_timex)) ? -EFAULT : ret;
}

View file

@ -162,22 +162,9 @@ asmlinkage long compat_sys_sysfs(u32 option, u32 arg1, u32 arg2)
}
/* Handle adjtimex compatibility. */
struct timex32 {
u32 modes;
s32 offset, freq, maxerror, esterror;
s32 status, constant, precision, tolerance;
struct compat_timeval time;
s32 tick;
s32 ppsfreq, jitter, shift, stabil;
s32 jitcnt, calcnt, errcnt, stbcnt;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
};
extern int do_adjtimex(struct timex *);
asmlinkage long compat_sys_adjtimex(struct timex32 __user *utp)
asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp)
{
struct timex txc;
int ret;

View file

@ -707,22 +707,9 @@ asmlinkage long sys32_sendfile64(int out_fd, int in_fd,
/* Handle adjtimex compatibility. */
struct timex32 {
u32 modes;
s32 offset, freq, maxerror, esterror;
s32 status, constant, precision, tolerance;
struct compat_timeval time;
s32 tick;
s32 ppsfreq, jitter, shift, stabil;
s32 jitcnt, calcnt, errcnt, stbcnt;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
};
extern int do_adjtimex(struct timex *);
asmlinkage long sys32_adjtimex(struct timex32 __user *utp)
asmlinkage long sys32_adjtimex(struct compat_timex __user *utp)
{
struct timex txc;
int ret;

View file

@ -947,22 +947,9 @@ asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd,
/* Handle adjtimex compatibility. */
struct timex32 {
u32 modes;
s32 offset, freq, maxerror, esterror;
s32 status, constant, precision, tolerance;
struct compat_timeval time;
s32 tick;
s32 ppsfreq, jitter, shift, stabil;
s32 jitcnt, calcnt, errcnt, stbcnt;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
};
extern int do_adjtimex(struct timex *);
asmlinkage long sys32_adjtimex(struct timex32 __user *utp)
asmlinkage long sys32_adjtimex(struct compat_timex __user *utp)
{
struct timex txc;
int ret;

View file

@ -769,30 +769,17 @@ sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
/* Handle adjtimex compatibility. */
struct timex32 {
u32 modes;
s32 offset, freq, maxerror, esterror;
s32 status, constant, precision, tolerance;
struct compat_timeval time;
s32 tick;
s32 ppsfreq, jitter, shift, stabil;
s32 jitcnt, calcnt, errcnt, stbcnt;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
s32 :32; s32 :32; s32 :32; s32 :32;
};
extern int do_adjtimex(struct timex *);
asmlinkage long
sys32_adjtimex(struct timex32 __user *utp)
sys32_adjtimex(struct compat_timex __user *utp)
{
struct timex txc;
int ret;
memset(&txc, 0, sizeof(struct timex));
if (!access_ok(VERIFY_READ, utp, sizeof(struct timex32)) ||
if (!access_ok(VERIFY_READ, utp, sizeof(struct compat_timex)) ||
__get_user(txc.modes, &utp->modes) ||
__get_user(txc.offset, &utp->offset) ||
__get_user(txc.freq, &utp->freq) ||
@ -817,7 +804,7 @@ sys32_adjtimex(struct timex32 __user *utp)
ret = do_adjtimex(&txc);
if (!access_ok(VERIFY_WRITE, utp, sizeof(struct timex32)) ||
if (!access_ok(VERIFY_WRITE, utp, sizeof(struct compat_timex)) ||
__put_user(txc.modes, &utp->modes) ||
__put_user(txc.offset, &utp->offset) ||
__put_user(txc.freq, &utp->freq) ||

View file

@ -45,6 +45,32 @@ struct compat_tms {
compat_clock_t tms_cstime;
};
struct compat_timex {
compat_uint_t modes;
compat_long_t offset;
compat_long_t freq;
compat_long_t maxerror;
compat_long_t esterror;
compat_int_t status;
compat_long_t constant;
compat_long_t precision;
compat_long_t tolerance;
struct compat_timeval time;
compat_long_t tick;
compat_long_t ppsfreq;
compat_long_t jitter;
compat_int_t shift;
compat_long_t stabil;
compat_long_t jitcnt;
compat_long_t calcnt;
compat_long_t errcnt;
compat_long_t stbcnt;
compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
};
#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
typedef struct {