• 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
10test()
11{
12	tst_res TINFO "cloneNS: namespace with shared point bind mounted within the same directory"
13
14	fs_bind_makedir rshared dir1
15
16	mkdir dir1/x dir2 dir3 dir4
17
18	EXPECT_PASS mount --rbind dir1 dir2
19	EXPECT_PASS mount --make-rslave dir2
20	EXPECT_PASS mount --make-rshared dir2
21
22	EXPECT_PASS mount --rbind dir2 dir3
23	EXPECT_PASS mount --make-rslave dir3
24	EXPECT_PASS mount --make-rshared dir3
25
26	EXPECT_PASS mount --rbind dir3 dir4
27	EXPECT_PASS mount --make-rslave dir4
28
29	fs_bind_create_ns
30
31	EXPECT_PASS mount --rbind "$FS_BIND_DISK1" dir1/x
32
33	fs_bind_check dir1/x dir2/x dir3/x dir4/x
34
35	EXPECT_PASS mount --rbind "$FS_BIND_DISK2" dir2/x/a
36	fs_bind_check -n dir1/x/a dir2/x/a
37	fs_bind_check dir2/x/a dir3/x/a dir4/x/a
38
39
40	fs_bind_check -s dir1/x dir2/x dir3/x dir4/x
41
42	fs_bind_check -s -n dir1/x/a dir2/x/a
43	fs_bind_check -s "$FS_BIND_DISK2" dir2/x/a dir3/x/a dir4/x/a
44
45	fs_bind_exec_ns mount --rbind "$PWD/$FS_BIND_DISK3" "$PWD/dir3/x/b"
46	fs_bind_check -s -n dir1/x/b dir3/x/b
47	fs_bind_check -s -n dir2/x/b dir3/x/b
48	fs_bind_check -s dir3/x/b dir4/x/b
49
50	fs_bind_exec_ns mount --rbind "$PWD/$FS_BIND_DISK4" "$PWD/dir4/x/c"
51	fs_bind_check -s -n dir1/x/c dir4/x/c
52	fs_bind_check -s -n dir2/x/c dir4/x/c
53	fs_bind_check -s -n dir3/x/c dir4/x/c
54
55
56	fs_bind_check -n dir1/x/b dir3/x/b
57	fs_bind_check -n dir2/x/b dir3/x/b
58	fs_bind_check dir3/x/b dir4/x/b
59	fs_bind_check "$FS_BIND_DISK3" dir3/x/b
60
61	fs_bind_check -n "$FS_BIND_DISK4" dir4/x/c
62	fs_bind_check dir1/x/c dir2/x/c dir3/x/c dir4/x/c
63
64
65	EXPECT_PASS umount dir3/x/b
66	EXPECT_PASS umount dir3/x/a
67	EXPECT_PASS umount dir2/x/a
68	EXPECT_PASS umount dir2/x
69	EXPECT_PASS umount dir1/x
70	EXPECT_PASS umount dir4
71	EXPECT_PASS umount dir3
72	EXPECT_PASS umount dir2
73	EXPECT_PASS umount dir1
74}
75
76. fs_bind_lib.sh
77tst_run
78