From b5565b0403d206e7d020c68b8c0ad42726125897 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 21 May 2012 18:25:39 +0200 Subject: [PATCH] cwfs: fix disappearing /tmp +t bug --- sys/src/cmd/cwfs/9p1.c | 14 ++++++++++---- sys/src/cmd/cwfs/9p2.c | 14 ++++++++++---- sys/src/cmd/cwfs/chk.c | 2 +- sys/src/cmd/cwfs/cw.c | 35 ++--------------------------------- 4 files changed, 23 insertions(+), 42 deletions(-) diff --git a/sys/src/cmd/cwfs/9p1.c b/sys/src/cmd/cwfs/9p1.c index cdeee8e34..071120e05 100644 --- a/sys/src/cmd/cwfs/9p1.c +++ b/sys/src/cmd/cwfs/9p1.c @@ -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; slotmode & 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; slotmode & DALLOC)) + if((d1->mode & mask) != DALLOC) continue; if(offset >= n) { offset -= n; diff --git a/sys/src/cmd/cwfs/9p2.c b/sys/src/cmd/cwfs/9p2.c index 543a0fa03..efcdef37c 100644 --- a/sys/src/cmd/cwfs/9p2.c +++ b/sys/src/cmd/cwfs/9p2.c @@ -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); diff --git a/sys/src/cmd/cwfs/chk.c b/sys/src/cmd/cwfs/chk.c index 8ee9a980f..3417536aa 100644 --- a/sys/src/cmd/cwfs/chk.c +++ b/sys/src/cmd/cwfs/chk.c @@ -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++; diff --git a/sys/src/cmd/cwfs/cw.c b/sys/src/cmd/cwfs/cw.c index 51e39a215..579edd887 100644 --- a/sys/src/cmd/cwfs/cw.c +++ b/sys/src/cmd/cwfs/cw.c @@ -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; imode & 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; imode & 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)