X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=sys%2Fsrc%2Flib9p%2Ffile.c;h=b2e726cbfd7a38b407c37a87d86f2e68ca327237;hb=8f64e448545a11c1c0e0db8bef34c23d3c0e0ad7;hp=1dc324f630f31684e1927c9e3f9343545a5577b4;hpb=a9060cc06bee66e12fe16644511f181a4b0cdbd3;p=plan9front.git diff --git a/sys/src/lib9p/file.c b/sys/src/lib9p/file.c index 1dc324f63..b2e726cbf 100644 --- a/sys/src/lib9p/file.c +++ b/sys/src/lib9p/file.c @@ -191,6 +191,12 @@ createfile(File *fp, char *name, char *uid, ulong perm, void *aux) } wlock(fp); + if(fp->parent == nil){ + wunlock(fp); + werrstr("create in deleted directory"); + return nil; + } + /* * We might encounter blank spots along the * way due to deleted files that have not yet @@ -229,7 +235,6 @@ createfile(File *fp, char *name, char *uid, ulong perm, void *aux) if(perm & DMEXCL) f->qid.type |= QTEXCL; - f->mode = perm; f->atime = f->mtime = time(0); f->length = 0; f->parent = fp; @@ -254,7 +259,8 @@ walkfile1(File *dir, char *elem) rlock(dir); if(strcmp(elem, "..") == 0){ fp = dir->parent; - incref(fp); + if(fp != nil) + incref(fp); runlock(dir); closefile(dir); return fp; @@ -388,12 +394,16 @@ opendirfile(File *dir) } long -readdirfile(Readdir *r, uchar *buf, long n) +readdirfile(Readdir *r, uchar *buf, long n, long o) { long x, m; Filelist *fl; - for(fl=r->fl, m=0; fl && m+2<=n; fl=fl->link, m+=x){ + if(o == 0) + fl = r->dir->filelist; + else + fl = r->fl; + for(m=0; fl && m+2<=n; fl=fl->link, m+=x){ if(fl->f == nil) x = 0; else if((x=convD2M(fl->f, buf+m, n-m)) <= BIT16SZ)