[Patch] Fix sys_time to handle intra-tick correction

From: Vinay Sridhar
Date: Tue Dec 09 2008 - 07:00:16 EST


Hi All,

This fix changes sys_time to use do_gettimeofday instead of get_seconds.
Running the stime01 test from LTP triggers this error. Calling sys_stime
and then calling sys_time causes this. "do_settimeofday" subtracts the
nsec offset from the nsec value(0 in this case) passed to it.
Subsequently, "set_normalized_timespec" modifies sec and nsec
accordingly. This compensation is handled in the do_gettimeofday path.
However, sys_time does not handle this case and reports an incorrect
seconds value.


signed-off by : Vinay Sridhar <vinay@xxxxxxxxxxxxxxxxxx>

--- time.c.orig 2008-12-04 06:30:12.000000000 -0600
+++ time.c 2008-12-04 06:31:25.000000000 -0600
@@ -61,7 +61,12 @@ EXPORT_SYMBOL(sys_tz);
*/
asmlinkage long sys_time(time_t __user * tloc)
{
- time_t i = get_seconds();
+ struct timeval t;
+ time_t i;
+
+ do_gettimeofday(&t);
+
+ i = t.tv_sec;

if (tloc) {
if (put_user(i,tloc))


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/