cwfs: fix disappearing /tmp +t bug

front
cinap_lenrek 2012-05-21 18:25:39 +02:00
parent c910640fdd
commit b5565b0403
4 changed files with 23 additions and 42 deletions

View File

@ -339,7 +339,7 @@ f_walk(Chan *cp, Fcall *in, Fcall *ou)
Dentry *d, *d1;
File *f;
Wpath *w;
int slot;
int slot, mask;
Off addr, qpath;
if(CHAT(cp)) {
@ -414,9 +414,12 @@ f_walk(Chan *cp, Fcall *in, Fcall *ou)
ou->err = Eentry;
goto out;
}
mask = DALLOC;
if(f->fs->dev->type == Devro)
mask |= DTMP;
for(slot=0; slot<DIRPERBUF; slot++) {
d1 = getdir(p1, slot);
if(!(d1->mode & DALLOC))
if((d1->mode & mask) != DALLOC)
continue;
if(strncmp(in->name, d1->name, sizeof(in->name)) != 0)
continue;
@ -812,7 +815,7 @@ f_read(Chan *cp, Fcall *in, Fcall *ou)
Tlock *t;
Off addr, offset;
Timet tim;
int nread, count, n, o, slot;
int nread, count, mask, n, o, slot;
if(CHAT(cp)) {
print("c_read %d\n", cp->chan);
@ -964,9 +967,12 @@ dread:
goto out;
}
n = DIRREC;
mask = DALLOC;
if(f->fs->dev->type == Devro)
mask |= DTMP;
for(slot=0; slot<DIRPERBUF; slot++) {
d1 = getdir(p1, slot);
if(!(d1->mode & DALLOC))
if((d1->mode & mask) != DALLOC)
continue;
if(offset >= n) {
offset -= n;

View File

@ -355,7 +355,7 @@ walkname(File* file, char* wname, Qid* wqid)
Wpath *w;
Iobuf *p, *p1;
Dentry *d, *d1;
int error, slot;
int error, slot, mask;
Off addr, qpath;
p = p1 = nil;
@ -446,9 +446,12 @@ setdot:
error = Eentry;
goto out;
}
mask = DALLOC;
if(file->fs->dev->type == Devro)
mask |= DTMP;
for(slot = 0; slot < DIRPERBUF; slot++){
d1 = getdir(p1, slot);
if (!(d1->mode & DALLOC) ||
if ((d1->mode & mask) != DALLOC ||
strncmp(wname, d1->name, NAMELEN) != 0)
continue;
/*
@ -957,7 +960,7 @@ fs_read(Chan* chan, Fcall* f, Fcall* r, uchar* data)
Tlock *t;
Off addr, offset, start;
Timet tim;
int error, iounit, nread, count, n, o, slot;
int error, iounit, nread, count, mask, n, o, slot;
Msgbuf *dmb;
Dir dir;
@ -1096,9 +1099,12 @@ dread:
goto out1;
}
mask = DALLOC;
if(file->fs->dev->type == Devro)
mask |= DTMP;
for(; slot < DIRPERBUF; slot++){
d1 = getdir(p1, slot);
if(!(d1->mode & DALLOC))
if((d1->mode & mask) != DALLOC)
continue;
mkdir9p2(&dir, d1, dmb->data);
n = convD2M(&dir, data+nread, iounit - nread);

View File

@ -393,7 +393,7 @@ fsck(Dentry *d)
lowstack = (uchar *)&edent;
/* check that entry is allocated */
if(!(d->mode & DALLOC))
if(!(d->mode & DALLOC) || (ronly && (d->mode & DTMP)))
return 0;
nfiles++;

View File

@ -1297,7 +1297,7 @@ isdirty(Cw *cw, Iobuf *p, Off addr, int tag)
Off
cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp)
{
Iobuf *p, *b;
Iobuf *p;
Dentry *d;
long qp1;
int i, j, shouldstop;
@ -1328,7 +1328,6 @@ cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp)
}
cw->depth++;
b = nil;
switch(tag) {
default:
fprint(2, "cwrecur: unknown tag %d %s\n", tag, cw->name);
@ -1360,9 +1359,7 @@ cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp)
for(i=0; i<DIRPERBUF; i++) {
d = getdir(p, i);
if(!(d->mode & DALLOC))
continue;
if(d->mode & DTMP)
if((d->mode & (DALLOC|DTMP)) != DALLOC)
continue;
qp1 = d->qid.path & ~QPDIR;
if(tag == Tdir)
@ -1393,20 +1390,6 @@ cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp)
}
}
}
for(i=0; i<DIRPERBUF; i++){
d = getdir(p, i);
if(!(d->mode & DALLOC))
continue;
if(d->mode & DTMP){
if(!b){
b = getbuf(devnone, Cwtmp, 0);
memmove(b->iobuf, p->iobuf, RBUFSIZE);
}
memset(d, 0, sizeof(Dentry));
p->flags |= Bmod;
}
}
break;
case Tind1:
@ -1450,20 +1433,6 @@ cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp)
cw->depth--;
if(b){
p = getbuf(cw->dev, na ? na : addr, Brd);
if(!p || checktag(p, tag, qp)){
fprint(2, "cwrecur: b/p null\n");
na = 0;
} else {
memmove(p->iobuf, b->iobuf, RBUFSIZE);
p->flags |= Bmod|Bimm;
}
if(p)
putbuf(p);
putbuf(b);
}
if(na){
if(shouldstop){
if(cw->falsehits < 10)