Add new LTP tests related to fsmount family of syscalls
v5 cover Add new LTP tests related to fsmount family of syscalls
Hello,
Here is the fifth version of my work rebased over the latest changes pushed around fsmount work by Zorro. This is tested on both ARM and X86 platforms now and no more errors are seen with it.
V4->V5:
- s/TBROK/TFAIL/ in run(int n) callbacks.
- Many conversions like TEST(fd = fsopen());
- A new implementation of tst_is_mounted().
- fspick.h created to take care of duplicate code.
- tmp directory not removed from code as that will be auto done anyway.
- Other minor improvements.
V3->V4:
- Only the first patch was resent after fixing git log and minor code modifications.
V2->V3:
- Fix errors with xfs.
- Add macros to define test names.
- Continue with multiple iteration tests on failures, instead of returning early.
- Set value of is_mounted in open_tree patch.
- Rename tst_ismount() and make it return 1 on success.
- Fix various formatting issues.
- Add all reviewed/ack tags.
V1->V2:
- Lots of changes, really :)
- Rebased over Zorro's work with fsmount.
- The success tests are modified to test all possible flags, attributes as well.
- Create tst_ismount() and fsopen_supported_by_kernel() helpers.
- Verify if mount is successful or not using tst_ismount().
- Remove min_kver and instead check if older kernels have patches backported or not.
- Test on multiple filesystems.
- Better handling of failures during setup/run callbacks.
- One of the patches around fsmount.h is already merged, dropped it now.
- Other minor cleanups.
Viresh Kumar (10):
tst_device: Add tst_is_mounted() helper lapi/fsmount.h: Add fsopen_supported_by_kernel() lapi/fsmount.h: Include "lapi/fcntl.h" syscalls/fsopen: New tests syscalls/fsconfig: New tests syscalls/fsmount: Improve fsmount01 test syscalls/fsmount: Add failure tests syscalls/move_mount: New tests syscalls/fspick: New tests syscalls/open_tree: New tests
include/lapi/fsmount.h | 11 +- include/tst_device.h | 6 + lib/tst_device.c | 14 ++ runtest/syscalls | 16 +++ testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 + .../kernel/syscalls/fsconfig/fsconfig01.c | 101 ++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 99 ++++++++++++++ testcases/kernel/syscalls/fsmount/.gitignore | 1 + testcases/kernel/syscalls/fsmount/fsmount01.c | 123 +++++++++--------- testcases/kernel/syscalls/fsmount/fsmount02.c | 80 ++++++++++++ testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 + testcases/kernel/syscalls/fsopen/fsopen01.c | 80 ++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 58 +++++++++ testcases/kernel/syscalls/fspick/.gitignore | 2 + testcases/kernel/syscalls/fspick/Makefile | 6 + testcases/kernel/syscalls/fspick/fspick.h | 60 +++++++++ testcases/kernel/syscalls/fspick/fspick01.c | 62 +++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 54 ++++++++ .../kernel/syscalls/move_mount/.gitignore | 2 + testcases/kernel/syscalls/move_mount/Makefile | 6 + .../kernel/syscalls/move_mount/move_mount01.c | 83 ++++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 92 +++++++++++++ .../kernel/syscalls/open_tree/.gitignore | 2 + testcases/kernel/syscalls/open_tree/Makefile | 6 + .../kernel/syscalls/open_tree/open_tree01.c | 108 +++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 105 +++++++++++++++ 28 files changed, 1132 insertions(+), 61 deletions(-) create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore create mode 100644 testcases/kernel/syscalls/fsopen/Makefile create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c create mode 100644 testcases/kernel/syscalls/fspick/.gitignore create mode 100644 testcases/kernel/syscalls/fspick/Makefile create mode 100644 testcases/kernel/syscalls/fspick/fspick.h create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore create mode 100644 testcases/kernel/syscalls/move_mount/Makefile create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore create mode 100644 testcases/kernel/syscalls/open_tree/Makefile create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.c
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v5 1/10 tst_device: Add tst_is_mounted() helper
This patch moves the ismount() helper added to the fsmount syscall tests to the standard library and renames it to tst_is_mounted(). The helper can be used across different files now.
Minor modifications are also done to the helper.
--- include/tst_device.h | 6 +++++ lib/tst_device.c | 14 +++++++++++ testcases/kernel/syscalls/fsmount/fsmount01.c | 25 +------------------ 3 files changed, 21 insertions(+), 24 deletions(-)
include/tst_device.h +6 -0
@@ -36,6 +36,12 @@ extern struct tst_device *tst_device;*/ int tst_umount (const char *path); +/* +* Verifies if an earlier mount is successful or not. +* @path: Mount path to verify +*/ +int tst_is_mounted (const char *path); +/* * Clears a first few blocks of the device. This is needed when device has * already been formatted with a filesystems, subset of mkfs.foo utils aborts
lib/tst_device.c +14 -0
@@ -386,6 +386,20 @@ int tst_umount(const char *path)return -1 ; } +int tst_is_mounted (const char *path) +{ +char cmd[PATH_MAX ]; +int ret; + +snprintf (cmd,sizeof (cmd),"mountpoint -q %s" , path); + ret =tst_system (cmd); + +if (ret) +tst_resm (TINFO ,"No device is mounted at %s" , path); + +return !ret; +} +int find_stat_file (const char *dev,char *path,size_t path_len) {const char *devname =strrchr (dev,'/' ) +1 ;
testcases/kernel/syscalls/fsmount/fsmount01.c +1 -24
@@ -12,30 +12,10 @@#include "tst_test.h" #include "lapi/fcntl.h" #include "lapi/fsmount.h" -#include "tst_safe_stdio.h" -#define LINELENGTH 256#define MNTPOINT "newmount_point"static int sfd, mfd, is_mounted; -static int ismount (char *mntpoint) -{ -int ret =0 ; -FILE *file; -char line[LINELENGTH ]; - - file =SAFE_FOPEN ("/proc/mounts" ,"r" ); - -while (fgets (line,sizeof (line), file)) { -if (strstr (line, mntpoint) !=NULL ) { - ret =1 ; -break ; - } - } -SAFE_FCLOSE (file); -return ret; -} -static void cleanup (void ) {if (is_mounted)
@@ -76,12 +56,9 @@ static void test_fsmount(void)tst_res (TPASS ,"move_mount() attached to the mount point" );SAFE_CLOSE (mfd); -if (ismount (MNTPOINT )) { -tst_res (TPASS ,"device mounted" ); +if (tst_is_mounted (MNTPOINT )) {SAFE_UMOUNT (MNTPOINT ); is_mounted =0 ; - }else { -tst_res (TFAIL ,"device not mounted" ); } }
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v5 1/10 tst_device: Add tst_is_mounted() helper
Hi!
Quoted 37 lines
This patch moves the
ismount()helper added to the fsmount syscall tests to the standard library and renames it totst_is_mounted(). The helper can be used across different files now.Minor modifications are also done to the helper.
Acked-by Li Wang <[email protected]>Reviewed-by Petr Vorel <[email protected]>Signed-off-by Viresh Kumar <[email protected]>--- include/tst_device.h | 6 +++++ lib/tst_device.c | 14 +++++++++++ testcases/kernel/syscalls/fsmount/fsmount01.c | 25 +------------------ 3 files changed, 21 insertions(+), 24 deletions(-)include/tst_device.h +6
-0@@ -36,6 +36,12 @@ extern struct tst_device *tst_device;*/ int tst_umount (const char *path); +/* +* Verifies if an earlier mount is successful or not. +* @path: Mount path to verify +*/ +int tst_is_mounted (const char *path); +/* * Clears a first few blocks of the device. This is needed when device has * already been formatted with a filesystems, subset of mkfs.foo utils aborts lib/tst_device.c +0
-0
lib/tst_device.c int tst_umount(const char *path) · line 395
Quoted 10 lines
lib/tst_device.c +7
-0@@ -386,6 +386,20 @@ int tst_umount(const char *path)return -1 ; } +int tst_is_mounted (const char *path) +{ +char cmd[PATH_MAX ]; +int ret; + +snprintf (cmd,sizeof (cmd),"mountpoint -q %s" , path); + ret =tst_system (cmd);
I'm not sure that depending on mountpoint command is right choice, there are all kinds of embedded systems out there that may be missing it.
Also this does not even handle the case that the command is missing.
Looking at the v4 version, all we need is to correctly parse each line from from /proc/mounts. I would just use strsep() with space as a delimited and took first token that starts with a slash i.e. '/', then we can just strcmp() it against the path. Or do I miss something?
Quoted 61 lines
lib/tst_device.c +6
-0+if (ret) +tst_resm (TINFO ,"No device is mounted at %s" , path); + +return !ret; +} +int find_stat_file (const char *dev,char *path,size_t path_len) {const char *devname =strrchr (dev,'/' ) +1 ;testcases/kernel/syscalls/fsmount/fsmount01.c +1
-24@@ -12,30 +12,10 @@#include "tst_test.h" #include "lapi/fcntl.h" #include "lapi/fsmount.h" -#include "tst_safe_stdio.h" -#define LINELENGTH 256#define MNTPOINT "newmount_point"static int sfd, mfd, is_mounted; -static int ismount (char *mntpoint) -{ -int ret =0 ; -FILE *file; -char line[LINELENGTH ]; - - file =SAFE_FOPEN ("/proc/mounts" ,"r" ); - -while (fgets (line,sizeof (line), file)) { -if (strstr (line, mntpoint) !=NULL ) { - ret =1 ; -break ; - } - } -SAFE_FCLOSE (file); -return ret; -} -static void cleanup (void ) {if (is_mounted)@@ -76,12 +56,9 @@ static void test_fsmount(void)tst_res (TPASS ,"move_mount() attached to the mount point" );SAFE_CLOSE (mfd); -if (ismount (MNTPOINT )) { -tst_res (TPASS ,"device mounted" ); +if (tst_is_mounted (MNTPOINT )) {SAFE_UMOUNT (MNTPOINT ); is_mounted =0 ; - }else { -tst_res (TFAIL ,"device not mounted" ); } }Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v5 1/10 tst_device: Add tst_is_mounted() helper
Quoted 12 lines · Cyril Hrubis
...
lib/tst_device.c int tst_umount(const char *path) · line 395
Quoted 8 lines
lib/tst_device.c +7
-0+int tst_is_mounted (const char *path) +{ +char cmd[PATH_MAX ]; +int ret; + +snprintf (cmd,sizeof (cmd),"mountpoint -q %s" , path); + ret =tst_system (cmd);I'm not sure that depending on mountpoint command is right choice, there are all kinds of embedded systems out there that may be missing it.
Good point, we'd better avoid involving other packages as the dependence of LTP.
Quoted 7 lines
Also this does not even handle the case that the command is missing.
Looking at the v4 version, all we need is to correctly parse each line from from
/proc/mounts. I would just usestrsep()with space as a delimited and took first token that starts with a slash i.e. '/', then we can juststrcmp()it against the path. Or do I miss something?
I'm afraid strcmp() can not satisfy the requirement for us. As you know LTP creates the MNTPOINT in temp dir that means it could not accurately match the string path which extracts from /proc/mounts with a slash.
e.g
#define MNTPOINT "fallocate"
.../dev/loop4 on /tmp/FPp7kh/fallocate type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
...strcmp("/tmp/FPp7kh/fallocate", MNTPOINT) will never ruturn 0 to us.
What I can think of is to use strrchr() to cut the string after last '/', but that can only work for test mount fs in LTP ways. Other situations might not satisfy.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200307/02bcfb77/attachment.htm>
PATCH v5 1/10 tst_device: Add tst_is_mounted() helper
Quoted 40 lines · Li Wang
Quoted 12 lines · Cyril Hrubis
...
lib/tst_device.c int tst_umount(const char *path) · line 395
Quoted 8 lines
lib/tst_device.c +7
-0+int tst_is_mounted (const char *path) +{ +char cmd[PATH_MAX ]; +int ret; + +snprintf (cmd,sizeof (cmd),"mountpoint -q %s" , path); + ret =tst_system (cmd);I'm not sure that depending on mountpoint command is right choice, there are all kinds of embedded systems out there that may be missing it.
Good point, we'd better avoid involving other packages as the dependence of LTP.
Quoted 7 lines
Also this does not even handle the case that the command is missing.
Looking at the v4 version, all we need is to correctly parse each line from from
/proc/mounts. I would just usestrsep()with space as a delimited and took first token that starts with a slash i.e. '/', then we can juststrcmp()it against the path. Or do I miss something?I'm afraid
strcmp()can not satisfy the requirement for us. As you know LTP creates the MNTPOINT in temp dir that means it could not accurately match the string path which extracts from/proc/mountswith a slash.e.g
#define MNTPOINT "fallocate"
.../dev/loop4on/tmp/FPp7kh/fallocatetype xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
...strcmp("/tmp/FPp7kh/fallocate", MNTPOINT)will never ruturn 0 to us.
Quoted 3 lines
What I can think of is to use
strrchr()to cut the string after last '/', but that can only work for test mount fs in LTP ways. Other situations might not satisfy.
@Cyril, can we please finalize what you guys want me to do here ? I don't really want to repost the patch, which still has issues :)
Signature · 1 line
viresh
PATCH v5 1/10 tst_device: Add tst_is_mounted() helper
Hi!
Quoted 12 lines
Quoted 12 lines
I'm afraid
strcmp()can not satisfy the requirement for us. As you know LTP creates the MNTPOINT in temp dir that means it could not accurately match the string path which extracts from/proc/mountswith a slash.e.g
#define MNTPOINT "fallocate"
.../dev/loop4on/tmp/FPp7kh/fallocatetype xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
...strcmp("/tmp/FPp7kh/fallocate", MNTPOINT)will never ruturn 0 to us.
Quoted 6 lines
Quoted 3 lines
What I can think of is to use
strrchr()to cut the string after last '/', but that can only work for test mount fs in LTP ways. Other situations might not satisfy.@Cyril, can we please finalize what you guys want me to do here ? I don't really want to repost the patch, which still has issues :)
Sorry for the back and forth.
I remmebered yesterday that there is setmntent() in libc, so i we call that on /proc/mounts, the whole problem would be reduced to a path comparsion.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v5 1/10 tst_device: Add tst_is_mounted() helper
In reply to Li WangHi!
Quoted 20 lines
Quoted 7 lines
Also this does not even handle the case that the command is missing.
Looking at the v4 version, all we need is to correctly parse each line from from
/proc/mounts. I would just usestrsep()with space as a delimited and took first token that starts with a slash i.e. '/', then we can juststrcmp()it against the path. Or do I miss something?I'm afraid
strcmp()can not satisfy the requirement for us. As you know LTP creates the MNTPOINT in temp dir that means it could not accurately match the string path which extracts from/proc/mountswith a slash.e.g
#define MNTPOINT "fallocate"
.../dev/loop4on/tmp/FPp7kh/fallocatetype xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
...strcmp("/tmp/FPp7kh/fallocate", MNTPOINT)will never ruturn 0 to us.
Quoted 3 lines
What I can think of is to use
strrchr()to cut the string after last '/', but that can only work for test mount fs in LTP ways. Other situations might not satisfy.
Hmm, for that we have to have compose the path for the comparsion anyways, since unless we pass an absoule path we can never be user if we have a right match or not. There may be leftover mount points from a failed tests that have faile to cleanup properly as well.
So I guess that we need one more function, with tmpdir in name, that would compose the right path for us and then call the tst_is_mntpoint().
I would have called that:
int tst_is_mntpoint_at_tmpdir(const char *path);
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v5 1/10 tst_device: Add tst_is_mounted() helper
Quoted 26 lines · Cyril Hrubis
Hi!
Quoted 9 lines
Quoted 7 lines
Also this does not even handle the case that the command is missing.
Looking at the v4 version, all we need is to correctly parse each line from from
/proc/mounts. I would just usestrsep()with space as a delimited and took first token that starts with a slash i.e. '/', then we can juststrcmp()it against the path. Or do I miss something?I'm afraid
strcmp()can not satisfy the requirement for us. As you knowLTP
Quoted 11 lines
creates the MNTPOINT in temp dir that means it could not accurately match the string path which extracts from
/proc/mountswith a slash.e.g
#define MNTPOINT "fallocate"
.../dev/loop4on/tmp/FPp7kh/fallocatetype xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
...strcmp("/tmp/FPp7kh/fallocate", MNTPOINT)will never ruturn 0 to us.Quoted 3 lines
What I can think of is to use
strrchr()to cut the string after last '/', but that can only work for test mount fs in LTP ways. Other situations might not satisfy.
Quoted 8 lines
Hmm, for that we have to have compose the path for the comparsion anyways, since unless we pass an absoule path we can never be user if we have a right match or not. There may be leftover mount points from a failed tests that have faile to cleanup properly as well.
So I guess that we need one more function, with tmpdir in name, that would compose the right path for us and then call the
tst_is_mntpoint().
+1 it makes sense to me.
Quoted 5 lines
I would have called that:
int
tst_is_mntpoint_at_tmpdir(const char *path);
Hmm, the return value shouldn't the full right path, why return int here? or I misunderstand here?
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200311/1972cc02/attachment.htm>
PATCH v5 1/10 tst_device: Add tst_is_mounted() helper
Quoted 9 lines · Li Wang
...
Quoted 3 lines
int
tst_is_mntpoint_at_tmpdir(const char *path);Hmm, the return value shouldn't the full right path, why return int here? or I misunderstand here?
s/shouldn't/should
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200311/538c16c8/attachment.htm>
PATCH v5 1/10 tst_device: Add tst_is_mounted() helper
In reply to Cyril HrubisQuoted 11 lines · Cyril Hrubis
Hmm, for that we have to have compose the path for the comparsion anyways, since unless we pass an absoule path we can never be user if we have a right match or not. There may be leftover mount points from a failed tests that have faile to cleanup properly as well.
So I guess that we need one more function, with tmpdir in name, that would compose the right path for us and then call the
tst_is_mntpoint().I would have called that:
int
tst_is_mntpoint_at_tmpdir(const char *path);
Is everyone fine with this code now :)
int tst_is_mounted(const char *path)
{
char line[PATH_MAX];
FILE *file;
int ret = 0;
file = SAFE_FOPEN(NULL, "/proc/mounts", "r");
while (fgets(line, sizeof(line), file)) {
if (strstr(line, path) != NULL) {
ret = 1;
break;
}
}
SAFE_FCLOSE(NULL, file);
if (!ret)
tst_resm(TINFO, "No device is mounted at %s", path);
return ret;
}int tst_is_mounted_at_tmpdir(const char *path)
{
char cdir[PATH_MAX], mpath[PATH_MAX];
int ret;
if (!getcwd(cdir, PATH_MAX))
return 0;
ret = snprintf(mpath, PATH_MAX, "%s/%s", cdir, path);
if (ret < 0 || ret >= PATH_MAX)
return 0;
return tst_is_mounted(mpath);
}Signature · 1 line
viresh
PATCH v5 1/10 tst_device: Add tst_is_mounted() helper
Hi Viresh,
Quoted 25 lines
Is everyone fine with this code now :)
int
tst_is_mounted(const char *path){ char line[PATH_MAX]; FILE *file; int ret = 0; file = SAFE_FOPEN(NULL, "/proc/mounts", "r"); while (fgets(line, sizeof(line), file)) { if (strstr(line, path) != NULL) { ret = 1; break; } } SAFE_FCLOSE(NULL, file); if (!ret) tst_resm(TINFO, "No device is mounted at %s", path); return ret; }
Quoted 7 lines
int
tst_is_mounted_at_tmpdir(const char *path){ char cdir[PATH_MAX], mpath[PATH_MAX]; int ret; if (!getcwd(cdir, PATH_MAX)) return 0;
LGTM. I guess we can ignore this, but maybe tst_res(TWARN | TERRNO, "..."), could be added here. But maybe it's not important.
Quoted 6 lines
ret = snprintf(mpath, PATH_MAX, "%s/%s", cdir, path);
if (ret < 0 || ret >= PATH_MAX)
return 0;
return tst_is_mounted(mpath);
}Kind regards,
Petr
PATCH v5 2/10 lapi/fsmount.h: Add fsopen_supported_by_kernel()
In reply to Viresh KumarAdd a helper to check if the fsmount() related syscalls are supported by the kernel or not.
--- include/lapi/fsmount.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/lapi/fsmount.h +9 -0
@@ -130,5 +130,14 @@ enum fsconfig_command {#endif /* OPEN_TREE_CLONE */ +void fsopen_supported_by_kernel (void ) +{ +if ((tst_kvercmp (5 ,2 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ +TEST (syscall (__NR_fsopen,NULL ,0 )); +if (TST_RET ==-1 &&TST_ERR ==ENOSYS ) +tst_brk (TCONF ,"Test not supported on kernel version < v5.2" ); + } +}#endif /* FSMOUNT_H__ */
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v5 2/10 lapi/fsmount.h: Add fsopen_supported_by_kernel()
Quoted 15 lines · Viresh Kumar
Add a helper to check if the
fsmount()related syscalls are supported by the kernel or not.Reviewed-by Petr Vorel <[email protected]>Acked-by Li Wang <[email protected]>Signed-off-by Viresh Kumar <[email protected]>--- include/lapi/fsmount.h | 9 +++++++++ 1 file changed, 9 insertions(+)include/lapi/fsmount.h +0
-0
include/lapi/fsmount.h enum fsconfig_command { · line 139
Quoted 10 lines
include/lapi/fsmount.h +7
-0@@ -130,5 +130,14 @@ enum fsconfig_command {#endif /* OPEN_TREE_CLONE */ +void fsopen_supported_by_kernel (void ) +{ +if ((tst_kvercmp (5 ,2 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ +TEST (syscall (__NR_fsopen,NULL ,0 )); +if (TST_RET ==-1 &&TST_ERR ==ENOSYS ) +tst_brk (TCONF ,"Test not supported on kernel version < v5.2" );
Shouldn't we close the TST_RET here?
Quoted 7 lines
include/lapi/fsmount.h +2
-0+ } +}#endif /* FSMOUNT_H__ */ Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v5 2/10 lapi/fsmount.h: Add fsopen_supported_by_kernel()
Quoted 19 lines · Cyril Hrubis
Quoted 18 lines · Viresh Kumar
Add a helper to check if the
fsmount()related syscalls are supported by the kernel or not.Reviewed-by Petr Vorel <[email protected]>Acked-by Li Wang <[email protected]>Signed-off-by Viresh Kumar <[email protected]>--- include/lapi/fsmount.h | 9 +++++++++ 1 file changed, 9 insertions(+)include/lapi/fsmount.h +0
-0@@ -130,5 +130,14 @@ enum fsconfig_command {#endif /* OPEN_TREE_CLONE */
Quoted 9 lines
include/lapi/fsmount.h enum fsconfig_command { · line 139
Quoted 7 lines
include/lapi/fsmount.h +7
-0+void fsopen_supported_by_kernel (void ) +{ +if ((tst_kvercmp (5 ,2 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ +TEST (syscall (__NR_fsopen,NULL ,0 )); +if (TST_RET ==-1 &&TST_ERR ==ENOSYS ) +tst_brk (TCONF ,"Test not supported on kernel version < v5.2" );Shouldn't we close the
TST_REThere?
I didn't do that in the else part as this call should never succeed and it will be a bug if it succeeds. Do you still want me to do it ?
Signature · 1 line
viresh
PATCH v5 3/10 lapi/fsmount.h: Include "lapi/fcntl.h"
In reply to Viresh KumarAll the files that include (and that will include it in future) are most probably going to need the definitions from "lapi/fcntl.h", include it directly instead of <fcntl.h>, which will break it for old RHL distros.
--- include/lapi/fsmount.h | 2 +- testcases/kernel/syscalls/fsmount/fsmount01.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
include/lapi/fsmount.h +1 -1
@@ -7,12 +7,12 @@#ifndef FSMOUNT_H__ #define FSMOUNT_H__ -#include <fcntl.h> #include <sys/mount.h> #include <sys/syscall.h> #include <sys/types.h> #include "config.h" +#include "lapi/fcntl.h" #include "lapi/syscalls.h" #ifndef HAVE_FSOPEN
testcases/kernel/syscalls/fsmount/fsmount01.c +0 -1
@@ -10,7 +10,6 @@#include <sys/mount.h> #include "tst_test.h" -#include "lapi/fcntl.h" #include "lapi/fsmount.h" #define MNTPOINT "newmount_point"
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v5 4/10 syscalls/fsopen: New tests
In reply to Viresh KumarAdd tests to check working of fsopen() syscall.
--- runtest/syscalls | 3 + testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 ++ testcases/kernel/syscalls/fsopen/fsopen01.c | 80 +++++++++++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 58 +++++++++++++++ 5 files changed, 149 insertions(+) create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore create mode 100644 testcases/kernel/syscalls/fsopen/Makefile create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c
runtest/syscalls +3 -0
@@ -343,6 +343,9 @@ fremovexattr02 fremovexattr02 fsmount01 fsmount01 +fsopen01 fsopen01 +fsopen02 fsopen02 + fstat02 fstat02 fstat02_64 fstat02_64 fstat03 fstat03
testcases/kernel/syscalls/fsopen/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/fsopen01 +/fsopen02
testcases/kernel/syscalls/fsopen/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fsopen/fsopen01.c new file +80 -0
80 lines not on this page · raw message
testcases/kernel/syscalls/fsopen/fsopen02.c new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v5 4/10 syscalls/fsopen: New tests
Hi!
Quoted 4 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +4
-0+TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT , +MOVE_MOUNT_F_EMPTY_PATH )); + +SAFE_CLOSE (fsmfd);
testcases/kernel/syscalls/fsopen/fsopen01.c line 65
Quoted 10 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +10
-0+ +if (TST_RET ==-1 ) { +tst_res (TFAIL |TERRNO ,"move_mount() failed" ); + goto out; + } + +if (tst_is_mounted (MNTPOINT )) +tst_res (TPASS ,"%s: fsopen() passed" , tc->name); + +SAFE_UMOUNT (MNTPOINT );
I gues sthat the SAFE_UMOUNT() should be inside of the if here and in the rest of the testcases.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v5 4/10 syscalls/fsopen: New tests
Quoted 10 lines · Cyril Hrubis
Hi!
Quoted 9 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +9
-0+TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT , +MOVE_MOUNT_F_EMPTY_PATH )); + +SAFE_CLOSE (fsmfd); + +if (TST_RET ==-1 ) { +tst_res (TFAIL |TERRNO ,"move_mount() failed" ); + goto out; + }
Quoted 8 lines
testcases/kernel/syscalls/fsopen/fsopen01.c line 65
Quoted 5 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +5
-0+ +if (tst_is_mounted (MNTPOINT )) +tst_res (TPASS ,"%s: fsopen() passed" , tc->name); + +SAFE_UMOUNT (MNTPOINT );I gues sthat the
SAFE_UMOUNT()should be inside of the if here and in the rest of the testcases.
Petr had a similar comment earlier and here is my explanation to it.
There should always be a unmount() in response to a successful call to mount() APIs. What if, because of some other bugs in the kernel or testsuite, tst_is_mounted() returns 0? We should still do the unmount() part as the mount() API didn't return an error.
Signature · 1 line
viresh
PATCH v5 4/10 syscalls/fsopen: New tests
Hi Viresh,
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +9
-0+TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT , +MOVE_MOUNT_F_EMPTY_PATH )); + +SAFE_CLOSE (fsmfd); + +if (TST_RET ==-1 ) { +tst_res (TFAIL |TERRNO ,"move_mount() failed" ); + goto out; + }Quoted 8 lines
testcases/kernel/syscalls/fsopen/fsopen01.c line 65
Quoted 5 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +5
-0+ +if (tst_is_mounted (MNTPOINT )) +tst_res (TPASS ,"%s: fsopen() passed" , tc->name); + +SAFE_UMOUNT (MNTPOINT );I gues sthat the
SAFE_UMOUNT()should be inside of the if here and in the rest of the testcases.
Quoted 6 lines
Petr had a similar comment earlier and here is my explanation to it.
There should always be a
unmount()in response to a successful call tomount()APIs. What if, because of some other bugs in the kernel or testsuite,tst_is_mounted()returns 0? We should still do theunmount()part as themount()API didn't return an error.
But IMHO if device is not mounted we get TBROK due EINVAL in safe_umount(). I'd understand if this was in cleanup function where TBROK turns to TWARN.
Kind regards,
Petr
PATCH v5 4/10 syscalls/fsopen: New tests
Quoted 20 lines · Petr Vorel
Hi Viresh,
Quoted 17 lines
Quoted 17 lines
Quoted 4 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +4
-0+TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT , +MOVE_MOUNT_F_EMPTY_PATH )); + +SAFE_CLOSE (fsmfd);testcases/kernel/syscalls/fsopen/fsopen01.c line 65
Quoted 10 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +10
-0+ +if (TST_RET ==-1 ) { +tst_res (TFAIL |TERRNO ,"move_mount() failed" ); + goto out; + } + +if (tst_is_mounted (MNTPOINT )) +tst_res (TPASS ,"%s: fsopen() passed" , tc->name); + +SAFE_UMOUNT (MNTPOINT );I gues sthat the
SAFE_UMOUNT()should be inside of the if here and in the rest of the testcases.
Quoted 7 lines
Quoted 6 lines
Petr had a similar comment earlier and here is my explanation to it.
There should always be a
unmount()in response to a successful call tomount()APIs. What if, because of some other bugs in the kernel or testsuite,tst_is_mounted()returns 0? We should still do theunmount()part as themount()API didn't return an error.But IMHO if device is not mounted we get TBROK due EINVAL in
safe_umount().
But why won't move_mount() fail if device isn't mounted ? Why do we need the tst_is_mounted() helper at all ? Just to catch a case where move_mount() is buggy and doesn't report the failure properly, right ? In case of that bug, isn't it possible that move_mount() allocates some resources which must be freed with a call to umount() nevertheless ?
Signature · 1 line
viresh
PATCH v5 4/10 syscalls/fsopen: New tests
Hi!
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
I gues sthat the
SAFE_UMOUNT()should be inside of the if here and in the rest of the testcases.Petr had a similar comment earlier and here is my explanation to it.
There should always be a
unmount()in response to a successful call tomount()APIs. What if, because of some other bugs in the kernel or testsuite,tst_is_mounted()returns 0? We should still do theunmount()part as themount()API didn't return an error.
Quoted 8 lines
Quoted 1 line
But IMHO if device is not mounted we get TBROK due EINVAL in
safe_umount().But why won't
move_mount()fail if device isn't mounted ? Why do we need thetst_is_mounted()helper at all ? Just to catch a case wheremove_mount()is buggy and doesn't report the failure properly, right ? In case of that bug, isn't it possible thatmove_mount()allocates some resources which must be freed with a call toumount()nevertheless ?
We can't really clean things up when something in kernel is misbehaving. If there is a bug we enter the wast lands of undefined behavior where anything is possible and any attempt to restore the system in a defined state is doomed to fail anyways.
So in the end I do not care here as long as we clean up properly when things work as expected, so either way is fine. It only looks a bit strange when we attempt to umount things that are possibly not mounted.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v5 5/10 syscalls/fsconfig: New tests
In reply to Viresh KumarAdd tests to check working of fsconfig() syscall.
--- runtest/syscalls | 3 + testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 ++ .../kernel/syscalls/fsconfig/fsconfig01.c | 101 ++++++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 99 +++++++++++++++++ 5 files changed, 211 insertions(+) create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c
runtest/syscalls +3 -0
@@ -341,6 +341,9 @@ fpathconf01 fpathconf01 fremovexattr01 fremovexattr01 fremovexattr02 fremovexattr02 +fsconfig01 fsconfig01 +fsconfig02 fsconfig02 + fsmount01 fsmount01 fsopen01 fsopen01
testcases/kernel/syscalls/fsconfig/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/fsconfig01 +/fsconfig02
testcases/kernel/syscalls/fsconfig/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +101 -0
101 lines not on this page · raw message
testcases/kernel/syscalls/fsconfig/fsconfig02.c new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v5 5/10 syscalls/fsconfig: New tests
Quoted 1 line
Add tests to check working of
fsconfig()syscall.
...
Quoted 1 line
+++
b/testcases/kernel/syscalls/fsconfig/fsconfig01.c
...
testcases/kernel/syscalls/fsconfig/fsconfig01.c line 24
Quoted 12 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +12
-0+static void run (void ) +{ +int fd, fsmfd; + +TEST (fd =fsopen (tst_device->fs_type,0 )); +if (fd ==-1 ) +tst_brk (TBROK |TERRNO ,"fsopen() failed" ); + +TEST (fsconfig (fd,FSCONFIG_SET_FLAG ,"rw" ,NULL ,0 )); +if (TST_RET ==-1 ) { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" ); + goto out;
Because there is .test_all (single run), although which is called N times for each filesystem (.all_filesystems = 1), but cleanup is called for each of them it's I'll move SAFE_CLOSE(fd) to cleanup function and use here (and on the rest of calls) return (trying to avoid goto when possible).
I'll change it before merge.
testcases/kernel/syscalls/fsconfig/fsconfig01.c line 72
Quoted 5 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +5
-0+ +TEST (fsmfd =fsmount (fd,0 ,0 )); +if (fsmfd ==-1 ) { +tst_res (TBROK |TERRNO ,"fsmount() failed" ); + goto out;
BTW This needs to be now tst_res(TFAIL) (this patchset now does not compile).
testcases/kernel/syscalls/fsconfig/fsconfig01.c line 61
Quoted 9 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +9
-0+TEST (fsconfig (fd,FSCONFIG_SET_FD ,"sync" ,NULL ,0 )); +if (TST_RET ==-1 ) { +if (TST_ERR ==EOPNOTSUPP ) { +tst_res (TCONF ,"fsconfig(): FSCONFIG_SET_FD not supported" ); + }else { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" ); + goto out; + } + }
I get TCONF for all fsconfig01 results, while I'm using 5.5.5-1-default:
tst_test.c:1290: INFO: Testing on ext2
tst_mkfs.c:89: INFO: Formatting /dev/loop0 with ext2 opts='' extra opts='' mke2fs 1.45.5 (07-Jan-2020)
tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF: fsconfig(): FSCONFIG_SET_PATH not supported fsconfig01.c:53: CONF: fsconfig(): FSCONFIG_SET_PATH_EMPTY not supported fsconfig01.c:63: CONF: fsconfig(): FSCONFIG_SET_FD not supported fsconfig01.c:92: PASS: fsconfig() passed
tst_test.c:1290: INFO: Testing on ext3
tst_mkfs.c:89: INFO: Formatting /dev/loop0 with ext3 opts='' extra opts='' mke2fs 1.45.5 (07-Jan-2020)
tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF: fsconfig(): FSCONFIG_SET_PATH not supported fsconfig01.c:53: CONF: fsconfig(): FSCONFIG_SET_PATH_EMPTY not supported fsconfig01.c:63: CONF: fsconfig(): FSCONFIG_SET_FD not supported fsconfig01.c:92: PASS: fsconfig() passed
tst_test.c:1290: INFO: Testing on ext4
tst_mkfs.c:89: INFO: Formatting /dev/loop0 with ext4 opts='' extra opts='' mke2fs 1.45.5 (07-Jan-2020)
tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF: fsconfig(): FSCONFIG_SET_PATH not supported fsconfig01.c:53: CONF: fsconfig(): FSCONFIG_SET_PATH_EMPTY not supported fsconfig01.c:63: CONF: fsconfig(): FSCONFIG_SET_FD not supported fsconfig01.c:92: PASS: fsconfig() passed
tst_test.c:1290: INFO: Testing on xfs
tst_mkfs.c:89: INFO: Formatting /dev/loop0 with xfs opts='' extra opts='' tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:92: PASS: fsconfig() passed
tst_test.c:1290: INFO: Testing on btrfs
tst_mkfs.c:89: INFO: Formatting /dev/loop0 with btrfs opts='' extra opts='' tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF: fsconfig(): FSCONFIG_SET_PATH not supported fsconfig01.c:53: CONF: fsconfig(): FSCONFIG_SET_PATH_EMPTY not supported fsconfig01.c:63: CONF: fsconfig(): FSCONFIG_SET_FD not supported fsconfig01.c:92: PASS: fsconfig() passed
tst_test.c:1290: INFO: Testing on vfat
tst_mkfs.c:89: INFO: Formatting /dev/loop0 with vfat opts='' extra opts='' tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF: fsconfig(): FSCONFIG_SET_PATH not supported fsconfig01.c:53: CONF: fsconfig(): FSCONFIG_SET_PATH_EMPTY not supported fsconfig01.c:63: CONF: fsconfig(): FSCONFIG_SET_FD not supported fsconfig01.c:92: PASS: fsconfig() passed
Not yet merged man page [1] (I reposted David Howells commit) there is explanation for EOPNOTSUPP: The command given by cmd was not valid.
First, I suspected "sync" option is wrong. But looking at kernel sources it's really not implemented:
fs/fsopen.c
if (fc->ops == &legacy_fs_context_ops) {
switch (cmd) {
case FSCONFIG_SET_BINARY:
case FSCONFIG_SET_PATH:
case FSCONFIG_SET_PATH_EMPTY:
case FSCONFIG_SET_FD:
ret = -EOPNOTSUPP;
goto out_f;
}
}fs/fs_context.c
/* TODO: Make all filesystems support this unconditionally */ init_fs_context = fc->fs_type->init_fs_context; if (!init_fs_context) init_fs_context = legacy_init_fs_context;
...
/*
* Initialise a legacy context for a filesystem that doesn't support
* fs_context.
*/
static int legacy_init_fs_context(struct fs_context *fc)
{
fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL);
if (!fc->fs_private)
return -ENOMEM;
fc->ops = &legacy_fs_context_ops;
return 0;
}Code coming from v5.1-rc1 f3a09c92018a91ad0981146a4ac59414f814d801 introduce fs_context methods [2]. Other patchsets here [3] shows there is some support for fs_context in VFS. So I wonder how to achieve not end up with legacy context.
Quoted 2 lines
+++
b/testcases/kernel/syscalls/fsconfig/fsconfig02.c
+ {"set-path-key", &fd,FSCONFIG_SET_PATH, NULL, "/dev/sda1",&aux_fdcwd, EINVAL},
...
Quoted 1 line
+ {"set-path-aux", &fd,
FSCONFIG_SET_PATH, "sync", "/dev/sda1",&aux_minus1, EINVAL},
/dev/sda1 is valid on some hosts, but invalid on others. Shouldn't we use /dev/foo instead?
...
testcases/kernel/syscalls/fsconfig/fsconfig02.c line 60
Quoted 3 lines
testcases/kernel/syscalls/fsconfig/fsconfig02.c new file +3
-0+ temp_fd =open ("testfile" ,O_RDWR |O_CREAT ,01444 ); +if (temp_fd ==-1 ) +tst_res (TBROK ,"Can't obtain temp_fd, open() failed" );
Here needs to be now tst_brk(TBROK).
Again I'll change it before merge.
...
Kind regards,
Petr
[1] https://marc.info/?l=linux-man&m=158109737907972&w=2
[2] https://patchwork.kernel.org/patch/10820207/
[3] https://patchwork.kernel.org/project/linux-security-module/list/?series=82377
PATCH v5 5/10 syscalls/fsconfig: New tests
Quoted 5 lines · Petr Vorel
testcases/kernel/syscalls/fsconfig/fsconfig01.c line 72
Quoted 4 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +4
-0+TEST (fsmfd =fsmount (fd,0 ,0 )); +if (fsmfd ==-1 ) { +tst_res (TBROK |TERRNO ,"fsmount() failed" ); + goto out;BTW This needs to be now
tst_res(TFAIL)(this patchset now does not compile).
For a minute I thought I failed with my testing :(
And then I looked at the recent changes and looks like compilation broke due to the changes you have pushed recently. Right ?
Quoted 11 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c line 61
Quoted 9 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +9
-0+TEST (fsconfig (fd,FSCONFIG_SET_FD ,"sync" ,NULL ,0 )); +if (TST_RET ==-1 ) { +if (TST_ERR ==EOPNOTSUPP ) { +tst_res (TCONF ,"fsconfig(): FSCONFIG_SET_FD not supported" ); + }else { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" ); + goto out; + } + }I get TCONF for all fsconfig01 results, while I'm using 5.5.5-1-default:
s/all/most/
I know, same here.
Quoted 20 lines
tst_test.c:1290: INFO: Testing on ext2
tst_mkfs.c:89: INFO: Formatting/dev/loop0with ext2 opts='' extra opts='' mke2fs 1.45.5 (07-Jan-2020)
tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF:fsconfig():FSCONFIG_SET_PATHnot supported fsconfig01.c:53: CONF:fsconfig():FSCONFIG_SET_PATH_EMPTYnot supported fsconfig01.c:63: CONF:fsconfig():FSCONFIG_SET_FDnot supported fsconfig01.c:92: PASS:fsconfig()passed
tst_test.c:1290: INFO: Testing on ext3
tst_mkfs.c:89: INFO: Formatting/dev/loop0with ext3 opts='' extra opts='' mke2fs 1.45.5 (07-Jan-2020)
tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF:fsconfig():FSCONFIG_SET_PATHnot supported fsconfig01.c:53: CONF:fsconfig():FSCONFIG_SET_PATH_EMPTYnot supported fsconfig01.c:63: CONF:fsconfig():FSCONFIG_SET_FDnot supported fsconfig01.c:92: PASS:fsconfig()passed
tst_test.c:1290: INFO: Testing on ext4
tst_mkfs.c:89: INFO: Formatting/dev/loop0with ext4 opts='' extra opts='' mke2fs 1.45.5 (07-Jan-2020)
tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s
Quoted 8 lines
fsconfig01.c:43: CONF:
fsconfig():FSCONFIG_SET_PATHnot supported fsconfig01.c:53: CONF:fsconfig():FSCONFIG_SET_PATH_EMPTYnot supported fsconfig01.c:63: CONF:fsconfig():FSCONFIG_SET_FDnot supported fsconfig01.c:92: PASS:fsconfig()passed
tst_test.c:1290: INFO: Testing on xfs
tst_mkfs.c:89: INFO: Formatting/dev/loop0with xfs opts='' extra opts='' tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:92: PASS:fsconfig()passed
You didn't get them for xfs :)
Quoted 44 lines
tst_test.c:1290: INFO: Testing on btrfs
tst_mkfs.c:89: INFO: Formatting/dev/loop0with btrfs opts='' extra opts='' tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF:fsconfig():FSCONFIG_SET_PATHnot supported fsconfig01.c:53: CONF:fsconfig():FSCONFIG_SET_PATH_EMPTYnot supported fsconfig01.c:63: CONF:fsconfig():FSCONFIG_SET_FDnot supported fsconfig01.c:92: PASS:fsconfig()passed
tst_test.c:1290: INFO: Testing on vfat
tst_mkfs.c:89: INFO: Formatting/dev/loop0with vfat opts='' extra opts='' tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF:fsconfig():FSCONFIG_SET_PATHnot supported fsconfig01.c:53: CONF:fsconfig():FSCONFIG_SET_PATH_EMPTYnot supported fsconfig01.c:63: CONF:fsconfig():FSCONFIG_SET_FDnot supported fsconfig01.c:92: PASS:fsconfig()passedNot yet merged man page [1] (I reposted David Howells commit) there is explanation for EOPNOTSUPP: The command given by cmd was not valid.
First, I suspected "sync" option is wrong. But looking at kernel sources it's really not implemented:
fs/fsopen.cif (fc->ops == &legacy_fs_context_ops) { switch (cmd) { case FSCONFIG_SET_BINARY: case FSCONFIG_SET_PATH: case FSCONFIG_SET_PATH_EMPTY: case FSCONFIG_SET_FD: ret = -EOPNOTSUPP; goto out_f; } }
fs/fs_context.c/* TODO: Make all filesystems support this unconditionally */ init_fs_context = fc->fs_type->init_fs_context; if (!init_fs_context) init_fs_context = legacy_init_fs_context;...
/*
* Initialise a legacy context for a filesystem that doesn't support
*fs_context.
*/
static intlegacy_init_fs_context(struct fs_context *fc)
Quoted 7 lines
{
fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL);
if (!fc->fs_private)
return -ENOMEM;
fc->ops = &legacy_fs_context_ops;
return 0;
}Right, I have seen that all earlier and so I knew that the failures here are just fine.
Quoted 10 lines
Code coming from v5.1-rc1
f3a09c92018a91ad0981146a4ac59414f814d801introducefs_contextmethods [2]. Other patchsets here [3] shows there is some support forfs_contextin VFS. So I wonder how to achieve not end up with legacy context.Quoted 2 lines
+++
b/testcases/kernel/syscalls/fsconfig/fsconfig02.c
+ {"set-path-key", &fd,FSCONFIG_SET_PATH, NULL, "/dev/sda1",&aux_fdcwd, EINVAL},...
Quoted 1 line
+ {"set-path-aux", &fd,
FSCONFIG_SET_PATH, "sync", "/dev/sda1",&aux_minus1, EINVAL},
/dev/sda1is valid on some hosts, but invalid on others. Shouldn't we use/dev/fooinstead?
Should be fine I think.
Quoted 6 lines
...
testcases/kernel/syscalls/fsconfig/fsconfig02.c line 60
Quoted 3 lines
testcases/kernel/syscalls/fsconfig/fsconfig02.c new file +3
-0+ temp_fd =open ("testfile" ,O_RDWR |O_CREAT ,01444 ); +if (temp_fd ==-1 ) +tst_res (TBROK ,"Can't obtain temp_fd, open() failed" );Here needs to be now
tst_brk(TBROK).
Again I'll change it before merge.
Thanks.
Signature · 1 line
viresh
PATCH v5 5/10 syscalls/fsconfig: New tests
In reply to Petr VorelHi Viresh,
Quoted 45 lines
I get TCONF for all fsconfig01 results, while I'm using 5.5.5-1-default:
tst_test.c:1290: INFO: Testing on ext2
tst_mkfs.c:89: INFO: Formatting/dev/loop0with ext2 opts='' extra opts='' mke2fs 1.45.5 (07-Jan-2020)
tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF:fsconfig():FSCONFIG_SET_PATHnot supported fsconfig01.c:53: CONF:fsconfig():FSCONFIG_SET_PATH_EMPTYnot supported fsconfig01.c:63: CONF:fsconfig():FSCONFIG_SET_FDnot supported fsconfig01.c:92: PASS:fsconfig()passed
tst_test.c:1290: INFO: Testing on ext3
tst_mkfs.c:89: INFO: Formatting/dev/loop0with ext3 opts='' extra opts='' mke2fs 1.45.5 (07-Jan-2020)
tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF:fsconfig():FSCONFIG_SET_PATHnot supported fsconfig01.c:53: CONF:fsconfig():FSCONFIG_SET_PATH_EMPTYnot supported fsconfig01.c:63: CONF:fsconfig():FSCONFIG_SET_FDnot supported fsconfig01.c:92: PASS:fsconfig()passed
tst_test.c:1290: INFO: Testing on ext4
tst_mkfs.c:89: INFO: Formatting/dev/loop0with ext4 opts='' extra opts='' mke2fs 1.45.5 (07-Jan-2020)
tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF:fsconfig():FSCONFIG_SET_PATHnot supported fsconfig01.c:53: CONF:fsconfig():FSCONFIG_SET_PATH_EMPTYnot supported fsconfig01.c:63: CONF:fsconfig():FSCONFIG_SET_FDnot supported fsconfig01.c:92: PASS:fsconfig()passed
tst_test.c:1290: INFO: Testing on xfs
tst_mkfs.c:89: INFO: Formatting/dev/loop0with xfs opts='' extra opts='' tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:92: PASS:fsconfig()passed
tst_test.c:1290: INFO: Testing on btrfs
tst_mkfs.c:89: INFO: Formatting/dev/loop0with btrfs opts='' extra opts='' tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF:fsconfig():FSCONFIG_SET_PATHnot supported fsconfig01.c:53: CONF:fsconfig():FSCONFIG_SET_PATH_EMPTYnot supported fsconfig01.c:63: CONF:fsconfig():FSCONFIG_SET_FDnot supported fsconfig01.c:92: PASS:fsconfig()passed
tst_test.c:1290: INFO: Testing on vfat
tst_mkfs.c:89: INFO: Formatting/dev/loop0with vfat opts='' extra opts='' tst_test.c:1227: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:43: CONF:fsconfig():FSCONFIG_SET_PATHnot supported fsconfig01.c:53: CONF:fsconfig():FSCONFIG_SET_PATH_EMPTYnot supported fsconfig01.c:63: CONF:fsconfig():FSCONFIG_SET_FDnot supported fsconfig01.c:92: PASS:fsconfig()passed
Quoted 5 lines
Not yet merged man page [1] (I reposted David Howells commit) there is explanation for EOPNOTSUPP: The command given by cmd was not valid.
First, I suspected "sync" option is wrong. But looking at kernel sources it's really not implemented:
I'm sorry, I was wrong. I overlooked It's supported, but just by xfs (which is surprising).
Kind regards,
Petr
PATCH v5 6/10 syscalls/fsmount: Improve fsmount01 test
In reply to Viresh KumarThis patch updates the fsmount01.c file to make it look similar to all other fsmount related syscall tests and here is the list of all changes:
- Test all fsmount flags and mount attributes
- Remove extra PASS messages as all we want to test here is fsmount() and not other syscalls.
- On the same lines, print TFAIL for fsmount() syscall and TBROK for other calls.
- close sfd on failures
- Make the file look similar to other fsmount related tests
- General cleanup
--- testcases/kernel/syscalls/fsmount/fsmount01.c | 103 +++++++++++------- 1 file changed, 65 insertions(+), 38 deletions(-)
testcases/kernel/syscalls/fsmount/fsmount01.c +65 -38
@@ -3,67 +3,94 @@* Copyright (C) 2020 Red Hat, Inc. All rights reserved. * Author: Zorro Lang <[email protected]> * -* Use new mount API from v5.2 (fsopen(), fsconfig(), fsmount(), move_mount()) -* to mount a filesystem without any specified mount options. +* Basic fsmount() test. */ -#include <sys/mount.h> -#include "tst_test.h" #include "lapi/fsmount.h" -#define MNTPOINT "newmount_point" -static int sfd, mfd, is_mounted; +#define MNTPOINT "mntpoint" -static void cleanup (void ) -{ -if (is_mounted) -SAFE_UMOUNT (MNTPOINT ); -} +#define TCASE_ENTRY (_flags, _attrs) {.name = "Flag " #_flags ", Attr " #_attrs, .flags = _flags, .attrs = _attrs} -static void test_fsmount (void ) +static struct tcase { +char *name; +unsigned int flags; +unsigned int attrs; +} tcases[] = { +TCASE_ENTRY (0 ,MOUNT_ATTR_RDONLY ), +TCASE_ENTRY (0 ,MOUNT_ATTR_NOSUID ), +TCASE_ENTRY (0 ,MOUNT_ATTR_NODEV ), +TCASE_ENTRY (0 ,MOUNT_ATTR_NOEXEC ), +TCASE_ENTRY (0 ,MOUNT_ATTR_RELATIME ), +TCASE_ENTRY (0 ,MOUNT_ATTR_NOATIME ), +TCASE_ENTRY (0 ,MOUNT_ATTR_STRICTATIME ), +TCASE_ENTRY (0 ,MOUNT_ATTR_NODIRATIME ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_RDONLY ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOSUID ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_NODEV ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOEXEC ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_RELATIME ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOATIME ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_STRICTATIME ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_NODIRATIME ), +}; + +static void run (unsigned int n) { -TEST (fsopen (tst_device->fs_type,FSOPEN_CLOEXEC )); -if (TST_RET <0 ) -tst_brk (TBROK |TTERRNO ,"fsopen() on %s failed" , tst_device->fs_type); - sfd =TST_RET ; -tst_res (TPASS ,"fsopen() on %s" , tst_device->fs_type); +struct tcase *tc = &tcases[n]; +int sfd, mfd; + +TEST (sfd =fsopen (tst_device->fs_type,FSOPEN_CLOEXEC )); +if (sfd ==-1 ) { +tst_res (TFAIL |TTERRNO ,"fsopen() on %s failed" , + tst_device->fs_type); +return ; + }TEST (fsconfig (sfd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 )); -if (TST_RET <0 ) -tst_brk (TBROK |TTERRNO , +if (TST_RET ==-1 ) { +SAFE_CLOSE (sfd); +tst_res (TFAIL |TTERRNO ,"fsconfig() failed to set source to %s" , tst_device->dev); -tst_res (TPASS ,"fsconfig() set source to %s" , tst_device->dev); - +return ; + }TEST (fsconfig (sfd,FSCONFIG_CMD_CREATE ,NULL ,NULL ,0 )); -if (TST_RET <0 ) -tst_brk (TBROK |TTERRNO ,"fsconfig() created superblock" ); -tst_res (TPASS ,"fsconfig() created superblock" ); +if (TST_RET ==-1 ) { +SAFE_CLOSE (sfd); +tst_res (TFAIL |TTERRNO ,"fsconfig() created superblock" ); +return ; + } -TEST (fsmount (sfd,FSMOUNT_CLOEXEC ,0 )); -if (TST_RET <0 ) -tst_brk (TBROK |TTERRNO ,"fsmount() failed to create a mount object" ); - mfd =TST_RET ; -tst_res (TPASS ,"fsmount() created a mount object" ); +TEST (mfd =fsmount (sfd, tc->flags, tc->attrs));SAFE_CLOSE (sfd); +if (mfd ==-1 ) { +tst_res (TFAIL |TTERRNO , +"fsmount() failed to create a mount object" ); +return ; + } +TEST (move_mount (mfd,"" ,AT_FDCWD ,MNTPOINT ,MOVE_MOUNT_F_EMPTY_PATH )); -if (TST_RET <0 ) -tst_brk (TBROK |TTERRNO ,"move_mount() failed to attach to the mount point" ); - is_mounted =1 ; -tst_res (TPASS ,"move_mount() attached to the mount point" );SAFE_CLOSE (mfd); -if (tst_is_mounted (MNTPOINT )) { -SAFE_UMOUNT (MNTPOINT ); - is_mounted =0 ; +if (TST_RET ==-1 ) { +tst_res (TFAIL |TTERRNO , +"move_mount() failed to attach to the mount point" ); +return ; } + +if (tst_is_mounted (MNTPOINT )) +tst_res (TPASS ,"%s: fsmount() passed" , tc->name); + +SAFE_UMOUNT (MNTPOINT ); }static struct tst_test test = { - .test_all = test_fsmount, - .cleanup = cleanup, + .tcnt =ARRAY_SIZE (tcases), + .test = run, + .setup = fsopen_supported_by_kernel, .needs_root =1 , .mntpoint =MNTPOINT , .format_device =1 ,
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v5 7/10 syscalls/fsmount: Add failure tests
In reply to Viresh KumarThis adds fsmount02.c tests to verify all the errors returned on failures.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/fsmount/.gitignore | 1 + testcases/kernel/syscalls/fsmount/fsmount02.c | 80 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c
runtest/syscalls +1 -0
@@ -345,6 +345,7 @@ fsconfig01 fsconfig01 fsconfig02 fsconfig02 fsmount01 fsmount01 +fsmount02 fsmount02 fsopen01 fsopen01 fsopen02 fsopen02
testcases/kernel/syscalls/fsmount/.gitignore +1 -0
@@ -1 +1,2 @@ /fsmount01 +/fsmount02
testcases/kernel/syscalls/fsmount/fsmount02.c new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v5 8/10 syscalls/move_mount: New tests
In reply to Viresh KumarAdd tests to check working of move_mount() syscall.
--- runtest/syscalls | 3 + .../kernel/syscalls/move_mount/.gitignore | 2 + testcases/kernel/syscalls/move_mount/Makefile | 6 ++ .../kernel/syscalls/move_mount/move_mount01.c | 83 +++++++++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 92 +++++++++++++++++++ 5 files changed, 186 insertions(+) create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore create mode 100644 testcases/kernel/syscalls/move_mount/Makefile create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c
runtest/syscalls +3 -0
@@ -731,6 +731,9 @@ mount04 mount04 mount05 mount05 mount06 mount06 +move_mount01 move_mount01 +move_mount02 move_mount02 + move_pages01 move_pages01 move_pages02 move_pages02 move_pages03 move_pages03
testcases/kernel/syscalls/move_mount/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/move_mount01 +/move_mount02
testcases/kernel/syscalls/move_mount/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/move_mount/move_mount01.c new file +83 -0
83 lines not on this page · raw message
testcases/kernel/syscalls/move_mount/move_mount02.c new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v5 9/10 syscalls/fspick: New tests
In reply to Viresh KumarAdd tests to check working of fspick() syscall.
--- runtest/syscalls | 3 + testcases/kernel/syscalls/fspick/.gitignore | 2 + testcases/kernel/syscalls/fspick/Makefile | 6 ++ testcases/kernel/syscalls/fspick/fspick.h | 60 ++++++++++++++++++++ testcases/kernel/syscalls/fspick/fspick01.c | 62 +++++++++++++++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 54 ++++++++++++++++++ 6 files changed, 187 insertions(+) create mode 100644 testcases/kernel/syscalls/fspick/.gitignore create mode 100644 testcases/kernel/syscalls/fspick/Makefile create mode 100644 testcases/kernel/syscalls/fspick/fspick.h create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c
runtest/syscalls +3 -0
@@ -350,6 +350,9 @@ fsmount02 fsmount02 fsopen01 fsopen01 fsopen02 fsopen02 +fspick01 fspick01 +fspick02 fspick02 + fstat02 fstat02 fstat02_64 fstat02_64 fstat03 fstat03
testcases/kernel/syscalls/fspick/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/fspick01 +/fspick02
testcases/kernel/syscalls/fspick/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fspick/fspick.h new file +60 -0
60 lines not on this page · raw message
testcases/kernel/syscalls/fspick/fspick01.c new file +62 -0
62 lines not on this page · raw message
testcases/kernel/syscalls/fspick/fspick02.c new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v5 10/10 syscalls/open_tree: New tests
In reply to Viresh KumarAdd tests to check working of open_tree() syscall.
--- runtest/syscalls | 3 + .../kernel/syscalls/open_tree/.gitignore | 2 + testcases/kernel/syscalls/open_tree/Makefile | 6 + .../kernel/syscalls/open_tree/open_tree01.c | 108 ++++++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 105 +++++++++++++++++ 5 files changed, 224 insertions(+) create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore create mode 100644 testcases/kernel/syscalls/open_tree/Makefile create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.c
runtest/syscalls +3 -0
@@ -844,6 +844,9 @@ openat01 openat01 openat02 openat02 openat03 openat03 +open_tree01 open_tree01 +open_tree02 open_tree02 + mincore01 mincore01 mincore02 mincore02
testcases/kernel/syscalls/open_tree/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/open_tree01 +/open_tree02
testcases/kernel/syscalls/open_tree/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/open_tree/open_tree01.c new file +108 -0
108 lines not on this page · raw message
testcases/kernel/syscalls/open_tree/open_tree02.c new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
v5 cover Add new LTP tests related to fsmount family of syscalls
In reply to Viresh KumarHi!
Otherwise the minor things I and Peter pointed out the patchset looks good to me.
Signature · 2 lines
Cyril Hrubis [email protected]