From: Robert Yang <liezhi.yang@windriver.com>
To: <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>
Subject: [PATCH][e2fsprogs] misc/create_inode.c: set dir's mode correctly
Date: Mon, 24 Feb 2020 19:08:42 +0800 [thread overview]
Message-ID: <1582542522-97508-1-git-send-email-liezhi.yang@windriver.com> (raw)
The dir's mode has been set by ext2fs_mkdir() with umask, so
reset it to the source's mode in set_inode_extra().
Fixed when source dir's mode is 521, but dst dir's mode is 721 which was
incorrect.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
misc/create_inode.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/misc/create_inode.c b/misc/create_inode.c
index 5161d5e..f82f74e 100644
--- a/misc/create_inode.c
+++ b/misc/create_inode.c
@@ -124,7 +124,14 @@ static errcode_t set_inode_extra(ext2_filsys fs, ext2_ino_t ino,
ext2fs_set_i_uid_high(inode, st->st_uid >> 16);
inode.i_gid = st->st_gid;
ext2fs_set_i_gid_high(inode, st->st_gid >> 16);
- inode.i_mode |= st->st_mode;
+ /*
+ * The dir's mode has been set by ext2fs_mkdir() with umask, so
+ * reset it to the source's mode
+ */
+ if S_ISDIR(st->st_mode)
+ inode.i_mode = LINUX_S_IFDIR | st->st_mode;
+ else
+ inode.i_mode |= st->st_mode;
inode.i_atime = st->st_atime;
inode.i_mtime = st->st_mtime;
inode.i_ctime = st->st_ctime;
--
2.7.4
next reply other threads:[~2020-02-24 11:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 11:08 Robert Yang [this message]
2020-03-07 17:43 ` [PATCH][e2fsprogs] misc/create_inode.c: set dir's mode correctly Theodore Y. Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1582542522-97508-1-git-send-email-liezhi.yang@windriver.com \
--to=liezhi.yang@windriver.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).