[PATCH 52/73] union-mount: Set opaque flag on new directories inunioned file systems [ver #2]

From: David Howells
Date: Tue Feb 21 2012 - 13:17:52 EST


From: Valerie Aurora <vaurora@xxxxxxxxxx>

If we mkdir() a directory on the top layer of a union, we don't want
entries from a matching directory on the lower layer to "show through"
suddenly. To prevent this, we set the opaque flag on a directory in a
union mount if there is no matching directory on the lower layers.

Signed-off-by: Jan Blunck <jblunck@xxxxxxx>
Signed-off-by: Valerie Aurora <vaurora@xxxxxxxxxx>
Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
---

fs/namei.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index f9e0d68..d52377d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2946,8 +2946,17 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
return error;

error = dir->i_op->mkdir(dir, dentry, mode);
- if (!error)
- fsnotify_mkdir(dir, dentry);
+ if (error)
+ return error;
+
+ /* XXX racy - crash now and dir isn't opaque */
+ if (IS_DIR_UNIONED(dentry->d_parent)) {
+ dentry->d_inode->i_flags |= S_OPAQUE;
+ mark_inode_dirty(dentry->d_inode);
+ }
+
+ fsnotify_mkdir(dir, dentry);
+
return error;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/