Unionfs: create opaque directories' whiteouts unconditionally
authorErez Zadok <ezk@cs.sunysb.edu>
Mon, 26 Nov 2007 04:01:28 +0000 (23:01 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Tue, 31 Jan 2012 04:57:04 +0000 (23:57 -0500)
Needed to maintain Unix semantics (LTP testing).

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

index 968ee8c6784fb244bfe6665d4802a2bf5eb9a296..1a26c57dff27c0c9f8b9ae7b1f201de6aa882793 100644 (file)
@@ -162,6 +162,19 @@ int make_dir_opaque(struct dentry *dentry, int bindex)
        struct dentry *lower_dentry, *diropq;
        struct inode *lower_dir;
        struct nameidata nd;
+       kernel_cap_t orig_cap;
+
+       /*
+        * Opaque directory whiteout markers are special files (like regular
+        * whiteouts), and should appear to the users as if they don't
+        * exist.  They should be created/deleted regardless of directory
+        * search/create permissions, but only for the duration of this
+        * creation of the .wh.__dir_opaque: file.  Note, this does not
+        * circumvent normal ->permission).
+        */
+       orig_cap = current->cap_effective;
+       cap_raise(current->cap_effective, CAP_DAC_READ_SEARCH);
+       cap_raise(current->cap_effective, CAP_DAC_OVERRIDE);
 
        lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
        lower_dir = lower_dentry->d_inode;
@@ -189,6 +202,7 @@ int make_dir_opaque(struct dentry *dentry, int bindex)
 
 out:
        mutex_unlock(&lower_dir->i_mutex);
+       current->cap_effective = orig_cap;
        return err;
 }