]> git.neil.brown.name Git - LaFS.git/commitdiff
subset: add dump lookup and readdir routines.
authorNeilBrown <neilb@suse.de>
Mon, 2 May 2011 02:03:16 +0000 (12:03 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 2 May 2011 02:03:16 +0000 (12:03 +1000)
For a subset filesystem object to look convincingly like and
empty directory it needs lookup and readdir routines which
do nothing useful.

Signed-off-by: NeilBrown <neilb@suse.de>
super.c
test/go

diff --git a/super.c b/super.c
index 3d1f94d2f79c92164b992fa384deb1132d2d5cb2..6e03eff7648abc2473d887e109aec76f3634a5ec 100644 (file)
--- a/super.c
+++ b/super.c
@@ -1165,10 +1165,47 @@ out_noput:
        return err;
 }
 
+static struct dentry *subset_lookup(struct inode *dir, struct dentry *dentry,
+                                   struct nameidata *nd)
+{
+       d_add(dentry, NULL);
+       return NULL;
+}
+
+static int subset_readdir(struct file *filp, void *dirent, filldir_t filldir)
+{
+       struct dentry *dentry = filp->f_dentry;
+       //struct lafs_inodee *lai = LAFSI(dentry->d_inode);
+       ino_t ino;
+       loff_t i = filp->f_pos;
+
+       switch (i) {
+       case 0:
+               ino = dentry->d_inode->i_ino;
+               if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
+                       break;
+               filp->f_pos ++;
+               i++;
+               /* fallthrough */
+       case 1:
+               ino = 2; /* FIXME need parent for subset! */
+               if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0)
+                       break;
+               filp->f_pos++;
+               i++;
+               /* fallthrough */
+       default:
+               break;
+       }
+       return 0;
+}
+
 const struct file_operations lafs_subset_file_operations = {
+       .readdir        = subset_readdir,
 };
 
 const struct inode_operations lafs_subset_ino_operations = {
+       .lookup         = subset_lookup,
 };
 
 
diff --git a/test/go b/test/go
index cafae040766a2e0fef3ae2d2fb07d0dee8c2c5ab..eb8d845ab682cbaec3382a60cc1cf4bab4a8e1e7 100644 (file)
--- a/test/go
+++ b/test/go
@@ -216,6 +216,7 @@ mount -t lafs_subset /mnt/1/foo /mnt/2 || exit 1
 rm /mnt/2/foo1 || exit 1
 ls -lai /mnt/2
 ls -lai /mnt/1/foo
+ls -laid /mnt/1/foo
 umount /mnt/2 || exit 1
 cd /
 (sleep 20 ; echo t > /proc/sysrq-trigger ; sleep 2 ; echo b > /proc/sysrq-trigger; ) &