From 304762d663608bbda4661c87d298d77c0629da5e Mon Sep 17 00:00:00 2001 From: Scott James Remnant Date: Thu, 24 Sep 2009 11:59:33 -0700 Subject: [PATCH] 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 --- hwclock/hwclock.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/hwclock/hwclock.c b/hwclock/hwclock.c index 3504f2be..9cdadfea 100644 --- a/hwclock/hwclock.c +++ b/hwclock/hwclock.c @@ -1136,9 +1136,11 @@ manipulate_clock(const bool show, const bool adjust, const bool noadjfile, int rc; /* local return code */ bool no_auth; /* User lacks necessary authorization to access the clock */ - no_auth = ur->get_permissions(); - if (no_auth) - return EX_NOPERM; + if (!systz) { + no_auth = ur->get_permissions(); + if (no_auth) + return EX_NOPERM; + } if (!noadjfile && (adjust || set || systohc || (!utc && !local_opt))) { rc = read_adjtime(&adjtime); @@ -1644,16 +1646,19 @@ main(int argc, char **argv) { if (debug) out_version(); - determine_clock_access_method(directisa); - if (!ur) { - fprintf(stderr, - _("Cannot access the Hardware Clock via " - "any known method.\n")); - if (!debug) + if (!systz) { + determine_clock_access_method(directisa); + if (!ur) { fprintf(stderr, - _("Use the --debug option to see the details " - "of our search for an access method.\n")); - hwclock_exit(1); + _("Cannot access the Hardware Clock via " + "any known method.\n")); + if (!debug) + fprintf(stderr, + _("Use the --debug option to see the " + "details of our search for an access " + "method.\n")); + hwclock_exit(1); + } } rc = manipulate_clock(show, adjust, noadjfile, set, set_time, -- 2.39.5