ref: b5565b0403d206e7d020c68b8c0ad42726125897
parent: c910640fdd12b3a4c78cb56717e6018a25139b86
author: cinap_lenrek <[email protected]>
date: Mon May 21 14:25:39 EDT 2012
cwfs: fix disappearing /tmp +t bug
--- a/sys/src/cmd/cwfs/9p1.c
+++ b/sys/src/cmd/cwfs/9p1.c
@@ -339,7 +339,7 @@
Dentry *d, *d1;
File *f;
Wpath *w;
- int slot;
+ int slot, mask;
Off addr, qpath;
if(CHAT(cp)) {
@@ -414,9 +414,12 @@
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 @@
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 @@
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;
--- a/sys/src/cmd/cwfs/9p2.c
+++ b/sys/src/cmd/cwfs/9p2.c
@@ -355,7 +355,7 @@
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 @@
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 @@
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 @@
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);
--- a/sys/src/cmd/cwfs/chk.c
+++ b/sys/src/cmd/cwfs/chk.c
@@ -393,7 +393,7 @@
lowstack = (uchar *)&edent;
/* check that entry is allocated */
- if(!(d->mode & DALLOC))
+ if(!(d->mode & DALLOC) || (ronly && (d->mode & DTMP)))
return 0;
nfiles++;
--- a/sys/src/cmd/cwfs/cw.c
+++ b/sys/src/cmd/cwfs/cw.c
@@ -1297,7 +1297,7 @@
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 @@
}
cw->depth++;
- b = nil;
switch(tag) {
default:
fprint(2, "cwrecur: unknown tag %d %s\n", tag, cw->name);
@@ -1360,10 +1359,8 @@
for(i=0; i<DIRPERBUF; i++) {
d = getdir(p, i);
- if(!(d->mode & DALLOC))
+ if((d->mode & (DALLOC|DTMP)) != DALLOC)
continue;
- if(d->mode & DTMP)
- continue;
qp1 = d->qid.path & ~QPDIR;
if(tag == Tdir)
strncpy(np, d->name, NAMELEN);
@@ -1393,20 +1390,6 @@
}
}
}
-
- 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:
@@ -1449,20 +1432,6 @@
na = split(cw, p, addr);
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){