From: ebiederm@xmission.com (Eric W. Biederman) Subject: Re: Building a clean namespace and MS_BIND across namespaces is now disabled Date: Sun, 20 Nov 2005 17:01:43 -0700 Message-ID: References: <20051120230451.GC9601@sergelap.austin.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Al Viro , linux-fsdevel@vger.kernel.org, Ram Pai , Miklos Szeredi , Christoph Hellwig , Jamie Lokier Return-path: Received: from ebiederm.dsl.xmission.com ([166.70.28.69]:51377 "EHLO ebiederm.dsl.xmission.com") by vger.kernel.org with ESMTP id S1750799AbVKUACx (ORCPT ); Sun, 20 Nov 2005 19:02:53 -0500 To: "Serge E. Hallyn" In-Reply-To: <20051120230451.GC9601@sergelap.austin.ibm.com> (Serge E. Hallyn's message of "Sun, 20 Nov 2005 17:04:51 -0600") Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org "Serge E. Hallyn" writes: > Quoting Eric W. Biederman (ebiederm@xmission.com): > Why not do > > do_clone_namespace > mount -t ramfs none /build > # set up a fs under /build > mkdir /build/oldmount > cd /build > pivot_root . oldmount > umount -l oldmount > > ? That's what I used to do in chroot_ns.c (attached) for bsdjail > (www.sf.net/projects/linuxjail). > > Hope I didn't completely misunderstand your question... Pivot root is probably a functional solution. Part of the reason for the question was I that I recall Al Viro making assertions to the effect that pivot_root and friends should no longer be necessary. Part of the question is that doing what I described you can get yourself into an interesting pickle, and having a clear reading if it was don't do it then kind of scenario. In addition there is a pain with pivot_root that you may need at least a mount point on the original filesystem, and coordinating all of those pieces may be unnecessarily complex. >> This leads me to the second part of my puzzle. When you have >> multiple namespaces around it can be handy to mount a filesystem >> from a different namespace. Especially if you want to derive >> your new namespace from an old one. > > Again, is it acceptable to do this ahead of time before doing > pivot_root (but after cloning the namespace)? In general you can't because you are not necessarily descended from a namespace you want to bind mount a filesystem from. As an example using mount bind across namespaces you can fairly easily match the whole shared subtree thing that is being implemented now but with userspace coordinating the sharing instead of the kernel. > #define MAX_PATH 256 You should be able to get MAX_PATH out of an appropriate header. As I recall on linux this value is generally 4096 at least for the kernel limit. > static inline _syscall2(int, clone, int, flags, int, foo) > static _syscall2(int,pivot_root,const char *,new_root,const char *,put_old) You probably want to make these wrappers around the libc syscall() function. I don't remember the specifics but I recall there being some portability limitations to using the _syscall macros. Eric