[LTP] [PATCH v3 1/6] Rewrite mountns01 test using new LTP API

Cyril Hrubis chrubis@suse.cz
Tue Mar 1 15:35:25 CET 2022


Hi!
Pushed with minor changes, thanks.

- changed the numbered list to simple list in the documentation
  as the three levels of different numbering looked a bit confusing

- changed the license to GPL-2.0 as the original was 2.0 only as well

- removed a few obvious comments, as long as the comment describes
  exactly what the next line does there is no value of keeping it

diff --git a/testcases/kernel/containers/mountns/mountns01.c b/testcases/kernel/containers/mountns/mountns01.c
index f2d67d17a..452fe1d10 100644
--- a/testcases/kernel/containers/mountns/mountns01.c
+++ b/testcases/kernel/containers/mountns/mountns01.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Red Hat, Inc.
  * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
@@ -12,21 +12,21 @@
  *
  * [Algorithm]
  *
- * . Creates directories "A", "B" and files "A/A", "B/B"
- * . Unshares mount namespace and makes it private (so mounts/umounts have no
+ * - Creates directories "A", "B" and files "A/A", "B/B"
+ * - Unshares mount namespace and makes it private (so mounts/umounts have no
  *   effect on a real system)
- * . Bind mounts directory "A" to "A"
- * . Makes directory "A" shared
- * . Clones a new child process with CLONE_NEWNS flag
- * . There are two test cases (where X is parent namespace and Y child namespace):
- * .. First test case
- * ... X: bind mounts "B" to "A"
- * ... Y: must see "A/B"
- * ... X: umounts "A"
- * .. Second test case
- * ... Y: bind mounts "B" to "A"
- * ... X: must see "A/B"
- * ... Y: umounts "A"
+ * - Bind mounts directory "A" to "A"
+ * - Makes directory "A" shared
+ * - Clones a new child process with CLONE_NEWNS flag
+ * - There are two test cases (where X is parent namespace and Y child namespace):
+ *  1. First test case
+ *   .. X: bind mounts "B" to "A"
+ *   .. Y: must see "A/B"
+ *   .. X: umounts "A"
+ *  2. Second test case
+ *   .. Y: bind mounts "B" to "A"
+ *   .. X: must see "A/B"
+ *   .. Y: umounts "A"
  */
 
 #include <sys/wait.h>
@@ -59,23 +59,18 @@ static void run(void)
 {
 	int ret;
 
-	/* unshares the mount ns */
 	SAFE_UNSHARE(CLONE_NEWNS);
 
 	/* makes sure parent mounts/umounts have no effect on a real system */
 	SAFE_MOUNT("none", "/", "none", MS_REC | MS_PRIVATE, NULL);
 
-	/* bind mounts DIRA to itself */
 	SAFE_MOUNT(DIRA, DIRA, "none", MS_BIND, NULL);
-
-	/* makes mount DIRA shared */
 	SAFE_MOUNT("none", DIRA, "none", MS_SHARED, NULL);
 
 	ret = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, child_func, NULL);
 	if (ret < 0)
 		tst_brk(TBROK, "clone failed");
 
-	/* bind mounts DIRB to DIRA making contents of DIRB visible in DIRA */
 	SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
 
 	TST_CHECKPOINT_WAKE_AND_WAIT(0);

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list