The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Randy Dunlap <randy.dunlap@oracle.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	akpm <akpm@linux-foundation.org>,
	miklos@szeredi.hu
Subject: Re: [PATCH 1/2] documentation: split and build smount.c
Date: Mon, 18 Aug 2008 01:04:31 -0400	[thread overview]
Message-ID: <20080818050431.GA20692@infradead.org> (raw)
In-Reply-To: <20080817214442.ca4345ce.randy.dunlap@oracle.com>

On Sun, Aug 17, 2008 at 09:44:42PM -0700, Randy Dunlap wrote:
> From: Randy Dunlap <randy.dunlap@oracle.com>
> 
> Make smount.c source file and add that to Makefile so that its
> build can be checked.

Just remove it, and modern /bin/mount handles shared subtrees just fine

> 
> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
> cc: Miklos Szeredi <miklos@szeredi.hu>
> ---
>  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(-)
> 
> --- /dev/null
> +++ lin2627-rc3g4-kerndoc/Documentation/filesystems/smount.c
> @@ -0,0 +1,73 @@
> +//
> +//this code was developed my Miklos Szeredi <miklos@szeredi.hu>
> +//and modified by Ram Pai <linuxram@us.ibm.com>
> +// 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;
> +}
> --- lin2627-rc3g4-kerndoc.orig/Documentation/filesystems/sharedsubtree.txt
> +++ lin2627-rc3g4-kerndoc/Documentation/filesystems/sharedsubtree.txt
> @@ -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 <miklos@szeredi.hu>
> -	//and modified by Ram Pai <linuxram@us.ibm.com>
> -	// 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:
> --- lin2627-rc3g4-kerndoc.orig/Documentation/Makefile
> +++ lin2627-rc3g4-kerndoc/Documentation/Makefile
> @@ -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/
> --- /dev/null
> +++ lin2627-rc3g4-kerndoc/Documentation/filesystems/Makefile
> @@ -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)
> --- lin2627-rc3g4-kerndoc.orig/Documentation/filesystems/00-INDEX
> +++ lin2627-rc3g4-kerndoc/Documentation/filesystems/00-INDEX
> @@ -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/
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
---end quoted text---

  reply	other threads:[~2008-08-18  5:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-18  4:44 [PATCH 1/2] documentation: split and build smount.c Randy Dunlap
2008-08-18  5:04 ` Christoph Hellwig [this message]
2008-08-19  1:14   ` [PATCH v2] " Randy Dunlap
2008-08-19 22:56     ` Karel Zak
2008-10-28 21:26       ` Randy Dunlap
2008-08-25 21:11     ` Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080818050431.GA20692@infradead.org \
    --to=hch@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=randy.dunlap@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox