diff options
author | Christoph Hellwig <hch@lst.de> | 2008-10-16 01:02:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:33 -0400 |
commit | b418da16dd44810e5d5a22bba377cca80512a524 (patch) | |
tree | 20ac32ea027bb8d978a22fbfaf6580fd34518aa5 /arch/mips/kernel/linux32.c | |
parent | f7a5000f7a8924e9c5fad1801616601d6dc65a17 (diff) |
compat: generic compat get/settimeofday
Nothing arch specific in get/settimeofday. The details of the timeval
conversion varied a little from arch to arch, but all with the same
results.
Also add an extern declaration for sys_tz to linux/time.h because externs
in .c files are fowned upon. I'll kill the externs in various other files
in a sparate patch.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: David S. Miller <davem@davemloft.net> [ sparc bits ]
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Kyle McMartin <kyle@mcmartin.ca>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Grant Grundler <grundler@parisc-linux.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/mips/kernel/linux32.c')
-rw-r--r-- | arch/mips/kernel/linux32.c | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c index 89223a9bff2c..aa2c55e3b55f 100644 --- a/arch/mips/kernel/linux32.c +++ b/arch/mips/kernel/linux32.c | |||
@@ -133,72 +133,6 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long __dummy, | |||
133 | return sys_ftruncate(fd, merge_64(a2, a3)); | 133 | return sys_ftruncate(fd, merge_64(a2, a3)); |
134 | } | 134 | } |
135 | 135 | ||
136 | static inline long | ||
137 | get_tv32(struct timeval *o, struct compat_timeval __user *i) | ||
138 | { | ||
139 | return (!access_ok(VERIFY_READ, i, sizeof(*i)) || | ||
140 | (__get_user(o->tv_sec, &i->tv_sec) | | ||
141 | __get_user(o->tv_usec, &i->tv_usec))); | ||
142 | } | ||
143 | |||
144 | static inline long | ||
145 | put_tv32(struct compat_timeval __user *o, struct timeval *i) | ||
146 | { | ||
147 | return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) || | ||
148 | (__put_user(i->tv_sec, &o->tv_sec) | | ||
149 | __put_user(i->tv_usec, &o->tv_usec))); | ||
150 | } | ||
151 | |||
152 | extern struct timezone sys_tz; | ||
153 | |||
154 | asmlinkage int | ||
155 | sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz) | ||
156 | { | ||
157 | if (tv) { | ||
158 | struct timeval ktv; | ||
159 | do_gettimeofday(&ktv); | ||
160 | if (put_tv32(tv, &ktv)) | ||
161 | return -EFAULT; | ||
162 | } | ||
163 | if (tz) { | ||
164 | if (copy_to_user(tz, &sys_tz, sizeof(sys_tz))) | ||
165 | return -EFAULT; | ||
166 | } | ||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | static inline long get_ts32(struct timespec *o, struct compat_timeval __user *i) | ||
171 | { | ||
172 | long usec; | ||
173 | |||
174 | if (!access_ok(VERIFY_READ, i, sizeof(*i))) | ||
175 | return -EFAULT; | ||
176 | if (__get_user(o->tv_sec, &i->tv_sec)) | ||
177 | return -EFAULT; | ||
178 | if (__get_user(usec, &i->tv_usec)) | ||
179 | return -EFAULT; | ||
180 | o->tv_nsec = usec * 1000; | ||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | asmlinkage int | ||
185 | sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz) | ||
186 | { | ||
187 | struct timespec kts; | ||
188 | struct timezone ktz; | ||
189 | |||
190 | if (tv) { | ||
191 | if (get_ts32(&kts, tv)) | ||
192 | return -EFAULT; | ||
193 | } | ||
194 | if (tz) { | ||
195 | if (copy_from_user(&ktz, tz, sizeof(ktz))) | ||
196 | return -EFAULT; | ||
197 | } | ||
198 | |||
199 | return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL); | ||
200 | } | ||
201 | |||
202 | asmlinkage int sys32_llseek(unsigned int fd, unsigned int offset_high, | 136 | asmlinkage int sys32_llseek(unsigned int fd, unsigned int offset_high, |
203 | unsigned int offset_low, loff_t __user * result, | 137 | unsigned int offset_low, loff_t __user * result, |
204 | unsigned int origin) | 138 | unsigned int origin) |