Commit 5362a354 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Fix sys_time() to get subtick correction from the new xtime

From: "La Monte H.P. Yarroll" <piggy@timesys.com>

This is a Scott Wood patch against 2.6.3.


Use gettimeofday() rather than xtime.tv_sec in sys_time(), since
sys_stime() uses settimeofday() and thus subtracts the subtick correction
from the new xtime.

stime() used settimeofday(), but time() did not use gettimeofday().  Since
settimeofday() subtracts out the current intra-tick correction, and nsec
was 0 (since stime() only allows seconds), this resulted in xtime being
slightly earlier than the time that was set.

If time() had used gettimeofday(), the correction would have been applied,
and everything would be fine.  However, instead time just reads the current
xtime.tv_sec, so if time() is called immediately after stime(), you'll
usually get a value one second earlier.
parent cea39746
......@@ -1090,10 +1090,11 @@ asmlinkage long
sys32_time (int *tloc)
{
int i;
struct timeval tv;
do_gettimeofday(&tv);
i = tv.tv_sec;
/* SMP: This is fairly trivial. We grab CURRENT_TIME and
stuff it to user space. No side effects */
i = get_seconds();
if (tloc) {
if (put_user(i, tloc))
i = -EFAULT;
......
......@@ -388,8 +388,10 @@ static inline long get_ts32(struct timespec *o, struct compat_timeval *i)
asmlinkage long sys32_time(compat_time_t *tloc)
{
time_t now = get_seconds();
compat_time_t now32 = now;
struct timeval tv;
do_gettimeofday(&tv);
compat_time_t now32 = tv.tv_sec;
if (tloc)
if (put_user(now32, tloc))
......
......@@ -832,10 +832,11 @@ sys32_writev(int fd, struct compat_iovec *vector, u32 count)
asmlinkage long sys32_time(int * tloc)
{
int i;
struct timeval tv;
do_gettimeofday(&tv);
i = tv.tv_sec;
/* SMP: This is fairly trivial. We grab CURRENT_TIME and
stuff it to user space. No side effects */
i = get_seconds();
if (tloc) {
if (put_user(i,tloc))
i = -EFAULT;
......
......@@ -51,10 +51,11 @@ EXPORT_SYMBOL(sys_tz);
asmlinkage long sys_time(int * tloc)
{
int i;
struct timeval tv;
do_gettimeofday(&tv);
i = tv.tv_sec;
/* SMP: This is fairly trivial. We grab CURRENT_TIME and
stuff it to user space. No side effects */
i = get_seconds();
if (tloc) {
if (put_user(i,tloc))
i = -EFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment