sync nix boot directory Reference: /n/atom/patch/applied/nixbootsync Date: Thu Apr 17 22:33:07 CES 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/nix/boot/bootauth.c Thu Apr 17 22:33:07 2014 +++ /sys/src/nix/boot/bootauth.c Thu Apr 17 22:33:07 2014 @@ -10,7 +10,7 @@ void authentication(int cpuflag) { - char *argv[16], **av; + char *s, *argv[16], **av; int ac; if(access("/boot/factotum", AEXEC) < 0){ @@ -24,6 +24,9 @@ av[ac++] = "factotum"; if(getenv("debugfactotum")) av[ac++] = "-p"; + s = getenv("factotumopts"); + if(s != nil && *s != '\0') + av[ac++] = s; // av[ac++] = "-d"; /* debug traces */ // av[ac++] = "-D"; /* 9p messages */ if(cpuflag) @@ -38,12 +41,10 @@ av[ac] = 0; switch(fork()){ case -1: - fatal("starting factotum"); + fatal("starting factotum: %r"); case 0: exec("/boot/factotum", av); fatal("execing /boot/factotum"); - default: - break; } /* wait for agent to really be there */ --- /sys/src/nix/boot/bootip.c Thu Apr 17 22:33:07 2014 +++ /sys/src/nix/boot/bootip.c Thu Apr 17 22:33:07 2014 @@ -12,7 +12,6 @@ static void netndb(char*, uchar*); static void netenv(char*, uchar*); - void configip(int bargc, char **bargv, int needfs) { @@ -26,11 +25,11 @@ arg = malloc((bargc+1) * sizeof(char*)); if(arg == nil) - fatal("malloc"); + fatal("%r"); memmove(arg, bargv, bargc * sizeof(char*)); arg[bargc] = 0; -print("ipconfig..."); + print("ipconfig..."); argc = bargc; argv = arg; strcpy(mpoint, "/net"); @@ -68,7 +67,7 @@ /* let ipconfig configure the ip interface */ switch(pid = fork()){ case -1: - fatal("fork configuring ip"); + fatal("fork configuring ip: %r"); case 0: exec("/boot/ipconfig", arg); fatal("execing /ipconfig"); @@ -139,8 +138,8 @@ int connecttcp(void) { - int fd; char buf[64]; + int fd; snprint(buf, sizeof buf, "tcp!%I!564", fsip); fd = dial(buf, 0, 0, 0); --- /sys/src/nix/boot/getpasswd.c Thu Apr 17 22:33:07 2014 +++ /sys/src/nix/boot/getpasswd.c Thu Apr 17 22:33:07 2014 @@ -12,7 +12,7 @@ if(fd < 0) fatal("can't open consctl; please reboot"); write(fd, "rawon", 5); - Prompt: +Prompt: print("password: "); n = 0; for(;;){ --- /sys/src/nix/boot/part.c Thu Apr 17 22:33:07 2014 +++ /sys/src/nix/boot/part.c Thu Apr 17 22:33:07 2014 @@ -229,7 +229,7 @@ static void partitions0(char *s, int l) { - char *p, *f[3], buf[20]; + char *p, *q, *f[3], buf[20]; int i; Dev d; @@ -240,6 +240,11 @@ if(tokenize(s, f, nelem(f)) < 1) continue; for(i = 0; i < 0x10; i++){ + snprint(buf, sizeof buf, "%s%xpart", f[0], i); + if((q = getenv(buf)) != nil){ + free(q); + continue; + } d.fd[0] = -1; d.fd[1] = -1; snprint(d.dev, sizeof d.dev, "#S/%s%x", f[0], i); --- /sys/src/nix/boot/settime.c Thu Apr 17 22:33:07 2014 +++ /sys/src/nix/boot/settime.c Thu Apr 17 22:33:07 2014 @@ -4,7 +4,7 @@ #include #include "../boot/boot.h" -static long lusertime(char*); +static long lusertime(char*, int); char *timeserver = "#s/boot"; @@ -12,7 +12,7 @@ settime(int islocal, int afd, char *rp) { int n, f; - Dir dir[2]; + Dir *dir; char timebuf[64]; static int timeset; @@ -33,7 +33,7 @@ }else do{ strcpy(timebuf, "yymmddhhmm[ss]"); outin("\ndate/time ", timebuf, sizeof(timebuf)); - }while((timeset=lusertime(timebuf)) <= 0); + }while((timeset=lusertime(timebuf, sizeof timebuf)) <= 0); } if(timeset == 0){ /* @@ -48,10 +48,10 @@ return; } close(f); - if(stat("/tmp", statbuf, sizeof statbuf) < 0) + if((dir = dirstat("/tmp")) == nil) fatal("stat"); - convM2D(statbuf, sizeof statbuf, &dir[0], (char*)&dir[1]); - sprint(timebuf, "%ld", dir[0].atime); + snprint(timebuf, sizeof timebuf, "%ld", dir->atime); + free(dir); unmount(0, "/tmp"); } @@ -105,7 +105,7 @@ * compute seconds since Jan 1 1970 */ static long -lusertime(char *argbuf) +lusertime(char *argbuf, int bufsz) { char *buf; ulong secs; @@ -145,6 +145,6 @@ if(*buf) secs += g2(&buf); - sprint(argbuf, "%ld", secs); + snprint(argbuf, bufsz, "%ld", secs); return secs; }