Commits

David du Colombier  committed 7d8e2ec

fossil: required p9p changes

R=rsc
https://codereview.appspot.com/13352057

  • Participants
  • Parent commits 35cedd3

Comments (0)

Files changed (15)

File src/cmd/fossil/9p.c

 		*path = "";
 }
 
+#ifndef PLAN9PORT
 /*
  * Check remote IP address against /mnt/ipok.
  * Sources.cs.bell-labs.com uses this to disallow
 	}
 	return 1;
 }
+#endif
 
 static int
 rTattach(Msg* m)
 	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);
 static int
 rTauth(Msg* m)
 {
+#ifndef PLAN9PORT
 	int afd;
+#endif
 	Con *con;
 	Fid *afid;
 	Fsys *fsys;
 	}
 	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;

File src/cmd/fossil/9proc.c

 }
 
 static void
-msgProc(void*)
+msgProc(void* v)
 {
 	Msg *m;
 	char e[ERRMAX];
 	Con *con;
 
+	USED(v);
 	threadsetname("msgProc");
 
 	for(;;){

File src/cmd/fossil/9srv.c

 	Srv*	tail;
 } sbox;
 
+#ifndef PLAN9PORT
 static int
 srvFd(char* name, int mode, int fd, char** mntpnt)
 {
 
 	return srvfd;
 }
+#endif
 
 static void
 srvFree(Srv* srv)
 		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;
 	}
 		return 1;
 	}
 
+#ifdef PLAN9PORT	/* fossilcons unsupported */
+	if(pflag)
+		return 1;
+#endif
+
 	if(pipe(fd) < 0){
 		werrstr("srv pipe: %r");
 		return 0;

File src/cmd/fossil/9user.c

 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))

File src/cmd/fossil/Ccmd.c

 }
 
 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];
 }
 
 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];
 }
 
 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);
 }
 
 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);
 }
 
 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);
 
 }
 
 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];
 }
 
 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];
 }
 
 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");
 	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)
 		else
 			return cliError("bind %s %s: %r", argv[0], argv[1]);
 	}
+#endif
 	return 1;
 }
 

File src/cmd/fossil/Ccons.c

 }
 
 static void
-consProc(void*)
+consProc(void* v)
 {
+	USED(v);
 	Q *q;
 	int argc, i, n, r;
 	char *argv[20], buf[Nq], *lp, *wbuf;
 
 	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);
 		return 0;
 	}
 	free(p);
+#endif
 
 	if(consOpen(fd, fd, ctl) == 0){
 		close(ctl);

File src/cmd/fossil/check.c

 }
 
 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;
 }

File src/cmd/fossil/dat.h

 	PartVenti,	/* fake partition */
 };
 
-extern vtType[BtMax];
+extern int vtType[BtMax];

File src/cmd/fossil/disk.c

 {
 	static char buf[256];
 
+#ifndef PLAN9PORT
 	if (fd2path(disk->fd, buf, sizeof buf) < 0)
 		strncpy(buf, "GOK", sizeof buf);
+#endif
 	return buf;
 }
 

File src/cmd/fossil/flchk.c

 }
 
 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);
 }
 

File src/cmd/fossil/fossil.c

 	/*
 	 * 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);

File src/cmd/fossil/mkfile

-</$objtype/mkfile
-BIN=/$objtype/bin/fossil
+<$PLAN9/src/mkhdr
+MKSHELL=$PLAN9/bin/rc
+BIN=$BIN/fossil
 
 TARG=fossil flchk flfmt conf last view
 
 
 LIBCFILES=${LIBFILES:%=%.c}
 LIBOFILES=${LIBFILES:%=%.$O}
-LIB=libfs.a$O
+LIB=libfs.a
 
 HFILES=\
-	/sys/include/venti.h\
+	$PLAN9/include/venti.h\
 	stdinc.h\
 	vac.h\
 	dat.h\
 #	unmount /n/fossil
 #	rm /srv/fossil
 
-</sys/src/cmd/mkmany
+<$PLAN9/src/mkmany
 
 $LIB(%.$O):N: %.$O
 $LIB:	${LIBOFILES:%=$LIB(%)}
-	names = `{echo $newprereq |sed 's/ /\n/g' |sed -n 's/'$LIB'\(([^)]+)\)/\1/gp'}
-	ar vu $LIB $names
+	names = `{echo $newprereq |sed 's/ /\n/g' |9 sed -n 's/'$LIB'\(([^)]+)\)/\1/gp'}
+	$AR rsc $LIB $names
 #	rm $names
 
 $O.flfmt: flfmt9660.$O
 
 $O.conf:D: conf.rc
 	{
-		echo '#!/bin/rc'
+		echo '#!/usr/local/plan9/bin/rc'
 		echo '# THIS FILE IS AUTOMATICALLY GENERATED'
-		echo '# FROM /sys/src/cmd/fossil/conf.rc.  DO NOT EDIT.'
+		echo '# FROM /usr/local/plan9/src/cmd/fossil/conf.rc.  DO NOT EDIT.'
 		echo 
 		sed 1d conf.rc
 	} >$target && chmod +x $target
+
+clean:
+	rm -f $LIB
+
+nuke: clean

File src/cmd/fossil/nobwatch.c

 }
 
 void
-bwatchSetBlockSize(uint)
+bwatchSetBlockSize(uint i)
 {
+	USED(i);
 }
 
 void

File src/cmd/fossil/stdinc.h

 #include <libc.h>
 #include <libsec.h>
 #include <thread.h>
-
-typedef uvlong	u64int;
-typedef	uchar	u8int;
-typedef ushort	u16int;
+#ifdef PLAN9PORT
+#include <9pclient.h>
+#endif
 
 #include "venti.h"
 #include "vac.h"

File src/cmd/fossil/view.c

 typedef struct Xblock Xblock;
 struct Xblock
 {
-	Tnode;
+	Tnode *t;
 	Block *b;
 	int (*gen)(void*, Block*, int, Tnode**);
 	void *arg;
 	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
 typedef struct Xentry Xentry;
 struct Xentry 
 {
-	Tnode;
+	Tnode *t;
 	Entry e;
 };
 
 {
 	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*
 	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
 }
 
 int
-xlocalrootgen(void*, Block *b, int o, Tnode **tp)
+xlocalrootgen(void *v, Block *b, int o, Tnode **tp)
 {
 	Entry e;
 
 }
 
 int
-xvacrootgen(void*, Block *b, int o, Tnode **tp)
+xvacrootgen(void *v, Block *b, int o, Tnode **tp)
 {
 	Entry e;
 
 }
 
 int
-metaentrygen(void *v, Block*, int o, Tnode **tp)
+metaentrygen(void *v, Block *b, int o, Tnode **tp)
 {
 	Tnode *t;
 	MetaBlock *mb;
 	/* 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;
 }