Commit Graph

58 Commits

Author SHA1 Message Date
Karel Zak b940bae397 hwclock: use c.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-16 01:37:09 +02:00
Scott James Remnant 2eefcaaace hwclock: set kernel timezone with --systz --utc
Even though --systz doesn't need to change the system clock when the
hardware clock is in UTC time (--systz --utc), it does need to set
the kernel timezone so that FAT timestamps, etc. will be correct.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-10-13 16:17:51 +02:00
Scott James Remnant 304762d663 hwclock: do not access hardware clock when using --systz
When using --systz we do not read from the hardware clock, so there
is no need to search for a hardware clock.  Indeed, we may be running
hwclock --systz before /dev is mounted.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-10-13 14:03:30 +02:00
Guillem Jover cef0ccd580 Remove now unused <sys/ioctl.h> includes
Those became unused with the switch to the blkdev functions.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2009-10-09 15:17:54 +02:00
Daniel Mierswa 437fa54f05 replace usleep() for systems that don't have them
This function is marked obsolete in POSIX.1-2001 and removed in
POSIX.1-2008.

Conditionally replaced with nanosleep().

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
2009-08-21 09:58:17 +02:00
Karel Zak 102f5d89d9 hwclocks: use time limit for KDGHWCLK busy wait
Currently the busy wait in synchronize_to_clock_tick_kd() is
restricted by number of loops. It's better to use time limit
(1.5s). We already use this method for RTC.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-08-20 15:46:10 +02:00
Peter Breitenlohner 93f9a8e4da hwclock.8: formatting
Signed-off-by: Peter Breitenlohner <peb@mppmu.mpg.de>
2009-08-17 12:11:13 +02:00
John Keeping 49c0c23d9d hwclock: fix mismatched popen/fclose.
date_child_fp is opened by popen, so should be closed with pclose.

Signed-off-by: John Keeping <john.keeping@lineone.net>
Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>
2009-05-27 22:59:25 +02:00
Scott James Remnant 88a3372e88 hwclock: add --systz option to set system clock from itself
Since the system clock time is already set from the hardware clock by the
kernel (when compiled with CONFIG_RTC_HCTOSYS), there's no particular need to
read the hardware clock again.

This option sets the system clock using itself as a reference if the
hardware clock was in local time.  The resulting system clock time
is in UTC, with the kernel timezone set to the difference.

[kzak@redhat.com: - fix the condition that controls read_adjtime() call]

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-10 13:27:49 +01:00
Karel Zak 715814d950 hwclock: clock.h is included more than once
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-11-26 14:31:19 +01:00
Karel Zak 433c8bea8a hwclock: remove "cli" and "sti" from i386 CMOS code
The protection against context switch is nonsense. There is possible
to optimize the access to CMOS by mlockall(MCL_CURRENT) and SCHED_FIFO.

For more details see: http://lkml.org/lkml/2008/10/12/132

Reported-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-10-16 23:37:38 +02:00
Pedro Ribeiro f9e151dddb hwclock: several strings without gettext calls
Signed-off-by: Pedro Ribeiro <p.m42.ribeiro@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-10-03 08:57:43 +02:00
Karel Zak 27f9db17bd hwclock: don't open /dev/rtc repeatedly
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-08-18 14:08:57 +02:00
Karel Zak 55a4a75ca0 hwclock: read_hardware_clock_rtc() need to return error codes
We shouldn't ignore RTC_RD_TIME/RTCGET error codes.

Signed-off-by: Karel Zak <kzak@redhat.com>
2008-08-13 11:47:10 +02:00
Kalev Soikonen ac1bb1ef93 hwclock: delay loop in set_hardware_clock_exact
- Avoid delaying 1.5 seconds when 0.5 will do.
- Guard for forward time resets as well.

[kzak@redhat.com: - fix the "Delaying.." debug message
                  - add comments]

Signed-off-by: Kalev Soikonen <ksop@hot.ee>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-08-13 11:43:59 +02:00
Karel Zak 982a4a5d98 hwclock: use time limit for synchronization busy wait
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-08-13 11:43:59 +02:00
Karel Zak 3b96a7acbc hwclock: use carefully synchronize_to_clock_tick() return codes
* It seems that

	rtc-isl1208 0-006f: chip found, driver version 0.3
	rtc-isl1208 0-006f: rtc core: registered rtc-isl1208 as rtc0
	rtc-isl1208 0-006f: rtc power failure detected, please set clock.

  causes that hardware clock returns persistent time and synchronization
  is impossible. The hwclock(8) has to ignore this problem and allows to
  set clock anyway.

* synchronize_to_clock_tick() shouldn't to print the "...got clock tick"
  debug message in case of failure.

Signed-off-by: Karel Zak <kzak@redhat.com>
2008-08-13 11:40:23 +02:00
David Brownell 442d61c6e9 hwclock: remove x86_64-specific bogon
I was puzzled why "hwclock" wrongly reported my x86_64 sytem didn't
support RTC update interrupts.  Bogus #ifdef, that's why ... added
by the 2.11y patch (from 2.11t).  Probably this whole #ifdef should
just vanish ... if the kernel rejects UIE_ON, the program ought to
just cope with it.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2008-08-12 12:50:11 +02:00
Karel Zak 28e984a419 hwclock: cleanup help output and man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-08-06 13:19:40 +02:00
Kalev Soikonen d458f94a7c hwclock: unshadow a diagnostic printf
- Bogus if test means one message is never produced.

- Avoid needless passing of a global variable (debug).

The --test option flag ought to be a global as well (and perhaps -n/--dry-run).

Signed-off-by: Kalev Soikonen <ksop@hot.ee>
2008-08-06 12:47:55 +02:00
Karel Zak cdedde039c hwclock: always reads hardware clock
It's a pity that hwclock first tries to read the clock when running

	hwclock --systohc --noadjfile --utc

and exits as this fails.  I cannot see a reason to read first in that
case.

Old version:

	# hwclock --systohc --noadjfile --utc --debug

	hwclock from util-linux-ng 2.14
	Using /dev interface to clock.
	Assuming hardware clock is kept in UTC time.
	Waiting for clock tick...
	/dev/rtc does not have interrupt functions. Waiting in loop for time
	from /dev/rtc to change
	...got clock tick
	Time read from Hardware Clock: 2008/06/17 11:18:24
	Hw clock time : 2008/06/17 11:18:24 = 1213701504 seconds since 1969
	Time elapsed since reference time has been 0.904855 seconds.
	Delaying further to reach the next full second.
	Setting Hardware Clock to 11:18:24 = 1213701504 seconds since 1969
	ioctl(RTC_SET_TIME) was successful.

New version:

	# hwclock --systohc --noadjfile --utc --debug

	hwclock from util-linux-ng 2.14
	Using /dev interface to clock.
	Assuming hardware clock is kept in UTC time.
	Time elapsed since reference time has been 0.572151 seconds.
	Delaying further to reach the next full second.
	Setting Hardware Clock to 11:18:52 = 1213701532 seconds since 1969
	ioctl(RTC_SET_TIME) was successful.

Addresses-Debian-Bug: #478663
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-06-17 13:19:18 +02:00
Matthias Koenig 0b0beca2bb hwclock: omit warning about drift if --noadjfile given
Currently, if hwclock is given the --noadjfile option it will
nevertheless display information about the drift rate when invoked with
the --debug option.

Signed-off-by: Matthias Koenig <mkoenig@suse.de>
2008-06-16 12:39:09 +02:00
James Youngman c4e1583799 build-sys: ignore a bunch of generated files, mostly binaries
Signed-off-by: James Youngman <jay@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-04-14 14:08:00 +02:00
Karel Zak da82f6fe2f hwclock: add --adjfile=path option
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-04-09 11:50:46 +02:00
Stepan Kasal a3ca3a44c5 build-sys: use dist_man_MANS instead of man_MANS
Signed-off-by: Stepan Kasal <skasal@redhat.com>
2007-12-17 10:08:49 +01:00
David Woodhouse df1d7dcf1e hwclock: check for ENODEV
/sbin/hwclock is supposed to fall back to using /dev/rtc0 if /dev/rtc isn't
working (which it isn't, because mkinitrd creates it with the old device
numbers, and we're switching to the new RTC_CLASS driver).

Unfortunately, it'll only cope if the error it gets is ENOENT (i.e. the device
node doesn't exist). It doesn't fall back to the next device in the list if the
error is ENODEV, which is what happens when the device node exists, but there's
no driver.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-12-04 14:44:05 +01:00
Alain Guibert 8f5b978e53 hwclock: do not create a zero adjfile
When hwclock --hctosys is started very early during the system startup,
with / still mounted read-only, and there was no /etc/adjtime file,
hwclock fails creating a default adjfile full of zeroes, and prints an
error message. I believe that such zero adjfile is not necessary,
because it means exactly the same as no adjfile at all.

The attached patch prevents creation of a zero adjfile, of course unless
something gets changed (this never happens during a --hctosys).

Signed-off-by: Alain Guibert <alguibert+ulng@free.fr>
2007-10-26 01:02:44 +02:00
Matthias Koenig 5d1f6bae3b hwclock: fix --rtc option
The --rtc option does not set the name of the device correctly.
It still uses /dev/rtc even if the --rtc option is given.

Testcase:
$ mv /dev/rtc /dev/foo
$ hwclock --show --debug --rtc=/dev/foo
hwclock from util-linux-2.13-rc2
Using /dev interface to clock.
Last drift adjustment done at 1190198135 seconds after 1969
Last calibration done at 1190198135 seconds after 1969
Hardware clock is on local time
Assuming hardware clock is kept in local time.
Waiting for clock tick...
hwclock: open() of /dev/rtc failed, errno=2: No such file or directory.
...got clock tick

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-09-20 13:40:14 +02:00
Karel Zak 8e522bb7e9 remove hardcoded package name from some utils
We have PACKAGE_STRING in config.h that includes package name and
version. It's better to use this macro that hardcoded strings.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-07-27 12:12:00 +02:00
Karel Zak 86d62711a9 man pages: add "AVAILABILITY" section
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-07-03 01:17:04 +02:00
Stepan Kasal 81c3ab2d60 build-sys: do not use wildcards in EXTRA_DIST
Wildcards in EXTRA_DIST break "make dist" for vpath build.
But plain directory names are ok.

Signed-off-by: Stepan Kasal <skasal@redhat.com>
2007-05-16 11:43:30 +02:00
Karel Zak 72bcf1898b hwclock: make ggc happy and check return values from fgets, read and write
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-03-21 16:21:34 +01:00
Karel Zak 9abb26854c hwclock: remove tailing white-spaces and clean up clock.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-03-21 15:05:58 +01:00
Karel Zak 88058a71e2 hwclock: add support for audit system
If you compile --with-audit the hwclock tool reports changes in sys/hw clock to
audit system. The real long-term and final solution is probably add hooks for
/dev/rtc to kernel, but it's not implemented yet.

Signed-off-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-03-21 14:12:05 +01:00
Karel Zak 99c392d8ba hwclock: fix --systohc sets clock 0.5 seconds slow
quote from rh150493:

	The kernel code, when setting the BIOS clock notes that the clock time
	ticks to the next second 0.5 seconds after adjusting it  (see
	linux/arch/i386/kernel/time.c).

	hwclock --systohc sets the CMOS clock at the 1 second boundry and thus
	causes the clock to be wrong by 500ms each time it is reset.  If the
	clock is set every shutdown then the clock will have a reboot-count
	related drift as well as the natural drift problems of the clock. Note
	that this also mucks up the drift calculations, of course.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-03-20 00:32:37 +01:00
Karel Zak 88681c5f1a hwclock: add --rtc=<path> option and support for /dev/rtc0
The patch to allow "hwclock --rtc /dev/rtc1" and so on,
since "/dev/rtc" may not be there and "/dev/rtc0" may not be
the right answer either.

The "--rtc" is compatible with next Bryan Henderson's hwclock
versions.

Signed-off-by: David Brownell <david-b@pacbell.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-03-19 10:14:13 +01:00
Karel Zak b8d1314dc6 build-sys: fix README filenames and add missing files to EXTRA_DISTs
Also, the patch makes "make mrproper" more robust.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-02-08 12:38:25 +01:00
Karel Zak 562218e6ea build-sys: add missing files
This patch add all missing headers, man pages and README files to automake
stuff and "make dist-gzip" produces useful tarball now.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-01-04 11:57:07 +01:00
Karel Zak 8eeb575c0d build-sys: remove generated autotools stuff from git
The generated autotools stuff shouldn't be maintained by SCM. After check out
from git use ./autogen.sh. For more details see README.devel.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-01-03 22:20:44 +01:00
Karel Zak cf6d7faebb Imported from util-linux-2.13-pre6 tarball. 2006-12-07 00:27:13 +01:00
Karel Zak ca3ea756e7 Imported from util-linux-2.13-pre4 tarball. 2006-12-07 00:27:06 +01:00
Karel Zak 9cb689775c Imported from util-linux-2.13-pre3 tarball. 2006-12-07 00:27:03 +01:00
Karel Zak baf39af15b Imported from util-linux-2.13-pre2 tarball. 2006-12-07 00:26:58 +01:00
Karel Zak 48d7b13a1e Imported from util-linux-2.13-pre1 tarball. 2006-12-07 00:26:54 +01:00
Karel Zak 5213517f54 Imported from util-linux-2.12l tarball. 2006-12-07 00:26:28 +01:00
Karel Zak 0b0bb92085 Imported from util-linux-2.12i tarball. 2006-12-07 00:26:22 +01:00
Karel Zak d03dd60840 Imported from util-linux-2.12a tarball. 2006-12-07 00:26:14 +01:00
Karel Zak df1dddf9ff Imported from util-linux-2.12 tarball. 2006-12-07 00:26:12 +01:00
Karel Zak a5a16c6853 Imported from util-linux-2.11y tarball. 2006-12-07 00:26:08 +01:00
Karel Zak 95f1bdeee4 Imported from util-linux-2.11x tarball. 2006-12-07 00:26:05 +01:00