aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9pfuse
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2008-07-04 12:16:53 -0400
committerRuss Cox <rsc@swtch.com>2008-07-04 12:16:53 -0400
commit9ec57f8b9e8a243ca94fbdef0ed571b823a095b7 (patch)
treee2d0f8a5214a0bcddfdbe7dc98fd5b88d53aeb62 /src/cmd/9pfuse
parent869875b48b4455937fdddb7c98fbff7699c1effb (diff)
downloadplan9port-9ec57f8b9e8a243ca94fbdef0ed571b823a095b7.tar.gz
plan9port-9ec57f8b9e8a243ca94fbdef0ed571b823a095b7.tar.bz2
plan9port-9ec57f8b9e8a243ca94fbdef0ed571b823a095b7.zip
9pfuse: always return . and ..
Diffstat (limited to 'src/cmd/9pfuse')
-rw-r--r--src/cmd/9pfuse/main.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c
index c9d4f55d..45041e66 100644
--- a/src/cmd/9pfuse/main.c
+++ b/src/cmd/9pfuse/main.c
@@ -855,6 +855,7 @@ fusereadlink(FuseMsg *m)
* are stored in m->d,nd,d0.
*/
int canpack(Dir*, uvlong, uchar**, uchar*);
+Dir *dotdirs(CFid*);
void
fusereaddir(FuseMsg *m)
{
@@ -871,9 +872,8 @@ fusereaddir(FuseMsg *m)
if(in->offset == 0){
fsseek(ff->fid, 0, 0);
free(ff->d0);
- ff->d0 = nil;
- ff->d = nil;
- ff->nd = 0;
+ ff->d0 = ff->d = dotdirs(ff->fid);
+ ff->nd = 2;
}
n = in->size;
if(n > fusemaxwrite)
@@ -906,6 +906,31 @@ out:
free(buf);
}
+/*
+ * Fuse assumes that it can always read two directory entries.
+ * If it gets just one, it will double it in the dirread results.
+ * Thus if a directory contains just "a", you see "a" twice.
+ * Adding . as the first directory entry works around this.
+ * We could add .. too, but it isn't necessary.
+ */
+Dir*
+dotdirs(CFid *f)
+{
+ Dir *d;
+ CFid *f1;
+
+ d = emalloc(2*sizeof *d);
+ d[0].name = ".";
+ d[0].qid = fsqid(f);
+ d[1].name = "..";
+ f1 = fswalk(f, "..");
+ if(f1){
+ d[1].qid = fsqid(f1);
+ fsclose(f1);
+ }
+ return d;
+}
+
int
canpack(Dir *d, uvlong off, uchar **pp, uchar *ep)
{