move_mount03: check allow to mount beneath top mount
PATCH 1/1 move_mount03: check allow to mount beneath top mount
--- include/lapi/fsmount.h | 4 ++ runtest/syscalls | 1 + .../kernel/syscalls/move_mount/.gitignore | 1 + .../kernel/syscalls/move_mount/move_mount03.c | 63 +++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 testcases/kernel/syscalls/move_mount/move_mount03.c
include/lapi/fsmount.h +4 -0
@@ -115,6 +115,10 @@ static inline int mount_setattr(int dirfd, const char *from_pathname, unsigned i }#endif /* HAVE_MOUNT_SETATTR */ +#ifndef MOVE_MOUNT_BENEATH +#define MOVE_MOUNT_BENEATH 0x00000200 +#endif /* MOVE_MOUNT_BENEATH */ +/* * New headers added in kernel after 5.2 release, create them for old userspace. */
runtest/syscalls +1 -0
@@ -824,6 +824,7 @@ mount_setattr01 mount_setattr01 move_mount01 move_mount01 move_mount02 move_mount02 +move_mount03 move_mount03 move_pages01 move_pages01 move_pages02 move_pages02
testcases/kernel/syscalls/move_mount/.gitignore +1 -0
@@ -1,2 +1,3 @@ /move_mount01 /move_mount02 +/move_mount03
testcases/kernel/syscalls/move_mount/move_mount03.c new file +63 -0
63 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Quoted 50 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/fsmount.h | 4 ++ runtest/syscalls | 1 + .../kernel/syscalls/move_mount/.gitignore | 1 + .../kernel/syscalls/move_mount/move_mount03.c | 63 +++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 testcases/kernel/syscalls/move_mount/move_mount03.cinclude/lapi/fsmount.h +4
-0@@ -115,6 +115,10 @@ static inline int mount_setattr(int dirfd, const char *from_pathname, unsigned i }#endif /* HAVE_MOUNT_SETATTR */ +#ifndef MOVE_MOUNT_BENEATH +#define MOVE_MOUNT_BENEATH 0x00000200 +#endif /* MOVE_MOUNT_BENEATH */ +/* * New headers added in kernel after 5.2 release, create them for old userspace. */ runtest/syscalls +1
-0@@ -824,6 +824,7 @@ mount_setattr01 mount_setattr01 move_mount01 move_mount01 move_mount02 move_mount02 +move_mount03 move_mount03 move_pages01 move_pages01 move_pages02 move_pages02testcases/kernel/syscalls/move_mount/.gitignore +1
-0@@ -1,2 +1,3 @@ /move_mount01 /move_mount02 +/move_mount03testcases/kernel/syscalls/move_mount/move_mount03.c new file +0
-0
testcases/kernel/syscalls/move_mount/move_mount03.c line 9
Quoted 9 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +9
-0@@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2023 Wei Gao <[email protected]> +*/ + +/*\ +* [Description] +* +* Verify allow to mount beneath top mount
This should at least reference the following commit:
commit 6ac392815628f317fcfdca1a39df00b9cc4ebc8b
Author: Christian Brauner <[email protected]> Date: Wed May 3 13:18:42 2023 +0200
fs: allow to mount beneath top mount
To be honest I am struggling to understand what all of this does. However I think that I found some issues with the test which I have noted below.
Quoted 11 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +11
-0+* +*/ + +#include <stdio.h> + +#include "tst_test.h" +#include "lapi/fsmount.h" +#include "lapi/sched.h" + +#define MNTPOINTR "mntpoint" +#define DIRA "LTP_DIR_A"
testcases/kernel/syscalls/move_mount/move_mount03.c line 30
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0+ +static void run (void ) +{ +int fd; + +SAFE_UNSHARE (CLONE_NEWNS ); +SAFE_MKDIR (DIRA ,0777 ); +SAFE_TOUCH (DIRA "/A" ,0 ,NULL ); +/* The parent mnt should be private if check MOVE_MOUNT_BENEATH */ +SAFE_MOUNT ("none" ,"/" ,"none" ,MS_REC |MS_PRIVATE ,NULL );
Is it necessary and safe to do this on root? It's not clear what effect setting all mounts under the present "/" and namespace might have. I guess it should be possible to create a mount to use as the parent that is private?
testcases/kernel/syscalls/move_mount/move_mount03.c line 32
Quoted 2 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +2
-0+SAFE_MOUNT (DIRA ,DIRA ,"none" ,MS_BIND ,NULL ); + fd =SAFE_OPEN (DIRA ,O_RDONLY |O_DIRECTORY );
Why do we open this directory? It seems both source and destination can be paths.
Also it is never closed.
testcases/kernel/syscalls/move_mount/move_mount03.c line 37
Quoted 5 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +5
-0+ +TST_EXP_PASS (move_mount (fd,"" ,AT_FDCWD ,MNTPOINT , +MOVE_MOUNT_BENEATH |MOVE_MOUNT_F_EMPTY_PATH )); + +if (access (MNTPOINT "/A" ,F_OK ) ==0 )
So we have mounted mntpoint/LTP_DIR_A at mntpoint (or moved it there), but we don't expect file A to be there?
testcases/kernel/syscalls/move_mount/move_mount03.c line 40
Quoted 3 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +3
-0+tst_res (TFAIL ,"mount beneath top mount failed" ); + else + tst_res(TPASS, "mount beneath top mount pass");
This message doesn't explain what the test is doing. You can probably use TST_EXP_* here as well.
testcases/kernel/syscalls/move_mount/move_mount03.c line 49
Quoted 9 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +9
-0+ +if (tst_is_mounted_at_tmpdir (MNTPOINT )) +SAFE_UMOUNT (MNTPOINT ); + +if (access (MNTPOINT "/A" ,F_OK ) ==0 ) +tst_res (TPASS ,"mount beneath top mount pass" ); +else +tst_res (TFAIL ,"mount beneath top mount failed" ); +
So if MNTPOINT is not under tmpdir we do nothing, but the test now expects A to exist?
If we always unmount MNTPOINT then this should always fail because we never created anything at mntpoint/A.
testcases/kernel/syscalls/move_mount/move_mount03.c line 50
Quoted 1 line
testcases/kernel/syscalls/move_mount/move_mount03.c new file +1
-0+remove (DIRA "/A" );
This should probably be SAFE_UNLINK.
Quoted 13 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +13
-0+SAFE_RMDIR (DIRA ); +} + +static struct tst_test test = { + .test_all = run, + .needs_root =1 , + .format_device =1 , + .mntpoint =MNTPOINT , + .mount_device =1 , + .all_filesystems =1 , + .skip_filesystems = (const char *const []){"fuse" ,NULL }, + .min_kver ="6.5.0" +};
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 7 lines · Richard Palethorpe
Hello,
Wei Gao via ltp <[email protected]> writes:
This should at least reference the following commit:
commit
6ac392815628f317fcfdca1a39df00b9cc4ebc8b
Quoted 9 lines
Author: Christian Brauner <[email protected]> Date: Wed May 3 13:18:42 2023 +0200fs: allow to mount beneath top mount
To be honest I am struggling to understand what all of this does. However I think that I found some issues with the test which I have noted below.
Thanks for your pateint review, i also spend a lot of time to recall my memory for this test case, so i decide to reconstruct this test case with heavy comments to introduce how this feature work and give every explaination for each step of test case.
Quoted 6 lines
Signature · 3 lines
-- Thank you, Richard.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 move_mount03: check allow to mount beneath top mount
In reply to Wei Gao via ltp--- runtest/syscalls | 1 + .../kernel/syscalls/move_mount/.gitignore | 1 + .../kernel/syscalls/move_mount/move_mount03.c | 111 ++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 testcases/kernel/syscalls/move_mount/move_mount03.c
runtest/syscalls +1 -0
@@ -824,6 +824,7 @@ mount_setattr01 mount_setattr01 move_mount01 move_mount01 move_mount02 move_mount02 +move_mount03 move_mount03 move_pages01 move_pages01 move_pages02 move_pages02
testcases/kernel/syscalls/move_mount/.gitignore +1 -0
@@ -1,2 +1,3 @@ /move_mount01 /move_mount02 +/move_mount03
testcases/kernel/syscalls/move_mount/move_mount03.c new file +111 -0
111 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
I suppose there was no v1, right?
-i2 fails, please fix it.
# move_mount03 -i2 move_mount03.c:79: TINFO: Mounting none to /tmp/LTP_movcovMfK/LTP_DIR_A fstyp=tmpfs flags=0 move_mount03.c:80: TINFO: Mounting none to /tmp/LTP_movcovMfK/LTP_DIR_B fstyp=tmpfs flags=0 move_mount03.c:92: TPASS: move_mount(fda, "", fdb, "", MOVE_MOUNT_BENEATH | MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_EMPTY_PATH) passed move_mount03.c:98: TPASS: access(DIRB "/B", F_OK) passed move_mount03.c:99: TINFO: Umounting /tmp/LTP_movcovMfK/LTP_DIR_B move_mount03.c:100: TPASS: access(DIRB "/A", F_OK) passed move_mount03.c:102: TINFO: Umounting /tmp/LTP_movcovMfK/LTP_DIR_B move_mount03.c:103: TINFO: Umounting /tmp/LTP_movcovMfK/LTP_DIR_A move_mount03.c:77: TBROK: mkdir(LTP_DIR_A, 0777) failed: EEXIST (17)
NOTE: you can speed up the review process, if you check list of common errors before sending patch to ML
https://github.com/linux-test-project/ltp/wiki/Maintainer-Patch-Review-Checklist#how-to-find-clear-errors
make check-move_mount03
CHECK testcases/kernel/syscalls/move_mount/move_mount03.c move_mount03.c:92:9: error: undefined identifier 'MOVE_MOUNT_BENEATH'
I see false positive from checkpatch.pl, it would be interesting to check if it can be fixed.
Quoted 6 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +0
-0
testcases/kernel/syscalls/move_mount/move_mount03.c line 10
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0@@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2023 Christian Brauner <[email protected]> +* Copyright (c) 2023 Wei Gao <[email protected]> +*/ + +/*\ +* [Description] +* +* Verify allow to mount beneath top mount base following commit:
This will be very badly formatted in docs.
testcases/kernel/syscalls/move_mount/move_mount03.c line 22
Quoted 12 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +12
-0+* commit 6ac392815628f317fcfdca1a39df00b9cc4ebc8b +* Author: Christian Brauner <[email protected]> +* Date: Wed May 3 13:18:42 2023 +0200 +* fs: allow to mount beneath top mount +* +* Above commit has heavily commented but i found following commit +* contain simple summary of this feature for easy understanding: +* +* commit c0a572d9d32fe1e95672f24e860776dba0750a38 +* Author: Linus Torvalds <[email protected]> +* TL;DR: +*
Please generate metadata and have look at result. The output below looks ugly.
Either you find a way to preformat it as generated output (put extra space after
* in the comment - equivalent of <pre>... </pre> HTML output) or put it into /*
* */, so that it's not in docs (good for some info useful in C source but more related to the test implementation so that it does not have to be in generated docs).
Quoted 29 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +29
-0+* > mount -t ext4 /dev/sda /mnt +* | +* --/mnt /dev/sda ext4 +* +* > mount --beneath -t xfs /dev/sdb /mnt +* | +* --/mnt /dev/sdb xfs +* --/mnt /dev/sda ext4 +* +* > umount /mnt +* | +* --/mnt /dev/sdb xfs +* +* So base above scenario design following scenario for LTP check: +* +* > mount -t tmpfs /DIRA +* | +* --/DIRA(create A file within DIRA) +* +* > mount -t tmpfs /DIRB +* | +* --/DIRA(create B file within DIRB) +* +* > move_mount --beneath /DIRA /DIRB +* | +* --/mnt /DIRA /DIRB +* --/mnt /DIRB +* +* If you check content of /DIRB, you can see file B
testcases/kernel/syscalls/move_mount/move_mount03.c line 61
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0+* +* > umount /DIRB +* | +* --/mnt /DIRA /DIRB +* Check content of /DIRB, you can see file A exist since +* current /DIRB mount source is already become /DIRA +* +* More detail can be found in following link: +* Link: https://lwn.net/Articles/930591/ +* Link: https://github.com/brauner/move-mount-beneath
Link is bogus (we use it only as tag in the git commit message, not in docs).
* See also:
* https://lwn.net/Articles/930591/
* https://github.com/brauner/move-mount-beneath
*/
Quoted 11 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +11
-0+*/ + +#include <stdio.h> + +#include "tst_test.h" +#include "lapi/fsmount.h" +#include "lapi/sched.h" + +#define DIRA "LTP_DIR_A" +#define DIRB "LTP_DIR_B" +
testcases/kernel/syscalls/move_mount/move_mount03.c line 82
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0+static void run (void ) +{ +int fda, fdb; + +SAFE_MKDIR (DIRA ,0777 ); +SAFE_MKDIR (DIRB ,0777 ); +SAFE_MOUNT ("none" ,DIRA ,"tmpfs" ,0 ,0 ); +SAFE_MOUNT ("none" ,DIRB ,"tmpfs" ,0 ,0 ); +SAFE_TOUCH (DIRA "/A" ,0 ,NULL ); +SAFE_TOUCH (DIRB "/B" ,0 ,NULL );
Maybe whole code in above could be in setup() function, it can be created only once even we run test more times with -iN, right? Setup function is for test speedup (imagine somebody run test with -i10000, why to create files all the time?
testcases/kernel/syscalls/move_mount/move_mount03.c line 89
Quoted 7 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +7
-0+ +TEST (fda =open_tree (AT_FDCWD ,DIRA ,OPEN_TREE_CLOEXEC |OPEN_TREE_CLONE )); + +if (fda ==-1 ) { +tst_res (TFAIL |TTERRNO ,"open_tree() failed" ); +return ; + }
Maybe this should also be in the setup function. also not using TEST() for it?
fda = open_tree(AT_FDCWD, DIRA, OPEN_TREE_CLOEXEC | OPEN_TREE_CLONE); if (fda > 0)
tst_brk(TBROK | TERRNO, "open_tree() failed");
testcases/kernel/syscalls/move_mount/move_mount03.c line 94
Quoted 5 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +5
-0+ + fdb =SAFE_OPEN (DIRB ,O_PATH |O_NOFOLLOW ,0666 ); +TST_EXP_PASS (move_mount (fda,"" , fdb,"" , +MOVE_MOUNT_BENEATH |MOVE_MOUNT_F_EMPTY_PATH | +MOVE_MOUNT_T_EMPTY_PATH ));
I wonder what happen if any of the following SAFE_*() functions fail. There will be unrelated errors and left mount directories. IMHO at least SAFE_UMOUNT() should be in cleanup functions and guarded by flags (e.g. not trying to umount() when nothing was mounted because tst_brk() earlier).
Kind regards,
Petr
Quoted 17 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +17
-0+SAFE_CLOSE (fda); +SAFE_CLOSE (fdb); + +TST_EXP_PASS (access (DIRB "/B" ,F_OK )); +SAFE_UMOUNT (DIRB ); +TST_EXP_PASS (access (DIRB "/A" ,F_OK )); + +SAFE_UMOUNT (DIRB ); +SAFE_UMOUNT (DIRA ); +} + +static struct tst_test test = { + .test_all = run, + .needs_root =1 , + .min_kver ="6.5.0" , + .needs_tmpdir =1 , +};
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Petr
Very strange I have not found this email in my mutt, so I have to reply it in my outlook, sorry for inconvenience. Regards
Gao Wei
I suppose there was no v1, right?
[GW] V1: https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
NOTE: you can speed up the review process, if you check list of common errors before sending patch to ML https://github.com/linux-test-project/ltp/wiki/Maintainer-Patch-Review-Checklist#how-to-find-clear-errors
[GW]: patch v2 send with following check: make check, m32, run with -i3
I see false positive from checkpatch.pl, it would be interesting to check if it can be fixed. [GW]: v1 has no this issue, I wrongly remove some change from v1.
testcases/kernel/syscalls/move_mount/move_mount03.c line 82
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0+static void run (void ) +{ +int fda, fdb; + +SAFE_MKDIR (DIRA ,0777 ); +SAFE_MKDIR (DIRB ,0777 ); +SAFE_MOUNT ("none" ,DIRA ,"tmpfs" ,0 ,0 ); +SAFE_MOUNT ("none" ,DIRB ,"tmpfs" ,0 ,0 ); +SAFE_TOUCH (DIRA "/A" ,0 ,NULL ); +SAFE_TOUCH (DIRB "/B" ,0 ,NULL );
Maybe whole code in above could be in setup() function, it can be created only once even we run test more times with -iN, right? Setup function is for test speedup (imagine somebody run test with -i10000, why to create files all the time? [GW]: MKDIR should put into setup otherwise issue will happen, but mount & touch should keep within run function since move_mount will change mount point later and we need rebuild mount env again when it rerun.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 1/1 move_mount03: check allow to mount beneath top mount
In reply to Wei Gao via ltp--- include/lapi/fsmount.h | 4 + runtest/syscalls | 1 + .../kernel/syscalls/move_mount/.gitignore | 1 + .../kernel/syscalls/move_mount/move_mount03.c | 128 ++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 testcases/kernel/syscalls/move_mount/move_mount03.c
include/lapi/fsmount.h +4 -0
@@ -115,6 +115,10 @@ static inline int mount_setattr(int dirfd, const char *from_pathname, unsigned i }#endif /* HAVE_MOUNT_SETATTR */ +#ifndef MOVE_MOUNT_BENEATH +#define MOVE_MOUNT_BENEATH 0x00000200 +#endif /* MOVE_MOUNT_BENEATH */ +/* * New headers added in kernel after 5.2 release, create them for old userspace. */
runtest/syscalls +1 -0
@@ -824,6 +824,7 @@ mount_setattr01 mount_setattr01 move_mount01 move_mount01 move_mount02 move_mount02 +move_mount03 move_mount03 move_pages01 move_pages01 move_pages02 move_pages02
testcases/kernel/syscalls/move_mount/.gitignore +1 -0
@@ -1,2 +1,3 @@ /move_mount01 /move_mount02 +/move_mount03
testcases/kernel/syscalls/move_mount/move_mount03.c new file +128 -0
128 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
some comments below.
Quoted 126 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/fsmount.h | 4 + runtest/syscalls | 1 + .../kernel/syscalls/move_mount/.gitignore | 1 + .../kernel/syscalls/move_mount/move_mount03.c | 128 ++++++++++++++++++ 4 files changed, 134 insertions(+)create mode 100644
testcases/kernel/syscalls/move_mount/move_mount03.cinclude/lapi/fsmount.h +4
-0@@ -115,6 +115,10 @@ static inline int mount_setattr(int dirfd, const char *from_pathname, unsigned i }#endif /* HAVE_MOUNT_SETATTR */ +#ifndef MOVE_MOUNT_BENEATH +#define MOVE_MOUNT_BENEATH 0x00000200 +#endif /* MOVE_MOUNT_BENEATH */ +/* * New headers added in kernel after 5.2 release, create them for old userspace. */ runtest/syscalls +1
-0@@ -824,6 +824,7 @@ mount_setattr01 mount_setattr01 move_mount01 move_mount01 move_mount02 move_mount02 +move_mount03 move_mount03 move_pages01 move_pages01 move_pages02 move_pages02testcases/kernel/syscalls/move_mount/.gitignore +1
-0@@ -1,2 +1,3 @@ /move_mount01 /move_mount02 +/move_mount03testcases/kernel/syscalls/move_mount/move_mount03.c new file +76
-0@@ -0,0 +1,128 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2023 Christian Brauner <[email protected]> +* Copyright (c) 2023 Wei Gao <[email protected]> +*/ + +/*\ +* [Description] +* +* Test allow to mount beneath top mount feature +*/ + +/* +* Test create for following commit: +* commit 6ac392815628f317fcfdca1a39df00b9cc4ebc8b +* Author: Christian Brauner <[email protected]> +* Date: Wed May 3 13:18:42 2023 +0200 +* fs: allow to mount beneath top mount +* +* Above commit has heavily commented but i found following commit +* contain simple summary of this feature for easy understanding: +* +* commit c0a572d9d32fe1e95672f24e860776dba0750a38 +* Author: Linus Torvalds <[email protected]> +* TL;DR: +* +* > mount -t ext4 /dev/sda /mnt +* | +* --/mnt /dev/sda ext4 +* +* > mount --beneath -t xfs /dev/sdb /mnt +* | +* --/mnt /dev/sdb xfs +* --/mnt /dev/sda ext4 +* +* > umount /mnt +* | +* --/mnt /dev/sdb xfs +* +* So base above scenario design following scenario for LTP check: +* +* > mount -t tmpfs /DIRA +* | +* --/DIRA(create A file within DIRA) +* +* > mount -t tmpfs /DIRB +* | +* --/DIRA(create B file within DIRB) +* +* > move_mount --beneath /DIRA /DIRB +* | +* --/mnt /DIRA /DIRB +* --/mnt /DIRB +* +* If you check content of /DIRB, you can see file B +* +* > umount /DIRB +* | +* --/mnt /DIRA /DIRB +* Check content of /DIRB, you can see file A exist since +* current /DIRB mount source is already become /DIRA +* +* See also: +* https://lwn.net/Articles/930591/ +* https://github.com/brauner/move-mount-beneath +*/ + +#include <stdio.h> + +#include "tst_test.h" +#include "lapi/fsmount.h" +#include "lapi/sched.h" + +#define DIRA "LTP_DIR_A" +#define DIRB "LTP_DIR_B" +
testcases/kernel/syscalls/move_mount/move_mount03.c line 86
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0+static void run (void ) +{ +int fda, fdb; + +SAFE_MOUNT ("none" ,DIRA ,"tmpfs" ,0 ,0 ); +SAFE_MOUNT ("none" ,DIRB ,"tmpfs" ,0 ,0 ); +SAFE_TOUCH (DIRA "/A" ,0 ,NULL ); +SAFE_TOUCH (DIRB "/B" ,0 ,NULL ); + +/* TEST(fda = open_tree(AT_FDCWD, DIRA, OPEN_TREE_CLOEXEC | OPEN_TREE_CLONE)); */
Is the comment needed?
testcases/kernel/syscalls/move_mount/move_mount03.c line 98
Quoted 12 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +12
-0+ fda =open_tree (AT_FDCWD ,DIRA ,OPEN_TREE_CLOEXEC |OPEN_TREE_CLONE ); +if (fda ==-1 ) +tst_brk (TBROK |TERRNO ,"open_tree() failed" ); + + fdb =SAFE_OPEN (DIRB ,O_PATH |O_NOFOLLOW ,0666 ); +TST_EXP_PASS (move_mount (fda,"" , fdb,"" , +MOVE_MOUNT_BENEATH |MOVE_MOUNT_F_EMPTY_PATH | +MOVE_MOUNT_T_EMPTY_PATH )); +SAFE_CLOSE (fda); +SAFE_CLOSE (fdb); + +TST_EXP_PASS (access (DIRB "/B" ,F_OK ));
It'd also make sense the check here that file A still exists in DIRA but not in DIRB.
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0+SAFE_UMOUNT (DIRB ); +TST_EXP_PASS (access (DIRB "/A" ,F_OK )); + +SAFE_UMOUNT (DIRB ); +SAFE_UMOUNT (DIRA ); +} + +static void setup (void ) +{ +SAFE_MKDIR (DIRA ,0777 );
testcases/kernel/syscalls/move_mount/move_mount03.c line 118
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0+SAFE_MKDIR (DIRB ,0777 ); +} + +static void cleanup (void ) +{ +if (tst_is_mounted_at_tmpdir (DIRA )) +SAFE_UMOUNT (DIRA ); + +if (tst_is_mounted_at_tmpdir (DIRB )) +SAFE_UMOUNT (DIRB );
I believe that DIRB may need to be unmounted twice here. Also please close fda and fdb here if they're still open.
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0+} + +static struct tst_test test = { + .test_all = run, + .needs_root =1 , + .min_kver ="6.5.0" , + .needs_tmpdir =1 , + .setup = setup, + .cleanup = cleanup, +};
Signature · 11 lines
Martin Doucha [email protected] SW Quality Engineer SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 131 lines
Hi,
some comments below.Quoted 127 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/fsmount.h | 4 + runtest/syscalls | 1 + .../kernel/syscalls/move_mount/.gitignore | 1 + .../kernel/syscalls/move_mount/move_mount03.c | 128 ++++++++++++++++++ 4 files changed, 134 insertions(+)create mode 100644
testcases/kernel/syscalls/move_mount/move_mount03.cinclude/lapi/fsmount.h +4
-0@@ -115,6 +115,10 @@ static inline int mount_setattr(int dirfd, const char *from_pathname, unsigned i }#endif /* HAVE_MOUNT_SETATTR */ +#ifndef MOVE_MOUNT_BENEATH +#define MOVE_MOUNT_BENEATH 0x00000200 +#endif /* MOVE_MOUNT_BENEATH */ +/* * New headers added in kernel after 5.2 release, create them for old userspace. */ runtest/syscalls +1
-0@@ -824,6 +824,7 @@ mount_setattr01 mount_setattr01 move_mount01 move_mount01 move_mount02 move_mount02 +move_mount03 move_mount03 move_pages01 move_pages01 move_pages02 move_pages02testcases/kernel/syscalls/move_mount/.gitignore +1
-0@@ -1,2 +1,3 @@ /move_mount01 /move_mount02 +/move_mount03testcases/kernel/syscalls/move_mount/move_mount03.c new file +80
-0@@ -0,0 +1,128 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2023 Christian Brauner <[email protected]> +* Copyright (c) 2023 Wei Gao <[email protected]> +*/ + +/*\ +* [Description] +* +* Test allow to mount beneath top mount feature +*/ + +/* +* Test create for following commit: +* commit 6ac392815628f317fcfdca1a39df00b9cc4ebc8b +* Author: Christian Brauner <[email protected]> +* Date: Wed May 3 13:18:42 2023 +0200 +* fs: allow to mount beneath top mount +* +* Above commit has heavily commented but i found following commit +* contain simple summary of this feature for easy understanding: +* +* commit c0a572d9d32fe1e95672f24e860776dba0750a38 +* Author: Linus Torvalds <[email protected]> +* TL;DR: +* +* > mount -t ext4 /dev/sda /mnt +* | +* --/mnt /dev/sda ext4 +* +* > mount --beneath -t xfs /dev/sdb /mnt +* | +* --/mnt /dev/sdb xfs +* --/mnt /dev/sda ext4 +* +* > umount /mnt +* | +* --/mnt /dev/sdb xfs +* +* So base above scenario design following scenario for LTP check: +* +* > mount -t tmpfs /DIRA +* | +* --/DIRA(create A file within DIRA) +* +* > mount -t tmpfs /DIRB +* | +* --/DIRA(create B file within DIRB) +* +* > move_mount --beneath /DIRA /DIRB +* | +* --/mnt /DIRA /DIRB +* --/mnt /DIRB +* +* If you check content of /DIRB, you can see file B +* +* > umount /DIRB +* | +* --/mnt /DIRA /DIRB +* Check content of /DIRB, you can see file A exist since +* current /DIRB mount source is already become /DIRA +* +* See also: +* https://lwn.net/Articles/930591/ +* https://github.com/brauner/move-mount-beneath +*/ + +#include <stdio.h> + +#include "tst_test.h" +#include "lapi/fsmount.h" +#include "lapi/sched.h" + +#define DIRA "LTP_DIR_A" +#define DIRB "LTP_DIR_B" + +static void run (void ) +{ +int fda, fdb; +
Quoted 8 lines
testcases/kernel/syscalls/move_mount/move_mount03.c line 86
Quoted 6 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +6
-0+SAFE_MOUNT ("none" ,DIRA ,"tmpfs" ,0 ,0 ); +SAFE_MOUNT ("none" ,DIRB ,"tmpfs" ,0 ,0 ); +SAFE_TOUCH (DIRA "/A" ,0 ,NULL ); +SAFE_TOUCH (DIRB "/B" ,0 ,NULL ); + +/* TEST(fda = open_tree(AT_FDCWD, DIRA, OPEN_TREE_CLOEXEC | OPEN_TREE_CLONE)); */ Is the comment needed?
+1
Quoted 31 lines
testcases/kernel/syscalls/move_mount/move_mount03.c line 98
Quoted 12 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +12
-0+ fda =open_tree (AT_FDCWD ,DIRA ,OPEN_TREE_CLOEXEC |OPEN_TREE_CLONE ); +if (fda ==-1 ) +tst_brk (TBROK |TERRNO ,"open_tree() failed" ); + + fdb =SAFE_OPEN (DIRB ,O_PATH |O_NOFOLLOW ,0666 ); +TST_EXP_PASS (move_mount (fda,"" , fdb,"" , +MOVE_MOUNT_BENEATH |MOVE_MOUNT_F_EMPTY_PATH | +MOVE_MOUNT_T_EMPTY_PATH )); +SAFE_CLOSE (fda); +SAFE_CLOSE (fdb); + +TST_EXP_PASS (access (DIRB "/B" ,F_OK ));It'd also make sense the check here that file A still exists in DIRA but not in DIRB.
Quoted 15 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +15
-0+SAFE_UMOUNT (DIRB ); +TST_EXP_PASS (access (DIRB "/A" ,F_OK )); + +SAFE_UMOUNT (DIRB ); +SAFE_UMOUNT (DIRA ); +} + +static void setup (void ) +{ +SAFE_MKDIR (DIRA ,0777 ); +SAFE_MKDIR (DIRB ,0777 ); +} + +static void cleanup (void ) +{
Quoted 8 lines
testcases/kernel/syscalls/move_mount/move_mount03.c line 118
Quoted 5 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +5
-0+if (tst_is_mounted_at_tmpdir (DIRA )) +SAFE_UMOUNT (DIRA ); + +if (tst_is_mounted_at_tmpdir (DIRB )) +SAFE_UMOUNT (DIRB );I believe that DIRB may need to be unmounted twice here. Also please close fda and fdb here if they're still open.
What would do the second mount? move_mount() ?
There are SAFE_UMOUNT() in the end of the testing function, that's why usually even these 2 SAFE_UMOUNT() aren't needed (but obviously we need to add them if SAFE_TOUCH() or something quits testing early):
move_mount03.c:92: TPASS: move_mount(fda, "", fdb, "", MOVE_MOUNT_BENEATH | MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_EMPTY_PATH) passed move_mount03.c:98: TPASS: access(DIRB "/B", F_OK) passed
move_mount03.c:99: TINFO: Umounting /tmp/LTP_movqeTZGu/LTP_DIR_B
move_mount03.c:100: TPASS: access(DIRB "/A", F_OK) passed
move_mount03.c:102: TINFO: Umounting /tmp/LTP_movqeTZGu/LTP_DIR_B
move_mount03.c:103: TINFO: Umounting /tmp/LTP_movqeTZGu/LTP_DIR_A
tst_device.c:442: TINFO: No device is mounted at /tmp/LTP_movqeTZGu/LTP_DIR_A
tst_device.c:442: TINFO: No device is mounted at /tmp/LTP_movqeTZGu/LTP_DIR_B
Kind regards,
Petr
Quoted 10 lines
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0+} + +static struct tst_test test = { + .test_all = run, + .needs_root =1 , + .min_kver ="6.5.0" , + .needs_tmpdir =1 , + .setup = setup, + .cleanup = cleanup, +};
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 18 lines · Petr Vorel
Quoted 11 lines · Wei Gao via ltp
testcases/kernel/syscalls/move_mount/move_mount03.c line 118
Quoted 7 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +7
-0+static void cleanup (void ) +{ +if (tst_is_mounted_at_tmpdir (DIRA )) +SAFE_UMOUNT (DIRA ); + +if (tst_is_mounted_at_tmpdir (DIRB )) +SAFE_UMOUNT (DIRB );I believe that DIRB may need to be unmounted twice here. Also please close fda and fdb here if they're still open.
What would do the second mount?
move_mount()?There are
SAFE_UMOUNT()in the end of the testing function, that's why usually even these 2SAFE_UMOUNT()aren't needed (but obviously we need to add them ifSAFE_TOUCH()or something quits testing early):
Quoted 8 lines
move_mount03.c:92: TPASS:
move_mount(fda, "", fdb, "", MOVE_MOUNT_BENEATH | MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_EMPTY_PATH)passed move_mount03.c:98: TPASS:access(DIRB "/B", F_OK)passed
move_mount03.c:99: TINFO: Umounting/tmp/LTP_movqeTZGu/LTP_DIR_B
move_mount03.c:100: TPASS:access(DIRB "/A", F_OK)passed
move_mount03.c:102: TINFO: Umounting/tmp/LTP_movqeTZGu/LTP_DIR_B
move_mount03.c:103: TINFO: Umounting/tmp/LTP_movqeTZGu/LTP_DIR_A
tst_device.c:442: TINFO: No device is mounted at/tmp/LTP_movqeTZGu/LTP_DIR_A
tst_device.c:442: TINFO: No device is mounted at/tmp/LTP_movqeTZGu/LTP_DIR_B
Yes, open_tree() was called with OPEN_TREE_CLONE so after move_mount(), the mounts look like this:
- tmpfs[1] at DIRA
- tmpfs[1] at DIRB
- tmpfs[2] at DIRB
If either SAFE_CLOSE() immediately after move_mount() fails, cleanup() will unmount tmpfs[1] from DIRA and tmpfs[2] from DIRB but leave tmpfs[1] mounted at DIRB.
Signature · 11 lines
Martin Doucha [email protected] SW Quality Engineer SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 34 lines · Petr Vorel
Quoted 18 lines
Quoted 11 lines · Wei Gao via ltp
testcases/kernel/syscalls/move_mount/move_mount03.c line 118
Quoted 7 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +7
-0+static void cleanup (void ) +{ +if (tst_is_mounted_at_tmpdir (DIRA )) +SAFE_UMOUNT (DIRA ); + +if (tst_is_mounted_at_tmpdir (DIRB )) +SAFE_UMOUNT (DIRB );I believe that DIRB may need to be unmounted twice here. Also please close fda and fdb here if they're still open.
What would do the second mount?
move_mount()?There are
SAFE_UMOUNT()in the end of the testing function, that's why usually even these 2SAFE_UMOUNT()aren't needed (but obviously we need to add them ifSAFE_TOUCH()or something quits testing early):Quoted 8 lines
move_mount03.c:92: TPASS:
move_mount(fda, "", fdb, "", MOVE_MOUNT_BENEATH | MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_EMPTY_PATH)passed move_mount03.c:98: TPASS:access(DIRB "/B", F_OK)passed
move_mount03.c:99: TINFO: Umounting/tmp/LTP_movqeTZGu/LTP_DIR_B
move_mount03.c:100: TPASS:access(DIRB "/A", F_OK)passed
move_mount03.c:102: TINFO: Umounting/tmp/LTP_movqeTZGu/LTP_DIR_B
move_mount03.c:103: TINFO: Umounting/tmp/LTP_movqeTZGu/LTP_DIR_A
tst_device.c:442: TINFO: No device is mounted at/tmp/LTP_movqeTZGu/LTP_DIR_A
tst_device.c:442: TINFO: No device is mounted at/tmp/LTP_movqeTZGu/LTP_DIR_BYes,
open_tree()was called withOPEN_TREE_CLONEso aftermove_mount(), the mounts look like this:
- tmpfs[1] at DIRA
- tmpfs[1] at DIRB
- tmpfs[2] at DIRB
Quoted 3 lines
If either
SAFE_CLOSE()immediately aftermove_mount()fails,cleanup()will unmount tmpfs[1] from DIRA and tmpfs[2] from DIRB but leave tmpfs[1] mounted at DIRB.
@Martin Thanks!
@Wai Please send another version.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 34 lines · Petr Vorel
Quoted 18 lines
Quoted 11 lines · Wei Gao via ltp
testcases/kernel/syscalls/move_mount/move_mount03.c line 118
Quoted 7 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +7
-0+static void cleanup (void ) +{ +if (tst_is_mounted_at_tmpdir (DIRA )) +SAFE_UMOUNT (DIRA ); + +if (tst_is_mounted_at_tmpdir (DIRB )) +SAFE_UMOUNT (DIRB );I believe that DIRB may need to be unmounted twice here. Also please close fda and fdb here if they're still open.
What would do the second mount?
move_mount()?There are
SAFE_UMOUNT()in the end of the testing function, that's why usually even these 2SAFE_UMOUNT()aren't needed (but obviously we need to add them ifSAFE_TOUCH()or something quits testing early):Quoted 8 lines
move_mount03.c:92: TPASS:
move_mount(fda, "", fdb, "", MOVE_MOUNT_BENEATH | MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_EMPTY_PATH)passed move_mount03.c:98: TPASS:access(DIRB "/B", F_OK)passed
move_mount03.c:99: TINFO: Umounting/tmp/LTP_movqeTZGu/LTP_DIR_B
move_mount03.c:100: TPASS:access(DIRB "/A", F_OK)passed
move_mount03.c:102: TINFO: Umounting/tmp/LTP_movqeTZGu/LTP_DIR_B
move_mount03.c:103: TINFO: Umounting/tmp/LTP_movqeTZGu/LTP_DIR_A
tst_device.c:442: TINFO: No device is mounted at/tmp/LTP_movqeTZGu/LTP_DIR_A
tst_device.c:442: TINFO: No device is mounted at/tmp/LTP_movqeTZGu/LTP_DIR_BYes,
open_tree()was called withOPEN_TREE_CLONEso aftermove_mount(), the mounts look like this:
- tmpfs[1] at DIRA
- tmpfs[1] at DIRB
- tmpfs[2] at DIRB
Quoted 3 lines
If either
SAFE_CLOSE()immediately aftermove_mount()fails,cleanup()will unmount tmpfs[1] from DIRA and tmpfs[2] from DIRB but leave tmpfs[1] mounted at DIRB.
Correct. Thanks!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 1/1 move_mount03: check allow to mount beneath top mount
In reply to Wei Gao via ltp--- include/lapi/fsmount.h | 4 + runtest/syscalls | 1 + .../kernel/syscalls/move_mount/.gitignore | 1 + .../kernel/syscalls/move_mount/move_mount03.c | 137 ++++++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 testcases/kernel/syscalls/move_mount/move_mount03.c
include/lapi/fsmount.h +4 -0
@@ -115,6 +115,10 @@ static inline int mount_setattr(int dirfd, const char *from_pathname, unsigned i }#endif /* HAVE_MOUNT_SETATTR */ +#ifndef MOVE_MOUNT_BENEATH +#define MOVE_MOUNT_BENEATH 0x00000200 +#endif /* MOVE_MOUNT_BENEATH */ +/* * New headers added in kernel after 5.2 release, create them for old userspace. */
runtest/syscalls +1 -0
@@ -824,6 +824,7 @@ mount_setattr01 mount_setattr01 move_mount01 move_mount01 move_mount02 move_mount02 +move_mount03 move_mount03 move_pages01 move_pages01 move_pages02 move_pages02
testcases/kernel/syscalls/move_mount/.gitignore +1 -0
@@ -1,2 +1,3 @@ /move_mount01 /move_mount02 +/move_mount03
testcases/kernel/syscalls/move_mount/move_mount03.c new file +137 -0
137 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
one note below but this can be merged as is.
Quoted 137 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/fsmount.h | 4 + runtest/syscalls | 1 + .../kernel/syscalls/move_mount/.gitignore | 1 + .../kernel/syscalls/move_mount/move_mount03.c | 137 ++++++++++++++++++ 4 files changed, 143 insertions(+)create mode 100644
testcases/kernel/syscalls/move_mount/move_mount03.cinclude/lapi/fsmount.h +4
-0@@ -115,6 +115,10 @@ static inline int mount_setattr(int dirfd, const char *from_pathname, unsigned i }#endif /* HAVE_MOUNT_SETATTR */ +#ifndef MOVE_MOUNT_BENEATH +#define MOVE_MOUNT_BENEATH 0x00000200 +#endif /* MOVE_MOUNT_BENEATH */ +/* * New headers added in kernel after 5.2 release, create them for old userspace. */ runtest/syscalls +1
-0@@ -824,6 +824,7 @@ mount_setattr01 mount_setattr01 move_mount01 move_mount01 move_mount02 move_mount02 +move_mount03 move_mount03 move_pages01 move_pages01 move_pages02 move_pages02testcases/kernel/syscalls/move_mount/.gitignore +1
-0@@ -1,2 +1,3 @@ /move_mount01 /move_mount02 +/move_mount03testcases/kernel/syscalls/move_mount/move_mount03.c new file +87
-0@@ -0,0 +1,137 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2023 Christian Brauner <[email protected]> +* Copyright (c) 2023 Wei Gao <[email protected]> +*/ + +/*\ +* [Description] +* +* Test allow to mount beneath top mount feature +*/ + +/* +* Test create for following commit: +* commit 6ac392815628f317fcfdca1a39df00b9cc4ebc8b +* Author: Christian Brauner <[email protected]> +* Date: Wed May 3 13:18:42 2023 +0200 +* fs: allow to mount beneath top mount +* +* Above commit has heavily commented but i found following commit +* contain simple summary of this feature for easy understanding: +* +* commit c0a572d9d32fe1e95672f24e860776dba0750a38 +* Author: Linus Torvalds <[email protected]> +* TL;DR: +* +* > mount -t ext4 /dev/sda /mnt +* | +* --/mnt /dev/sda ext4 +* +* > mount --beneath -t xfs /dev/sdb /mnt +* | +* --/mnt /dev/sdb xfs +* --/mnt /dev/sda ext4 +* +* > umount /mnt +* | +* --/mnt /dev/sdb xfs +* +* So base above scenario design following scenario for LTP check: +* +* > mount -t tmpfs /DIRA +* | +* --/DIRA(create A file within DIRA) +* +* > mount -t tmpfs /DIRB +* | +* --/DIRA(create B file within DIRB) +* +* > move_mount --beneath /DIRA /DIRB +* | +* --/mnt /DIRA /DIRB +* --/mnt /DIRB +* +* If you check content of /DIRB, you can see file B +* +* > umount /DIRB +* | +* --/mnt /DIRA /DIRB +* Check content of /DIRB, you can see file A exist since +* current /DIRB mount source is already become /DIRA +* +* See also: +* https://lwn.net/Articles/930591/ +* https://github.com/brauner/move-mount-beneath +*/ + +#include <stdio.h> + +#include "tst_test.h" +#include "lapi/fsmount.h" +#include "lapi/sched.h" + +#define DIRA "LTP_DIR_A" +#define DIRB "LTP_DIR_B" + +static int fda =-1 , fdb =-1 ; + +static void run (void ) +{ +SAFE_MOUNT ("none" ,DIRA ,"tmpfs" ,0 ,0 ); +SAFE_MOUNT ("none" ,DIRB ,"tmpfs" ,0 ,0 ); +SAFE_TOUCH (DIRA "/A" ,0 ,NULL ); +SAFE_TOUCH (DIRB "/B" ,0 ,NULL ); + + fda =open_tree (AT_FDCWD ,DIRA ,OPEN_TREE_CLOEXEC |OPEN_TREE_CLONE ); +if (fda ==-1 )
testcases/kernel/syscalls/move_mount/move_mount03.c line 97
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +10
-0+tst_brk (TBROK |TERRNO ,"open_tree() failed" ); + + fdb =SAFE_OPEN (DIRB ,O_PATH |O_NOFOLLOW ,0666 ); +TST_EXP_PASS (move_mount (fda,"" , fdb,"" , +MOVE_MOUNT_BENEATH |MOVE_MOUNT_F_EMPTY_PATH | +MOVE_MOUNT_T_EMPTY_PATH )); +SAFE_CLOSE (fda); +SAFE_CLOSE (fdb); + +TST_EXP_PASS (access (DIRB "/B" ,F_OK ));
That extra check I've asked for in v3 would still be nice here.
Quoted 40 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +40
-0+SAFE_UMOUNT (DIRB ); +TST_EXP_PASS (access (DIRB "/A" ,F_OK )); + +SAFE_UMOUNT (DIRB ); +SAFE_UMOUNT (DIRA ); +} + +static void setup (void ) +{ +SAFE_MKDIR (DIRA ,0777 ); +SAFE_MKDIR (DIRB ,0777 ); +} + +static void cleanup (void ) +{ + +if (fda >=0 ) +SAFE_CLOSE (fda); + +if (fdb >=0 ) +SAFE_CLOSE (fdb); + +if (tst_is_mounted_at_tmpdir (DIRA )) +SAFE_UMOUNT (DIRA ); + +if (tst_is_mounted_at_tmpdir (DIRB )) +SAFE_UMOUNT (DIRB ); + +if (tst_is_mounted_at_tmpdir (DIRB )) +SAFE_UMOUNT (DIRB ); +} + +static struct tst_test test = { + .test_all = run, + .needs_root =1 , + .min_kver ="6.5.0" , + .needs_tmpdir =1 , + .setup = setup, + .cleanup = cleanup, +};
Signature · 11 lines
Martin Doucha [email protected] SW Quality Engineer SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp
Petr Vorel
Reviewed-byHi Wei, Marting,
Quoted 4 lines
Hi,
one note below but this can be merged as is.Reviewed-by Martin Doucha <[email protected]>
Thanks!
...
Quoted 2 lines
Quoted 2 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +0
-0
...
Quoted 4 lines
+/*\
+ * [Description]
+ *
+ * Test allow to mount beneath top mount feature
very nit: missing dot.
But more important the docparse docs are very sparse now, when everything is in the documentation visible only when looking into source code.
I would also mention the commit and the original test in docparse, e.g. something like:
/*\
* [Description]
*
* Test allow to mount beneath top mount feature added in kernel 6.5:
* 6ac392815628 ("fs: allow to mount beneath top mount")
*
* Test based on:
* https://github.com/brauner/move-mount-beneath
*
* See also:
* https://lore.kernel.org/all/[email protected]/
*/
Quoted 1 line
+ */
...
Quoted 2 lines
+ * See also:
+ * https://lwn.net/Articles/930591/
I would move these two into docparse as in example above.
This cover letter of v3. Wouldn't it be better to link the final version (v4) and from lwn.net (as in example above)?
https://lore.kernel.org/all/[email protected]/
Quoted 1 line
...
Quoted 13 lines
Quoted 13 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +13
-0+static void run (void ) +{ +SAFE_MOUNT ("none" ,DIRA ,"tmpfs" ,0 ,0 ); +SAFE_MOUNT ("none" ,DIRB ,"tmpfs" ,0 ,0 ); +SAFE_TOUCH (DIRA "/A" ,0 ,NULL ); +SAFE_TOUCH (DIRB "/B" ,0 ,NULL ); + + fda =open_tree (AT_FDCWD ,DIRA ,OPEN_TREE_CLOEXEC |OPEN_TREE_CLONE ); +if (fda ==-1 ) +tst_brk (TBROK |TERRNO ,"open_tree() failed" ); + + fdb =SAFE_OPEN (DIRB ,O_PATH |O_NOFOLLOW ,0666 ); + TST_EXP_PASS(move_mount(fda, "", fdb, "",
Quoted 8 lines
testcases/kernel/syscalls/move_mount/move_mount03.c line 97
Quoted 6 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +6
-0+MOVE_MOUNT_BENEATH |MOVE_MOUNT_F_EMPTY_PATH | + MOVE_MOUNT_T_EMPTY_PATH)); +SAFE_CLOSE (fda); +SAFE_CLOSE (fdb); + +TST_EXP_PASS (access (DIRB "/B" ,F_OK ));That extra check I've asked for in v3 would still be nice here.
Would you mind to send v5 with checks Martin suggested?
https://lore.kernel.org/ltp/[email protected]/
Quoted 6 lines
Quoted 6 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +6
-0+SAFE_UMOUNT (DIRB ); +TST_EXP_PASS (access (DIRB "/A" ,F_OK )); + +SAFE_UMOUNT (DIRB ); +SAFE_UMOUNT (DIRA ); +}
...
testcases/kernel/syscalls/move_mount/move_mount03.c line 112
Quoted 2 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +2
-0+static void cleanup (void ) +{
very nit: remove extra space here:
Quoted 6 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +6
-0+ +if (fda >=0 ) +SAFE_CLOSE (fda); + +if (fdb >=0 ) +SAFE_CLOSE (fdb);
....
testcases/kernel/syscalls/move_mount/move_mount03.c line 133
Quoted 4 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +4
-0+static struct tst_test test = { + .test_all = run, + .needs_root =1 , + .min_kver ="6.5.0" ,
nit: .min_kver = "6.5", would be enough
Otherwise LGTM.
BTW briefly looking into the Christian's testing source code, these flags are not yet covered by LTP:MOVE_MOUNT_SET_GROUP, MOUNT_ATTR_RDONLY, AT_RECURSIVE
Kind regards,
Petr
Quoted 4 lines
testcases/kernel/syscalls/move_mount/move_mount03.c new file +4
-0+ .needs_tmpdir = 1, + .setup = setup, + .cleanup = cleanup, +};
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 1/1 move_mount03: check allow to mount beneath top mount
In reply to Wei Gao via ltp--- include/lapi/fsmount.h | 4 + runtest/syscalls | 1 + .../kernel/syscalls/move_mount/.gitignore | 1 + .../kernel/syscalls/move_mount/move_mount03.c | 145 ++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 testcases/kernel/syscalls/move_mount/move_mount03.c
include/lapi/fsmount.h +4 -0
@@ -115,6 +115,10 @@ static inline int mount_setattr(int dirfd, const char *from_pathname, unsigned i }#endif /* HAVE_MOUNT_SETATTR */ +#ifndef MOVE_MOUNT_BENEATH +#define MOVE_MOUNT_BENEATH 0x00000200 +#endif /* MOVE_MOUNT_BENEATH */ +/* * New headers added in kernel after 5.2 release, create them for old userspace. */
runtest/syscalls +1 -0
@@ -824,6 +824,7 @@ mount_setattr01 mount_setattr01 move_mount01 move_mount01 move_mount02 move_mount02 +move_mount03 move_mount03 move_pages01 move_pages01 move_pages02 move_pages02
testcases/kernel/syscalls/move_mount/.gitignore +1 -0
@@ -1,2 +1,3 @@ /move_mount01 /move_mount02 +/move_mount03
testcases/kernel/syscalls/move_mount/move_mount03.c new file +145 -0
145 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
merged with adding 6ac392815628f linux-git tag and formatting changes. Thank you!
Kind regards,
Petr
+++ include/lapi/fsmount.h
@@ -114,14 +114,14 @@ static inline int mount_setattr(int dirfd, const char *from_pathname, unsigned i
}
#endif /* HAVE_MOUNT_SETATTR */
-#ifndef MOVE_MOUNT_BENEATH
-#define MOVE_MOUNT_BENEATH 0x00000200
-#endif /* MOVE_MOUNT_BENEATH */
-
/*
* New headers added in kernel after 5.2 release, create them for old userspace.
*/
+#ifndef MOVE_MOUNT_BENEATH
+# define MOVE_MOUNT_BENEATH 0x00000200
+#endif
+
#ifndef OPEN_TREE_CLONE
/*
kernel/syscalls/move_mount/move_mount03.c +8 -6
@@ -5,8 +5,6 @@*/ /*\ -* [Description] -* * Test allow to mount beneath top mount feature added in kernel 6.5: * 6ac392815628 ("fs: allow to mount beneath top mount") *
@@ -14,9 +12,10 @@* https://github.com/brauner/move-mount-beneath * * See also: -* https://lore.kernel.org/all/[email protected]/ -* https://lwn.net/Articles/930591/ -* https://github.com/brauner/move-mount-beneath +* +* - https://lore.kernel.org/all/[email protected]/ +* - https://lwn.net/Articles/930591/ +* - https://github.com/brauner/move-mount-beneath */ /*
@@ -68,7 +67,6 @@* --/mnt /DIRA /DIRB * Check content of /DIRB, you can see file A exist since * current /DIRB mount source is already become /DIRA -* */ #include <stdio.h>
@@ -142,4 +140,8 @@ static struct tst_test test = { .needs_tmpdir = 1, .setup = setup, .cleanup = cleanup, + .tags = (const struct tst_tag []) { + {"linux-git" ,"6ac392815628f" }, + {} + }, };
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp