• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) International Business Machines  Corp., 2005
4# Copyright (c) 2021 Joerg Vehlow <joerg.vehlow@aox-tech.de>
5# Author: Avantika Mathur (mathurav@us.ibm.com)
6
7FS_BIND_TESTFUNC=test
8
9. fs_bind_lib.sh
10
11test()
12{
13	tst_res TINFO "cloneNS: namespace with shared point bind mounted within the same directory"
14
15	fs_bind_makedir rshared dir1
16
17	mkdir dir1/x dir2 dir3 dir4
18
19	EXPECT_PASS mount --rbind dir1 dir2
20	EXPECT_PASS mount --make-rslave dir2
21	EXPECT_PASS mount --make-rshared dir2
22
23	EXPECT_PASS mount --rbind dir2 dir3
24	EXPECT_PASS mount --make-rslave dir3
25	EXPECT_PASS mount --make-rshared dir3
26
27	EXPECT_PASS mount --rbind dir3 dir4
28	EXPECT_PASS mount --make-rslave dir4
29
30	fs_bind_create_ns
31
32	EXPECT_PASS mount --rbind "$FS_BIND_DISK1" dir1/x
33
34	fs_bind_check dir1/x dir2/x dir3/x dir4/x
35
36	EXPECT_PASS mount --rbind "$FS_BIND_DISK2" dir2/x/a
37	fs_bind_check -n dir1/x/a dir2/x/a
38	fs_bind_check dir2/x/a dir3/x/a dir4/x/a
39
40
41	fs_bind_check -s dir1/x dir2/x dir3/x dir4/x
42
43	fs_bind_check -s -n dir1/x/a dir2/x/a
44	fs_bind_check -s "$FS_BIND_DISK2" dir2/x/a dir3/x/a dir4/x/a
45
46	fs_bind_exec_ns mount --rbind "$PWD/$FS_BIND_DISK3" "$PWD/dir3/x/b"
47	fs_bind_check -s -n dir1/x/b dir3/x/b
48	fs_bind_check -s -n dir2/x/b dir3/x/b
49	fs_bind_check -s dir3/x/b dir4/x/b
50
51	fs_bind_exec_ns mount --rbind "$PWD/$FS_BIND_DISK4" "$PWD/dir4/x/c"
52	fs_bind_check -s -n dir1/x/c dir4/x/c
53	fs_bind_check -s -n dir2/x/c dir4/x/c
54	fs_bind_check -s -n dir3/x/c dir4/x/c
55
56
57	fs_bind_check -n dir1/x/b dir3/x/b
58	fs_bind_check -n dir2/x/b dir3/x/b
59	fs_bind_check dir3/x/b dir4/x/b
60	fs_bind_check "$FS_BIND_DISK3" dir3/x/b
61
62	fs_bind_check -n "$FS_BIND_DISK4" dir4/x/c
63	fs_bind_check dir1/x/c dir2/x/c dir3/x/c dir4/x/c
64
65
66	EXPECT_PASS umount dir3/x/b
67	EXPECT_PASS umount dir3/x/a
68	EXPECT_PASS umount dir2/x/a
69	EXPECT_PASS umount dir2/x
70	EXPECT_PASS umount dir1/x
71	EXPECT_PASS umount dir4
72	EXPECT_PASS umount dir3
73	EXPECT_PASS umount dir2
74	EXPECT_PASS umount dir1
75}
76
77tst_run
78