tbuild changes - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 6c0209f6f0eb41151397e4784730d2b6bca8d7ea
 (DIR) parent 7d59ed711467b2b2c8ac25f86724225c8be7524c
 (HTM) Author: rsc <devnull@localhost>
       Date:   Fri, 11 Feb 2005 20:32:41 +0000
       
       build changes
       
       Diffstat:
         M include/venti.h                     |      41 +++++++++++++++++++++++++++----
         M src/cmd/factotum/attr.c             |       2 ++
         M src/cmd/factotum/plan9.c            |      65 +------------------------------
         M src/cmd/tar.C                       |       2 +-
         M src/cmd/vac/vac.c                   |       2 ++
         M src/lib9p/mkfile                    |       1 -
         M src/libauthsrv/readnvram.c          |      90 ++++++--------------------------
         M src/libndb/ndbipinfo.c              |       1 -
         M src/mkmk.sh                         |       7 ++++++-
       
       9 files changed, 63 insertions(+), 148 deletions(-)
       ---
 (DIR) diff --git a/include/venti.h b/include/venti.h
       t@@ -4,6 +4,11 @@
        extern "C" { 
        #endif
        
       +#ifndef PLAN9PORT
       +#pragma lib "libventi.a"
       +#pragma src "/sys/src/libventi"
       +#endif
       +
        AUTOLIB(venti)
        
        /* XXX should be own library? */
       t@@ -38,12 +43,38 @@ int packetcmp(Packet*, Packet*);
        void packetstats(void);
        void packetsha1(Packet*, uchar sha1[20]);
        
       -/* XXX begin actual venti.h */
       +/* XXX should be own library? */
       +/*
       + * Logging
       + */
       +typedef struct VtLog VtLog;
       +typedef struct VtLogChunk VtLogChunk;
        
       -#ifndef PLAN9PORT
       -#pragma lib "libventi.a"
       -#pragma src "/sys/src/libventi"
       -#endif
       +struct VtLog
       +{
       +        VtLog *next;        /* in hash table */
       +        VtLogChunk *chunk;
       +        uint nchunk;
       +        VtLogChunk *w;
       +        QLock lk;
       +        int ref;
       +};
       +
       +struct VtLogchunk
       +{
       +        char *buf;
       +        uint nbuf;
       +        char *w;
       +};
       +
       +VtLog *vtlogopen(char *name, uint size);
       +void        vtlogprint(VtLog *log, char *fmt, ...);
       +void        vtlog(char *name, char *fmt, ...);
       +void        vtlogclose(char *name);
       +void        vtlogremove(char *name);
       +int        vtlogdump(int fd, VtLog*);
       +
       +/* XXX begin actual venti.h */
        
        typedef struct VtFcall VtFcall;
        typedef struct VtConn VtConn;
 (DIR) diff --git a/src/cmd/factotum/attr.c b/src/cmd/factotum/attr.c
       t@@ -130,6 +130,7 @@ attrnamefmt(Fmt *fmt)
                return fmtstrcpy(fmt, buf+1);
        }
        
       +/*
        static int
        hasqueries(Attr *a)
        {
       t@@ -138,6 +139,7 @@ hasqueries(Attr *a)
                                return 1;
                return 0;
        }
       +*/
        
        char *ignored[] = {
                "role",
 (DIR) diff --git a/src/cmd/factotum/plan9.c b/src/cmd/factotum/plan9.c
       t@@ -12,73 +12,10 @@ memrandom(void *p, int n)
                return 0;
        }
        
       -/*
       - *  create a change uid capability 
       - */
       -static int caphashfd = -1;
       -
       -static char*
       -mkcap(char *from, char *to)
       -{
       -        uchar rand[20];
       -        char *cap;
       -        char *key;
       -        int nfrom, nto;
       -        uchar hash[SHA1dlen];
       -
       -        if(caphashfd < 0)
       -                return nil;
       -
       -        /* create the capability */
       -        nto = strlen(to);
       -        nfrom = strlen(from);
       -        cap = emalloc(nfrom+1+nto+1+sizeof(rand)*3+1);
       -        sprint(cap, "%s@%s", from, to);
       -        memrandom(rand, sizeof(rand));
       -        key = cap+nfrom+1+nto+1;
       -        enc64(key, sizeof(rand)*3, rand, sizeof(rand));
       -
       -        /* hash the capability */
       -        hmac_sha1((uchar*)cap, strlen(cap), (uchar*)key, strlen(key), hash, nil);
       -
       -        /* give the kernel the hash */
       -        key[-1] = '@';
       -        if(write(caphashfd, hash, SHA1dlen) < 0){
       -                free(cap);
       -                return nil;
       -        }
       -
       -        return cap;
       -}
       -
        Attr*
        addcap(Attr *a, char *from, Ticket *t)
        {
       -        char *cap;
       -
       -        cap = mkcap(from, t->suid);
       -        return addattr(a, "cuid=%q suid=%q cap=%q", t->cuid, t->suid, cap);
       -}
       -
       -/* bind in the default network and cs */
       -static int
       -bindnetcs(void)
       -{
       -        int srvfd;
       -
       -        if(access("/net/tcp", AEXIST) < 0)
       -                bind("#I", "/net", MBEFORE);
       -
       -        if(access("/net/cs", AEXIST) < 0){
       -                if((srvfd = open("#s/cs", ORDWR)) >= 0){
       -                        /* mount closes srvfd on success */
       -                        if(mount(srvfd, -1, "/net", MBEFORE, "") >= 0)
       -                                return 0;
       -                        close(srvfd);
       -                }
       -                return -1;
       -        }
       -        return 0;
       +        return addattr(a, "cuid=%q suid=%q cap=''", t->cuid, t->suid);
        }
        
        int
 (DIR) diff --git a/src/cmd/tar.C b/src/cmd/tar.C
       t@@ -90,7 +90,7 @@ typedef union {
                };
        } Hdr;
        
       -static int debug;
       +int debug;
        static int verb;
        static int posix = 1;
        static int creat;
 (DIR) diff --git a/src/cmd/vac/vac.c b/src/cmd/vac/vac.c
       t@@ -400,6 +400,8 @@ vacfile(DirSink *dsink, char *lname, char *sname, VacFile *vf)
        
                if((dir = dirstat(sname)) == nil){
                        warn("could not stat file %s: %r", lname);
       +                return;
       +        }
                if(dir->mode&(DMSYMLINK|DMDEVICE|DMNAMEDPIPE|DMSOCKET)){
                        free(dir);
                        return;
 (DIR) diff --git a/src/lib9p/mkfile b/src/lib9p/mkfile
       t@@ -10,7 +10,6 @@ OFILES=\
                mem.$O\
                req.$O\
                parse.$O\
       -        post.$O\
                srv.$O\
                tpost.$O\
                uid.$O\
 (DIR) diff --git a/src/libauthsrv/readnvram.c b/src/libauthsrv/readnvram.c
       t@@ -41,80 +41,20 @@ static struct {
                "debug", "/tmp/nvram", 0, sizeof(Nvrsafe),
        };
        
       -static char*
       -readcons(char *prompt, char *def, int raw, char *buf, int nbuf)
       +char*
       +xreadcons(char *prompt, char *def, int secret, char *buf, int nbuf)
        {
       -        int fdin, fdout, ctl, n, m;
       -        char line[10];
       -
       -        fdin = open("/dev/cons", OREAD);
       -        if(fdin < 0)
       -                fdin = 0;
       -        fdout = open("/dev/cons", OWRITE);
       -        if(fdout < 0)
       -                fdout = 1;
       -        if(def != nil)
       -                fprint(fdout, "%s[%s]: ", prompt, def);
       -        else
       -                fprint(fdout, "%s: ", prompt);
       -        if(raw){
       -                ctl = open("/dev/consctl", OWRITE);
       -                if(ctl >= 0)
       -                        write(ctl, "rawon", 5);
       -        } else
       -                ctl = -1;
       -
       -        m = 0;
       -        for(;;){
       -                n = read(fdin, line, 1);
       -                if(n == 0){
       -                        close(ctl);
       -                        werrstr("readcons: EOF");
       -                        return nil;
       -                }
       -                if(n < 0){
       -                        close(ctl);
       -                        werrstr("can't read cons");
       -                        return nil;
       -                }
       -                if(line[0] == 0x7f)
       -                        exits(0);
       -                if(n == 0 || line[0] == '\n' || line[0] == '\r'){
       -                        if(raw){
       -                                write(ctl, "rawoff", 6);
       -                                write(fdout, "\n", 1);
       -                                close(ctl);
       -                        }
       -                        buf[m] = '\0';
       -                        if(buf[0]=='\0' && def)
       -                                strcpy(buf, def);
       -                        return buf;
       -                }
       -                if(line[0] == '\b'){
       -                        if(m > 0)
       -                                m--;
       -                }else if(line[0] == 0x15){        /* ^U: line kill */
       -                        m = 0;
       -                        if(def != nil)
       -                                fprint(fdout, "%s[%s]: ", prompt, def);
       -                        else
       -                                fprint(fdout, "%s: ", prompt);
       -                }else{
       -                        if(m >= nbuf-1){
       -                                fprint(fdout, "line too long\n");
       -                                m = 0;
       -                                if(def != nil)
       -                                        fprint(fdout, "%s[%s]: ", prompt, def);
       -                                else
       -                                        fprint(fdout, "%s: ", prompt);
       -                        }else
       -                                buf[m++] = line[0];
       -                }
       -        }
       -        return buf;        /* how does this happen */
       +        char *p;
       +        
       +        p = readcons(prompt, def, secret);
       +        if(p == nil)
       +                return nil;
       +        strecpy(buf, buf+nbuf, p);
       +        memset(p, 0, strlen(p));
       +        free(p);
       +        return buf;
        }
        
       -
        /*
         *  get key info out of nvram.  since there isn't room in the PC's nvram use
         *  a disk partition there.
       t@@ -210,11 +150,11 @@ readnvram(Nvrsafe *safep, int flag)
                }
        
                if((flag&NVwrite) || (err && (flag&NVwriteonerr))){
       -                readcons("authid", nil, 0, safe->authid, sizeof(safe->authid));
       -                readcons("authdom", nil, 0, safe->authdom, sizeof(safe->authdom));
       -                readcons("secstore key", nil, 1, safe->config, sizeof(safe->config));
       +                xreadcons("authid", nil, 0, safe->authid, sizeof(safe->authid));
       +                xreadcons("authdom", nil, 0, safe->authdom, sizeof(safe->authdom));
       +                xreadcons("secstore key", nil, 1, safe->config, sizeof(safe->config));
                        for(;;){
       -                        if(readcons("password", nil, 1, in, sizeof in) == nil)
       +                        if(xreadcons("password", nil, 1, in, sizeof in) == nil)
                                        goto Out;
                                if(passtokey(safe->machkey, in))
                                        break;
 (DIR) diff --git a/src/libndb/ndbipinfo.c b/src/libndb/ndbipinfo.c
       t@@ -14,7 +14,6 @@ enum
        static Ndbtuple*        filter(Ndb *db, Ndbtuple *t, Ndbtuple *f);
        static Ndbtuple*        mkfilter(int argc, char **argv);
        static int                filtercomplete(Ndbtuple *f);
       -static Ndbtuple*        toipaddr(Ndb *db, Ndbtuple *t);
        static int                prefixlen(uchar *ip);
        static Ndbtuple*        subnet(Ndb *db, uchar *net, Ndbtuple *f, int prefix);
        
 (DIR) diff --git a/src/mkmk.sh b/src/mkmk.sh
       t@@ -19,6 +19,7 @@ cd lib9
        9c  convM2S.c
        9c  convS2M.c
        9c  create.c
       +9c  crypt.c
        9c  ctime.c
        9c  date.c
        9c  dial.c
       t@@ -51,6 +52,7 @@ cd lib9
        9c  nan.c
        9c  needsrcquote.c
        9c  needstack.c
       +9c  netcrypt.c
        9c  netmkaddr.c
        9c  notify.c
        9c  nrand.c
       t@@ -64,14 +66,17 @@ cd lib9
        9c  quote.c
        9c  rand.c
        9c  read9pmsg.c
       +9c  readcons.c
        9c  readn.c
        9c  rfork.c
       +9c  searchpath.c
        9c  seek.c
        9c  sendfd.c
        9c  sleep.c
        9c  strdup.c
        9c  strecpy.c
        9c  sysfatal.c
       +9c  syslog.c
        9c  sysname.c
        9c  time.c
        9c  tokenize.c
       t@@ -135,7 +140,7 @@ cd lib9
        9c  utf/utfrrune.c
        9c  utf/utfrune.c
        9c  utf/utfutf.c
       -9ar rvc $PLAN9/lib/lib9.a _exits.o _p9dialparse.o _p9dir.o announce.o argv0.o atexit.o atoi.o atol.o atoll.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o create.o ctime.o date.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirread.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o execl.o fcallfmt.o get9root.o getcallerpc-$OBJTYPE.o getenv.o getfields.o getns.o getuser.o getwd.o jmp.o lrand.o lnrand.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o needstack.o netmkaddr.o notify.o nrand.o nulldir.o open.o opentemp.o pipe.o post9p.o postnote.o qlock.o quote.o rand.o read9pmsg.o readn.o rfork.o seek.o sendfd.o sleep.o strdup.o strecpy.o sysfatal.o sysname.o time.o tokenize.o truerand.o u16.o u32.o u64.o unsharp.o wait.o waitpid.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlock2.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o
       +9ar rvc $PLAN9/lib/lib9.a _exits.o _p9dialparse.o _p9dir.o announce.o argv0.o atexit.o atoi.o atol.o atoll.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o create.o crypt.o ctime.o date.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirread.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o execl.o fcallfmt.o get9root.o getcallerpc-$OBJTYPE.o getenv.o getfields.o getns.o getuser.o getwd.o jmp.o lrand.o lnrand.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o needstack.o netcrypt.o netmkaddr.o notify.o nrand.o nulldir.o open.o opentemp.o pipe.o post9p.o postnote.o qlock.o quote.o rand.o read9pmsg.o readcons.o readn.o rfork.o searchpath.o seek.o sendfd.o sleep.o strdup.o strecpy.o sysfatal.o syslog.o sysname.o time.o tokenize.o truerand.o u16.o u32.o u64.o unsharp.o wait.o waitpid.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlock2.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o
        cd ..
        cd libbio
        9c  bbuffered.c