commit 94ba84d567f5c7d8e1989f3f30630d2c9bf1f579
Author: Josef 'Jeff' Sipek <[EMAIL PROTECTED]>
Date:   Sat Nov 17 22:27:29 2007 -0500

    Unionfs: unionfs_create rewrite
    
    The code was hard to follow and violated some invariants (e.g., never modify
    a read only branch, and always create on branch 0).
    
    Signed-off-by: Josef 'Jeff' Sipek <[EMAIL PROTECTED]>

diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 262e955..bfac433 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -44,7 +44,20 @@ static int unionfs_create(struct inode *parent, struct 
dentry *dentry,
         */
        BUG_ON(!valid && dentry->d_inode);
 
-       /* We start out in the leftmost branch. */
+       /*
+        * We shouldn't create things in a read-only branch; this check is a
+        * bit redundant as we don't allow branch 0 to be read-only at the
+        * moment
+        */
+       err = is_robranch_super(dentry->d_sb, 0);
+       if (err) {
+               err = -EROFS;
+               goto out;
+       }
+
+       /*
+        * We _always_ create on branch 0
+        */
        bstart = 0;
 
        lower_dentry = unionfs_lower_dentry_idx(dentry, bstart);
@@ -77,10 +90,8 @@ static int unionfs_create(struct inode *parent, struct 
dentry *dentry,
                err = PTR_ERR(lower_parent_dentry);
                goto out;
        }
-       /* We shouldn't create things in a read-only branch. */
-       if (!(err = is_robranch_super(dentry->d_sb, bstart)))
-               err = vfs_create(lower_parent_dentry->d_inode,
-                                lower_dentry, mode, nd);
+       err = vfs_create(lower_parent_dentry->d_inode,
+                        lower_dentry, mode, nd);
 
        if (err || !lower_dentry->d_inode)
                unlock_dir(lower_parent_dentry);
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to