From: adilger Date: Thu, 19 Feb 2004 23:10:37 +0000 (+0000) Subject: Fix up permissions of existing directories and files if needed. X-Git-Tag: v1_7_100~1^71~19 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7749fb09856e2f946846ee8648dd364af3f9f931;p=fs%2Flustre-release.git Fix up permissions of existing directories and files if needed. b=2661 --- diff --git a/lustre/lvfs/lvfs_linux.c b/lustre/lvfs/lvfs_linux.c index 935548e..b59039f 100644 --- a/lustre/lvfs/lvfs_linux.c +++ b/lustre/lvfs/lvfs_linux.c @@ -193,9 +193,16 @@ struct dentry *simple_mknod(struct dentry *dir, char *name, int mode) GOTO(out_up, dchild); if (dchild->d_inode) { - if (!S_ISREG(dchild->d_inode->i_mode)) + int old_mode = dchild->d_inode->i_mode; + if (!S_ISREG(old_mode)) GOTO(out_err, err = -EEXIST); + /* Fixup file permissions if necessary */ + if ((old_mode & S_IALLUGO) != (mode & S_IALLUGO)) { + dchild->d_inode->i_mode = (mode & S_IALLUGO) | + (old_mode & ~S_IALLUGO); + mark_inode_dirty(dchild->d_inode); + } GOTO(out_up, dchild); } @@ -228,9 +235,16 @@ struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode) GOTO(out_up, dchild); if (dchild->d_inode) { - if (!S_ISDIR(dchild->d_inode->i_mode)) + int old_mode = dchild->d_inode->i_mode; + if (!S_ISDIR(old_mode)) GOTO(out_err, err = -ENOTDIR); + /* Fixup directory permissions if necessary */ + if ((old_mode & S_IALLUGO) != (mode & S_IALLUGO)) { + dchild->d_inode->i_mode = (mode & S_IALLUGO) | + (old_mode & ~S_IALLUGO); + mark_inode_dirty(dchild->d_inode); + } GOTO(out_up, dchild); }