Cleanups for rtcwake in util-linux-ng-2.13.0.1:
- Minor doc updates: highlight the framebuffer problem,
give correct history of this code
- Improve debug output
- Fix some linelength bugs
Note that this code predated the sysfs "wakealarm" mechanism, and
works around several now-fixed bugs in the kernel RTC framework.
Nowadays it would make sense to make this program use only the sysfs
interface to the RTC, using "since_epoch" instead of RTC_RD_TIME and
"wakealarm" instead of the four other ioctls. That could simplify
the mess involved in timezone handling.
Signed-off-by: David Brownell <[EMAIL PROTECTED]>
---
sys-utils/rtcwake.8 | 11 ++++++++---
sys-utils/rtcwake.c | 48 ++++++++++++++++++++++++++++--------------------
2 files changed, 36 insertions(+), 23 deletions(-)
--- util-linux-ng-2.13.0.1.orig/sys-utils/rtcwake.8 2007-11-30
13:33:26.000000000 -0800
+++ util-linux-ng-2.13.0.1/sys-utils/rtcwake.8 2007-11-30 13:33:33.000000000
-0800
@@ -76,15 +76,20 @@ is the time in seconds since 1970-01-01,
Use standby state \fImode\fP. Valid values are \fIstandby\fP,
\fImem\fP, \fIdisk\fP and \fIon\fP (no suspend). The default is
\fIstandby\fP.
+.SH NOTES
+Some PC systems can't currently exit sleep states such as \fImem\fP
+using only the kernel code accessed by this driver.
+They need help from userspace code to make the framebuffer work again.
.SH HISTORY
-The program first appeared as kernel commit message for Linux 2.6 in the GIT
+The program was posted several times on LKML and other lists
+before appearing in kernel commit message for Linux 2.6 in the GIT
commit 87ac84f42a7a580d0dd72ae31d6a5eb4bfe04c6d.
.SH AVAILABILITY
The rtcwake command is part of the util-linux-ng package and is available from
ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
.SH AUTHOR
-The program was written by David Brownell <[EMAIL PROTECTED]> and improved by
-Bernhard Walle <[EMAIL PROTECTED]>.
+The program was written by David Brownell <[EMAIL PROTECTED]>
+and improved by Bernhard Walle <[EMAIL PROTECTED]>.
.SH COPYRIGHT
This is free software. You may redistribute copies of it under the terms
of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
--- util-linux-ng-2.13.0.1.orig/sys-utils/rtcwake.c 2007-11-30
13:33:26.000000000 -0800
+++ util-linux-ng-2.13.0.1/sys-utils/rtcwake.c 2007-11-30 13:33:33.000000000
-0800
@@ -16,6 +16,7 @@
* The best way to set the system's RTC is so that it holds the current
* time in UTC. Use the "-l" flag to tell this program that the system
* RTC uses a local timezone instead (maybe you dual-boot MS-Windows).
+ * That flag should not be needed on systems with adjtime support.
*/
#include <stdio.h>
@@ -163,14 +164,18 @@ static int get_basetimes(int fd)
}
if (verbose) {
- if (clock_mode == CM_LOCAL) {
- printf("\ttzone = %ld\n", timezone);
- printf("\ttzname = %s\n", tzname[daylight]);
- gmtime_r(&rtc_time, &tm);
- }
- printf("\tsystime = %ld, (UTC) %s\n",
+ /* Unless the system uses UTC, either delta or tzone
+ * reflects a seconds offset from UTC. The value can
+ * help sort out problems like bugs in your C library.
+ */
+ printf("\tdelta = %ld\n", sys_time - rtc_time);
+ printf("\ttzone = %ld\n", timezone);
+
+ printf("\ttzname = %s\n", tzname[daylight]);
+ gmtime_r(&rtc_time, &tm);
+ printf("\tsystime = %ld, (UTC) %s",
(long) sys_time, asctime(gmtime(&sys_time)));
- printf("\trtctime = %ld, (UTC) %s\n",
+ printf("\trtctime = %ld, (UTC) %s",
(long) rtc_time, asctime(&tm));
}
@@ -190,11 +195,14 @@ static int setup_alarm(int fd, time_t *w
wake.time.tm_mday = tm->tm_mday;
wake.time.tm_mon = tm->tm_mon;
wake.time.tm_year = tm->tm_year;
- wake.time.tm_wday = tm->tm_wday;
- wake.time.tm_yday = tm->tm_yday;
- wake.time.tm_isdst = tm->tm_isdst;
+ /* wday, yday, and isdst fields are unused by Linux */
+ wake.time.tm_wday = -1;
+ wake.time.tm_yday = -1;
+ wake.time.tm_isdst = -1;
- /* many rtc alarms only support up to 24 hours from 'now' ... */
+ /* many rtc alarms only support up to 24 hours from 'now',
+ * so use the "more than 24 hours" request only if we must
+ */
if ((rtc_time + (24 * 60 * 60)) > *wakeup) {
if (ioctl(fd, RTC_ALM_SET, &wake.time) < 0) {
perror(_("set rtc alarm"));
@@ -204,8 +212,6 @@ static int setup_alarm(int fd, time_t *w
perror(_("enable rtc alarm"));
return 0;
}
-
- /* ... so use the "more than 24 hours" request only if we must
*/
} else {
/* avoid an extra AIE_ON call */
wake.enabled = 1;
@@ -321,8 +327,9 @@ int main(int argc, char **argv)
suspend = strdup(optarg);
break;
}
- fprintf(stderr, _("%s: unrecognized suspend state
'%s'\n"),
- progname, optarg);
+ fprintf(stderr,
+ _("%s: unrecognized suspend state '%s'\n"),
+ progname, optarg);
usage(EXIT_FAILURE);
/* alarm time, seconds-to-sleep (relative) */
@@ -376,10 +383,10 @@ int main(int argc, char **argv)
printf(_("%s: assuming RTC uses UTC ...\n"), progname);
clock_mode = CM_UTC;
}
- if (verbose)
- printf(_("Using %s time\n"),
- clock_mode == CM_UTC ? "UTC" :
_("local"));
}
+ if (verbose)
+ printf(_("Using %s time\n"),
+ clock_mode == CM_UTC ? "UTC" : _("local"));
if (!alarm && !seconds) {
fprintf(stderr, _("%s: must provide wake time\n"), progname);
@@ -423,8 +430,9 @@ int main(int argc, char **argv)
alarm, sys_time, rtc_time, seconds);
if (alarm) {
if (alarm < sys_time) {
- fprintf(stderr, _("%s: time doesn't go backward to
%s\n"),
- progname, ctime(&alarm));
+ fprintf(stderr,
+ _("%s: time doesn't go backward to %s\n"),
+ progname, ctime(&alarm));
exit(EXIT_FAILURE);
}
alarm += sys_time - rtc_time;
-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html