linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: fix mkfs flush inode i_u
@ 2021-01-31  9:45 Hu Weiwen
  2021-01-31 10:34 ` Gao Xiang via Linux-erofs
  2021-02-06 13:56 ` Li GuiFu via Linux-erofs
  0 siblings, 2 replies; 3+ messages in thread
From: Hu Weiwen @ 2021-01-31  9:45 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] erofs-utils: fix mkfs flush inode i_u
  2021-01-31  9:45 [PATCH] erofs-utils: fix mkfs flush inode i_u Hu Weiwen
@ 2021-01-31 10:34 ` Gao Xiang via Linux-erofs
  2021-02-06 13:56 ` Li GuiFu via Linux-erofs
  1 sibling, 0 replies; 3+ messages in thread
From: Gao Xiang via Linux-erofs @ 2021-01-31 10:34 UTC (permalink / raw)
  To: Hu Weiwen; +Cc: linux-erofs

On Sun, Jan 31, 2021 at 05:45:25PM +0800, Hu Weiwen wrote:
> 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>

Yeah, thanks for catching this!

Reviewed-by: Gao Xiang <hsiangkao@aol.com>

Thanks,
Gao Xiang

> ---
>  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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] erofs-utils: fix mkfs flush inode i_u
  2021-01-31  9:45 [PATCH] erofs-utils: fix mkfs flush inode i_u Hu Weiwen
  2021-01-31 10:34 ` Gao Xiang via Linux-erofs
@ 2021-02-06 13:56 ` Li GuiFu via Linux-erofs
  1 sibling, 0 replies; 3+ messages in thread
From: Li GuiFu via Linux-erofs @ 2021-02-06 13:56 UTC (permalink / raw)
  To: Hu Weiwen, Gao Xiang, linux-erofs



On 2021/1/31 17:45, Hu Weiwen wrote:
> 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>


It looks good
Reviewed-by: Li Guifu <bluce.lee@aliyun.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-06 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-31  9:45 [PATCH] erofs-utils: fix mkfs flush inode i_u Hu Weiwen
2021-01-31 10:34 ` Gao Xiang via Linux-erofs
2021-02-06 13:56 ` Li GuiFu via Linux-erofs

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).