aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRandy Dunlap <randy.dunlap@oracle.com>2009-09-23 18:56:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-24 10:20:57 -0400
commit0288b95b432b88f9daf895b526f64beeaca9ac73 (patch)
treec101445baa2776f33a9a7c0688c263eba31c7bce
parent57f1f0874f426a9bdfc5cd3f886113dd5cd17834 (diff)
doc/filesystems: remove smount program
mount(8) handles shared subtrees just fine, so remove the smount program from Documentation/filesystems/sharedsubtree.txt. Fix annoying "Lets" -> "Let's". Insert space between '#' prompt and "mount" command. Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Acked-by: Miklos Szeredi <miklos@szeredi.hu> Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Documentation/filesystems/sharedsubtree.txt209
1 files changed, 34 insertions, 175 deletions
diff --git a/Documentation/filesystems/sharedsubtree.txt b/Documentation/filesystems/sharedsubtree.txt
index 736540045dc7..b2c1ee5d98fc 100644
--- a/Documentation/filesystems/sharedsubtree.txt
+++ b/Documentation/filesystems/sharedsubtree.txt
@@ -41,14 +41,14 @@ replicas continue to be exactly same.
41 41
42 Here is an example: 42 Here is an example:
43 43
44 Lets say /mnt has a mount that is shared. 44 Let's say /mnt has a mount that is shared.
45 mount --make-shared /mnt 45 mount --make-shared /mnt
46 46
47 note: mount command does not yet support the --make-shared flag. 47 Note: mount(8) command now supports the --make-shared flag,
48 I have included a small C program which does the same by executing 48 so the sample 'smount' program is no longer needed and has been
49 'smount /mnt shared' 49 removed.
50 50
51 #mount --bind /mnt /tmp 51 # mount --bind /mnt /tmp
52 The above command replicates the mount at /mnt to the mountpoint /tmp 52 The above command replicates the mount at /mnt to the mountpoint /tmp
53 and the contents of both the mounts remain identical. 53 and the contents of both the mounts remain identical.
54 54
@@ -58,8 +58,8 @@ replicas continue to be exactly same.
58 #ls /tmp 58 #ls /tmp
59 a b c 59 a b c
60 60
61 Now lets say we mount a device at /tmp/a 61 Now let's say we mount a device at /tmp/a
62 #mount /dev/sd0 /tmp/a 62 # mount /dev/sd0 /tmp/a
63 63
64 #ls /tmp/a 64 #ls /tmp/a
65 t1 t2 t2 65 t1 t2 t2
@@ -80,21 +80,20 @@ replicas continue to be exactly same.
80 80
81 Here is an example: 81 Here is an example:
82 82
83 Lets say /mnt has a mount which is shared. 83 Let's say /mnt has a mount which is shared.
84 #mount --make-shared /mnt 84 # mount --make-shared /mnt
85 85
86 Lets bind mount /mnt to /tmp 86 Let's bind mount /mnt to /tmp
87 #mount --bind /mnt /tmp 87 # mount --bind /mnt /tmp
88 88
89 the new mount at /tmp becomes a shared mount and it is a replica of 89 the new mount at /tmp becomes a shared mount and it is a replica of
90 the mount at /mnt. 90 the mount at /mnt.
91 91
92 Now lets make the mount at /tmp; a slave of /mnt 92 Now let's make the mount at /tmp; a slave of /mnt
93 #mount --make-slave /tmp 93 # mount --make-slave /tmp
94 [or smount /tmp slave]
95 94
96 lets mount /dev/sd0 on /mnt/a 95 let's mount /dev/sd0 on /mnt/a
97 #mount /dev/sd0 /mnt/a 96 # mount /dev/sd0 /mnt/a
98 97
99 #ls /mnt/a 98 #ls /mnt/a
100 t1 t2 t3 99 t1 t2 t3
@@ -104,9 +103,9 @@ replicas continue to be exactly same.
104 103
105 Note the mount event has propagated to the mount at /tmp 104 Note the mount event has propagated to the mount at /tmp
106 105
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
108 107
109 #mount /dev/sd1 /tmp/b 108 # mount /dev/sd1 /tmp/b
110 109
111 #ls /tmp/b 110 #ls /tmp/b
112 s1 s2 s3 111 s1 s2 s3
@@ -124,12 +123,11 @@ replicas continue to be exactly same.
124 123
1252d) A unbindable mount is a unbindable private mount 1242d) A unbindable mount is a unbindable private mount
126 125
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
128 127
129 #mount --make-unbindable /mnt 128 # mount --make-unbindable /mnt
130 [ smount /mnt unbindable ]
131 129
132 Lets try to bind mount this mount somewhere else. 130 Let's try to bind mount this mount somewhere else.
133 # mount --bind /mnt /tmp 131 # mount --bind /mnt /tmp
134 mount: wrong fs type, bad option, bad superblock on /mnt, 132 mount: wrong fs type, bad option, bad superblock on /mnt,
135 or too many mounted file systems 133 or too many mounted file systems
@@ -139,147 +137,8 @@ replicas continue to be exactly same.
139 137
1403) smount command 1383) smount command
141 139
142 Currently the mount command is not aware of shared subtree features. 140 Modern mount(8) command is aware of shared subtree features,
143 Work is in progress to add the support in mount ( util-linux package ). 141 so use it instead of the 'smount' command. [source code removed]
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
283 142
284 143
2854) Use cases 1444) Use cases
@@ -558,7 +417,7 @@ replicas continue to be exactly same.
558 then the subtree under the unbindable mount is pruned in the new 417 then the subtree under the unbindable mount is pruned in the new
559 location. 418 location.
560 419
561 eg: lets say we have the following mount tree. 420 eg: let's say we have the following mount tree.
562 421
563 A 422 A
564 / \ 423 / \
@@ -566,7 +425,7 @@ replicas continue to be exactly same.
566 / \ / \ 425 / \ / \
567 D E F G 426 D E F G
568 427
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
570 of a type other than unbindable. 429 of a type other than unbindable.
571 430
572 If this tree is rbound to say Z 431 If this tree is rbound to say Z
@@ -683,13 +542,13 @@ replicas continue to be exactly same.
683 'b' on mounts that receive propagation from mount 'B' and does not have 542 'b' on mounts that receive propagation from mount 'B' and does not have
684 sub-mounts within them are unmounted. 543 sub-mounts within them are unmounted.
685 544
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
687 each other. 546 each other.
688 547
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
690 'B1', 'B2' and 'B3' respectively. 549 'B1', 'B2' and 'B3' respectively.
691 550
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
693 mount 'B1', 'B2' and 'B3' respectively. 552 mount 'B1', 'B2' and 'B3' respectively.
694 553
695 if 'C1' is unmounted, all the mounts that are most-recently-mounted on 554 if 'C1' is unmounted, all the mounts that are most-recently-mounted on
@@ -710,7 +569,7 @@ replicas continue to be exactly same.
710 A cloned namespace contains all the mounts as that of the parent 569 A cloned namespace contains all the mounts as that of the parent
711 namespace. 570 namespace.
712 571
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
714 child namespace. 573 child namespace.
715 574
716 If 'A' is shared, then 'B' is also shared and 'A' and 'B' propagate to 575 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.
759 mount --make-slave /mnt 618 mount --make-slave /mnt
760 619
761 At this point we have the first mount at /tmp and 620 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'
763 And then we have a second mount at /tmp1 with root 622 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'
765 Next we have a third mount at /mnt with root dentry 624 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'
767 626
768 'B' is the slave of 'A' and 'C' is a slave of 'B' 627 'B' is the slave of 'A' and 'C' is a slave of 'B'
769 A -> B -> C 628 A -> B -> C
@@ -794,7 +653,7 @@ replicas continue to be exactly same.
794 653
795 Q3 Why is unbindable mount needed? 654 Q3 Why is unbindable mount needed?
796 655
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
798 locations within the same subtree. 657 locations within the same subtree.
799 658
800 if one rbind mounts a tree within the same subtree 'n' times 659 if one rbind mounts a tree within the same subtree 'n' times
@@ -803,7 +662,7 @@ replicas continue to be exactly same.
803 mounts. Here is a example. 662 mounts. Here is a example.
804 663
805 step 1: 664 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
807 one vfsmount. 666 one vfsmount.
808 root 667 root
809 / \ 668 / \
@@ -875,7 +734,7 @@ replicas continue to be exactly same.
875 Unclonable mounts come in handy here. 734 Unclonable mounts come in handy here.
876 735
877 step 1: 736 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
879 one vfsmount. 738 one vfsmount.
880 root 739 root
881 / \ 740 / \