summaryrefslogtreecommitdiffstats
path: root/hwclock
diff options
context:
space:
mode:
authorKarel Zak2007-03-21 15:05:58 +0100
committerKarel Zak2007-03-21 15:05:58 +0100
commit9abb26854c5f185683ba7bd812bb5076cedc8f0e (patch)
tree8d7101ca0d504ee7e88a382210f20838fd256af0 /hwclock
parenthwclock: add support for audit system (diff)
downloadkernel-qcow2-util-linux-9abb26854c5f185683ba7bd812bb5076cedc8f0e.tar.gz
kernel-qcow2-util-linux-9abb26854c5f185683ba7bd812bb5076cedc8f0e.tar.xz
kernel-qcow2-util-linux-9abb26854c5f185683ba7bd812bb5076cedc8f0e.zip
hwclock: remove tailing white-spaces and clean up clock.h
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'hwclock')
-rw-r--r--hwclock/clock.h13
-rw-r--r--hwclock/cmos.c16
-rw-r--r--hwclock/hwclock.8158
-rw-r--r--hwclock/hwclock.c202
-rw-r--r--hwclock/kd.c6
-rw-r--r--hwclock/rtc.c10
6 files changed, 207 insertions, 198 deletions
diff --git a/hwclock/clock.h b/hwclock/clock.h
index 39971f721..6e8a9b4ca 100644
--- a/hwclock/clock.h
+++ b/hwclock/clock.h
@@ -1,3 +1,6 @@
+#ifndef HWCLOCK_CLOCK_H
+#define HWCLOCK_CLOCK_H
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -24,8 +27,12 @@ typedef int bool;
extern char *progname;
extern int debug;
extern int epoch_option;
-extern void outsyserr(char *msg, ...);
-
+extern void outsyserr(char *msg, ...)
+#ifdef __GNUC__
+ __attribute__ ((format (printf, 1, 2)));
+#else
+ ;
+#endif
/* cmos.c */
extern void set_cmos_epoch(int ARCconsole, int SRM);
extern void set_cmos_access(int Jensen, int funky_toy);
@@ -41,3 +48,5 @@ extern void hwaudit_exit(int status);
#else
# define hwclock_exit(_status) exit(_status)
#endif
+
+#endif /* HWCLOCK_CLOCK_H */
diff --git a/hwclock/cmos.c b/hwclock/cmos.c
index e4e55f772..93f74294b 100644
--- a/hwclock/cmos.c
+++ b/hwclock/cmos.c
@@ -84,7 +84,7 @@ int inb(int c){ return 0; }
#define TM_EPOCH 1900
int cmos_epoch = 1900;
-/* Martin Ostermann writes:
+/* Martin Ostermann writes:
The problem with the Jensen is twofold: First, it has the clock at a
different address. Secondly, it has a distinction beween "local" and
normal bus addresses. The local ones pertain to the hardware integrated
@@ -377,7 +377,7 @@ static unsigned long cmos_set_time(unsigned long arg)
pmbit = 0x80;
}
}
-
+
if (!(save_control & 0x04)) { /* BCD mode - the default */
BIN_TO_BCD(tm.tm_sec);
BIN_TO_BCD(tm.tm_min);
@@ -388,7 +388,7 @@ static unsigned long cmos_set_time(unsigned long arg)
BIN_TO_BCD(tm.tm_year);
BIN_TO_BCD(century);
}
-
+
cmos_write (0, tm.tm_sec);
cmos_write (2, tm.tm_min);
cmos_write (4, tm.tm_hour | pmbit);
@@ -402,7 +402,7 @@ static unsigned long cmos_set_time(unsigned long arg)
/* The kernel sources, linux/arch/i386/kernel/time.c, have the
following comment:
-
+
The following flags have to be released exactly in this order,
otherwise the DS12887 (popular MC146818A clone with integrated
battery and quartz) will not reset the oscillator and will not
@@ -410,7 +410,7 @@ static unsigned long cmos_set_time(unsigned long arg)
in the Dallas Semiconductor data sheets, but who believes data
sheets anyway ... -- Markus Kuhn
*/
-
+
cmos_write (11, save_control);
cmos_write (10, save_freq_select);
return 0;
@@ -485,8 +485,8 @@ read_hardware_clock_cmos(struct tm *tm) {
while (!got_time) {
/* Bit 7 of Byte 10 of the Hardware Clock value is the Update In Progress
- (UIP) bit, which is on while and 244 uS before the Hardware Clock
- updates itself. It updates the counters individually, so reading
+ (UIP) bit, which is on while and 244 uS before the Hardware Clock
+ updates itself. It updates the counters individually, so reading
them during an update would produce garbage. The update takes 2mS,
so we could be spinning here that long waiting for this bit to turn
off.
@@ -512,7 +512,7 @@ read_hardware_clock_cmos(struct tm *tm) {
century = hclock_read(century_byte);
#endif
- /* Unless the clock changed while we were reading, consider this
+ /* Unless the clock changed while we were reading, consider this
a good clock read .
*/
if (tm->tm_sec == hclock_read (0))
diff --git a/hwclock/hwclock.8 b/hwclock/hwclock.8
index 37d80e79b..1272dc4e9 100644
--- a/hwclock/hwclock.8
+++ b/hwclock/hwclock.8
@@ -6,7 +6,7 @@ hwclock \- query and set the hardware clock (RTC)
.br
.BR "hwclock \-w" " or " "hwclock \-\-systohc"
.br
-.BR "hwclock \-s" " or " "hwclock \-\-hctosys"
+.BR "hwclock \-s" " or " "hwclock \-\-hctosys"
.br
.BR "hwclock \-a" " or " "hwclock \-\-adjust"
.br
@@ -39,15 +39,15 @@ current time, set the Hardware Clock to a specified time, set the
Hardware Clock to the System Time, and set the System Time from the
Hardware Clock.
.PP
-You can also run
-.B hwclock
+You can also run
+.B hwclock
periodically to insert or remove time from the Hardware Clock to
compensate for systematic drift (where the clock consistently gains or
loses time at a certain rate if left to run).
.SH OPTIONS
-You need exactly one of the following options to tell
-.B hwclock
+You need exactly one of the following options to tell
+.B hwclock
what function to perform:
.PP
.TP
@@ -60,17 +60,17 @@ option.
.TP
.B \-\-set
-Set the Hardware Clock to the time given by the
+Set the Hardware Clock to the time given by the
.B \-\-date
option.
.TP
.B \-\-hctosys
-Set the System Time from the Hardware Clock.
+Set the System Time from the Hardware Clock.
Also set the kernel's timezone value to the local timezone
as indicated by the TZ environment variable and/or
.IR /usr/share/zoneinfo ,
-as
+as
.BR tzset (3)
would interpret them.
The obsolete tz_dsttime field of the kernel's timezone value is set
@@ -105,8 +105,8 @@ option. See the
option for details.
.TP
.B \-\-version
-Print the version of
-.B hwclock
+Print the version of
+.B hwclock
on Standard Output.
.TP
.B \-\-date=date_string
@@ -121,8 +121,8 @@ For example,
.sp
.I hwclock --set --date="9/22/96 16:45:05"
.sp
-The argument is in local time, even if you keep your Hardware Clock in
-Coordinated Universal time. See the
+The argument is in local time, even if you keep your Hardware Clock in
+Coordinated Universal time. See the
.B \-\-utc
option.
@@ -163,7 +163,7 @@ nor
.B hwclock
was used to set the clock (i.e. hwclock was successfully run with the
.B \-\-set
-,
+,
.B \-\-systohc
,
or
@@ -194,12 +194,12 @@ and so on.
.TP
.B \-\-directisa
is meaningful only on an ISA machine or an Alpha (which implements enough
-of ISA to be, roughly speaking, an ISA machine for
+of ISA to be, roughly speaking, an ISA machine for
.BR hwclock 's
purposes). For other machines, it has no effect. This option tells
.B hwclock
to use explicit I/O instructions to access the Hardware Clock.
-Without this option,
+Without this option,
.B hwclock
will try to use the /dev/rtc device (which it assumes to be driven by the
rtc device driver). If it is unable to open the device (for read), it will
@@ -209,7 +209,7 @@ The rtc device driver was new in Linux Release 2.
.TP
.B \-\-badyear
Indicates that the Hardware Clock is incapable of storing years outside
-the range 1994-1999. There is a problem in some BIOSes (almost all
+the range 1994-1999. There is a problem in some BIOSes (almost all
Award BIOSes made between 4/26/94 and 5/31/95) wherein they are unable
to deal with years after 1999. If one attempts to set the year-of-century
value to something less than 94 (or 95 in some cases), the value that
@@ -219,20 +219,20 @@ cannot set the year after 1999 and cannot use the value of the clock as
the true time in the normal way.
To compensate for this (without your getting a BIOS update, which would
-definitely be preferable), always use
+definitely be preferable), always use
.B \-\-badyear
-if you have one of these machines. When
+if you have one of these machines. When
.B hwclock
knows it's working with a brain-damaged clock, it ignores the year part of
-the Hardware Clock value and instead tries to guess the year based on the
+the Hardware Clock value and instead tries to guess the year based on the
last calibrated date in the adjtime file, by assuming that that date is
-within the past year. For this to work, you had better do a
+within the past year. For this to work, you had better do a
.I hwclock \-\-set
or
.I hwclock \-\-systohc
at least once a year!
-Though
+Though
.B hwclock
ignores the year value when it reads the Hardware Clock, it sets the
year value when it sets the clock. It sets it to 1995, 1996, 1997, or
@@ -243,9 +243,9 @@ year without setting it, this scheme could be defeated and you could
end up losing a day.
.B hwclock
-warns you that you probably need
+warns you that you probably need
.B \-\-badyear
-whenever it finds your Hardware Clock set to 1994 or 1995.
+whenever it finds your Hardware Clock set to 1994 or 1995.
.TP
.B \-\-srm
@@ -265,25 +265,25 @@ with ARC console (but Ruffians have epoch 1900).
.B \-\-funky\-toy
These two options specify what kind of Alpha machine you have. They
are invalid if you don't have an Alpha and are usually unnecessary
-if you do, because
-.B hwclock
-should be able to determine by itself what it's
+if you do, because
+.B hwclock
+should be able to determine by itself what it's
running on, at least when
.I /proc
is mounted.
(If you find you need one of these options to make
-.B hwclock
+.B hwclock
work, contact the maintainer to see if the program can be improved
to detect your system automatically. Output of `hwclock --debug'
and `cat /proc/cpuinfo' may be of interest.)
-.B \-\-jensen
+.B \-\-jensen
means you are running on a Jensen model.
-.B \-\-funky\-toy
+.B \-\-funky\-toy
means that on your machine, one has to use the UF bit instead
of the UIP bit in the Hardware Clock to detect a time transition. "Toy"
-in the option name refers to the Time Of Year facility of the machine.
+in the option name refers to the Time Of Year facility of the machine.
.TP
@@ -291,12 +291,12 @@ in the option name refers to the Time Of Year facility of the machine.
Do everything except actually updating the Hardware Clock or anything
else. This is useful, especially in conjunction with
.B \-\-debug,
-in learning about
+in learning about
.B hwclock.
.TP
.B \-\-debug
-Display a lot of information about what
-.B hwclock
+Display a lot of information about what
+.B hwclock
is doing internally. Some of its function is complex and this output
can help you understand how the program works.
@@ -308,7 +308,7 @@ can help you understand how the program works.
.PP
There are two main clocks in a Linux system:
.PP
-.B The Hardware Clock:
+.B The Hardware Clock:
This is a clock that runs independently of any control program running
in the CPU and even when the machine is powered off.
@@ -319,8 +319,8 @@ ticks, so the clock actually has virtually infinite precision.
.PP
This clock is commonly called the hardware clock, the real time clock,
the RTC, the BIOS clock, and the CMOS clock. Hardware Clock, in its
-capitalized form, was coined for use by
-.B hwclock
+capitalized form, was coined for use by
+.B hwclock
because all of the other names are inappropriate to the point of being
misleading.
.PP
@@ -330,7 +330,7 @@ A very low power external I2C or SPI clock chip might be used with a
backup battery as the hardware clock to initialize a more functional
integrated real-time clock which is used for most other purposes.
.PP
-.B The System Time:
+.B The System Time:
This is the time kept by a clock inside the Linux kernel and driven by
a timer interrupt. (On an ISA machine, the timer interrupt is part of
the ISA standard). It has meaning only while Linux is running on the
@@ -346,12 +346,12 @@ starts up, and then never use the Hardware Clock again. Note that in DOS,
for which ISA was designed, the Hardware Clock is the only real time clock.
.PP
It is important that the System Time not have any discontinuities such as
-would happen if you used the
+would happen if you used the
.BR date (1L)
program to set it while the system is running. You can, however, do whatever
you want to the Hardware Clock while the system is running, and the next
time Linux starts up, it will do so with the adjusted time from the Hardware
-Clock. You can also use the program
+Clock. You can also use the program
.BR adjtimex (8)
to smoothly adjust the System Time while the system runs.
.PP
@@ -373,7 +373,7 @@ set the wrong timestamps on files.
.B hwclock
sets the kernel timezone to the value indicated by TZ and/or
.I /usr/share/zoneinfo
-when you set the System Time using the
+when you set the System Time using the
.B \-\-hctosys
option.
.PP
@@ -388,7 +388,7 @@ This second field is not used under Linux and is always zero.
.SH How hwclock Accesses the Hardware Clock
.PP
-.B hwclock
+.B hwclock
Uses many different ways to get and set Hardware Clock values.
The most normal way is to do I/O to the device special file /dev/rtc,
which is presumed to be driven by the rtc device driver. However,
@@ -406,16 +406,16 @@ or
instead.
.PP
On older systems, the method of accessing the Hardware Clock depends on
-the system hardware.
+the system hardware.
.PP
-On an ISA system,
-.B hwclock
+On an ISA system,
+.B hwclock
can directly access the "CMOS memory" registers that
constitute the clock, by doing I/O to Ports 0x70 and 0x71. It does
this with actual I/O instructions and consequently can only do it if
running with superuser effective userid. (In the case of a Jensen
Alpha, there is no way for
-.B hwclock
+.B hwclock
to execute those I/O instructions, and so it uses instead the
/dev/port device special file, which provides almost as low-level an
interface to the I/O subsystem).
@@ -432,11 +432,11 @@ On an m68k system,
can access the clock via the console driver, via the device special
file /dev/tty1.
.PP
-.B hwclock
+.B hwclock
tries to use /dev/rtc. If it is compiled for a kernel that doesn't have
that function or it is unable to open /dev/rtc
(or the alternative special file you've defined on the command line)
-.B hwclock
+.B hwclock
will fall back to another method, if available. On an ISA or Alpha
machine, you can force
.B hwclock
@@ -450,64 +450,64 @@ by specifying the \-\-directisa option.
The Hardware Clock is usually not very accurate. However, much of its
inaccuracy is completely predictable - it gains or loses the same amount
of time every day. This is called systematic drift.
-.BR hwclock 's
+.BR hwclock 's
"adjust" function lets you make systematic corrections to correct the
systematic drift.
.PP
-It works like this:
-.B hwclock
+It works like this:
+.B hwclock
keeps a file,
.I /etc/adjtime,
that keeps some historical information. This is called the adjtime file.
.PP
-Suppose you start with no adjtime file. You issue a
+Suppose you start with no adjtime file. You issue a
.I hwclock \-\-set
-command to set the Hardware Clock to the true current time.
-.B Hwclock
-creates the adjtime file and records in it the current time as the
+command to set the Hardware Clock to the true current time.
+.B Hwclock
+creates the adjtime file and records in it the current time as the
last time the clock was calibrated.
5 days later, the clock has gained 10 seconds, so you issue another
.I hwclock \-\-set
-command to set it back 10 seconds.
-.B Hwclock
+command to set it back 10 seconds.
+.B Hwclock
updates the adjtime file to show the current time as the last time the
clock was calibrated, and records 2 seconds per day as the systematic
drift rate. 24 hours go by, and then you issue a
.I hwclock \-\-adjust
-command.
-.B Hwclock
+command.
+.B Hwclock
consults the adjtime file and sees that the clock gains 2 seconds per
day when left alone and that it has been left alone for exactly one
day. So it subtracts 2 seconds from the Hardware Clock. It then
records the current time as the last time the clock was adjusted.
Another 24 hours goes by and you issue another
.I hwclock \-\-adjust.
-.B Hwclock
+.B Hwclock
does the same thing: subtracts 2 seconds and updates the adjtime file
with the current time as the last time the clock was adjusted.
.PP
-Every time you calibrate (set) the clock (using
+Every time you calibrate (set) the clock (using
.I \-\-set
or
.I \-\-systohc
),
-.B hwclock
+.B hwclock
recalculates the systematic drift rate based on how long it has been
since the last calibration, how long it has been since the last
adjustment, what drift rate was assumed in any intervening
adjustments, and the amount by which the clock is presently off.
.PP
-A small amount of error creeps in any time
-.B hwclock
+A small amount of error creeps in any time
+.B hwclock
sets the clock, so it refrains from making an adjustment that would be
less than 1 second. Later on, when you request an adjustment again,
the accumulated drift will be more than a second and
-.B hwclock
+.B hwclock
will do the adjustment then.
.PP
-It is good to do a
+It is good to do a
.I hwclock \-\-adjust
-just before the
+just before the
.I hwclock \-\-hctosys
at system startup time, and maybe periodically while the system is
running via cron.
@@ -528,26 +528,26 @@ as a decimal integer.
Line 2: 1 number: Resulting number of seconds since 1969 UTC of most
recent calibration. Zero if there has been no calibration yet or it
is known that any previous calibration is moot (for example, because
-the Hardware Clock has been found, since that calibration, not to
+the Hardware Clock has been found, since that calibration, not to
contain a valid time). This is a decimal integer.
.PP
-Line 3: "UTC" or "LOCAL". Tells whether the Hardware Clock is set to
+Line 3: "UTC" or "LOCAL". Tells whether the Hardware Clock is set to
Coordinated Universal Time or local time. You can always override this
-value with options on the
+value with options on the
.B hwclock
command line.
.PP
-You can use an adjtime file that was previously used with the
+You can use an adjtime file that was previously used with the
.BR clock (8)
-program with
+program with
.B hwclock.
.SH "Automatic Hardware Clock Synchronization By the Kernel"
-You should be aware of another way that the Hardware Clock is kept
+You should be aware of another way that the Hardware Clock is kept
synchronized in some systems. The Linux kernel has a mode wherein it
-copies the System Time to the Hardware Clock every 11 minutes.
+copies the System Time to the Hardware Clock every 11 minutes.
This is a good mode to use when you are using something sophisticated
like ntp to keep your System Time synchronized. (ntp is a way to keep
your System Time synchronized either to a time server somewhere on the
@@ -560,18 +560,18 @@ can turn it off by running anything, including
that sets the System Time the old fashioned way.
To see if it is on or
-off, use the command
+off, use the command
.I adjtimex \-\-print
and look at the value of "status". If the "64" bit of this number
(expressed in binary) equal to 0, 11 minute mode is on. Otherwise, it
is off.
-If your system runs with 11 minute mode on, don't use
+If your system runs with 11 minute mode on, don't use
.I hwclock \-\-adjust
or
.IR "hwclock \-\-hctosys" .
You'll just make a mess. It is acceptable to use a
-.I hwclock \-\-hctosys
+.I hwclock \-\-hctosys
at startup time to get a reasonable System Time until your system is
able to set the System Time from the external source and start 11
minute mode.
@@ -580,14 +580,14 @@ minute mode.
.SH ISA Hardware Clock Century value
There is some sort of standard that defines CMOS memory Byte 50 on an ISA
-machine as an indicator of what century it is.
+machine as an indicator of what century it is.
.B hwclock
does not use or set that byte because there are some machines that
don't define the byte that way, and it really isn't necessary anyway,
since the year-of-century does a good job of implying which century it
is.
-If you have a bona fide use for a CMOS century byte, contact the
+If you have a bona fide use for a CMOS century byte, contact the
.B hwclock
maintainer; an option may be appropriate.
@@ -622,6 +622,6 @@ on old systems)
Written by Bryan Henderson, September 1996 (bryanh@giraffe-data.com),
based on work done on the
.I clock
-program by Charles Hedrick, Rob Hooft, and Harald Koenig.
+program by Charles Hedrick, Rob Hooft, and Harald Koenig.
See the source code for complete history and credits.
diff --git a/hwclock/hwclock.c b/hwclock/hwclock.c
index 7cb0ca27d..ee6309cb3 100644
--- a/hwclock/hwclock.c
+++ b/hwclock/hwclock.c
@@ -15,7 +15,7 @@
*
* Reshuffled things, added sparc code, and re-added alpha stuff
* by David Mosberger <davidm@azstarnet.com>
- * and Jay Estabrook <jestabro@amt.tay1.dec.com>
+ * and Jay Estabrook <jestabro@amt.tay1.dec.com>
* and Martin Ostermann <ost@coments.rwth-aachen.de>, aeb@cwi.nl, 990212.
*
* Fix for Award 2094 bug, Dave Coffin (dcoffin@shore.net) 11/12/98
@@ -112,12 +112,12 @@ struct adjtime {
adjtime file, so see documentation of that file for details.
Exception is <dirty>, which is an indication that what's in this
structure is not what's in the disk file (because it has been
- updated since read from the disk file).
+ updated since read from the disk file).
*/
bool dirty;
/* line 1 */
- double drift_factor;
+ double drift_factor;
time_t last_adj_time;
double not_adjusted;
@@ -180,7 +180,7 @@ read_date_from_file (struct tm *tm) {
write_date_to_file (tm);
}
-static double
+static double
time_diff(struct timeval subtrahend, struct timeval subtractor) {
/*---------------------------------------------------------------------------
The difference in seconds between two times in "timeval" format.
@@ -241,7 +241,7 @@ read_adjtime(struct adjtime *adjtime_p) {
Return them as the adjtime structure <*adjtime_p>.
If there is no /etc/adjtime file, return defaults.
If values are missing from the file, return defaults for them.
-
+
return value 0 if all OK, !=0 otherwise.
-----------------------------------------------------------------------------*/
@@ -272,26 +272,26 @@ read_adjtime(struct adjtime *adjtime_p) {
char line2[81]; /* String: second line of adjtime file */
char line3[81]; /* String: third line of adjtime file */
long timeval;
-
+
line1[0] = '\0'; /* In case fgets fails */
fgets(line1, sizeof(line1), adjfile);
line2[0] = '\0'; /* In case fgets fails */
fgets(line2, sizeof(line2), adjfile);
line3[0] = '\0'; /* In case fgets fails */
fgets(line3, sizeof(line3), adjfile);
-
+
fclose(adjfile);
-
+
/* Set defaults in case values are missing from file */
adjtime_p->drift_factor = 0;
adjtime_p->last_adj_time = 0;
adjtime_p->not_adjusted = 0;
adjtime_p->last_calib_time = 0;
timeval = 0;
-
- sscanf(line1, "%lf %ld %lf",
+
+ sscanf(line1, "%lf %ld %lf",
&adjtime_p->drift_factor,
- &timeval,
+ &timeval,
&adjtime_p->not_adjusted);
adjtime_p->last_adj_time = timeval;
@@ -315,7 +315,7 @@ read_adjtime(struct adjtime *adjtime_p) {
adjtime_p->dirty = FALSE;
if (debug) {
- printf(_("Last drift adjustment done at %ld seconds after 1969\n"),
+ printf(_("Last drift adjustment done at %ld seconds after 1969\n"),
(long) adjtime_p->last_adj_time);
printf(_("Last calibration done at %ld seconds after 1969\n"),
(long) adjtime_p->last_calib_time);
@@ -339,7 +339,7 @@ synchronize_to_clock_tick(void) {
once per second, right on the falling edge of the update flag.
We wait (up to one second) either blocked waiting for an rtc device
- or in a CPU spin loop. The former is probably not very accurate.
+ or in a CPU spin loop. The former is probably not very accurate.
Return 0 if it worked, nonzero if it didn't.
-----------------------------------------------------------------------------*/
@@ -357,7 +357,7 @@ synchronize_to_clock_tick(void) {
static void
-mktime_tz(struct tm tm, const bool universal,
+mktime_tz(struct tm tm, const bool universal,
bool *valid_p, time_t *systime_p) {
/*-----------------------------------------------------------------------------
Convert a time in broken down format (hours, minutes, etc.) into standard
@@ -379,8 +379,8 @@ mktime_tz(struct tm tm, const bool universal,
time_t mktime_result; /* The value returned by our mktime() call */
char *zone; /* Local time zone name */
- /* We use the C library function mktime(), but since it only works on
- local time zone input, we may have to fake it out by temporarily
+ /* We use the C library function mktime(), but since it only works on
+ local time zone input, we may have to fake it out by temporarily
changing the local time zone to UTC.
*/
zone = getenv("TZ"); /* remember original time zone */
@@ -409,7 +409,7 @@ mktime_tz(struct tm tm, const bool universal,
} else {
*valid_p = TRUE;
*systime_p = mktime_result;
- if (debug)
+ if (debug)
printf(_("Hw clock time : %4d/%.2d/%.2d %.2d:%.2d:%.2d = "
"%ld seconds since 1969\n"),
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
@@ -446,15 +446,15 @@ read_hardware_clock(const bool universal, bool *valid_p, time_t *systime_p){
static void
-set_hardware_clock(const time_t newtime,
- const bool universal,
+set_hardware_clock(const time_t newtime,
+ const bool universal,
const bool testing) {
/*----------------------------------------------------------------------------
Set the Hardware Clock to the time <newtime>, in local time zone or UTC,
according to <universal>.
----------------------------------------------------------------------------*/
int err;
- struct tm new_broken_time;
+ struct tm new_broken_time;
/* Time to which we will set Hardware Clock, in broken down format, in
the time zone of caller's choice
*/
@@ -464,10 +464,10 @@ set_hardware_clock(const time_t newtime,
else
new_broken_time = *localtime(&newtime);
- if (debug)
+ if (debug)
printf(_("Setting Hardware Clock to %.2d:%.2d:%.2d "
- "= %ld seconds since 1969\n"),
- new_broken_time.tm_hour, new_broken_time.tm_min,
+ "= %ld seconds since 1969\n"),
+ new_broken_time.tm_hour, new_broken_time.tm_min,
new_broken_time.tm_sec, (long) newtime);
if (testing)
@@ -489,9 +489,9 @@ set_hardware_clock(const time_t newtime,
static void
-set_hardware_clock_exact(const time_t sethwtime,
+set_hardware_clock_exact(const time_t sethwtime,
const struct timeval refsystime,
- const bool universal,
+ const bool universal,
const bool testing) {
/*----------------------------------------------------------------------------
Set the Hardware Clock to the time "sethwtime", in local time zone or UTC,
@@ -505,7 +505,7 @@ set_hardware_clock_exact(const time_t sethwtime,
to 14:03:07, thus getting a precise and retroactive setting of the clock.
(Don't be confused by the fact that the system clock and the Hardware
- Clock differ by two hours in the above example. That's just to remind
+ Clock differ by two hours in the above example. That's just to remind
you that there are two independent time scales here).
This function ought to be able to accept set times as fractional times.
@@ -518,11 +518,11 @@ set_hardware_clock_exact(const time_t sethwtime,
time_resync:
gettimeofday(&beginsystime, NULL);
newhwtime = sethwtime + (int) time_diff(beginsystime, refsystime) + 1;
- if (debug)
+ if (debug)
printf(_("Time elapsed since reference time has been %.6f seconds.\n"
"Delaying further to reach the next full second.\n"),
time_diff(beginsystime, refsystime));
-
+
/*
* Now delay some more until Hardware Clock time newhwtime arrives. The -500
* ms is because the Hardware Clock always sets to your set time plus 500 ms
@@ -536,14 +536,14 @@ set_hardware_clock_exact(const time_t sethwtime,
if (tdiff < 0)
goto time_resync; /* probably time was reset */
} while (time_diff(nowsystime, refsystime) - 0.5 < newhwtime - sethwtime);
-
+
set_hardware_clock(newhwtime, universal, testing);
}
static void
-display_time(const bool hclock_valid, const time_t systime,
+display_time(const bool hclock_valid, const time_t systime,
const double sync_duration) {
/*----------------------------------------------------------------------------
Put the time "systime" on standard output in display format.
@@ -575,7 +575,7 @@ interpret_date_string(const char *date_opt, time_t * const time_p) {
Interpret the value of the --date option, which is something like
"13:05:01". In fact, it can be any of the myriad ASCII strings that specify
a time which the "date" program can understand. The date option value in
- question is our "dateopt" argument.
+ question is our "dateopt" argument.
The specified time is in the local time zone.
@@ -592,7 +592,7 @@ interpret_date_string(const char *date_opt, time_t * const time_p) {
FILE *date_child_fp;
char date_resp[100];
const char magic[]="seconds-into-epoch=";
- char date_command[100];
+ char date_command[100];
int retcode; /* our eventual return code */
int rc; /* local return code */
@@ -615,7 +615,7 @@ interpret_date_string(const char *date_opt, time_t * const time_p) {
return 12;
}
- sprintf(date_command, "date --date=\"%s\" +seconds-into-epoch=%%s",
+ sprintf(date_command, "date --date=\"%s\" +seconds-into-epoch=%%s",
date_opt);
if (debug)
printf(_("Issuing date command: %s\n"), date_command);
@@ -635,7 +635,7 @@ interpret_date_string(const char *date_opt, time_t * const time_p) {
fprintf(stderr, _("The date command issued by %s returned "
"unexpected results.\n"
"The command was:\n %s\n"
- "The response was:\n %s\n"),
+ "The response was:\n %s\n"),
MYNAME, date_command, date_resp);
retcode = 8;
} else {
@@ -654,7 +654,7 @@ interpret_date_string(const char *date_opt, time_t * const time_p) {
} else {
retcode = 0;
*time_p = seconds_since_epoch;
- if (debug)
+ if (debug)
printf(_("date string %s equates to "
"%ld seconds since 1969.\n"),
date_opt, (long) *time_p);
@@ -665,15 +665,15 @@ interpret_date_string(const char *date_opt, time_t * const time_p) {
return retcode;
}
-
-static int
-set_system_clock(const bool hclock_valid, const time_t newtime,
+
+static int
+set_system_clock(const bool hclock_valid, const time_t newtime,
const bool testing) {
/*----------------------------------------------------------------------------
Set the System Clock to time 'newtime'.
- Also set the kernel time zone value to the value indicated by the
+ Also set the kernel time zone value to the value indicated by the
TZ environment variable and/or /usr/lib/zoneinfo/, interpreted as
tzset() would interpret them.
@@ -681,7 +681,7 @@ set_system_clock(const bool hclock_valid, const time_t newtime,
saying there is no valid time in the Hardware Clock to which to set
the system time.
- If 'testing' is true, don't actually update anything -- just say we
+ If 'testing' is true, don't actually update anything -- just say we
would have.
-----------------------------------------------------------------------------*/
int retcode;
@@ -695,10 +695,10 @@ set_system_clock(const bool hclock_valid, const time_t newtime,
struct tm *broken;
int minuteswest;
int rc;
-
+
tv.tv_sec = newtime;
tv.tv_usec = 0;
-
+
broken = localtime(&newtime);
#ifdef HAVE_TM_GMTOFF
minuteswest = -broken->tm_gmtoff/60; /* GNU extension */
@@ -707,7 +707,7 @@ set_system_clock(const bool hclock_valid, const time_t newtime,
if (broken->tm_isdst)
minuteswest -= 60;
#endif
-
+
if (debug) {
printf(_("Calling settimeofday:\n"));
printf(_("\ttv.tv_sec = %ld, tv.tv_usec = %ld\n"),
@@ -739,7 +739,7 @@ set_system_clock(const bool hclock_valid, const time_t newtime,
static void
adjust_drift_factor(struct adjtime *adjtime_p,
- const time_t nowtime,
+ const time_t nowtime,
const bool hclock_valid,
const time_t hclocktime,
const double sync_delay) {
@@ -824,15 +824,15 @@ adjust_drift_factor(struct adjtime *adjtime_p,
(int) (nowtime - adjtime_p->last_calib_time),
adjtime_p->drift_factor,
factor_adjust);
-
+
adjtime_p->drift_factor += factor_adjust;
}
adjtime_p->last_calib_time = nowtime;
-
+
adjtime_p->last_adj_time = nowtime;
-
+
adjtime_p->not_adjusted = 0;
-
+
adjtime_p->dirty = TRUE;
}
@@ -840,10 +840,10 @@ adjust_drift_factor(struct adjtime *adjtime_p,
static void
calculate_adjustment(const double factor,
- const time_t last_time,
+ const time_t last_time,
const double not_adjusted,
const time_t systime,
- int *adjustment_p,
+ int *adjustment_p,
double *retro_p,
const int debug ) {
/*----------------------------------------------------------------------------
@@ -852,7 +852,7 @@ calculate_adjustment(const double factor,
The way we have to set the clock, we need the adjustment in two parts:
1) an integer number of seconds (return as *adjustment_p)
-
+
2) a positive fraction of a second (less than 1) (return as *retro_p)
The sum of these two values is the adjustment needed. Positive means to
@@ -864,7 +864,7 @@ calculate_adjustment(const double factor,
exact_adjustment = ((double) (systime - last_time)) * factor / (24 * 60 * 60)
+ not_adjusted;
*adjustment_p = FLOOR(exact_adjustment);
-
+
*retro_p = exact_adjustment - (double) *adjustment_p;
if (debug) {
printf (_("Time since last adjustment is %d seconds\n"),
@@ -899,7 +899,7 @@ save_adjtime(const struct adjtime adjtime, const bool testing) {
if (testing) {
printf(_("Not updating adjtime file because of testing mode.\n"));
- printf(_("Would have written the following to %s:\n%s"),
+ printf(_("Would have written the following to %s:\n%s"),
ADJPATH, newfile);
} else {
FILE *adjfile;
@@ -932,11 +932,11 @@ save_adjtime(const struct adjtime adjtime, const bool testing) {
static void
do_adjustment(struct adjtime *adjtime_p,
- const bool hclock_valid, const time_t hclocktime,
+ const bool hclock_valid, const time_t hclocktime,
const struct timeval read_time,
const bool universal, const bool testing) {
/*---------------------------------------------------------------------------
- Do the adjustment requested, by 1) setting the Hardware Clock (if
+ Do the adjustment requested, by 1) setting the Hardware Clock (if
necessary), and 2) updating the last-adjusted time in the adjtime
structure.
@@ -949,7 +949,7 @@ do_adjustment(struct adjtime *adjtime_p,
<hclock_valid> means the Hardware Clock contains a valid time, and that
time is <hclocktime>.
- <read_time> is the current system time (to be precise, it is the system
+ <read_time> is the current system time (to be precise, it is the system
time at the time <hclocktime> was read, which due to computational delay
could be a short time ago).
@@ -977,7 +977,7 @@ do_adjustment(struct adjtime *adjtime_p,
} else {
int adjustment;
/* Number of seconds we must insert in the Hardware Clock */
- double retro;
+ double retro;
/* Fraction of second we have to remove from clock after inserting
<adjustment> whole seconds.
*/
@@ -988,14 +988,14 @@ do_adjustment(struct adjtime *adjtime_p,
&adjustment, &retro,
debug );
if (adjustment > 0 || adjustment < -1) {
- set_hardware_clock_exact(hclocktime + adjustment,
+ set_hardware_clock_exact(hclocktime + adjustment,
time_inc(read_time, -retro),
universal, testing);
adjtime_p->last_adj_time = hclocktime + adjustment;
adjtime_p->not_adjusted = 0;
adjtime_p->dirty = TRUE;
- } else
- if (debug)
+ } else
+ if (debug)
printf(_("Needed adjustment is less than one second, "
"so not setting clock.\n"));
}
@@ -1031,8 +1031,8 @@ determine_clock_access_method(const bool user_requests_ISA) {
static int
manipulate_clock(const bool show, const bool adjust, const bool noadjfile,
const bool set, const time_t set_time,
- const bool hctosys, const bool systohc,
- const struct timeval startup_time,
+ const bool hctosys, const bool systohc,
+ const struct timeval startup_time,
const bool utc, const bool local_opt,
const bool testing) {
/*---------------------------------------------------------------------------
@@ -1057,7 +1057,7 @@ manipulate_clock(const bool show, const bool adjust, const bool noadjfile,
return rc;
} else {
/* A little trick to avoid reading the file if we don't have to */
- adjtime.dirty = FALSE;
+ adjtime.dirty = FALSE;
rc = 0;
}
@@ -1075,7 +1075,7 @@ manipulate_clock(const bool show, const bool adjust, const bool noadjfile,
return rc;
{
- struct timeval read_time;
+ struct timeval read_time;
/* The time at which we read the Hardware Clock */
bool hclock_valid;
@@ -1088,34 +1088,34 @@ manipulate_clock(const bool show, const bool adjust, const bool noadjfile,
synchronized to its next clock tick when we started up.
Defined only if hclock_valid is true.
*/
-
+
gettimeofday(&read_time, NULL);
- read_hardware_clock(universal, &hclock_valid, &hclocktime);
-
+ read_hardware_clock(universal, &hclock_valid, &hclocktime);
+
if (show) {
- display_time(hclock_valid, hclocktime,
+ display_time(hclock_valid, hclocktime,
time_diff(read_time, startup_time));
} else if (set) {
- set_hardware_clock_exact(set_time, startup_time,
+ set_hardware_clock_exact(set_time, startup_time,
universal, testing);
adjust_drift_factor(&adjtime, set_time, hclock_valid, hclocktime,
time_diff(read_time, startup_time));
} else if (adjust) {
- do_adjustment(&adjtime, hclock_valid, hclocktime,
+ do_adjustment(&adjtime, hclock_valid, hclocktime,
read_time, universal, testing);
} else if (systohc) {
struct timeval nowtime, reftime;
/* We can only set_hardware_clock_exact to a whole seconds
time, so we set it with reference to the most recent
- whole seconds time.
+ whole seconds time.
*/
gettimeofday(&nowtime, NULL);
reftime.tv_sec = nowtime.tv_sec;
reftime.tv_usec = 0;
-
- set_hardware_clock_exact((time_t) reftime.tv_sec, reftime,
+
+ set_hardware_clock_exact((time_t) reftime.tv_sec, reftime,
universal, testing);
- adjust_drift_factor(&adjtime, (time_t) reftime.tv_sec, hclock_valid,
+ adjust_drift_factor(&adjtime, (time_t) reftime.tv_sec, hclock_valid,
hclocktime, (double) read_time.tv_usec / 1E6);
} else if (hctosys) {
rc = set_system_clock(hclock_valid, hclocktime, testing);
@@ -1133,7 +1133,7 @@ manipulate_clock(const bool show, const bool adjust, const bool noadjfile,
static void
-manipulate_epoch(const bool getepoch, const bool setepoch,
+manipulate_epoch(const bool getepoch, const bool setepoch,
const int epoch_opt, const bool testing) {
/*----------------------------------------------------------------------------
Get or set the Hardware Clock epoch value in the kernel, as appropriate.
@@ -1143,7 +1143,7 @@ manipulate_epoch(const bool getepoch, const bool setepoch,
-----------------------------------------------------------------------------*/
/*
- Maintenance note: This should work on non-Alpha machines, but the
+ Maintenance note: This should work on non-Alpha machines, but the
evidence today (98.03.04) indicates that the kernel only keeps the
epoch value on Alphas. If that is ever fixed, this function should be
changed.
@@ -1160,7 +1160,7 @@ manipulate_epoch(const bool getepoch, const bool setepoch,
if (get_epoch_rtc(&epoch, 0))
fprintf(stderr, _("Unable to get the epoch value from the kernel.\n"));
- else
+ else
printf(_("Kernel is assuming an epoch value of %lu\n"), epoch);
} else if (setepoch) {
if (epoch_opt == -1)
@@ -1189,14 +1189,14 @@ out_version(void) {
/*
usage - Output (error and) usage information
- This function is called both directly from main to show usage
- information and as fatal function from shhopt if some argument is
- not understood. In case of normal usage info FMT should be NULL.
- In that case the info is printed to stdout. If FMT is given
- usage will act like fprintf( stderr, fmt, ... ), show a usage
+ This function is called both directly from main to show usage
+ information and as fatal function from shhopt if some argument is
+ not understood. In case of normal usage info FMT should be NULL.
+ In that case the info is printed to stdout. If FMT is given
+ usage will act like fprintf( stderr, fmt, ... ), show a usage
information and terminate the program afterwards.
*/
-static void
+static void
usage( const char *fmt, ... ) {
FILE *usageto;
va_list ap;
@@ -1245,7 +1245,7 @@ usage( const char *fmt, ... ) {
vfprintf(stderr, fmt, ap);
va_end(ap);
}
-
+
hwclock_exit(fmt ? EX_USAGE : 0);
}
@@ -1290,7 +1290,7 @@ static const struct option longopts[] = {
* 0: OK (or not)
* 1: failure
*/
-int
+int
main(int argc, char **argv) {
struct timeval startup_time;
@@ -1476,16 +1476,16 @@ main(int argc, char **argv) {
}
}
- if (!(show | set | systohc | hctosys | adjust | getepoch | setepoch))
+ if (!(show | set | systohc | hctosys | adjust | getepoch | setepoch))
show = 1; /* default to show */
-
+
if (getuid() == 0)
permitted = TRUE;
else {
/* program is designed to run setuid (in some situations) */
if (set || hctosys || systohc || adjust) {
- fprintf(stderr,
+ fprintf(stderr,
_("Sorry, only the superuser can change "
"the Hardware Clock.\n"));
permitted = FALSE;
@@ -1495,7 +1495,7 @@ main(int argc, char **argv) {
"the System Clock.\n"));
permitted = FALSE;
} else if (setepoch) {
- fprintf(stderr,
+ fprintf(stderr,
_("Sorry, only the superuser can change the "
"Hardware Clock epoch in the kernel.\n"));
permitted = FALSE;
@@ -1537,7 +1537,7 @@ void
outsyserr(char *msg, ...) {
va_list args;
int errsv = errno;
-
+
fprintf(stderr, "%s: ", progname);
va_start(args, msg);
vfprintf(stderr, msg, args);
@@ -1564,7 +1564,7 @@ hwaudit_exit(int status)
History of this program:
- 98.08.12 BJH Version 2.4
+ 98.08.12 BJH Version 2.4
Don't use century byte from Hardware Clock. Add comments telling why.
@@ -1574,9 +1574,9 @@ hwaudit_exit(int status)
Make --hctosys set the kernel timezone from TZ environment variable
and/or /usr/lib/zoneinfo. From Klaus Ripke (klaus@ripke.com).
- 98.03.05 BJH. Version 2.2.
+ 98.03.05 BJH. Version 2.2.
- Add --getepoch and --setepoch.
+ Add --getepoch and --setepoch.
Fix some word length things so it works on Alpha.
@@ -1589,7 +1589,7 @@ hwaudit_exit(int status)
97.06.01: BJH. Version 2.1. Read and write the century byte (Byte
50) of the ISA Hardware Clock when using direct ISA I/O. Problem
discovered by job (jei@iclnl.icl.nl).
-
+
Use the rtc clock access method in preference to the KDGHWCLK method.
Problem discovered by Andreas Schwab <schwab@LS5.informatik.uni-dortmund.de>.
@@ -1610,13 +1610,13 @@ hwaudit_exit(int status)
in this program will be compiled as external references. Since you
probably won't be linking with any functions by these names, you will
have unresolved external references when you link.
-
+
The program is designed to run setuid superuser, since we need to be
- able to do direct I/O. (More to the point: we need permission to
- execute the iopl() system call). (However, if you use one of the
+ able to do direct I/O. (More to the point: we need permission to
+ execute the iopl() system call). (However, if you use one of the
methods other than direct ISA I/O to access the clock, no setuid is
required).
-
+
Here's some info on how we must deal with the time that elapses while
this program runs: There are two major delays as we run:
@@ -1637,7 +1637,7 @@ hwaudit_exit(int status)
So we check the system time as soon as we start up, then run "date"
and do file I/O if necessary, then wait to synchronize with a
Hardware Clock edge, then check the system time again to see how
- much time we spent. We immediately read the clock then and (if
+ much time we spent. We immediately read the clock then and (if
appropriate) report that time, and additionally, the delay we measured.
If we're setting the clock to a time given by the user, we wait some
@@ -1658,7 +1658,7 @@ hwaudit_exit(int status)
complications that might cause, we set the clock as soon as possible
after an oscillator tick.
-
+
About synchronizing to the Hardware Clock when reading the time: The
precision of the Hardware Clock counters themselves is one second.
You can't read the counters and find out that is 12:01:02.5. But if
@@ -1681,5 +1681,5 @@ hwaudit_exit(int status)
fail if we miss the goal by more than .1 second, as could happen if
we get pre-empted (by the kernel dispatcher).
-****************************************************************************/
+****************************************************************************/
diff --git a/hwclock/kd.c b/hwclock/kd.c
index b9f8d74d5..6be5fabd0 100644
--- a/hwclock/kd.c
+++ b/hwclock/kd.c
@@ -44,7 +44,7 @@ static int
synchronize_to_clock_tick_kd(void) {
/*----------------------------------------------------------------------------
Wait for the top of a clock tick by calling KDGHWCLK in a busy loop until
- we see it.
+ we see it.
-----------------------------------------------------------------------------*/
int i;
@@ -58,7 +58,7 @@ synchronize_to_clock_tick_kd(void) {
outsyserr(_("KDGHWCLK ioctl to read time failed"));
return 3;
}
-
+
i = 0;
do {
/* Added by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
@@ -95,7 +95,7 @@ read_hardware_clock_kd(struct tm *tm) {
Read the hardware clock and return the current time via <tm>
argument. Use ioctls to /dev/tty1 on what we assume is an m68k
machine.
-
+
Note that we don't use /dev/console here. That might be a serial
console.
-----------------------------------------------------------------------------*/
diff --git a/hwclock/rtc.c b/hwclock/rtc.c
index dddb1e372..f8e626eb8 100644
--- a/hwclock/rtc.c
+++ b/hwclock/rtc.c
@@ -177,7 +177,7 @@ static int
busywait_for_rtc_clock_tick(const int rtc_fd) {
/*----------------------------------------------------------------------------
Wait for the top of a clock tick by reading /dev/rtc in a busy loop until
- we see it.
+ we see it.
-----------------------------------------------------------------------------*/
struct tm start_time;
/* The time when we were called (and started waiting) */
@@ -395,13 +395,13 @@ get_epoch_rtc(unsigned long *epoch_p, int silent) {
rtc_fd = open_rtc();
if (rtc_fd < 0) {
if (!silent) {
- if (errno == ENOENT)
+ if (errno == ENOENT)
fprintf(stderr, _(
"To manipulate the epoch value in the kernel, we must "
"access the Linux 'rtc' device driver via the device special "
"file %s. This file does not exist on this system.\n"),
rtc_dev_name);
- else
+ else
outsyserr(_("Unable to open %s"), rtc_dev_name);
}
return 1;
@@ -442,7 +442,7 @@ set_epoch_rtc(unsigned long epoch) {
rtc_fd = open_rtc();
if (rtc_fd < 0) {
- if (errno == ENOENT)
+ if (errno == ENOENT)
fprintf(stderr, _("To manipulate the epoch value in the kernel, we must "
"access the Linux 'rtc' device driver via the device special "
"file %s. This file does not exist on this system.\n"),
@@ -460,7 +460,7 @@ set_epoch_rtc(unsigned long epoch) {
if (errno == EINVAL)
fprintf(stderr, _("The kernel device driver for %s "
"does not have the RTC_EPOCH_SET ioctl.\n"), rtc_dev_name);
- else
+ else
outsyserr(_("ioctl(RTC_EPOCH_SET) to %s failed"), rtc_dev_name);
close(rtc_fd);
return 1;