[patch] gettimeofday.2: mention reasons for failure of settimeofday()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

   as observed recently settimeofday(2) may fail when called
with reasonably looking values for the time/date if they're
near to the Epoch. The reason is that it's not possible to
set the system time to a value that is lower than the number
of seconds since the system was booted - otherwise the time
of boot reported by 'uptime -s' would predate the Epoch.

As this took some time to figure out I think it might be
worth to mention it in the NOTES section of the man page
of gettimeofday/settimeofday, see the attached patch.

                        Best regards, Jens
-- 
  \   Jens Thoms Toerring  ________      jt@xxxxxxxxxxx
   \_______________________________      http://toerring.de
diff --git a/man2/gettimeofday.2 b/man2/gettimeofday.2
index b365436..3f89603 100644
--- a/man2/gettimeofday.2
+++ b/man2/gettimeofday.2
@@ -183,6 +183,19 @@ affected by discontinuous jumps in the system time
 If you need a monotonically increasing clock, see
 .BR clock_gettime (2).
 .PP
+.BR settimeofday ()
+fails and sets errno to
+.B EINVAL
+on attempts to set the system time to a value that would result
+in the time of booting the system to predate the Epoch, i.e. in
+the value of the
+.I uptime
+field in the
+.I sysinfo
+structure filled in by
+.BR sysinfo (2)
+to be larger than the reported number of seconds since the Epoch.
+.PP
 Macros for operating on
 .I timeval
 structures are described in

[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux