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

View File

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

View File

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

View File

@ -1297,7 +1297,7 @@ isdirty(Cw *cw, Iobuf *p, Off addr, int tag)
Off Off
cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp) cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp)
{ {
Iobuf *p, *b; Iobuf *p;
Dentry *d; Dentry *d;
long qp1; long qp1;
int i, j, shouldstop; int i, j, shouldstop;
@ -1328,7 +1328,6 @@ cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp)
} }
cw->depth++; cw->depth++;
b = nil;
switch(tag) { switch(tag) {
default: default:
fprint(2, "cwrecur: unknown tag %d %s\n", tag, cw->name); 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++) { for(i=0; i<DIRPERBUF; i++) {
d = getdir(p, i); d = getdir(p, i);
if(!(d->mode & DALLOC)) if((d->mode & (DALLOC|DTMP)) != DALLOC)
continue;
if(d->mode & DTMP)
continue; continue;
qp1 = d->qid.path & ~QPDIR; qp1 = d->qid.path & ~QPDIR;
if(tag == Tdir) 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; break;
case Tind1: case Tind1:
@ -1450,20 +1433,6 @@ cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp)
cw->depth--; 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(na){
if(shouldstop){ if(shouldstop){
if(cw->falsehits < 10) if(cw->falsehits < 10)