Fixes bug that Roger Peppe pointed out on 9fans. See my 9fans post (Re: [9fans] namespace oddness) for details. Reference: /n/sources/patch/applied/namec Date: Mon Nov 19 15:45:12 CET 2007 Signed-off-by: rsc@swtch.com --- /sys/src/9/port/chan.c Mon Nov 19 15:44:37 2007 +++ /sys/src/9/port/chan.c Mon Nov 19 15:44:34 2007 @@ -113,7 +113,7 @@ x = --r->ref; unlock(r); if(x < 0) - panic("deccnt pc=0x%lux", getcallerpc(&r)); + panic("decref pc=0x%lux", getcallerpc(&r)); return x; } @@ -947,7 +947,7 @@ int walk(Chan **cp, char **names, int nnames, int nomount, int *nerror) { - int dev, dotdot, i, n, nhave, ntry, type; + int dev, didmount, dotdot, i, n, nhave, ntry, type; Chan *c, *nc, *mtpt; Path *path; Mhead *mh, *nmh; @@ -967,9 +967,13 @@ * 3. move to the first mountpoint along the way. * 4. repeat. * - * An invariant is that each time through the loop, c is on the undomount - * side of the mount point, and c's full path is path. + * Each time through the loop: + * + * If didmount==0, c is on the undomount side of the mount point. + * If didmount==1, c is on the domount side of the mount point. + * Either way, c's full path is path. */ + didmount = 0; for(nhave=0; nhaveqid.type&QTDIR)==0){ if(nerror) @@ -996,9 +1000,9 @@ } } - if(!dotdot && !nomount) + if(!dotdot && !nomount && !didmount) domount(&c, &mh, &path); - + type = c->type; dev = c->dev; @@ -1029,21 +1033,26 @@ } } - nmh = nil; + didmount = 0; if(dotdot){ assert(wq->nqid == 1); assert(wq->clone != nil); path = addelem(path, "..", nil); nc = undomount(wq->clone, path); + nmh = nil; n = 1; }else{ nc = nil; nmh = nil; - if(!nomount) - for(i=0; inqid && iqid[i])) + if(!nomount){ + for(i=0; inqid && iqid[i])){ + didmount = 1; break; + } + } + } if(nc == nil){ /* no mount points along path */ if(wq->clone == nil){ cclose(c); @@ -1065,6 +1074,7 @@ n = wq->nqid; nc = wq->clone; }else{ /* stopped early, at a mount point */ + didmount = 1; if(wq->clone != nil){ cclose(wq->clone); wq->clone = nil;