summaryrefslogtreecommitdiffstats
path: root/sys-utils/hwclock-rtc.c
Commit message (Collapse)AuthorAgeFilesLines
* hwclock: use monotonic time to measure how long setting time takesSami Kerola2019-01-121-2/+3
| | | | | | | | | Earlier gettimeofday() was affected by discontinuous jumps. Measuring how long time it takes to set time using function that effected by the very thing being measured makes head spin. Lets make this less confusing with monotonic clock that ticks on without jumps. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: rely on kernel for RTC_UIE_ON on Aplha and SparcKarel Zak2018-08-031-11/+2Star
| | | | | | | | | | | It's kernel business to return EINVAL for unsupported RTC_UIE_ON. We (userspace) should not make decisions about things that we do not control. If kernel is wrong then fix the kernel, don't hide the problem by crazy ifdefs in userspace. Signed-off-by: Karel Zak <kzak@redhat.com>
* hwclock: add --delay <seconds>Karel Zak2018-07-181-0/+6
| | | | | | | | | | | * add command line option --delay <seconds> * read RTC type from /sys/class/rtc/rtc<N>/name * default to 0.5 (500ms) for rtc_cmos or when RTC type is impossible determine; otherwise delay is 0. Signed-off-by: Karel Zak <kzak@redhat.com>
* hwclock: rename --debug option to --verboseJ William Piggott2018-01-171-5/+5
| | | | | | | | | Warn on --debug; do not fallthrough because the message is lost in the verbose output. Coauthored-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: revert ioctl testKarel Zak2017-11-231-2/+2
| | | | | | | | | | This commit reverts 1d5cffa16a0183175684809cf215294ec20b8fd9. (I did this revert manually as there was another changes in the code and git-revert does not work in this case.) Addresses: https://github.com/karelzak/util-linux/issues/543 Signed-off-by: Karel Zak <kzak@redhat.com>
* hwclock: remove sysexits.hJ William Piggott2017-09-031-3/+2Star
| | | | | | | | | | | | | sysexits.h was introduced in v2.11t prior to util-linux-ng, with the HISTORY entry: * hwclock: minor polishing. So there was no specific issue solved by adding it. Its use was never documented so it should be safe to remove. Also, fix return values being used for the exit status that were not magic constants (portability issue). Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: remove busywait tristate return statusJ William Piggott2017-08-041-6/+5Star
| | | | | | | | | The select() synchronization branch only returns success or fail. There is no reason for the busywait branch to do more. If synchronization fails for any reason then it must exit, otherwise all drift correction operation will be invalid. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: restore select() timeout warningJ William Piggott2017-08-041-3/+2Star
| | | | | | | | | | | hwclock now exits on select(2) timeout so restore the warning. Reverts commit ab8f402952301106ad0bd5c5a51dc8646d1bff64 and commit efc4eaf4229f78f14430d8739ddef2c5101f05cc Except use warnx(), because select() timeout does not set errno. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: remove custom errno stringJ William Piggott2017-07-311-14/+12Star
| | | | | | | | | | | | | | Custom errno messages are unnecessary and problematic for translators. The current messages are also too long, > 90 columns: /dev/rtc0 does not have interrupt functions. Waiting in loop for time from \ /dev/rtc0 to change Fixed: ioctl(3, RTC_UIE_ON, 0): Inappropriate ioctl for device Waiting in loop for time from /dev/rtc0 to change Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: fix unimplemented ioctl testJ William Piggott2017-07-311-2/+2
| | | | | | | | | The rtc driver has not returned EINVAL for unimplemented ioctls since v2.5.8 in 2002. However, it does return it for other errors; making the current test potentially problematic. Since 9f3d0fc util-linux assumes kernel >= 2.6.0 so remove EINVAL as an ioctl test. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: squash custom errno stringsJ William Piggott2017-07-311-8/+2Star
| | | | | | | | warn() appends ENOENT as: No such file or directory The custom string is unnecessary and problematic for translators. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: improve RTC epoch messagesJ William Piggott2017-07-161-19/+14Star
| | | | | | | Make consistent and improve messages in get_epoch_rtc() and set_epoch_rtc(). Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: remove dead ioctl checkJ William Piggott2017-07-161-7/+1Star
| | | | | | | | | | The epoch ioctls test hasn't been valid for 20 years (v2.1.88). RTC has returned ENOTTY for unimplemented ioctls for 15 years. The check is made for RTC_EPOCH_SET, but not for RTC_EPOCH_READ. They were both implemented at the same time. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: --epoch presence test failsJ William Piggott2017-07-161-11/+8Star
| | | | | | | | | | | | | | hwclock --setepoch --epoch 0 Will warn that the epoch option is required. The --epoch presence test is made on its argument after it is converted to an integer. This means any value it can be tested for, can also be given as an input. So make the conversion after the presence test, like the --date option does. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: fix whitespace in hwclock-rtc.cJ William Piggott2017-04-101-2/+1Star
| | | | Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: remove unused 'silent' argJ William Piggott2017-03-311-12/+8Star
| | | | | | | | | | | | | | The 'silent' argument for get_epoch_rtc() was used to silence error messages when querying the rtc driver for an alpha epoch while using cmos direct access. Alpha cmos has since been removed so 'silent' is no longer used. * sys-utils/hwclock.h: remove 'silent' argument * sys-utils/hwclock.c: same * sys-utils/hwclock-rtc.c: same Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock-rtc.c: try the 'new' rtc class firstJ William Piggott2017-03-231-1/+1
| | | | | | | * sys-utils/hwclock-rtc.c: try to open the 'new' rtc class driver first. * sys-utils/hwclock.8.in: document this. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: remove trailing dot from messages that include system error messageSami Kerola2017-02-051-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: fix rtc atexit registrationSami Kerola2017-02-051-1/+1
| | | | | | | | Commit 27f9db17bd57b85947445c03e2cd9dda36ca377f missed a minus sign from comparison. Reviewed-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: try RTCGET and RTCSET only when normal rtc failsSami Kerola2017-02-051-21/+23
| | | | | | | | | The RTCGET and RTCSET are in use for sparcs with sbus, so try them as fallback rather than always. Reference: https://github.com/torvalds/linux/blob/master/fs/compat_ioctl.c#L967-L974 Reviewed-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: stream line synchronize_to_clock_tick_rtc()Sami Kerola2017-02-051-22/+19Star
| | | | | | | Flip if clauses to hit common case first. This should be easier and quicker to read and run. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: improve coding styleSami Kerola2017-02-051-8/+10
| | | | | | | | | Make string constants to be symbolical declarations. Use longer variable name for rtc and cmos function pointer values. Exclude code that is architecture specific with preprocessor directives. And remove message duplication. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: add debugging to open_rtc()Sami Kerola2017-02-051-18/+16Star
| | | | | | | | | | Earlier when open_rtc() returned -1 the char *rtc_dev_name end up having NULL that made it unsuitable to be used in error message. Now one can debug what paths the open_rtc() tries to use when one has to debug why 'cannot open rtc device' happen. Reviewed-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: use symbolic magic values passed in between functionsSami Kerola2017-02-051-4/+4
| | | | | | | | | | The manipulate_clock() is seeing return value from busywait_for_rtc_clock_tick(). And the get_permissions_cmos() can see i386_iopl() return value. Reviewed-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: remove dead code and other minor fixesSami Kerola2017-02-051-12/+0Star
| | | | | | | | | | | | | | | | | Use #ifdef rather than #if to avoid undefined preprocessor identifier warning. Remove dead code. The #if 0 ensured the code has not been used for long time, which is good because the linux/mc146818rtc.h is not been part of user-api for long time. Value of the adjtime_p->last_calib_time is checked if it has value of zero, so testing none-zero bit later is necessarily true, and therefore does not need to be checked. And at the and remove unnecessary boolean variable. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: move error messages to determine_clock_access_method()Sami Kerola2017-02-051-1/+1
| | | | | | | This makes main() a little bit shorter. Reviewed-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: move command-line options to control structureSami Kerola2017-02-051-36/+40
| | | | | | | | | | | | | | | The control structure is read-only everywhere else but in main(). Almost all changes are about how variables are referred, with one exception. Calls to read_adjtime() from manipulate_clock() and compare_clock() are moved to main(). This way it is possible to keep variable that tells if hwclock is using UTC-0 be part of control structure. Changes within #ifdef __alpha__ segments were tested by flipping the preprocessor directivive otherway around and getting good compilaton all the way to the point where linking on none-alpha system failed. Reviewed-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: fix format specifier [cppcheck]Boris Egorov2016-01-191-1/+1
| | | | [sys-utils/hwclock-rtc.c:435]: (warning) %ld in format string (no. 1) requires 'long' but the argument type is 'unsigned long'.
* sys-utils/disk-utils/lib: fix printf format types [cppcheck]Boris Egorov2015-06-251-1/+1
| | | | | | Fix 'invalidPrintfArgType' cppcheck warnings Signed-off-by: Boris Egorov <egorov@linux.com>
* hwclock: remove dead codeJ William Piggott2015-04-211-14/+0Star
| | | | | | | Removes never used #ifdef dead code. Reported-by: Karel Zak <kzak@redhat.com> Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: regression fixJ William Piggott2015-04-211-4/+5
| | | | | | | | | | Commit ab8f402952301106ad0bd5c5a51dc8646d1bff64 regression where synchronize_to_clock_tick_rtc() only returns the correct value for a select() time out if using debug mode. This caused hwclock to have invalid output when select() timed out in normal mode. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: internationalizing the message of the used interfaceBenno Schulenberg2014-02-101-1/+1
| | | | | | In addition, do it in a single sentence instead of in two fragments. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* hwclock: cleanup _() usage in synchronize_to_clock_tick_rtc()Karel Zak2013-03-211-10/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* hwclock: don't confuse users with select() timeout warningKarel Zak2013-03-211-3/+2Star
| | | | | Reported-by: Daniel Drake <dsd@laptop.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* hwclock: wait time in hwclock is not long enough for some ARM devicesKarel Zak2012-09-211-2/+2
| | | | | | | | | | | | | On Sun, Sep 16, 2012 at 02:11:48PM +0800, Queen Adam wrote: > I'm using Archlinux ARM for my Melo A100 box. > The hwclock always timeout when using select() in rtc.c. > > After I change the timeout from 5 to 10, the problem is solved. > > In fact the timeout in my ARM box seems only to be a little larger > than 5s. Signed-off-by: Karel Zak <kzak@redhat.com>
* translation: unify file open error messagesSami Kerola2012-07-161-5/+5
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build-sys: move hwclock to sys-utils/Karel Zak2012-06-261-0/+509
Signed-off-by: Karel Zak <kzak@redhat.com>