summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-09-12 03:58:46 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-09-12 03:58:46 +0200
commitc06e464ec45dd5880850fa60c850498861c514d3 (patch)
tree54198a9d83bf990faca2d51757931974e2d9fca6 /sys
parentc823f136df8d3fcfea6adfc6e87924357dacf3c8 (diff)
cwfs: initialize /env/timezone on boot so dumps are in localtime
when /env/timezone file is missing (boot case), copy /adm/timezone/local to /env/timezone so localtime() can correct timezone offset.
Diffstat (limited to 'sys')
-rw-r--r--sys/src/cmd/cwfs/con.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/src/cmd/cwfs/con.c b/sys/src/cmd/cwfs/con.c
index bace9df29..ea1154b58 100644
--- a/sys/src/cmd/cwfs/con.c
+++ b/sys/src/cmd/cwfs/con.c
@@ -7,6 +7,7 @@ static int whoflag;
static void consserve1(void *);
static void installcmds(void);
+static void tzinit(char*);
void
consserve(void)
@@ -599,6 +600,7 @@ cmd_remove(int argc, char *argv[])
static void
cmd_version(int, char *[])
{
+ tzinit("/adm/timezone/local");
print("%d-bit %s as of %T\n", sizeof(Off)*8 - 1, service, fs_mktime);
print("\tlast boot %T\n", boottime);
}
@@ -680,6 +682,28 @@ cmd_prof(int argc, char *argv[])
}
static void
+tzinit(char *file)
+{
+ char buf[1024];
+ Off o;
+ int f, n;
+
+ f = create("#e/timezone", OEXCL|OWRITE, 0666);
+ if(f < 0)
+ return;
+ if(walkto(file) || con_open(FID2, 0)) {
+ print("tzinit: cannot access %s\n", file);
+ close(f);
+ remove("#e/timezone");
+ return;
+ }
+ for(o = 0; (n = con_read(FID2, buf, o, sizeof(buf))) > 0; o += n)
+ write(f, buf, n);
+ close(f);
+}
+
+
+static void
cmd_time(int argc, char *argv[])
{
int i, len;