From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ram Pai Subject: Re: Mirror a file system on the fly Date: Thu, 18 Aug 2005 14:03:12 -0700 Message-ID: <1124398992.5222.404.camel@localhost> References: <3e32b777050818124045dcd1f0@mail.gmail.com> <1124395116.5222.396.camel@localhost> <3e32b77705081813273f887aef@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from e33.co.us.ibm.com ([32.97.110.131]:10705 "EHLO e33.co.us.ibm.com") by vger.kernel.org with ESMTP id S932436AbVHRVDQ (ORCPT ); Thu, 18 Aug 2005 17:03:16 -0400 Received: from westrelay02.boulder.ibm.com (westrelay02.boulder.ibm.com [9.17.195.11]) by e33.co.us.ibm.com (8.12.10/8.12.9) with ESMTP id j7IL3Ef5546022 for ; Thu, 18 Aug 2005 17:03:14 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by westrelay02.boulder.ibm.com (8.12.10/NCO/VERS6.7) with ESMTP id j7IL2oJ7466962 for ; Thu, 18 Aug 2005 15:02:50 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11/8.13.3) with ESMTP id j7IL3D58031042 for ; Thu, 18 Aug 2005 15:03:14 -0600 To: Dave Schwartz In-Reply-To: <3e32b77705081813273f887aef@mail.gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Thu, 2005-08-18 at 13:27, Dave Schwartz wrote: > Hi Ram, > Thanks for the inputs. I was going over the man pages describing the > clone system call and its option of CLONE_NEWNS. Could understand the > description only in parts. > > The man page suggests that this flag when set, the cloned child is > started in a new name space, initialized with a copy of the parent. > Now does that mean, a program like a shell when cloned with > CLONE_NEWNS set, will have a copy of file hierarchy of the underlying > parent process? Yes the child process will see an exact copy of all the mounts of various filesystems as that of the parent. However if you mount/unmount any filesystems in the child, the same will not be mounted/unmounted in the parent and vice-versa. Each has its individual view of the the filesystem heirarchy. Try the following program that clones off a child process with a mirror namespace and gives you a bash prompt. Try mounting and unmounting in this bash prompt and see if the same is visible in a totally different window. #include #include #include char somemem[4096]; int myfunc(){ system("bash"); } int main(int argc, char *argv[]) { if(clone(myfunc, somemem, CLONE_NEWNS|SIGCHLD, NULL)) { wait(NULL); } else { printf("clone failed\n"); } printf("exit\n"); } Hope this helps, RP > > Gracias, > decebel > > > > On 8/19/05, Ram Pai wrote: > > On Thu, 2005-08-18 at 12:40, Dave Schwartz wrote: > > > Hi list, > > > > > > Not too sure if this is the right forum to ask this question but since > > > my requirement is around linux filesystems, I shall take this liberty > > > to post my question. > > > > > > My requirement is to develop a kernel/user space module to add an > > > extension to the shell program environment such that this shell forks > > > a mirror look-alike filesystem of the underlying OS to the programs > > > run in that particular shell. > > > > u seem to be talking about namespaces, if I get you right. > > > > there is a flag CLONE_NEWNS to the system call 'clone' which does what > > u r talking about. > > > > RP > > > > > > > > > > > > > > > > > Was trying to look thru the FAQ and a few list archives to look for > > > ideas around my requirement. The archives were overwhelming. > > > > > > > > > Any ideas/pointers will be a great help, > > > Gracias, > > > decebel > > > - > > > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > > > the body of a message to majordomo@vger.kernel.org > > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > > > > - > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html