summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2003-07-17 19:27:04 -0700
committerLinus Torvalds <torvalds@home.osdl.org>2003-07-17 19:27:04 -0700
commit73a9eb391316788570f02505dcff876779a1f85e (patch)
tree024672b70016413a27b12c0a90f7109140102b04 /kernel
parent5808e76e2a71f1539ba6fe6f16094349b22cb254 (diff)
[PATCH] settimeofday() fixes
From: davem - sys_stime() takes an int*, but it should be a time_t*: they have different sizes on (for example) sparc64. - sys_settimeofday() is confusing timevals with timespecs. They have different sizes on sparc64 and the time keeps on getting set to epoch.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/kernel/time.c b/kernel/time.c
index beb7b007b443..fd23f6774b56 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -66,7 +66,7 @@ asmlinkage long sys_time(int * tloc)
* architectures that need it).
*/
-asmlinkage long sys_stime(int * tptr)
+asmlinkage long sys_stime(time_t *tptr)
{
struct timespec tv;
@@ -160,22 +160,25 @@ int do_sys_settimeofday(struct timespec *tv, struct timezone *tz)
return 0;
}
-asmlinkage long sys_settimeofday(struct timeval __user *tv, struct timezone __user *tz)
+asmlinkage long sys_settimeofday(struct timeval __user *tv,
+ struct timezone __user *tz)
{
- struct timespec new_tv;
+ struct timeval user_tv;
+ struct timespec new_ts;
struct timezone new_tz;
if (tv) {
- if (copy_from_user(&new_tv, tv, sizeof(*tv)))
+ if (copy_from_user(&user_tv, tv, sizeof(*tv)))
return -EFAULT;
- new_tv.tv_nsec *= NSEC_PER_USEC;
+ new_ts.tv_sec = user_tv.tv_sec;
+ new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
}
if (tz) {
if (copy_from_user(&new_tz, tz, sizeof(*tz)))
return -EFAULT;
}
- return do_sys_settimeofday(tv ? &new_tv : NULL, tz ? &new_tz : NULL);
+ return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
}
long pps_offset; /* pps time offset (us) */