documentation: split and build smount.c
PATCH 1/2 documentation: split and build smount.c
From: Randy Dunlap <[email protected]>
Make smount.c source file and add that to Makefile so that its build can be checked.
--- Documentation/Makefile | 2 Documentation/filesystems/00-INDEX | 2 Documentation/filesystems/Makefile | 8 ++ Documentation/filesystems/sharedsubtree.txt | 82 +--------------------------- Documentation/filesystems/smount.c | 73 ++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 79 deletions(-)
Documentation/filesystems/smount.c new file +73 -0
@@ -0,0 +1,73 @@ +// +//this code was developed my Miklos Szeredi <[email protected]> +//and modified by Ram Pai <[email protected]> +// sample usage: +// smount /tmp shared +// +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/mount.h> +#include <sys/fsuid.h> + +#ifndef MS_REC +#define MS_REC 0x4000/* 16384: Recursive loopback */ +#endif + +#ifndef MS_SHARED +#define MS_SHARED 1<<20/* Shared */ +#endif + +#ifndef MS_PRIVATE +#define MS_PRIVATE 1<<18/* Private */ +#endif + +#ifndef MS_SLAVE +#define MS_SLAVE 1<<19/* Slave */ +#endif + +#ifndef MS_UNBINDABLE +#define MS_UNBINDABLE 1<<17/* Unbindable */ +#endif + +int main (int argc,char *argv[]) +{ +int type; +if (argc !=3 ) { +fprintf (stderr,"usage: %s dir " +"<rshared|rslave|rprivate|runbindable|shared|slave" +"|private|unbindable>\n" , argv[0 ]); +return 1 ; + } + +fprintf (stdout,"%s %s %s\n" , argv[0 ], argv[1 ], argv[2 ]); + +if (strcmp (argv[2 ],"rshared" )==0 ) + type=(MS_SHARED |MS_REC ); +else if (strcmp (argv[2 ],"rslave" )==0 ) + type=(MS_SLAVE |MS_REC ); +else if (strcmp (argv[2 ],"rprivate" )==0 ) + type=(MS_PRIVATE |MS_REC ); +else if (strcmp (argv[2 ],"runbindable" )==0 ) + type=(MS_UNBINDABLE |MS_REC ); +else if (strcmp (argv[2 ],"shared" )==0 ) + type=MS_SHARED ; +else if (strcmp (argv[2 ],"slave" )==0 ) + type=MS_SLAVE ; +else if (strcmp (argv[2 ],"private" )==0 ) + type=MS_PRIVATE ; +else if (strcmp (argv[2 ],"unbindable" )==0 ) + type=MS_UNBINDABLE ; +else { +fprintf (stderr,"invalid operation: %s\n" , argv[2 ]); +return 1 ; + } +setfsuid (getuid ()); + +if (mount ("" , argv[1 ],"dontcare" , type,"" ) ==-1 ) { +perror ("mount" ); +return 1 ; + } +return 0 ; +}
Documentation/filesystems/sharedsubtree.txt +4 -78
97 lines not on this page · raw message
Documentation/Makefile +1 -1
@@ -1,3 +1,3 @@ obj-m := DocBook/ accounting/ auxdisplay/ connector/ \ - filesystems/configfs/ ia64/ networking/ \ + filesystems/ filesystems/configfs/ ia64/ networking/ \ pcmcia/ spi/ video4linux/ vm/ watchdog/src/
Documentation/filesystems/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# kbuild trick to avoid linker error. Can be omitted if a module is built. +obj- := dummy.o + +# List of programs to build +hostprogs-y := smount + +# Tell kbuild to always build the programs +always := $(hostprogs-y)
Documentation/filesystems/00-INDEX +2 -0
@@ -92,6 +92,8 @@ sharedsubtree.txt - a description of shared subtrees for namespaces. smbfs.txt - info on using filesystems with the SMB protocol (Win 3.11 and NT). +smount.c + - sample source code for mounting shared subtrees spufs.txt - info and mount options for the SPU filesystem used on Cell. sysfs-pci.txt
---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/
Quoted 4 lines · Randy Dunlap
From: Randy Dunlap <[email protected]>
Make
smount.csource file and add that toMakefileso that its build can be checked.
Just remove it, and modern /bin/mount handles shared subtrees just fine
Quoted 220 lines
Signed-off-by Randy Dunlap <[email protected]>cc Miklos Szeredi <[email protected]>--- Documentation/Makefile | 2 Documentation/filesystems/00-INDEX | 2 Documentation/filesystems/Makefile | 8 ++ Documentation/filesystems/sharedsubtree.txt | 82 +--------------------------- Documentation/filesystems/smount.c | 73 ++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 79 deletions(-)Documentation/filesystems/smount.c new file +73
-0@@ -0,0 +1,73 @@ +// +//this code was developed my Miklos Szeredi <[email protected]> +//and modified by Ram Pai <[email protected]> +// sample usage: +// smount /tmp shared +// +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/mount.h> +#include <sys/fsuid.h> + +#ifndef MS_REC +#define MS_REC 0x4000/* 16384: Recursive loopback */ +#endif + +#ifndef MS_SHARED +#define MS_SHARED 1<<20/* Shared */ +#endif + +#ifndef MS_PRIVATE +#define MS_PRIVATE 1<<18/* Private */ +#endif + +#ifndef MS_SLAVE +#define MS_SLAVE 1<<19/* Slave */ +#endif + +#ifndef MS_UNBINDABLE +#define MS_UNBINDABLE 1<<17/* Unbindable */ +#endif + +int main (int argc,char *argv[]) +{ +int type; +if (argc !=3 ) { +fprintf (stderr,"usage: %s dir " +"<rshared|rslave|rprivate|runbindable|shared|slave" +"|private|unbindable>\n" , argv[0 ]); +return 1 ; + } + +fprintf (stdout,"%s %s %s\n" , argv[0 ], argv[1 ], argv[2 ]); + +if (strcmp (argv[2 ],"rshared" )==0 ) + type=(MS_SHARED |MS_REC ); +else if (strcmp (argv[2 ],"rslave" )==0 ) + type=(MS_SLAVE |MS_REC ); +else if (strcmp (argv[2 ],"rprivate" )==0 ) + type=(MS_PRIVATE |MS_REC ); +else if (strcmp (argv[2 ],"runbindable" )==0 ) + type=(MS_UNBINDABLE |MS_REC ); +else if (strcmp (argv[2 ],"shared" )==0 ) + type=MS_SHARED ; +else if (strcmp (argv[2 ],"slave" )==0 ) + type=MS_SLAVE ; +else if (strcmp (argv[2 ],"private" )==0 ) + type=MS_PRIVATE ; +else if (strcmp (argv[2 ],"unbindable" )==0 ) + type=MS_UNBINDABLE ; +else { +fprintf (stderr,"invalid operation: %s\n" , argv[2 ]); +return 1 ; + } +setfsuid (getuid ()); + +if (mount ("" , argv[1 ],"dontcare" , type,"" ) ==-1 ) { +perror ("mount" ); +return 1 ; + } +return 0 ; +}Documentation/filesystems/sharedsubtree.txt +4
-78@@ -47,6 +47,7 @@ replicas continue to be exactly same. note: mount command does not yet support the --make-shared flag. I have included a small C program which does the same by executing 'smount /mnt shared' + [see Documentation/filesystems/smount.c] #mount --bind /mnt /tmp The above command replicates the mount at /mnt to the mountpoint /tmp@@ -141,87 +142,12 @@ replicas continue to be exactly same. Currently the mount command is not aware of shared subtree features. Work is in progress to add the support in mount ( util-linux package ). - Till then use the following program. + Until then use the 'smount' program that is located in + "Documentation/filesystems/smount.c" and build it like: - ------------------------------------------------------------------------ - // - //this code was developed my Miklos Szeredi <[email protected]> - //and modified by Ram Pai <[email protected]> - // sample usage: - // smount /tmp shared - // - #include <stdio.h> - #include <stdlib.h> - #include <unistd.h> - #include <string.h> - #include <sys/mount.h> - #include <sys/fsuid.h> - - #ifndef MS_REC - #define MS_REC 0x4000 /* 16384: Recursive loopback */ - #endif - - #ifndef MS_SHARED - #define MS_SHARED 1<<20 /* Shared */ - #endif - - #ifndef MS_PRIVATE - #define MS_PRIVATE 1<<18 /* Private */ - #endif - - #ifndef MS_SLAVE - #define MS_SLAVE 1<<19 /* Slave */ - #endif - - #ifndef MS_UNBINDABLE - #define MS_UNBINDABLE 1<<17 /* Unbindable */ - #endif - - int main(int argc, char *argv[]) - { - int type; - if(argc != 3) { - fprintf(stderr, "usage: %s dir " - "<rshared|rslave|rprivate|runbindable|shared|slave" - "|private|unbindable>\n" , argv[0]); - return 1; - } - - fprintf(stdout, "%s %s %s\n", argv[0], argv[1], argv[2]); - - if (strcmp(argv[2],"rshared")==0) - type=(MS_SHARED|MS_REC); - else if (strcmp(argv[2],"rslave")==0) - type=(MS_SLAVE|MS_REC); - else if (strcmp(argv[2],"rprivate")==0) - type=(MS_PRIVATE|MS_REC); - else if (strcmp(argv[2],"runbindable")==0) - type=(MS_UNBINDABLE|MS_REC); - else if (strcmp(argv[2],"shared")==0) - type=MS_SHARED; - else if (strcmp(argv[2],"slave")==0) - type=MS_SLAVE; - else if (strcmp(argv[2],"private")==0) - type=MS_PRIVATE; - else if (strcmp(argv[2],"unbindable")==0) - type=MS_UNBINDABLE; - else { - fprintf(stderr, "invalid operation: %s\n", argv[2]); - return 1; - } - setfsuid(getuid()); - - if(mount("", argv[1], "dontcare", type, "") == -1) { - perror("mount"); - return 1; - } - return 0; - } - ----------------------------------------------------------------------- - - Copy the above code snippet into smount.c gcc -o smount smount.c + ----------------------------------------------------------------------- (i) To mark all the mounts under /mnt as shared execute the following command:Documentation/Makefile +1
-1@@ -1,3 +1,3 @@ obj-m := DocBook/ accounting/ auxdisplay/ connector/ \ - filesystems/configfs/ ia64/ networking/ \ + filesystems/ filesystems/configfs/ ia64/ networking/ \ pcmcia/ spi/ video4linux/ vm/ watchdog/src/Documentation/filesystems/Makefile new file +8
-0@@ -0,0 +1,8 @@ +# kbuild trick to avoid linker error. Can be omitted if a module is built. +obj- := dummy.o + +# List of programs to build +hostprogs-y := smount + +# Tell kbuild to always build the programs +always := $(hostprogs-y)Documentation/filesystems/00-INDEX +2
-1@@ -92,6 +92,8 @@ sharedsubtree.txt - a description of shared subtrees for namespaces. smbfs.txt - info on using filesystems with the SMB protocol (Win 3.11 and NT). +smount.c + - sample source code for mounting shared subtrees spufs.txt - info and mount options for the SPU filesystem used on Cell. sysfs-pci.txt ---
Quoted 8 lines
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
---end quoted text---
PATCH v2 1/1 documentation: split and build smount.c
Quoted 1 line · On Mon, 18 Aug 2008 01:04:31 -0400 Christoph Hellwig wrote:
Just remove it, and modern
/bin/mounthandles shared subtrees just fine
Miklos... ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: Randy Dunlap <[email protected]>
mount(8) handles shared subtrees just fine, so remove the smount program from Documentation/filesystems/sharedsubtree.txt.
Fix annoying "Lets" -> "Let's".
--- Documentation/filesystems/sharedsubtree.txt | 192 +++------------------------- 1 file changed, 25 insertions(+), 167 deletions(-)
Documentation/filesystems/sharedsubtree.txt +25 -167
@@ -41,12 +41,11 @@ replicas continue to be exactly same. Here is an example: - Lets say /mnt has a mount that is shared. + Let's say /mnt has a mount that is shared. mount --make-shared /mnt - note: mount command does not yet support the --make-shared flag. - I have included a small C program which does the same by executing - 'smount /mnt shared' + Note: mount(8) command now supports the --make-shared flag, + so the sample 'smount' program is no longer needed. #mount --bind /mnt /tmp The above command replicates the mount at /mnt to the mountpoint /tmp
@@ -58,7 +57,7 @@ replicas continue to be exactly same. #ls /tmp a b c - Now lets say we mount a device at /tmp/a + Now let's say we mount a device at /tmp/a #mount /dev/sd0 /tmp/a #ls /tmp/a
@@ -80,20 +79,19 @@ replicas continue to be exactly same. Here is an example: - Lets say /mnt has a mount which is shared. + Let's say /mnt has a mount which is shared. #mount --make-shared /mnt - Lets bind mount /mnt to /tmp + Let's bind mount /mnt to /tmp #mount --bind /mnt /tmp the new mount at /tmp becomes a shared mount and it is a replica of the mount at /mnt. - Now lets make the mount at /tmp; a slave of /mnt + Now let's make the mount at /tmp; a slave of /mnt #mount --make-slave /tmp - [or smount /tmp slave] - lets mount /dev/sd0 on /mnt/a + let's mount /dev/sd0 on /mnt/a #mount /dev/sd0 /mnt/a #ls /mnt/a
@@ -104,7 +102,7 @@ replicas continue to be exactly same. Note the mount event has propagated to the mount at /tmp - However lets see what happens if we mount something on the mount at /tmp + However let's see what happens if we mount something on the mount at /tmp #mount /dev/sd1 /tmp/b
@@ -124,12 +122,11 @@ replicas continue to be exactly same. 2d) A unbindable mount is a unbindable private mount - lets say we have a mount at /mnt and we make is unbindable + let's say we have a mount at /mnt and we make is unbindable #mount --make-unbindable /mnt - [ smount /mnt unbindable ] - Lets try to bind mount this mount somewhere else. + Let's try to bind mount this mount somewhere else. # mount --bind /mnt /tmp mount: wrong fs type, bad option, bad superblock on /mnt, or too many mounted file systems
@@ -139,147 +136,8 @@ replicas continue to be exactly same. 3) smount command - Currently the mount command is not aware of shared subtree features. - Work is in progress to add the support in mount ( util-linux package ). - Till then use the following program. - - ------------------------------------------------------------------------ - // - //this code was developed my Miklos Szeredi <[email protected]> - //and modified by Ram Pai <[email protected]> - // sample usage: - // smount /tmp shared - // - #include <stdio.h> - #include <stdlib.h> - #include <unistd.h> - #include <string.h> - #include <sys/mount.h> - #include <sys/fsuid.h> - - #ifndef MS_REC - #define MS_REC 0x4000 /* 16384: Recursive loopback */ - #endif - - #ifndef MS_SHARED - #define MS_SHARED 1<<20 /* Shared */ - #endif - - #ifndef MS_PRIVATE - #define MS_PRIVATE 1<<18 /* Private */ - #endif - - #ifndef MS_SLAVE - #define MS_SLAVE 1<<19 /* Slave */ - #endif - - #ifndef MS_UNBINDABLE - #define MS_UNBINDABLE 1<<17 /* Unbindable */ - #endif - - int main(int argc, char *argv[]) - { - int type; - if(argc != 3) { - fprintf(stderr, "usage: %s dir " - "<rshared|rslave|rprivate|runbindable|shared|slave" - "|private|unbindable>\n" , argv[0]); - return 1; - } - - fprintf(stdout, "%s %s %s\n", argv[0], argv[1], argv[2]); - - if (strcmp(argv[2],"rshared")==0) - type=(MS_SHARED|MS_REC); - else if (strcmp(argv[2],"rslave")==0) - type=(MS_SLAVE|MS_REC); - else if (strcmp(argv[2],"rprivate")==0) - type=(MS_PRIVATE|MS_REC); - else if (strcmp(argv[2],"runbindable")==0) - type=(MS_UNBINDABLE|MS_REC); - else if (strcmp(argv[2],"shared")==0) - type=MS_SHARED; - else if (strcmp(argv[2],"slave")==0) - type=MS_SLAVE; - else if (strcmp(argv[2],"private")==0) - type=MS_PRIVATE; - else if (strcmp(argv[2],"unbindable")==0) - type=MS_UNBINDABLE; - else { - fprintf(stderr, "invalid operation: %s\n", argv[2]); - return 1; - } - setfsuid(getuid()); - - if(mount("", argv[1], "dontcare", type, "") == -1) { - perror("mount"); - return 1; - } - return 0; - } - ----------------------------------------------------------------------- - - Copy the above code snippet into smount.c - gcc -o smount smount.c - - - (i) To mark all the mounts under /mnt as shared execute the following - command: - - smount /mnt rshared - the corresponding syntax planned for mount command is - mount --make-rshared /mnt - - just to mark a mount /mnt as shared, execute the following - command: - smount /mnt shared - the corresponding syntax planned for mount command is - mount --make-shared /mnt - - (ii) To mark all the shared mounts under /mnt as slave execute the - following - - command: - smount /mnt rslave - the corresponding syntax planned for mount command is - mount --make-rslave /mnt - - just to mark a mount /mnt as slave, execute the following - command: - smount /mnt slave - the corresponding syntax planned for mount command is - mount --make-slave /mnt - - (iii) To mark all the mounts under /mnt as private execute the - following command: - - smount /mnt rprivate - the corresponding syntax planned for mount command is - mount --make-rprivate /mnt - - just to mark a mount /mnt as private, execute the following - command: - smount /mnt private - the corresponding syntax planned for mount command is - mount --make-private /mnt - - NOTE: by default all the mounts are created as private. But if - you want to change some shared/slave/unbindable mount as - private at a later point in time, this command can help. - - (iv) To mark all the mounts under /mnt as unbindable execute the - following - - command: - smount /mnt runbindable - the corresponding syntax planned for mount command is - mount --make-runbindable /mnt - - just to mark a mount /mnt as unbindable, execute the following - command: - smount /mnt unbindable - the corresponding syntax planned for mount command is - mount --make-unbindable /mnt + Modern mount(8) command is aware of shared subtree features, + so use it instead of the 'smount' command. [source code removed] 4) Use cases
@@ -558,7 +416,7 @@ replicas continue to be exactly same. then the subtree under the unbindable mount is pruned in the new location. - eg: lets say we have the following mount tree. + eg: let's say we have the following mount tree. A / \
@@ -566,7 +424,7 @@ replicas continue to be exactly same. / \ / \ D E F G - Lets say all the mount except the mount C in the tree are + Let's say all the mount except the mount C in the tree are of a type other than unbindable. If this tree is rbound to say Z
@@ -683,13 +541,13 @@ replicas continue to be exactly same. 'b' on mounts that receive propagation from mount 'B' and does not have sub-mounts within them are unmounted. - Example: Lets say 'B1', 'B2', 'B3' are shared mounts that propagate to + Example: Let's say 'B1', 'B2', 'B3' are shared mounts that propagate to each other. - lets say 'A1', 'A2', 'A3' are first mounted at dentry 'b' on mount + let's say 'A1', 'A2', 'A3' are first mounted at dentry 'b' on mount 'B1', 'B2' and 'B3' respectively. - lets say 'C1', 'C2', 'C3' are next mounted at the same dentry 'b' on + let's say 'C1', 'C2', 'C3' are next mounted at the same dentry 'b' on mount 'B1', 'B2' and 'B3' respectively. if 'C1' is unmounted, all the mounts that are most-recently-mounted on
@@ -710,7 +568,7 @@ replicas continue to be exactly same. A cloned namespace contains all the mounts as that of the parent namespace. - Lets say 'A' and 'B' are the corresponding mounts in the parent and the + Let's say 'A' and 'B' are the corresponding mounts in the parent and the child namespace. If 'A' is shared, then 'B' is also shared and 'A' and 'B' propagate to
@@ -759,11 +617,11 @@ replicas continue to be exactly same. mount --make-slave /mnt At this point we have the first mount at /tmp and - its root dentry is 1. Lets call this mount 'A' + its root dentry is 1. Let's call this mount 'A' And then we have a second mount at /tmp1 with root - dentry 2. Lets call this mount 'B' + dentry 2. Let's call this mount 'B' Next we have a third mount at /mnt with root dentry - mnt. Lets call this mount 'C' + mnt. Let's call this mount 'C' 'B' is the slave of 'A' and 'C' is a slave of 'B' A -> B -> C
@@ -794,7 +652,7 @@ replicas continue to be exactly same. Q3 Why is unbindable mount needed? - Lets say we want to replicate the mount tree at multiple + Let's say we want to replicate the mount tree at multiple locations within the same subtree. if one rbind mounts a tree within the same subtree 'n' times
@@ -803,7 +661,7 @@ replicas continue to be exactly same. mounts. Here is a example. step 1: - lets say the root tree has just two directories with + let's say the root tree has just two directories with one vfsmount. root / \
@@ -875,7 +733,7 @@ replicas continue to be exactly same. Unclonable mounts come in handy here. step 1: - lets say the root tree has just two directories with + let's say the root tree has just two directories with one vfsmount. root / \
Quoted 11 lines · Randy Dunlap
Quoted 1 line · On Mon, 18 Aug 2008 01:04:31 -0400 Christoph Hellwig wrote:
Just remove it, and modern
/bin/mounthandles shared subtrees just fineMiklos... ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: Randy Dunlap <[email protected]>mount(8) handles shared subtrees just fine, so remove the smount program from
Documentation/filesystems/sharedsubtree.txt.
[...]
Documentation/filesystems/sharedsubtree.txt replicas continue to be exactly same. · line 47
Quoted 1 line
Documentation/filesystems/sharedsubtree.txt +1
-0+ Note: mount(8) command now supports the --make-shared flag,
Right, ACK ;-)
Quoted 1 line
#mount --bind /mnt /tmp
BTW, people usually use a space between prompt and command, so:
# mount --bind /mnt /tmp
Karel
Signature · 1 line
Karel Zak <[email protected]>
Quoted 17 lines · On Wed, 20 Aug 2008 00:56:25 +0200 Karel Zak wrote:
Quoted 11 lines · Randy Dunlap
Quoted 1 line · On Mon, 18 Aug 2008 01:04:31 -0400 Christoph Hellwig wrote:
Just remove it, and modern
/bin/mounthandles shared subtrees just fineMiklos... ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: Randy Dunlap <[email protected]>mount(8) handles shared subtrees just fine, so remove the smount program from
Documentation/filesystems/sharedsubtree.txt.[...]
Documentation/filesystems/sharedsubtree.txt replicas continue to be exactly same. · line 47
Quoted 1 line
Documentation/filesystems/sharedsubtree.txt +1
-0+ Note: mount(8) command now supports the --make-shared flag,Right, ACK ;-)
Quoted 5 lines
Quoted 1 line
#mount --bind /mnt /tmp
BTW, people usually use a space between prompt and command, so:
# mount --bind /mnt /tmp
Done for upcoming patch. Thanks.
---
~Randy
Quoted 5 lines · Randy Dunlap
Quoted 1 line · On Mon, 18 Aug 2008 01:04:31 -0400 Christoph Hellwig wrote:
Just remove it, and modern
/bin/mounthandles shared subtrees just fineMiklos... ?
Yes, ACK from me too. Thanks Randy!
Miklos
Quoted 327 lines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: Randy Dunlap <[email protected]>mount(8) handles shared subtrees just fine, so remove the smount program from
Documentation/filesystems/sharedsubtree.txt.Fix annoying "Lets" -> "Let's".
Signed-off-by Randy Dunlap <[email protected]>cc Miklos Szeredi <[email protected]>--- Documentation/filesystems/sharedsubtree.txt | 192 +++------------------------- 1 file changed, 25 insertions(+), 167 deletions(-)Documentation/filesystems/sharedsubtree.txt +25
-167@@ -41,12 +41,11 @@ replicas continue to be exactly same. Here is an example: - Lets say /mnt has a mount that is shared. + Let's say /mnt has a mount that is shared. mount --make-shared /mnt - note: mount command does not yet support the --make-shared flag. - I have included a small C program which does the same by executing - 'smount /mnt shared' + Note: mount(8) command now supports the --make-shared flag, + so the sample 'smount' program is no longer needed. #mount --bind /mnt /tmp The above command replicates the mount at /mnt to the mountpoint /tmp@@ -58,7 +57,7 @@ replicas continue to be exactly same. #ls /tmp a b c - Now lets say we mount a device at /tmp/a + Now let's say we mount a device at /tmp/a #mount /dev/sd0 /tmp/a #ls /tmp/a@@ -80,20 +79,19 @@ replicas continue to be exactly same. Here is an example: - Lets say /mnt has a mount which is shared. + Let's say /mnt has a mount which is shared. #mount --make-shared /mnt - Lets bind mount /mnt to /tmp + Let's bind mount /mnt to /tmp #mount --bind /mnt /tmp the new mount at /tmp becomes a shared mount and it is a replica of the mount at /mnt. - Now lets make the mount at /tmp; a slave of /mnt + Now let's make the mount at /tmp; a slave of /mnt #mount --make-slave /tmp - [or smount /tmp slave] - lets mount /dev/sd0 on /mnt/a + let's mount /dev/sd0 on /mnt/a #mount /dev/sd0 /mnt/a #ls /mnt/a@@ -104,7 +102,7 @@ replicas continue to be exactly same. Note the mount event has propagated to the mount at /tmp - However lets see what happens if we mount something on the mount at /tmp + However let's see what happens if we mount something on the mount at /tmp #mount /dev/sd1 /tmp/b@@ -124,12 +122,11 @@ replicas continue to be exactly same. 2d) A unbindable mount is a unbindable private mount - lets say we have a mount at /mnt and we make is unbindable + let's say we have a mount at /mnt and we make is unbindable #mount --make-unbindable /mnt - [ smount /mnt unbindable ] - Lets try to bind mount this mount somewhere else. + Let's try to bind mount this mount somewhere else. # mount --bind /mnt /tmp mount: wrong fs type, bad option, bad superblock on /mnt, or too many mounted file systems@@ -139,147 +136,8 @@ replicas continue to be exactly same. 3) smount command - Currently the mount command is not aware of shared subtree features. - Work is in progress to add the support in mount ( util-linux package ). - Till then use the following program. - - ------------------------------------------------------------------------ - // - //this code was developed my Miklos Szeredi <[email protected]> - //and modified by Ram Pai <[email protected]> - // sample usage: - // smount /tmp shared - // - #include <stdio.h> - #include <stdlib.h> - #include <unistd.h> - #include <string.h> - #include <sys/mount.h> - #include <sys/fsuid.h> - - #ifndef MS_REC - #define MS_REC 0x4000 /* 16384: Recursive loopback */ - #endif - - #ifndef MS_SHARED - #define MS_SHARED 1<<20 /* Shared */ - #endif - - #ifndef MS_PRIVATE - #define MS_PRIVATE 1<<18 /* Private */ - #endif - - #ifndef MS_SLAVE - #define MS_SLAVE 1<<19 /* Slave */ - #endif - - #ifndef MS_UNBINDABLE - #define MS_UNBINDABLE 1<<17 /* Unbindable */ - #endif - - int main(int argc, char *argv[]) - { - int type; - if(argc != 3) { - fprintf(stderr, "usage: %s dir " - "<rshared|rslave|rprivate|runbindable|shared|slave" - "|private|unbindable>\n" , argv[0]); - return 1; - } - - fprintf(stdout, "%s %s %s\n", argv[0], argv[1], argv[2]); - - if (strcmp(argv[2],"rshared")==0) - type=(MS_SHARED|MS_REC); - else if (strcmp(argv[2],"rslave")==0) - type=(MS_SLAVE|MS_REC); - else if (strcmp(argv[2],"rprivate")==0) - type=(MS_PRIVATE|MS_REC); - else if (strcmp(argv[2],"runbindable")==0) - type=(MS_UNBINDABLE|MS_REC); - else if (strcmp(argv[2],"shared")==0) - type=MS_SHARED; - else if (strcmp(argv[2],"slave")==0) - type=MS_SLAVE; - else if (strcmp(argv[2],"private")==0) - type=MS_PRIVATE; - else if (strcmp(argv[2],"unbindable")==0) - type=MS_UNBINDABLE; - else { - fprintf(stderr, "invalid operation: %s\n", argv[2]); - return 1; - } - setfsuid(getuid()); - - if(mount("", argv[1], "dontcare", type, "") == -1) { - perror("mount"); - return 1; - } - return 0; - } - ----------------------------------------------------------------------- - - Copy the above code snippet into smount.c - gcc -o smount smount.c - - - (i) To mark all the mounts under /mnt as shared execute the following - command: - - smount /mnt rshared - the corresponding syntax planned for mount command is - mount --make-rshared /mnt - - just to mark a mount /mnt as shared, execute the following - command: - smount /mnt shared - the corresponding syntax planned for mount command is - mount --make-shared /mnt - - (ii) To mark all the shared mounts under /mnt as slave execute the - following - - command: - smount /mnt rslave - the corresponding syntax planned for mount command is - mount --make-rslave /mnt - - just to mark a mount /mnt as slave, execute the following - command: - smount /mnt slave - the corresponding syntax planned for mount command is - mount --make-slave /mnt - - (iii) To mark all the mounts under /mnt as private execute the - following command: - - smount /mnt rprivate - the corresponding syntax planned for mount command is - mount --make-rprivate /mnt - - just to mark a mount /mnt as private, execute the following - command: - smount /mnt private - the corresponding syntax planned for mount command is - mount --make-private /mnt - - NOTE: by default all the mounts are created as private. But if - you want to change some shared/slave/unbindable mount as - private at a later point in time, this command can help. - - (iv) To mark all the mounts under /mnt as unbindable execute the - following - - command: - smount /mnt runbindable - the corresponding syntax planned for mount command is - mount --make-runbindable /mnt - - just to mark a mount /mnt as unbindable, execute the following - command: - smount /mnt unbindable - the corresponding syntax planned for mount command is - mount --make-unbindable /mnt + Modern mount(8) command is aware of shared subtree features, + so use it instead of the 'smount' command. [source code removed] 4) Use cases@@ -558,7 +416,7 @@ replicas continue to be exactly same. then the subtree under the unbindable mount is pruned in the new location. - eg: lets say we have the following mount tree. + eg: let's say we have the following mount tree. A / \@@ -566,7 +424,7 @@ replicas continue to be exactly same. / \ / \ D E F G - Lets say all the mount except the mount C in the tree are + Let's say all the mount except the mount C in the tree are of a type other than unbindable. If this tree is rbound to say Z@@ -683,13 +541,13 @@ replicas continue to be exactly same. 'b' on mounts that receive propagation from mount 'B' and does not have sub-mounts within them are unmounted. - Example: Lets say 'B1', 'B2', 'B3' are shared mounts that propagate to + Example: Let's say 'B1', 'B2', 'B3' are shared mounts that propagate to each other. - lets say 'A1', 'A2', 'A3' are first mounted at dentry 'b' on mount + let's say 'A1', 'A2', 'A3' are first mounted at dentry 'b' on mount 'B1', 'B2' and 'B3' respectively. - lets say 'C1', 'C2', 'C3' are next mounted at the same dentry 'b' on + let's say 'C1', 'C2', 'C3' are next mounted at the same dentry 'b' on mount 'B1', 'B2' and 'B3' respectively. if 'C1' is unmounted, all the mounts that are most-recently-mounted on@@ -710,7 +568,7 @@ replicas continue to be exactly same. A cloned namespace contains all the mounts as that of the parent namespace. - Lets say 'A' and 'B' are the corresponding mounts in the parent and the + Let's say 'A' and 'B' are the corresponding mounts in the parent and the child namespace. If 'A' is shared, then 'B' is also shared and 'A' and 'B' propagate to@@ -759,11 +617,11 @@ replicas continue to be exactly same. mount --make-slave /mnt At this point we have the first mount at /tmp and - its root dentry is 1. Lets call this mount 'A' + its root dentry is 1. Let's call this mount 'A' And then we have a second mount at /tmp1 with root - dentry 2. Lets call this mount 'B' + dentry 2. Let's call this mount 'B' Next we have a third mount at /mnt with root dentry - mnt. Lets call this mount 'C' + mnt. Let's call this mount 'C' 'B' is the slave of 'A' and 'C' is a slave of 'B' A -> B -> C@@ -794,7 +652,7 @@ replicas continue to be exactly same. Q3 Why is unbindable mount needed? - Lets say we want to replicate the mount tree at multiple + Let's say we want to replicate the mount tree at multiple locations within the same subtree. if one rbind mounts a tree within the same subtree 'n' times@@ -803,7 +661,7 @@ replicas continue to be exactly same. mounts. Here is a example. step 1: - lets say the root tree has just two directories with + let's say the root tree has just two directories with one vfsmount. root / \@@ -875,7 +733,7 @@ replicas continue to be exactly same. Unclonable mounts come in handy here. step 1: - lets say the root tree has just two directories with + let's say the root tree has just two directories with one vfsmount. root / \