fossil: required p9p changes

R=rsc
https://codereview.appspot.com/13352057
This commit is contained in:
David du Colombier 2013-09-26 20:12:45 +02:00
parent 4b57665805
commit b32de4ae73
15 changed files with 156 additions and 67 deletions

View file

@ -935,6 +935,7 @@ parseAname(char *aname, char **fsname, char **path)
*path = "";
}
#ifndef PLAN9PORT
/*
* Check remote IP address against /mnt/ipok.
* Sources.cs.bell-labs.com uses this to disallow
@ -972,6 +973,7 @@ conIPCheck(Con* con)
}
return 1;
}
#endif
static int
rTattach(Msg* m)
@ -996,12 +998,14 @@ 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);
@ -1032,7 +1036,9 @@ rTattach(Msg* m)
static int
rTauth(Msg* m)
{
#ifndef PLAN9PORT
int afd;
#endif
Con *con;
Fid *afid;
Fsys *fsys;
@ -1064,13 +1070,20 @@ rTauth(Msg* m)
}
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;

View file

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

View file

@ -20,6 +20,7 @@ static struct {
Srv* tail;
} sbox;
#ifndef PLAN9PORT
static int
srvFd(char* name, int mode, int fd, char** mntpnt)
{
@ -54,6 +55,7 @@ srvFd(char* name, int mode, int fd, char** mntpnt)
return srvfd;
}
#endif
static void
srvFree(Srv* srv)
@ -100,7 +102,12 @@ srvAlloc(char* service, int mode, int fd)
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 @@ cmdSrv(int argc, char* argv[])
return 1;
}
#ifdef PLAN9PORT /* fossilcons unsupported */
if(pflag)
return 1;
#endif
if(pipe(fd) < 0){
werrstr("srv pipe: %r");
return 0;

View file

@ -338,7 +338,11 @@ int
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))

View file

@ -27,19 +27,22 @@ cmd9pStrtoull(char* s)
}
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 @@ cmd9pTwstat(Fcall* f, int, char **argv)
}
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 @@ cmd9pTwrite(Fcall* f, int, char** argv)
}
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 @@ cmd9pTread(Fcall* f, int, char** argv)
}
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 @@ cmd9pTcreate(Fcall* f, int, char** argv)
}
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 @@ cmd9pTwalk(Fcall* f, int argc, char** argv)
}
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 @@ cmd9pTattach(Fcall* f, int, char** argv)
}
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 @@ cmd9pTauth(Fcall* f, int, char** argv)
}
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 @@ cmdBind(int argc, char* argv[])
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 @@ cmdBind(int argc, char* argv[])
else
return cliError("bind %s %s: %r", argv[0], argv[1]);
}
#endif
return 1;
}

View file

@ -221,8 +221,9 @@ qAlloc(void)
}
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 @@ consTTY(void)
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 @@ consTTY(void)
return 0;
}
free(p);
#endif
if(consOpen(fd, fd, ctl) == 0){
close(ctl);

View file

@ -778,22 +778,34 @@ warn(Fsck *chk, char *fmt, ...)
}
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;
}

View file

@ -328,4 +328,4 @@ enum {
PartVenti, /* fake partition */
};
extern vtType[BtMax];
extern int vtType[BtMax];

View file

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

View file

@ -28,26 +28,33 @@ flprint(char *fmt, ...)
}
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);
}

View file

@ -73,7 +73,11 @@ threadmain(int argc, char* argv[])
/*
* 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);

View file

@ -1,5 +1,6 @@
</$objtype/mkfile
BIN=/$objtype/bin/fossil
<$PLAN9/src/mkhdr
MKSHELL=$PLAN9/bin/rc
BIN=$BIN/fossil
TARG=fossil flchk flfmt conf last view
@ -34,10 +35,10 @@ LIBFILES=\
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\
@ -98,12 +99,12 @@ test:V: all
# 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
@ -128,9 +129,14 @@ bundle:V:
$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

View file

@ -15,8 +15,9 @@ bwatchInit(void)
}
void
bwatchSetBlockSize(uint)
bwatchSetBlockSize(uint i)
{
USED(i);
}
void

View file

@ -2,10 +2,9 @@
#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"

View file

@ -463,7 +463,7 @@ initxlabel(Label l)
typedef struct Xblock Xblock;
struct Xblock
{
Tnode;
Tnode *t;
Block *b;
int (*gen)(void*, Block*, int, Tnode**);
void *arg;
@ -478,57 +478,58 @@ xblockexpand(Tnode *tt)
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 @@ initxentryblock(Block *b, Entry *ed)
typedef struct Xentry Xentry;
struct Xentry
{
Tnode;
Tnode *t;
Entry e;
};
@ -566,12 +567,12 @@ xentryexpand(Tnode *tt)
{
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 @@ initxentry(Entry e)
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 @@ initxsource(Entry e, int dowrap)
}
int
xlocalrootgen(void*, Block *b, int o, Tnode **tp)
xlocalrootgen(void *v, Block *b, int o, Tnode **tp)
{
Entry e;
@ -684,7 +686,7 @@ initxlocalroot(char *name, u32int addr)
}
int
xvacrootgen(void*, Block *b, int o, Tnode **tp)
xvacrootgen(void *v, Block *b, int o, Tnode **tp)
{
Entry e;
@ -734,7 +736,7 @@ initxdirentry(MetaEntry *me)
}
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 @@ metablockgen(void *v, Block *b, int o, Tnode **tp)
/* 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;
}