From mboxrd@z Thu Jan 1 00:00:00 1970 From: Valerie Aurora Subject: [PATCH 55/74] union-mount: Set opaque flag on new directories in unioned file systems Date: Tue, 22 Mar 2011 19:04:46 -0700 Message-ID: <1300845905-14433-12-git-send-email-valerie.aurora@gmail.com> References: <1300845905-14433-1-git-send-email-valerie.aurora@gmail.com> Cc: viro@zeniv.linux.org.uk, Valerie Aurora , Jan Blunck , Valerie Aurora To: linux-fsdevel@vger.kernel.org, linux@vger.kernel.org Return-path: Received: from mail-yi0-f46.google.com ([209.85.218.46]:45835 "EHLO mail-yi0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754174Ab1CWCFu (ORCPT ); Tue, 22 Mar 2011 22:05:50 -0400 In-Reply-To: <1300845905-14433-1-git-send-email-valerie.aurora@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Valerie Aurora 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 Signed-off-by: Valerie Aurora Signed-off-by: Valerie Aurora --- fs/namei.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 9c6803a..47fe25a 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2323,8 +2323,17 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int 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; } -- 1.7.0.4