ref: 7fd3085a86e397bb9d4bb489fb887c39940d19f4
parent: f290dc94ee82b06b7c46822ccffea1c4d120d495
author: 9ferno <gophone2015@gmail.com>
date: Mon Nov 7 03:32:30 EST 2022
do not show zeroed out directory entries
--- a/9p.c
+++ b/9p.c
@@ -103,8 +103,12 @@
respond(req, errstring[Ephase]);
return;
}
+
d = &dbuf->io->d;
- fsmkdir(d, &req->d, nil);
+ /* nothing to do for already zero'ed out slots */
+ if(dbuf->io->path != Qpnone)
+ fsmkdir(d, &req->d, nil);
+
putbuf(dbuf);
respond(req, nil);
}
@@ -227,6 +231,36 @@
ctlread(req);
return;
}
+ if((req->fid->qid.type & QTDIR) != 0){
+ /* using this loop to skip over zero'ed out blocks */
+ dbuf = cbuf = nil;
+ do{
+ if(dbuf != nil)
+ freesearchstate(&dbuf, &cbuf);
+ /* some directory, find the child at offset */
+ d = searchdir(((Aux*)req->fid->aux)->dblkno, req->fid->qid.path,
+ ((Aux*)req->fid->aux)->uid, nil,
+ ((Aux*)req->fid->aux)->dri, &dbuf, &cbuf);
+ if(d == nil){
+ req->ofcall.offset = req->ifcall.offset;
+ req->ofcall.count = 0;
+ ((Aux*)req->fid->aux)->dri = 0;
+ respond(req, nil);
+ return;
+ }
+ ((Aux*)req->fid->aux)->dri++;
+ }while(d->qid.path == 0);
+
+ fsmkdir(d, &dir, nbuf);
+ req->ofcall.count = n = convD2M(&dir, (u8*)req->ofcall.data, req->ifcall.count);
+ req->ofcall.offset = req->ifcall.offset+n;
+ if(n == 0)
+ ((Aux*)req->fid->aux)->dri = 0;
+ freesearchstate(&dbuf, &cbuf);
+ respond(req, nil);
+ return;
+ }
+
if((req->fid->qid.type & QTDIR) != 0){
/* some directory, find the child at offset */
d = searchdir(((Aux*)req->fid->aux)->dblkno, req->fid->qid.path,
--- /dev/null
+++ b/tests/test.e/action.rc
@@ -1,0 +1,9 @@
+#!/bin/rc
+
+mkdir -p /n/mafs_test.e/a/^(b c)
+touch /n/mafs_test.e/a/^(1.txt 2.txt)
+du -a /n/mafs_test.e/
+rm -rf /n/mafs_test.e/a/b
+rm /n/mafs_test.e/a/1.txt
+du -a /n/mafs_test.e/
+cat /n/mafs_test.e/adm/ctl
--- /dev/null
+++ b/tests/test.e/blocks/0
@@ -1,0 +1,3 @@
+Tmagic 1
+mafs device
+512
--- /dev/null
+++ b/tests/test.e/blocks/1
@@ -1,0 +1,7 @@
+Tdata 2
+size 16384
+nblocks 32
+backup config 1 to 31 24
+backup super 2 to 30 23
+backup root 3 to 29 22
+service mafs_test.e
--- /dev/null
+++ b/tests/test.e/blocks/10
@@ -1,0 +1,52 @@
+Tdentry 8
+qid.version 0
+qid.path 8
+size 503
+pdblkno 9
+pqpath 7
+mtime 1666359865759946606
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 31
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name config.0
--- /dev/null
+++ b/tests/test.e/blocks/11
@@ -1,0 +1,52 @@
+Tdentry 9
+qid.version 0
+qid.path 9
+size 503
+pdblkno 9
+pqpath 7
+mtime 1666359865759948486
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 30
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name super.0
--- /dev/null
+++ b/tests/test.e/blocks/12
@@ -1,0 +1,52 @@
+Tdentry 10
+qid.version 0
+qid.path 10
+size 503
+pdblkno 9
+pqpath 7
+mtime 1666359865759953319
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 29
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name root.0
--- /dev/null
+++ b/tests/test.e/blocks/13
@@ -1,0 +1,52 @@
+Tdentry 11
+qid.version 0
+qid.path 11
+size 503
+pdblkno 9
+pqpath 7
+mtime 1666359865759955235
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 24
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name config.1
--- /dev/null
+++ b/tests/test.e/blocks/14
@@ -1,0 +1,52 @@
+Tdentry 12
+qid.version 0
+qid.path 12
+size 503
+pdblkno 9
+pqpath 7
+mtime 1666359865759956872
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 23
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name super.1
--- /dev/null
+++ b/tests/test.e/blocks/15
@@ -1,0 +1,52 @@
+Tdentry 13
+qid.version 0
+qid.path 13
+size 503
+pdblkno 9
+pqpath 7
+mtime 1666359865759962493
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 22
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name root.1
--- /dev/null
+++ b/tests/test.e/blocks/16
@@ -1,0 +1,52 @@
+Tdentry 14
+qid.version 0
+qid.path 14
+size 0
+pdblkno 4
+pqpath 5
+mtime 1666359865759931465
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name ctl
--- /dev/null
+++ b/tests/test.e/blocks/17
@@ -1,0 +1,52 @@
+Tdentry 15
+qid.version 0
+qid.path 15
+size 9
+pdblkno 4
+pqpath 5
+mtime 1666359868040073037
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 26
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name frees
--- /dev/null
+++ b/tests/test.e/blocks/18
@@ -1,0 +1,52 @@
+Tdentry 64
+qid.version 0
+qid.path 64
+size 0
+pdblkno 3
+pqpath 63
+mtime 1666359866898311852
+mode 20000000777
+uid 10006
+gid -1
+muid 10006
+direct blocks
+ 0 19
+ 1 20
+ 2 21
+ 3 25
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name a
--- /dev/null
+++ b/tests/test.e/blocks/19
@@ -1,0 +1,52 @@
+Tdentry 0
+qid.version 0
+qid.path 0
+size 0
+pdblkno 0
+pqpath 0
+mtime 0
+mode 0
+uid 0
+gid 0
+muid 0
+direct blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name
--- /dev/null
+++ b/tests/test.e/blocks/2
@@ -1,0 +1,6 @@
+Tdata 3
+start 0
+tfree 0
+qidgen 69
+frees 0
+fsok 1
--- /dev/null
+++ b/tests/test.e/blocks/20
@@ -1,0 +1,52 @@
+Tdentry 66
+qid.version 0
+qid.path 66
+size 0
+pdblkno 18
+pqpath 64
+mtime 1666359866898986491
+mode 20000000777
+uid 10006
+gid -1
+muid 10006
+direct blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name c
--- /dev/null
+++ b/tests/test.e/blocks/21
@@ -1,0 +1,52 @@
+Tdentry 0
+qid.version 0
+qid.path 0
+size 0
+pdblkno 0
+pqpath 0
+mtime 0
+mode 0
+uid 0
+gid 0
+muid 0
+direct blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name
--- /dev/null
+++ b/tests/test.e/blocks/22
@@ -1,0 +1,1 @@
+Tdata 13
--- /dev/null
+++ b/tests/test.e/blocks/23
@@ -1,0 +1,6 @@
+Tdata 12
+start 0
+tfree 0
+qidgen 69
+frees 0
+fsok 1
--- /dev/null
+++ b/tests/test.e/blocks/24
@@ -1,0 +1,7 @@
+Tdata 11
+size 16384
+nblocks 32
+backup config 1 to 31 24
+backup super 2 to 30 23
+backup root 3 to 29 22
+service mafs_test.e
--- /dev/null
+++ b/tests/test.e/blocks/29
@@ -1,0 +1,1 @@
+Tdata 10
--- /dev/null
+++ b/tests/test.e/blocks/3
@@ -1,0 +1,52 @@
+Tdentry 63
+qid.version 0
+qid.path 63
+size 0
+pdblkno 0
+pqpath 0
+mtime 1666359865759968192
+mode 20000000777
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 4
+ 1 18
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name /
--- /dev/null
+++ b/tests/test.e/blocks/30
@@ -1,0 +1,6 @@
+Tdata 9
+start 0
+tfree 0
+qidgen 69
+frees 0
+fsok 1
--- /dev/null
+++ b/tests/test.e/blocks/31
@@ -1,0 +1,7 @@
+Tdata 8
+size 16384
+nblocks 32
+backup config 1 to 31 24
+backup super 2 to 30 23
+backup root 3 to 29 22
+service mafs_test.e
--- /dev/null
+++ b/tests/test.e/blocks/4
@@ -1,0 +1,52 @@
+Tdentry 5
+qid.version 0
+qid.path 5
+size 0
+pdblkno 3
+pqpath 63
+mtime 1666359865759923176
+mode 20000000777
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 9
+ 1 5
+ 2 16
+ 3 6
+ 4 7
+ 5 17
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name adm
--- /dev/null
+++ b/tests/test.e/blocks/5
@@ -1,0 +1,52 @@
+Tdentry 2
+qid.version 0
+qid.path 2
+size 0
+pdblkno 4
+pqpath 5
+mtime 1666359865759929589
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 1
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name config
--- /dev/null
+++ b/tests/test.e/blocks/6
@@ -1,0 +1,52 @@
+Tdentry 3
+qid.version 0
+qid.path 3
+size 0
+pdblkno 4
+pqpath 5
+mtime 1666359865759933393
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 2
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name super
--- /dev/null
+++ b/tests/test.e/blocks/7
@@ -1,0 +1,52 @@
+Tdentry 6
+qid.version 0
+qid.path 6
+size 126
+pdblkno 4
+pqpath 5
+mtime 1666359865759939962
+mode 444
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 8
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name users
--- /dev/null
+++ b/tests/test.e/blocks/8
@@ -1,0 +1,9 @@
+Tdata 6
+-1:adm:adm:
+0:none:adm:
+9999:noworld::
+10000:sys::
+10001:upas:upas:
+10002:bootes:bootes:
+10006:glenda:glenda:
+10007:manies::
--- /dev/null
+++ b/tests/test.e/blocks/9
@@ -1,0 +1,52 @@
+Tdentry 7
+qid.version 0
+qid.path 7
+size 126
+pdblkno 4
+pqpath 5
+mtime 1666359865759927105
+mode 20000000777
+uid -1
+gid -1
+muid -1
+direct blocks
+ 0 10
+ 1 11
+ 2 12
+ 3 13
+ 4 14
+ 5 15
+ 6 0
+ 7 0
+ 8 0
+ 9 0
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 0
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 0
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 0
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+indirect blocks
+ 0 0
+ 1 0
+ 2 0
+ 3 0
+ 4 0
+ 5 0
+name bkp
--- /dev/null
+++ b/tests/test.e/notes
@@ -1,0 +1,43 @@
+Creates a disk of 32 blocks. Unmarked blocks are filled from /dev/random.
+
+Duplicate of test.2 but seeded with random data.
+
+test mkdir -p a/b/c/d/e/f/g/h
+
+block - description
+0 - magic
+1 - config
+2 - super block
+3 - / direntry
+4 - /adm/ dir entry
+5 - /adm/config dir entry
+6 - /adm/super dir entry
+7 - /adm/users dir entry
+8 - /adm/users contents
+9 - /adm/bkp/ dir entry
+10 - /adm/bkp/config.0 dir entry
+11 - /adm/bkp/super.0 dir entry
+12 - /adm/bkp/root.0 dir entry
+13 - /adm/bkp/config.1 dir entry
+14 - /adm/bkp/super.1 dir entry
+15 - /adm/bkp/root.1 dir entry
+16 - /adm/ctl dir entry -- virtual file, empty contents
+17 - /adm/frees dir entry
+
+18 - /dir1 directory entry
+19 - /dir1/file1 directory entry
+20 - /dir1/file1 contents
+21 - /adm/frees contents
+
+22 - / direntry
+23 - super block
+24 - config
+
+25
+26
+27
+28
+
+29 - / direntry
+30 - super block
+31 - config
--- /dev/null
+++ b/tests/test.e/params
@@ -1,0 +1,1 @@
+nblocks=32
--- /dev/null
+++ b/tests/test.e/setup.rc
@@ -1,0 +1,3 @@
+#!/bin/rc
+
+dd -if /dev/random -of $1 -bs 512 -count $2