hjfs: various changes
This commit is contained in:
parent
2e19497159
commit
34bf0ce496
|
@ -76,15 +76,15 @@ tqueue(Req *req)
|
||||||
if(ch->lreq != nil)
|
if(ch->lreq != nil)
|
||||||
((Req *) ch->lreq)->aux = req;
|
((Req *) ch->lreq)->aux = req;
|
||||||
ch->lreq = req;
|
ch->lreq = req;
|
||||||
if(ch->qnext == nil){
|
if(ch->qnext == nil && (ch->wflags & CHWBUSY) == 0){
|
||||||
ch->qnext = &readych;
|
ch->qnext = &readych;
|
||||||
ch->qprev = ch->qnext->qprev;
|
ch->qprev = ch->qnext->qprev;
|
||||||
ch->qnext->qprev = ch;
|
ch->qnext->qprev = ch;
|
||||||
ch->qprev->qnext = ch;
|
ch->qprev->qnext = ch;
|
||||||
|
rwakeup(&chanre);
|
||||||
}
|
}
|
||||||
if(req->ifcall.type == Tremove)
|
if(req->ifcall.type == Tremove)
|
||||||
req->fid->aux = nil;
|
req->fid->aux = nil;
|
||||||
rwakeup(&chanre);
|
|
||||||
qunlock(&chanqu);
|
qunlock(&chanqu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +100,17 @@ tdestroyfid(Fid *fid)
|
||||||
qlock(&chanqu);
|
qlock(&chanqu);
|
||||||
ch = fid->aux;
|
ch = fid->aux;
|
||||||
fid->aux = nil;
|
fid->aux = nil;
|
||||||
|
if(ch != nil){
|
||||||
|
ch->wflags |= CHWCLUNK;
|
||||||
|
if(ch->qnext == nil && (ch->wflags & CHWBUSY) == 0){
|
||||||
|
ch->qnext = &readych;
|
||||||
|
ch->qprev = ch->qnext->qprev;
|
||||||
|
ch->qnext->qprev = ch;
|
||||||
|
ch->qprev->qnext = ch;
|
||||||
|
rwakeup(&chanre);
|
||||||
|
}
|
||||||
|
}
|
||||||
qunlock(&chanqu);
|
qunlock(&chanqu);
|
||||||
if(ch != nil)
|
|
||||||
chanclunk(ch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -137,31 +145,29 @@ start9p(char *service, int stdio)
|
||||||
threadpostmountsrv(&mysrv, service, nil, 0);
|
threadpostmountsrv(&mysrv, service, nil, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static int
|
||||||
tclone(Fid *old, Fid *new, void *)
|
twalk(Chan *ch, Fid *fid, Fid *nfid, int n, char **name, Qid *qid)
|
||||||
{
|
{
|
||||||
Chan *ch;
|
int i;
|
||||||
|
|
||||||
ch = old->aux;
|
if(nfid != fid){
|
||||||
if(ch->open != 0)
|
if(ch->open != 0){
|
||||||
return "trying to clone an open fid";
|
werrstr("trying to clone an open fid");
|
||||||
new->aux = chanclone(ch);
|
return -1;
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
twalk(Fid *fid, char *name, void *)
|
|
||||||
{
|
|
||||||
Chan *ch;
|
|
||||||
char buf[ERRMAX];
|
|
||||||
|
|
||||||
ch = fid->aux;
|
|
||||||
if(chanwalk(ch, name) < 0){
|
|
||||||
rerrstr(buf, ERRMAX);
|
|
||||||
return strdup(buf);
|
|
||||||
}
|
}
|
||||||
fid->qid = ch->loc->Qid;
|
ch = chanclone(ch);
|
||||||
return nil;
|
if(ch == nil)
|
||||||
|
return -1;
|
||||||
|
nfid->aux = ch;
|
||||||
|
nfid->qid = ch->loc->Qid;
|
||||||
|
}
|
||||||
|
for(i = 0; i < n; i++){
|
||||||
|
if(chanwalk(ch, name[i]) <= 0)
|
||||||
|
return i > 0 ? i : -1;
|
||||||
|
qid[i] = ch->loc->Qid;
|
||||||
|
nfid->qid = ch->loc->Qid;
|
||||||
|
}
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -181,6 +187,8 @@ workerproc(void *)
|
||||||
ch->qprev->qnext = ch->qnext;
|
ch->qprev->qnext = ch->qnext;
|
||||||
ch->qprev = nil;
|
ch->qprev = nil;
|
||||||
ch->qnext = nil;
|
ch->qnext = nil;
|
||||||
|
assert((ch->wflags & CHWBUSY) == 0);
|
||||||
|
ch->wflags |= CHWBUSY;
|
||||||
while(ch != nil && ch->freq != nil){
|
while(ch != nil && ch->freq != nil){
|
||||||
req = ch->freq;
|
req = ch->freq;
|
||||||
ch->freq = req->aux;
|
ch->freq = req->aux;
|
||||||
|
@ -188,12 +196,15 @@ workerproc(void *)
|
||||||
ch->lreq = nil;
|
ch->lreq = nil;
|
||||||
req->aux = nil;
|
req->aux = nil;
|
||||||
qunlock(&chanqu);
|
qunlock(&chanqu);
|
||||||
|
assert(req->responded == 0);
|
||||||
i = &req->ifcall;
|
i = &req->ifcall;
|
||||||
o = &req->ofcall;
|
o = &req->ofcall;
|
||||||
switch(req->ifcall.type){
|
switch(req->ifcall.type){
|
||||||
case Twalk:
|
case Twalk:
|
||||||
walkandclone(req, twalk, tclone, nil);
|
rc = twalk(ch, req->fid, req->newfid, i->nwname, i->wname, o->wqid);
|
||||||
goto noret;
|
if(rc >= 0)
|
||||||
|
o->nwqid = rc;
|
||||||
|
break;
|
||||||
case Topen:
|
case Topen:
|
||||||
rc = chanopen(ch, i->mode);
|
rc = chanopen(ch, i->mode);
|
||||||
break;
|
break;
|
||||||
|
@ -228,9 +239,13 @@ workerproc(void *)
|
||||||
responderror(req);
|
responderror(req);
|
||||||
else
|
else
|
||||||
respond(req, nil);
|
respond(req, nil);
|
||||||
noret:
|
|
||||||
qlock(&chanqu);
|
qlock(&chanqu);
|
||||||
}
|
}
|
||||||
|
if(ch != nil){
|
||||||
|
ch->wflags &= ~CHWBUSY;
|
||||||
|
if((ch->wflags & CHWCLUNK) != 0)
|
||||||
|
chanclunk(ch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ userssave(Fs *fs, Chan *ch)
|
||||||
{
|
{
|
||||||
User *u, *v;
|
User *u, *v;
|
||||||
int nu, i;
|
int nu, i;
|
||||||
char buf[512], *p, *e;
|
char buf[512], *p, *e, *s;
|
||||||
uvlong off;
|
uvlong off;
|
||||||
|
|
||||||
rlock(&fs->udatal);
|
rlock(&fs->udatal);
|
||||||
|
@ -206,8 +206,11 @@ userssave(Fs *fs, Chan *ch)
|
||||||
p = buf;
|
p = buf;
|
||||||
e = buf + sizeof(buf);
|
e = buf + sizeof(buf);
|
||||||
p = seprint(p, e, "%d:%s:", v->uid, v->name);
|
p = seprint(p, e, "%d:%s:", v->uid, v->name);
|
||||||
if(v->lead != NOUID)
|
if(v->lead != NOUID){
|
||||||
p = strecpy(p, e, uid2name(fs, v->lead));
|
s = uid2name(fs, v->lead);
|
||||||
|
p = strecpy(p, e, s);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
if(p < e)
|
if(p < e)
|
||||||
*p++ = ':';
|
*p++ = ':';
|
||||||
for(i = 0; i < v->nmemb; i++){
|
for(i = 0; i < v->nmemb; i++){
|
||||||
|
@ -215,7 +218,9 @@ userssave(Fs *fs, Chan *ch)
|
||||||
continue;
|
continue;
|
||||||
if(p < e && i > 0)
|
if(p < e && i > 0)
|
||||||
*p++ = ',';
|
*p++ = ',';
|
||||||
p = strecpy(p, e, uid2name(fs, v->memb[i]));
|
s = uid2name(fs, v->memb[i]);
|
||||||
|
p = strecpy(p, e, s);
|
||||||
|
free(s);
|
||||||
}
|
}
|
||||||
*p++ = '\n';
|
*p++ = '\n';
|
||||||
if(ch == nil)
|
if(ch == nil)
|
||||||
|
|
|
@ -185,6 +185,9 @@ enum {
|
||||||
CHFDUMP = 1,
|
CHFDUMP = 1,
|
||||||
CHFNOLOCK = 2,
|
CHFNOLOCK = 2,
|
||||||
CHFRO = 4,
|
CHFRO = 4,
|
||||||
|
|
||||||
|
CHWBUSY = 1,
|
||||||
|
CHWCLUNK = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,6 +206,7 @@ struct Chan {
|
||||||
/* workers */
|
/* workers */
|
||||||
void *freq, *lreq;
|
void *freq, *lreq;
|
||||||
Chan *qnext, *qprev;
|
Chan *qnext, *qprev;
|
||||||
|
int wflags;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern QLock chanqu;
|
extern QLock chanqu;
|
||||||
|
|
|
@ -111,7 +111,7 @@ chancreat(Chan *ch, char *name, int perm, int mode)
|
||||||
chend(ch);
|
chend(ch);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(!namevalid || ch->open != 0){
|
if(!namevalid(name) || ch->open != 0){
|
||||||
werrstr(Einval);
|
werrstr(Einval);
|
||||||
chend(ch);
|
chend(ch);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -520,6 +520,7 @@ chandirread(Chan *ch, void *buf, ulong n, uvlong off)
|
||||||
free(di.uid);
|
free(di.uid);
|
||||||
free(di.gid);
|
free(di.gid);
|
||||||
free(di.muid);
|
free(di.muid);
|
||||||
|
free(di.name);
|
||||||
if(rc <= BIT16SZ)
|
if(rc <= BIT16SZ)
|
||||||
break;
|
break;
|
||||||
wr += rc;
|
wr += rc;
|
||||||
|
|
|
@ -13,6 +13,8 @@ char Eperm[] = "permission denied";
|
||||||
char Eexists[] = "file exists";
|
char Eexists[] = "file exists";
|
||||||
char Elocked[] = "file locked";
|
char Elocked[] = "file locked";
|
||||||
|
|
||||||
|
int mainstacksize = 65536;
|
||||||
|
|
||||||
void*
|
void*
|
||||||
emalloc(int c)
|
emalloc(int c)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue