# HG changeset patch # User David du Colombier <0intro@gmail.com> # Date 1377813600 -7200 # Node ID 94c3cc32b3d548756fe2c5621a8f141475f60558 # Parent 664ed2209ae41aa25abc4b76f73c7efbb6112097 fossil: required changes on fossil diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/9p.c --- a/src/cmd/fossil/9p.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/9p.c Fri Aug 30 00:00:00 2013 +0200 @@ -935,6 +935,7 @@ *path = ""; } +#ifndef PLAN9PORT /* * Check remote IP address against /mnt/ipok. * Sources.cs.bell-labs.com uses this to disallow @@ -972,6 +973,7 @@ } return 1; } +#endif static int rTattach(Msg* m) @@ -996,12 +998,14 @@ else fid->uname = vtstrdup(unamenone); +#ifndef PLAN9PORT if((fid->con->flags&ConIPCheck) && !conIPCheck(fid->con)){ consPrint("reject %s from %s: %r\n", fid->uname, fid->con->remote); fidClunk(fid); vtfree(fsname); return 0; } +#endif if(fsysNoAuthCheck(fsys) || (m->con->flags&ConNoAuthCheck)){ if((fid->uid = uidByUname(fid->uname)) == nil) fid->uid = vtstrdup(unamenone); @@ -1032,7 +1036,9 @@ static int rTauth(Msg* m) { +#ifndef PLAN9PORT int afd; +#endif Con *con; Fid *afid; Fsys *fsys; @@ -1064,13 +1070,20 @@ } afid->fsys = fsys; +#ifndef PLAN9PORT if((afd = open("/mnt/factotum/rpc", ORDWR)) < 0){ werrstr("can't open \"/mnt/factotum/rpc\""); fidClunk(afid); return 0; } +#endif + +#ifdef PLAN9PORT + if((afid->rpc = auth_allocrpc()) == nil){ +#else if((afid->rpc = auth_allocrpc(afd)) == nil){ close(afd); +#endif werrstr("can't auth_allocrpc"); fidClunk(afid); return 0; diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/9proc.c --- a/src/cmd/fossil/9proc.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/9proc.c Fri Aug 30 00:00:00 2013 +0200 @@ -250,12 +250,13 @@ } static void -msgProc(void*) +msgProc(void* v) { Msg *m; char e[ERRMAX]; Con *con; + USED(v); threadsetname("msgProc"); for(;;){ diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/9srv.c --- a/src/cmd/fossil/9srv.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/9srv.c Fri Aug 30 00:00:00 2013 +0200 @@ -20,6 +20,7 @@ Srv* tail; } sbox; +#ifndef PLAN9PORT static int srvFd(char* name, int mode, int fd, char** mntpnt) { @@ -54,6 +55,7 @@ return srvfd; } +#endif static void srvFree(Srv* srv) @@ -100,7 +102,12 @@ break; } +#ifdef PLAN9PORT + mntpnt = nil; + if((srvfd = post9pservice(fd, service, mntpnt)) < 0){ +#else if((srvfd = srvFd(service, mode, fd, &mntpnt)) < 0){ +#endif wunlock(&sbox.lock); return nil; } @@ -203,6 +210,11 @@ return 1; } +#ifdef PLAN9PORT /* fossilcons unsupported */ + if(pflag) + return 1; +#endif + if(pipe(fd) < 0){ werrstr("srv pipe: %r"); return 0; diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/9user.c --- a/src/cmd/fossil/9user.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/9user.c Fri Aug 30 00:00:00 2013 +0200 @@ -338,7 +338,11 @@ validUserName(char* name) { Rune *r; +#ifdef PLAN9PORT + static Rune invalid[] = {'#', ':', ',', '(', ')', '\0'}; +#else static Rune invalid[] = L"#:,()"; +#endif for(r = invalid; *r != '\0'; r++){ if(utfrune(name, *r)) diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/Ccmd.c --- a/src/cmd/fossil/Ccmd.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/Ccmd.c Fri Aug 30 00:00:00 2013 +0200 @@ -27,19 +27,22 @@ } static int -cmd9pTag(Fcall*, int, char **argv) +cmd9pTag(Fcall* f, int i, char **argv) { + USED(f); + USED(i); cbox.tag = strtoul(argv[0], 0, 0)-1; return 1; } static int -cmd9pTwstat(Fcall* f, int, char **argv) +cmd9pTwstat(Fcall* f, int i, char **argv) { Dir d; static uchar buf[DIRMAX]; + USED(i); memset(&d, 0, sizeof d); nulldir(&d); d.name = argv[1]; @@ -61,32 +64,36 @@ } static int -cmd9pTstat(Fcall* f, int, char** argv) +cmd9pTstat(Fcall* f, int i, char** argv) { + USED(i); f->fid = strtol(argv[0], 0, 0); return 1; } static int -cmd9pTremove(Fcall* f, int, char** argv) +cmd9pTremove(Fcall* f, int i, char** argv) { + USED(i); f->fid = strtol(argv[0], 0, 0); return 1; } static int -cmd9pTclunk(Fcall* f, int, char** argv) +cmd9pTclunk(Fcall* f, int i, char** argv) { + USED(i); f->fid = strtol(argv[0], 0, 0); return 1; } static int -cmd9pTwrite(Fcall* f, int, char** argv) +cmd9pTwrite(Fcall* f, int i, char** argv) { + USED(i); f->fid = strtol(argv[0], 0, 0); f->offset = strtoll(argv[1], 0, 0); f->data = argv[2]; @@ -96,8 +103,9 @@ } static int -cmd9pTread(Fcall* f, int, char** argv) +cmd9pTread(Fcall* f, int i, char** argv) { + USED(i); f->fid = strtol(argv[0], 0, 0); f->offset = strtoll(argv[1], 0, 0); f->count = strtol(argv[2], 0, 0); @@ -106,8 +114,9 @@ } static int -cmd9pTcreate(Fcall* f, int, char** argv) +cmd9pTcreate(Fcall* f, int i, char** argv) { + USED(i); f->fid = strtol(argv[0], 0, 0); f->name = argv[1]; f->perm = strtol(argv[2], 0, 8); @@ -117,8 +126,9 @@ } static int -cmd9pTopen(Fcall* f, int, char** argv) +cmd9pTopen(Fcall* f, int i, char** argv) { + USED(i); f->fid = strtol(argv[0], 0, 0); f->mode = strtol(argv[1], 0, 0); @@ -148,16 +158,18 @@ } static int -cmd9pTflush(Fcall* f, int, char** argv) +cmd9pTflush(Fcall* f, int i, char** argv) { + USED(i); f->oldtag = strtol(argv[0], 0, 0); return 1; } static int -cmd9pTattach(Fcall* f, int, char** argv) +cmd9pTattach(Fcall* f, int i, char** argv) { + USED(i); f->fid = strtol(argv[0], 0, 0); f->afid = strtol(argv[1], 0, 0); f->uname = argv[2]; @@ -167,8 +179,9 @@ } static int -cmd9pTauth(Fcall* f, int, char** argv) +cmd9pTauth(Fcall* f, int i, char** argv) { + USED(i); f->afid = strtol(argv[0], 0, 0); f->uname = argv[1]; f->aname = argv[2]; @@ -177,8 +190,9 @@ } static int -cmd9pTversion(Fcall* f, int, char** argv) +cmd9pTversion(Fcall* f, int i, char** argv) { + USED(i); f->msize = strtoul(argv[0], 0, 0); if(f->msize > cbox.con->msize){ werrstr("msize too big"); @@ -420,6 +434,7 @@ if(argc != 2 || (flag&MAFTER)&&(flag&MBEFORE)) return cliError(usage); +#ifndef PLAN9PORT if(bind(argv[0], argv[1], flag) < 0){ /* try to give a less confusing error than the default */ if(access(argv[0], 0) < 0) @@ -429,6 +444,7 @@ else return cliError("bind %s %s: %r", argv[0], argv[1]); } +#endif return 1; } diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/Ccons.c --- a/src/cmd/fossil/Ccons.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/Ccons.c Fri Aug 30 00:00:00 2013 +0200 @@ -221,8 +221,9 @@ } static void -consProc(void*) +consProc(void* v) { + USED(v); Q *q; int argc, i, n, r; char *argv[20], buf[Nq], *lp, *wbuf; @@ -345,13 +346,21 @@ name = "/dev/cons"; if((fd = open(name, ORDWR)) < 0){ +#ifdef PLAN9PORT + name = "/dev/tty"; +#else name = "#c/cons"; +#endif if((fd = open(name, ORDWR)) < 0){ werrstr("consTTY: open %s: %r", name); return 0; } } +#ifdef PLAN9PORT + USED(p); + ctl = 0; +#else p = smprint("%sctl", name); if((ctl = open(p, OWRITE)) < 0){ close(fd); @@ -367,6 +376,7 @@ return 0; } free(p); +#endif if(consOpen(fd, fd, ctl) == 0){ close(ctl); diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/check.c --- a/src/cmd/fossil/check.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/check.c Fri Aug 30 00:00:00 2013 +0200 @@ -778,22 +778,34 @@ } static void -clrenop(Fsck*, Block*, int) +clrenop(Fsck *chk, Block *b, int i) { + USED(chk); + USED(b); + USED(i); } static void -closenop(Fsck*, Block*, u32int) +closenop(Fsck *chk, Block *b, u32int i) { + USED(chk); + USED(b); + USED(i); } static void -clrinop(Fsck*, char*, MetaBlock*, int, Block*) +clrinop(Fsck *chk, char *c, MetaBlock *mb, int i, Block *b) { + USED(chk); + USED(c); + USED(mb); + USED(i); + USED(b); } static int -printnop(char*, ...) +printnop(char *c, ...) { + USED(c); return 0; } diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/conf.rc --- a/src/cmd/fossil/conf.rc Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/conf.rc Fri Aug 30 00:00:00 2013 +0200 @@ -1,4 +1,4 @@ -#!/bin/rc +#!/usr/local/plan9/bin/rc # the fossil configuration is stored at the 127kB offset in the disk # and extends for at most 1 kB. @@ -28,7 +28,7 @@ usage disk=$1 -if(! test -f $disk){ +if(! 9 test -f $disk){ echo 'unknown disk' $1 >[1=2] exit nodisk } @@ -39,24 +39,24 @@ if(~ $wflag yes){ {echo fossil config; cat $2} >/tmp/fossilconf.$pid || exit oops - if(! test -s /tmp/fossilconf.$pid){ + if(! 9 test -s /tmp/fossilconf.$pid){ echo 'config is empty; will not install' >[1=2] exit emptyconfig } - if(test `{ls -l /tmp/fossilconf.$pid | awk '{print $6}'} -gt 1024){ + if(9 test `{9 ls -l /tmp/fossilconf.$pid | awk '{print $6}'} -gt 1024){ echo 'config is too long; max is a little less than a kilobyte' >[1=2] exit toolong } - dd -quiet 1 -bs 1024 -count 1 -if $disk -iseek 127 \ + 9 dd -quiet 1 -bs 1024 -count 1 -if $disk -iseek 127 \ >/tmp/_fossilconf.old || exit backup - dd -quiet 1 -count 2 >/tmp/fossilconf.$pid || exit dd - dd -quiet 1 -bs 1024 -count 1 -if /tmp/fossilconf.$pid \ + 9 dd -quiet 1 -count 2 >/tmp/fossilconf.$pid || exit dd + 9 dd -quiet 1 -bs 1024 -count 1 -if /tmp/fossilconf.$pid \ -trunc 0 -of $disk -oseek 127 || exit dd2 exit 0 } -dd -quiet 1 -bs 1024 -count 1 -if $disk -iseek 127 | - aux/zerotrunc >/tmp/fossilconf.$pid +9 dd -quiet 1 -bs 1024 -count 1 -if $disk -iseek 127 | + zerotrunc >/tmp/fossilconf.$pid if(! cmp -s <{sed 1q /tmp/fossilconf.$pid} <{echo fossil config}){ echo 'config has bad header' >[1=2] diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/dat.h --- a/src/cmd/fossil/dat.h Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/dat.h Fri Aug 30 00:00:00 2013 +0200 @@ -328,4 +328,4 @@ PartVenti, /* fake partition */ }; -extern vtType[BtMax]; +extern int vtType[BtMax]; diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/disk.c --- a/src/cmd/fossil/disk.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/disk.c Fri Aug 30 00:00:00 2013 +0200 @@ -288,8 +288,10 @@ { static char buf[256]; +#ifndef PLAN9PORT if (fd2path(disk->fd, buf, sizeof buf) < 0) strncpy(buf, "GOK", sizeof buf); +#endif return buf; } diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/flchk.c --- a/src/cmd/fossil/flchk.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/flchk.c Fri Aug 30 00:00:00 2013 +0200 @@ -28,26 +28,33 @@ } static void -flclre(Fsck*, Block *b, int o) +flclre(Fsck *chk, Block *b, int o) { + USED(chk); Bprint(&bout, "# clre 0x%ux %d\n", b->addr, o); } static void -flclrp(Fsck*, Block *b, int o) +flclrp(Fsck *chk, Block *b, int o) { + USED(chk); Bprint(&bout, "# clrp 0x%ux %d\n", b->addr, o); } static void -flclri(Fsck*, char *name, MetaBlock*, int, Block*) +flclri(Fsck *chk, char *name, MetaBlock *mb, int i, Block *b) { + USED(chk); + USED(mb); + USED(i); + USED(b); Bprint(&bout, "# clri %s\n", name); } static void -flclose(Fsck*, Block *b, u32int epoch) +flclose(Fsck *chk, Block *b, u32int epoch) { + USED(chk); Bprint(&bout, "# bclose 0x%ux %ud\n", b->addr, epoch); } diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/fossil.c --- a/src/cmd/fossil/fossil.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/fossil.c Fri Aug 30 00:00:00 2013 +0200 @@ -73,7 +73,11 @@ /* * Insulate from the invoker's environment. */ +#ifdef PLAN9PORT + if(rfork(RFNAMEG) < 0) +#else if(rfork(RFREND|RFNOTEG|RFNAMEG) < 0) +#endif sysfatal("rfork: %r"); close(0); diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/mkfile --- a/src/cmd/fossil/mkfile Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/mkfile Fri Aug 30 00:00:00 2013 +0200 @@ -1,5 +1,6 @@ -$target && chmod +x $target + +clean: + rm -f $LIB + +nuke: clean diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/nobwatch.c --- a/src/cmd/fossil/nobwatch.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/nobwatch.c Fri Aug 30 00:00:00 2013 +0200 @@ -15,8 +15,9 @@ } void -bwatchSetBlockSize(uint) +bwatchSetBlockSize(uint i) { + USED(i); } void diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/stdinc.h --- a/src/cmd/fossil/stdinc.h Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/stdinc.h Fri Aug 30 00:00:00 2013 +0200 @@ -2,10 +2,9 @@ #include #include #include - -typedef uvlong u64int; -typedef uchar u8int; -typedef ushort u16int; +#ifdef PLAN9PORT +#include <9pclient.h> +#endif #include "venti.h" #include "vac.h" diff -r 664ed2209ae4 -r 94c3cc32b3d5 src/cmd/fossil/view.c --- a/src/cmd/fossil/view.c Fri Aug 30 00:00:00 2013 +0200 +++ b/src/cmd/fossil/view.c Fri Aug 30 00:00:00 2013 +0200 @@ -463,7 +463,7 @@ typedef struct Xblock Xblock; struct Xblock { - Tnode; + Tnode *t; Block *b; int (*gen)(void*, Block*, int, Tnode**); void *arg; @@ -478,57 +478,58 @@ Xblock *t = (Xblock*)tt; Tnode *nn; - if(t->nkid >= 0) + if(t->t->nkid >= 0) return; j = 0; if(t->printlabel){ - t->kid = mallocz(Q*sizeof(t->kid[0]), 1); - t->kid[0] = initxlabel(t->b->l); + t->t->kid = mallocz(Q*sizeof(t->t->kid[0]), 1); + t->t->kid[0] = initxlabel(t->b->l); j = 1; } for(i=0;; i++){ switch((*t->gen)(t->arg, t->b, i, &nn)){ case -1: - t->nkid = j; + t->t->nkid = j; return; case 0: break; case 1: if(j%Q == 0) - t->kid = realloc(t->kid, (j+Q)*sizeof(t->kid[0])); - t->kid[j++] = nn; + t->t->kid = realloc(t->t->kid, (j+Q)*sizeof(t->t->kid[0])); + t->t->kid[j++] = nn; break; } } } int -nilgen(void*, Block*, int, Tnode**) +nilgen(void *v, Block *b, int o, Tnode **tp) { return -1; } Tnode* -initxblock(Block *b, char *s, int (*gen)(void*, Block*, int, Tnode**), void *arg) +initxblock(Block *b, char *s, int (*gen)(void *v, Block *b, int o, Tnode **tp), void *arg) { Xblock *t; if(gen == nil) gen = nilgen; t = mallocz(sizeof(Xblock), 1); + t->t = mallocz(sizeof(Tnode), 1); t->b = b; t->gen = gen; t->arg = arg; if(b->addr == NilBlock) - t->str = smprint("Block %V: %s", b->score, s); + t->t->str = smprint("Block %V: %s", b->score, s); else - t->str = smprint("Block %#ux: %s", b->addr, s); + t->t->str = smprint("Block %#ux: %s", b->addr, s); t->printlabel = 1; - t->nkid = -1; - t->expand = xblockexpand; - return t; + t->t->nkid = -1; + t->t->expand = xblockexpand; + return t->t; } int @@ -557,7 +558,7 @@ typedef struct Xentry Xentry; struct Xentry { - Tnode; + Tnode *t; Entry e; }; @@ -566,12 +567,12 @@ { Xentry *t = (Xentry*)tt; - if(t->nkid >= 0) + if(t->t->nkid >= 0) return; - t->nkid = 1; - t->kid = mallocz(sizeof(t->kid[0])*t->nkid, 1); - t->kid[0] = initxsource(t->e, 1); + t->t->nkid = 1; + t->t->kid = mallocz(sizeof(t->t->kid[0])*t->t->nkid, 1); + t->t->kid[0] = initxsource(t->e, 1); } Tnode* @@ -580,14 +581,15 @@ Xentry *t; t = mallocz(sizeof *t, 1); - t->nkid = -1; - t->str = smprint("Entry gen=%#ux psize=%d dsize=%d depth=%d flags=%#ux size=%lld score=%V", + t->t = mallocz(sizeof(Tnode), 1); + t->t->nkid = -1; + t->t->str = smprint("Entry gen=%#ux psize=%d dsize=%d depth=%d flags=%#ux size=%lld score=%V", e.gen, e.psize, e.dsize, e.depth, e.flags, e.size, e.score); if(e.flags & VtEntryLocal) - t->str = smprint("%s archive=%d snap=%d tag=%#ux", t->str, e.archive, e.snap, e.tag); - t->expand = xentryexpand; + t->t->str = smprint("%s archive=%d snap=%d tag=%#ux", t->t->str, e.archive, e.snap, e.tag); + t->t->expand = xentryexpand; t->e = e; - return t; + return t->t; } int @@ -659,7 +661,7 @@ } int -xlocalrootgen(void*, Block *b, int o, Tnode **tp) +xlocalrootgen(void *v, Block *b, int o, Tnode **tp) { Entry e; @@ -684,7 +686,7 @@ } int -xvacrootgen(void*, Block *b, int o, Tnode **tp) +xvacrootgen(void *v, Block *b, int o, Tnode **tp) { Entry e; @@ -734,7 +736,7 @@ } int -metaentrygen(void *v, Block*, int o, Tnode **tp) +metaentrygen(void *v, Block *b, int o, Tnode **tp) { Tnode *t; MetaBlock *mb; @@ -765,11 +767,11 @@ /* hack: reuse initxblock as a generic iterator */ mb = v; t = (Xblock*)initxblock(b, "", metaentrygen, mb); - t->str = smprint("MetaBlock %d/%d space used, %d add'l free %d/%d table used%s", + t->t->str = smprint("MetaBlock %d/%d space used, %d add'l free %d/%d table used%s", mb->size, mb->maxsize, mb->free, mb->nindex, mb->maxindex, mb->botch ? " [BOTCH]" : ""); t->printlabel = 0; - *tp = t; + *tp = t->t; return 1; }