Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/etc Add a new /etc/rc.conf option: rtclocaltime=YES adapts t...
details: https://anonhg.NetBSD.org/src/rev/3617638fed85
branches: trunk
changeset: 556777:3617638fed85
user: martin <martin%NetBSD.org@localhost>
date: Sat Dec 27 00:23:22 2003 +0000
description:
Add a new /etc/rc.conf option: rtclocaltime=YES adapts the RTC offset
at boot automatically, so a machine dual booting another OS that uses
the RTC at localtime and NetBSD agree on the current time even if daylight
saving started/ended (without recompiling a kernel twice per year).
Awk code by Matt Thomas.
diffstat:
etc/defaults/rc.conf | 6 +++++-
etc/rc.d/rtclocaltime | 33 +++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletions(-)
diffs (57 lines):
diff -r d3d021261cbe -r 3617638fed85 etc/defaults/rc.conf
--- a/etc/defaults/rc.conf Sat Dec 27 00:05:46 2003 +0000
+++ b/etc/defaults/rc.conf Sat Dec 27 00:23:22 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: rc.conf,v 1.51 2003/10/20 15:02:15 christos Exp $
+# $NetBSD: rc.conf,v 1.52 2003/12/27 00:23:22 martin Exp $
#
# /etc/defaults/rc.conf --
# default configuration of /etc/rc.conf
@@ -105,6 +105,10 @@
accounting=NO # uses /var/account/acct
newsyslog=NO newsyslog_flags="" # trim log files
+# cope with other OSes using the real time clock at localtime on this
+# machine (by adjusting kern.rtc_offset at boot)
+rtclocaltime=NO
+
# NOTE: default coredump name now set in /etc/sysctl.conf
#
diff -r d3d021261cbe -r 3617638fed85 etc/rc.d/rtclocaltime
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/rc.d/rtclocaltime Sat Dec 27 00:23:22 2003 +0000
@@ -0,0 +1,33 @@
+#! /bin/sh
+
+# PROVIDE: rtclocaltime
+# REQUIRE: mountcritremote
+# BEFORE: ntpdate ntpd
+
+. /etc/rc.subr
+
+name="rtclocaltime"
+rcvar=$name
+start_cmd="rtclocaltime_start"
+stop_cmd=":"
+
+rtclocaltime_start()
+{
+ rtcoff=$(date '+%z' | awk '{
+ offset = int($1);
+ if (offset < 0) {
+ sign = -1;
+ offset = -offset;
+ } else {
+ sign = 1;
+ }
+ minutes = offset % 100;
+ hours = offset / 100;
+ offset = sign * (hours * 60 + minutes);
+ print offset;
+ }')
+ sysctl -w kern.rtc_offset=$((-1 * $rtcoff))
+}
+
+load_rc_config $name
+run_rc_command "$1"
Home |
Main Index |
Thread Index |
Old Index