@@ -41,14 +41,14 @@ replicas continue to be exactly same.
4141
4242 Here is an example:
4343
44- Lets say /mnt has a mount that is shared.
44+ Let's say /mnt has a mount that is shared.
4545 mount --make-shared /mnt
4646
47- note : mount command does not yet support the --make-shared flag.
48- I have included a small C program which does the same by executing
49- 'smount /mnt shared'
47+ Note : mount(8) command now supports the --make-shared flag,
48+ so the sample 'smount' program is no longer needed and has been
49+ removed.
5050
51- #mount --bind /mnt /tmp
51+ # mount --bind /mnt /tmp
5252 The above command replicates the mount at /mnt to the mountpoint /tmp
5353 and the contents of both the mounts remain identical.
5454
@@ -58,8 +58,8 @@ replicas continue to be exactly same.
5858 #ls /tmp
5959 a b c
6060
61- Now lets say we mount a device at /tmp/a
62- #mount /dev/sd0 /tmp/a
61+ Now let's say we mount a device at /tmp/a
62+ # mount /dev/sd0 /tmp/a
6363
6464 #ls /tmp/a
6565 t1 t2 t2
@@ -80,21 +80,20 @@ replicas continue to be exactly same.
8080
8181 Here is an example:
8282
83- Lets say /mnt has a mount which is shared.
84- #mount --make-shared /mnt
83+ Let's say /mnt has a mount which is shared.
84+ # mount --make-shared /mnt
8585
86- Lets bind mount /mnt to /tmp
87- #mount --bind /mnt /tmp
86+ Let's bind mount /mnt to /tmp
87+ # mount --bind /mnt /tmp
8888
8989 the new mount at /tmp becomes a shared mount and it is a replica of
9090 the mount at /mnt.
9191
92- Now lets make the mount at /tmp; a slave of /mnt
93- #mount --make-slave /tmp
94- [or smount /tmp slave]
92+ Now let's make the mount at /tmp; a slave of /mnt
93+ # mount --make-slave /tmp
9594
96- lets mount /dev/sd0 on /mnt/a
97- #mount /dev/sd0 /mnt/a
95+ let's mount /dev/sd0 on /mnt/a
96+ # mount /dev/sd0 /mnt/a
9897
9998 #ls /mnt/a
10099 t1 t2 t3
@@ -104,9 +103,9 @@ replicas continue to be exactly same.
104103
105104 Note the mount event has propagated to the mount at /tmp
106105
107- However lets see what happens if we mount something on the mount at /tmp
106+ However let's see what happens if we mount something on the mount at /tmp
108107
109- #mount /dev/sd1 /tmp/b
108+ # mount /dev/sd1 /tmp/b
110109
111110 #ls /tmp/b
112111 s1 s2 s3
@@ -124,12 +123,11 @@ replicas continue to be exactly same.
124123
1251242d) A unbindable mount is a unbindable private mount
126125
127- lets say we have a mount at /mnt and we make is unbindable
126+ let's say we have a mount at /mnt and we make is unbindable
128127
129- #mount --make-unbindable /mnt
130- [ smount /mnt unbindable ]
128+ # mount --make-unbindable /mnt
131129
132- Lets try to bind mount this mount somewhere else.
130+ Let's try to bind mount this mount somewhere else.
133131 # mount --bind /mnt /tmp
134132 mount: wrong fs type, bad option, bad superblock on /mnt,
135133 or too many mounted file systems
@@ -139,147 +137,8 @@ replicas continue to be exactly same.
139137
1401383) smount command
141139
142- Currently the mount command is not aware of shared subtree features.
143- Work is in progress to add the support in mount ( util-linux package ).
144- Till then use the following program.
145-
146- ------------------------------------------------------------------------
147- //
148- //this code was developed my Miklos Szeredi <miklos@szeredi.hu>
149- //and modified by Ram Pai <linuxram@us.ibm.com>
150- // sample usage:
151- // smount /tmp shared
152- //
153- #include <stdio.h>
154- #include <stdlib.h>
155- #include <unistd.h>
156- #include <string.h>
157- #include <sys/mount.h>
158- #include <sys/fsuid.h>
159-
160- #ifndef MS_REC
161- #define MS_REC 0x4000 /* 16384: Recursive loopback */
162- #endif
163-
164- #ifndef MS_SHARED
165- #define MS_SHARED 1<<20 /* Shared */
166- #endif
167-
168- #ifndef MS_PRIVATE
169- #define MS_PRIVATE 1<<18 /* Private */
170- #endif
171-
172- #ifndef MS_SLAVE
173- #define MS_SLAVE 1<<19 /* Slave */
174- #endif
175-
176- #ifndef MS_UNBINDABLE
177- #define MS_UNBINDABLE 1<<17 /* Unbindable */
178- #endif
179-
180- int main(int argc, char *argv[])
181- {
182- int type;
183- if(argc != 3) {
184- fprintf(stderr, "usage: %s dir "
185- "<rshared|rslave|rprivate|runbindable|shared|slave"
186- "|private|unbindable>\n" , argv[0]);
187- return 1;
188- }
189-
190- fprintf(stdout, "%s %s %s\n", argv[0], argv[1], argv[2]);
191-
192- if (strcmp(argv[2],"rshared")==0)
193- type=(MS_SHARED|MS_REC);
194- else if (strcmp(argv[2],"rslave")==0)
195- type=(MS_SLAVE|MS_REC);
196- else if (strcmp(argv[2],"rprivate")==0)
197- type=(MS_PRIVATE|MS_REC);
198- else if (strcmp(argv[2],"runbindable")==0)
199- type=(MS_UNBINDABLE|MS_REC);
200- else if (strcmp(argv[2],"shared")==0)
201- type=MS_SHARED;
202- else if (strcmp(argv[2],"slave")==0)
203- type=MS_SLAVE;
204- else if (strcmp(argv[2],"private")==0)
205- type=MS_PRIVATE;
206- else if (strcmp(argv[2],"unbindable")==0)
207- type=MS_UNBINDABLE;
208- else {
209- fprintf(stderr, "invalid operation: %s\n", argv[2]);
210- return 1;
211- }
212- setfsuid(getuid());
213-
214- if(mount("", argv[1], "dontcare", type, "") == -1) {
215- perror("mount");
216- return 1;
217- }
218- return 0;
219- }
220- -----------------------------------------------------------------------
221-
222- Copy the above code snippet into smount.c
223- gcc -o smount smount.c
224-
225-
226- (i) To mark all the mounts under /mnt as shared execute the following
227- command:
228-
229- smount /mnt rshared
230- the corresponding syntax planned for mount command is
231- mount --make-rshared /mnt
232-
233- just to mark a mount /mnt as shared, execute the following
234- command:
235- smount /mnt shared
236- the corresponding syntax planned for mount command is
237- mount --make-shared /mnt
238-
239- (ii) To mark all the shared mounts under /mnt as slave execute the
240- following
241-
242- command:
243- smount /mnt rslave
244- the corresponding syntax planned for mount command is
245- mount --make-rslave /mnt
246-
247- just to mark a mount /mnt as slave, execute the following
248- command:
249- smount /mnt slave
250- the corresponding syntax planned for mount command is
251- mount --make-slave /mnt
252-
253- (iii) To mark all the mounts under /mnt as private execute the
254- following command:
255-
256- smount /mnt rprivate
257- the corresponding syntax planned for mount command is
258- mount --make-rprivate /mnt
259-
260- just to mark a mount /mnt as private, execute the following
261- command:
262- smount /mnt private
263- the corresponding syntax planned for mount command is
264- mount --make-private /mnt
265-
266- NOTE: by default all the mounts are created as private. But if
267- you want to change some shared/slave/unbindable mount as
268- private at a later point in time, this command can help.
269-
270- (iv) To mark all the mounts under /mnt as unbindable execute the
271- following
272-
273- command:
274- smount /mnt runbindable
275- the corresponding syntax planned for mount command is
276- mount --make-runbindable /mnt
277-
278- just to mark a mount /mnt as unbindable, execute the following
279- command:
280- smount /mnt unbindable
281- the corresponding syntax planned for mount command is
282- mount --make-unbindable /mnt
140+ Modern mount(8) command is aware of shared subtree features,
141+ so use it instead of the 'smount' command. [source code removed]
283142
284143
2851444) Use cases
@@ -558,15 +417,15 @@ replicas continue to be exactly same.
558417 then the subtree under the unbindable mount is pruned in the new
559418 location.
560419
561- eg: lets say we have the following mount tree.
420+ eg: let's say we have the following mount tree.
562421
563422 A
564423 / \
565424 B C
566425 / \ / \
567426 D E F G
568427
569- Lets say all the mount except the mount C in the tree are
428+ Let's say all the mount except the mount C in the tree are
570429 of a type other than unbindable.
571430
572431 If this tree is rbound to say Z
@@ -683,13 +542,13 @@ replicas continue to be exactly same.
683542 'b' on mounts that receive propagation from mount 'B' and does not have
684543 sub-mounts within them are unmounted.
685544
686- Example: Lets say 'B1', 'B2', 'B3' are shared mounts that propagate to
545+ Example: Let's say 'B1', 'B2', 'B3' are shared mounts that propagate to
687546 each other.
688547
689- lets say 'A1', 'A2', 'A3' are first mounted at dentry 'b' on mount
548+ let's say 'A1', 'A2', 'A3' are first mounted at dentry 'b' on mount
690549 'B1', 'B2' and 'B3' respectively.
691550
692- lets say 'C1', 'C2', 'C3' are next mounted at the same dentry 'b' on
551+ let's say 'C1', 'C2', 'C3' are next mounted at the same dentry 'b' on
693552 mount 'B1', 'B2' and 'B3' respectively.
694553
695554 if 'C1' is unmounted, all the mounts that are most-recently-mounted on
@@ -710,7 +569,7 @@ replicas continue to be exactly same.
710569 A cloned namespace contains all the mounts as that of the parent
711570 namespace.
712571
713- Lets say 'A' and 'B' are the corresponding mounts in the parent and the
572+ Let's say 'A' and 'B' are the corresponding mounts in the parent and the
714573 child namespace.
715574
716575 If 'A' is shared, then 'B' is also shared and 'A' and 'B' propagate to
@@ -759,11 +618,11 @@ replicas continue to be exactly same.
759618 mount --make-slave /mnt
760619
761620 At this point we have the first mount at /tmp and
762- its root dentry is 1. Lets call this mount 'A'
621+ its root dentry is 1. Let's call this mount 'A'
763622 And then we have a second mount at /tmp1 with root
764- dentry 2. Lets call this mount 'B'
623+ dentry 2. Let's call this mount 'B'
765624 Next we have a third mount at /mnt with root dentry
766- mnt. Lets call this mount 'C'
625+ mnt. Let's call this mount 'C'
767626
768627 'B' is the slave of 'A' and 'C' is a slave of 'B'
769628 A -> B -> C
@@ -794,7 +653,7 @@ replicas continue to be exactly same.
794653
795654 Q3 Why is unbindable mount needed?
796655
797- Lets say we want to replicate the mount tree at multiple
656+ Let's say we want to replicate the mount tree at multiple
798657 locations within the same subtree.
799658
800659 if one rbind mounts a tree within the same subtree 'n' times
@@ -803,7 +662,7 @@ replicas continue to be exactly same.
803662 mounts. Here is a example.
804663
805664 step 1:
806- lets say the root tree has just two directories with
665+ let's say the root tree has just two directories with
807666 one vfsmount.
808667 root
809668 / \
@@ -875,7 +734,7 @@ replicas continue to be exactly same.
875734 Unclonable mounts come in handy here.
876735
877736 step 1:
878- lets say the root tree has just two directories with
737+ let's say the root tree has just two directories with
879738 one vfsmount.
880739 root
881740 / \
0 commit comments