ref: 57e1959e5973841f4b91e004b283eed9a1076a51
parent: 19c1e356756072a514d155e0b7f757158d11e60f
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Sep 11 23:58:46 EDT 2015
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.
--- a/sys/src/cmd/cwfs/con.c
+++ b/sys/src/cmd/cwfs/con.c
@@ -7,6 +7,7 @@
static void consserve1(void *);
static void installcmds(void);
+static void tzinit(char*);
void
consserve(void)
@@ -599,6 +600,7 @@
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);}
@@ -678,6 +680,28 @@
return;
}
}
+
+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[])
--
⑨