bugfix: statfs lower file system properly
authorErez Zadok <ezk@bigvaio.(none)>
Tue, 22 May 2007 22:04:14 +0000 (18:04 -0400)
committerErez_Zadok <ezk@cs.sunysb.edu>
Mon, 23 Jul 2007 00:50:41 +0000 (20:50 -0400)
Get the correct lower dentry to use to statfs the first branch (always), now
works with disk-based as well as network file systems.  Also document the
code better.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/super.c

index d68b4eda0495c7482b61bcbf1596b996735db0fb..1ca6c54c2fafd57f28f37739f2df455f99656305 100644 (file)
@@ -114,23 +114,37 @@ static void unionfs_put_super(struct super_block *sb)
 static int unionfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
        int err = 0;
-       struct super_block *sb, *hidden_sb;
+       struct super_block *sb;
+       struct dentry *lower_dentry;
 
        BUG_ON(!is_valid_dentry(dentry));
+       unionfs_check_dentry(dentry);
 
        sb = dentry->d_sb;
 
        unionfs_read_lock(sb);
-       hidden_sb = unionfs_lower_super_idx(sb, sbstart(sb));
+       lower_dentry = unionfs_lower_dentry(sb->s_root);
        unionfs_read_unlock(sb);
-       err = vfs_statfs(hidden_sb->s_root, buf);
+       err = vfs_statfs(lower_dentry, buf);
 
+       /* set return buf to our f/s to avoid confusing user-level utils */
        buf->f_type = UNIONFS_SUPER_MAGIC;
+       /*
+        * Our maximum file name can is shorter bya few bytes because every
+        * file name could potentially be whited-out.
+        *
+        * XXX: this restriction goes away with ODF.
+        */
        buf->f_namelen -= UNIONFS_WHLEN;
 
+       /*
+        * reset two fields to avoid confusing user-land.
+        * XXX: is this still necessary?
+        */
        memset(&buf->f_fsid, 0, sizeof(__kernel_fsid_t));
        memset(&buf->f_spare, 0, sizeof(buf->f_spare));
 
+       unionfs_check_dentry(dentry);
        return err;
 }