Skip to contentSkip to conversation

syscalls/statx: Add judgment to the MODE value

PATCH Superseded Zou Wei 2 participants 3 messages Mar 28, 2020 – Mar 30, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zou Wei

author
#0 lore raw

PATCH 1/1 syscalls/statx: Add judgment to the MODE value

1. The default value of umask in most linux systems is 0022, but in some other systems is 0077, which results in different MODE values when opening files.

2. Adding judgment to the MODE value can improve the versatility of this case.

3. 63 translates to 77 in octal, meaning the running process has a umask of 0022. That means the process will open files with 0600 as permissions on the filesystem.

---
 testcases/kernel/syscalls/statx/statx01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/statx/statx01.c +1 -1
index 4f9d582..adca1d3 100644
@@ -47,7 +47,7 @@
 #define TESTFILE "test_file"
 #define MNTPOINT "mntpoint/"
 #define DEVICEFILE MNTPOINT"blk_dev"
-#define MODE 0644
+#define MODE ((umask(0)==63)?0600:0644)
 
 #define SIZE 256
 #define MAJOR 8

--
2.6.2

#1 lore raw

PATCH 1/1 syscalls/statx: Add judgment to the MODE value

Quoted 18 lines · Zou Wei

1. The default value of umask in most linux systems is 0022, but in some other systems is 0077, which results in different MODE values when opening files.

2. Adding judgment to the MODE value can improve the versatility of this case.

3. 63 translates to 77 in octal, meaning the running process has a umask of 0022. That means the process will open files with 0600 as permissions on the filesystem.

---
  testcases/kernel/syscalls/statx/statx01.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/statx/statx01.c +0 -0
index 4f9d582..adca1d3 100644

testcases/kernel/syscalls/statx/statx01.c line 50

Quoted 5 lines
testcases/kernel/syscalls/statx/statx01.c +1 -1
@@ -47,7 +47,7 @@
  #define TESTFILE "test_file"
  #define MNTPOINT "mntpoint/"
  #define DEVICEFILE MNTPOINT"blk_dev"
-#define MODE 0644
+#define MODE ((umask(0)==63)?0600:0644)

Hi Zou,

1) For the fix, I think you just need to clear current mask by umask(0) in setup().

2) Don't mix the fix and adding coverage(i.e. different permissions).? Please use

??? other ways(create two files with different permissions or change
the permission

??? during test, etc) if you want to run test with different permissions.

Thanks,

Xiao Yang

Quoted 7 lines
testcases/kernel/syscalls/statx/statx01.c +0 -1
  #define SIZE 256
  #define MAJOR 8
--

2.6.2

#2 lore raw

Hi Yang,

Thanks for your review and comments, I will send the v2 patch.

Best Regards
Zou Wei

-----????-----
???: Xiao Yang [mailto:[email protected]]
????: 2020?3?28? 19:38
???: Zouwei (Samuel) <[email protected]>; [email protected] ??: Re: [LTP] [PATCH] syscalls/statx: Add judgment to the MODE value

Quoted 19 lines · Zou Wei

1. The default value of umask in most linux systems is 0022, but in some other systems is 0077, which results in different MODE values when opening files.

2. Adding judgment to the MODE value can improve the versatility of this case.

3. 63 translates to 77 in octal, meaning the running process has a umask of 0022. That means the process will open files with 0600 as permissions on the filesystem.

---
  testcases/kernel/syscalls/statx/statx01.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/statx/statx01.c +0 -0
index 4f9d582..adca1d3 100644

testcases/kernel/syscalls/statx/statx01.c line 50

Quoted 5 lines
testcases/kernel/syscalls/statx/statx01.c +1 -1
@@ -47,7 +47,7 @@
  #define TESTFILE "test_file"
  #define MNTPOINT "mntpoint/"
  #define DEVICEFILE MNTPOINT"blk_dev"
-#define MODE 0644
+#define MODE ((umask(0)==63)?0600:0644)

Hi Zou,

1) For the fix, I think you just need to clear current mask by umask(0) in setup().

2) Don't mix the fix and adding coverage(i.e. different permissions). Please use

??? other ways(create two files with different permissions or change the permission

??? during test, etc) if you want to run test with different permissions.

Thanks,

Xiao Yang

Quoted 7 lines
testcases/kernel/syscalls/statx/statx01.c +0 -1
  #define SIZE 256
  #define MAJOR 8
--

2.6.2