----- Original Message ----- > From: "Jiri Jaburek" <jjabu...@redhat.com> > To: "Matus Marhefka" <mmarh...@redhat.com> > Cc: ltp-list@lists.sourceforge.net, "Jan Stancek" <jstan...@redhat.com> > Sent: Thursday, 11 September, 2014 5:09:46 PM > Subject: Re: [LTP] [PATCH 1/2 v2] containers: added mountns/mountns03.c
> >> +++ b/testcases/kernel/containers/mountns/mountns03.c > >> @@ -0,0 +1,245 @@ > >> +/* Copyright (c) 2014 Red Hat, Inc. > >> + * > >> + * This program is free software: you can redistribute it and/or modify > >> + * it under the terms of version 2 the GNU General Public License as > >> + * published by the Free Software Foundation. > >> + * > >> + * This program is distributed in the hope that it will be useful, > >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of > >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > >> + * GNU General Public License for more details. > >> + * > >> + * You should have received a copy of the GNU General Public License > >> + * along with this program. If not, see <http://www.gnu.org/licenses/>. > >> + *********************************************************************** > >> + * File: mountns03.c > >> + * > >> + * Tests a slave mount: slave mount is like a shared mount except that > >> + * mount and umount events only propagate towards it. > >> + * Description: > >> + * 1. Creates directories "A", "B", "C", "D" and files "A/A", "B/B" > >> + * "C/C", "D/D" > >> + * 2. Unshares mount namespace and makes it private (so mounts/umounts > >> + * have no effect on a real system) > > > > Hi, > > > >> + * 3. Bind mounts directory "A" to "A" and "B" to "B" > > > > is the "B" to "B" part necessary in this case? First thing child does is > > it mounts A to B. > > > >> + * 4. Makes both directories ("A" and "B") shared > > > > related to above, is it necessary to make B shared? > > The obvious answer would be "yes", because ... (atm. replying to this part only) If you don't make B shared in parent, doesn't a bind operation in child make it shared regardless? You are bind mounting a shared mount to non-shared one. --------------------------------------------------------------------------- | BIND MOUNT OPERATION | |************************************************************************** |source(A)->| shared | private | slave | unbindable | | dest(B) | | | | | | | | | | | | | v | | | | | |************************************************************************** | shared | shared | shared | shared & slave | invalid | | | | | | | |non-shared| shared | private | slave | invalid | *************************************************************************** I modified the mountns03 testcase, so it doesn't bind and make B shared, consider following strace output: unshare(CLONE_NEWNS) = 0 mount("none", "/", "none", MS_REC|MS_PRIVATE, NULL) = 0 mount("A", "A", 0x407ab0, MS_BIND, NULL) = 0 --> bind mounts directory "A" to "A" mount("none", "A", "none", MS_SHARED, NULL) = 0 --> make "A" shared access("A/C", F_OK) = -1 ENOENT (No such file or directory) --> there's no C file in "A" clone(child_stack=0x2597030, flags=CLONE_NEWNS|SIGCHLD) = 2396 read(3, Process 2396 attached <unfinished ...> [pid 2396] getpid() = 2396 [pid 2396] mount("A", "B", 0x407ab0, MS_BIND, NULL) = 0 --> bind shared mount "A" to "B" [pid 2396] mount("C", "B", 0x407ab0, MS_BIND, NULL) = 0 --> bind mount "C" to "B" [pid 2396] write(4, "0", 1 <unfinished ...> [pid 2394] <... read resumed> "0", 1) = 1 [pid 2394] access("A/C", F_OK) = 0 --> parent can see file "C" in "A" Regards, Jan ------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list