From: NeilBrown Date: Mon, 2 May 2011 02:03:16 +0000 (+1000) Subject: subset: add dump lookup and readdir routines. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=973df2992e27b22dea0a2a9c2aae7c077a85cbbb;p=LaFS.git subset: add dump lookup and readdir routines. 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 --- diff --git a/super.c b/super.c index 3d1f94d..6e03eff 100644 --- 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 cafae04..eb8d845 100644 --- 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; ) &