Skip to content

Commit

Permalink
[PATCH] create struct compat_timex and use it everywhere
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Rothwell authored and Linus Torvalds committed Mar 26, 2006
1 parent eb76b3f commit 88959ea
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 119 deletions.
15 changes: 1 addition & 14 deletions arch/ia64/ia32/sys_ia32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 1 addition & 14 deletions arch/mips/kernel/linux32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
37 changes: 4 additions & 33 deletions arch/parisc/kernel/sys_parisc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}


Expand Down
15 changes: 1 addition & 14 deletions arch/powerpc/kernel/sys_ppc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 1 addition & 14 deletions arch/s390/kernel/compat_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 1 addition & 14 deletions arch/sparc64/kernel/sys_sparc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 3 additions & 16 deletions arch/x86_64/ia32/sys_ia32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand All @@ -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) ||
Expand Down
26 changes: 26 additions & 0 deletions include/linux/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 88959ea

Please sign in to comment.