From: Hu Weiwen <sehuww@mail.scut.edu.cn>
To: Gao Xiang <hsiangkao@redhat.com>, linux-erofs@lists.ozlabs.org
Subject: [PATCH] erofs-utils: fix mkfs flush inode i_u
Date: Sun, 31 Jan 2021 17:45:25 +0800 [thread overview]
Message-ID: <20210131094525.168251-1-sehuww@mail.scut.edu.cn> (raw)
When choosing which field of i_u to use, it should be `inode->i_mode & S_IFMT'
Previously, the default branch is always taken. Fortunately, all 3 field has
the same data type, and they are in the same union, so it happens to work.
Signed-off-by: Hu Weiwen <sehuww@mail.scut.edu.cn>
---
lib/inode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/inode.c b/lib/inode.c
index 73a7e69..0ed4264 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -412,7 +412,7 @@ static bool erofs_bh_flush_write_inode(struct erofs_buffer_head *bh)
u.dic.i_uid = cpu_to_le16((u16)inode->i_uid);
u.dic.i_gid = cpu_to_le16((u16)inode->i_gid);
- switch ((inode->i_mode) >> S_SHIFT) {
+ switch (inode->i_mode & S_IFMT) {
case S_IFCHR:
case S_IFBLK:
case S_IFIFO:
@@ -445,7 +445,7 @@ static bool erofs_bh_flush_write_inode(struct erofs_buffer_head *bh)
u.die.i_ctime = cpu_to_le64(inode->i_ctime);
u.die.i_ctime_nsec = cpu_to_le32(inode->i_ctime_nsec);
- switch ((inode->i_mode) >> S_SHIFT) {
+ switch (inode->i_mode & S_IFMT) {
case S_IFCHR:
case S_IFBLK:
case S_IFIFO:
--
2.25.1
next reply other threads:[~2021-01-31 9:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-31 9:45 Hu Weiwen [this message]
2021-01-31 10:34 ` [PATCH] erofs-utils: fix mkfs flush inode i_u Gao Xiang via Linux-erofs
2021-02-06 13:56 ` Li GuiFu via Linux-erofs
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=20210131094525.168251-1-sehuww@mail.scut.edu.cn \
--to=sehuww@mail.scut.edu.cn \
--cc=hsiangkao@redhat.com \
--cc=linux-erofs@lists.ozlabs.org \
/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).