All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: Jiri Jaburek <jjaburek@redhat.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH 1/2 v2] containers: added mountns/mountns03.c
Date: Fri, 12 Sep 2014 08:59:32 -0400 (EDT)	[thread overview]
Message-ID: <1194817182.22301656.1410526772686.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <5411BB3A.70308@redhat.com>



----- Original Message -----
> From: "Jiri Jaburek" <jjaburek@redhat.com>
> To: "Matus Marhefka" <mmarhefk@redhat.com>
> Cc: ltp-list@lists.sourceforge.net, "Jan Stancek" <jstancek@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

  reply	other threads:[~2014-09-12 12:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26  9:59 [LTP] [PATCH 1/2] containers: added mountns/mountns03.c Matus Marhefka
2014-08-26  9:59 ` [LTP] [PATCH 2/2] containers: added mountns/mountns04.c Matus Marhefka
2014-08-29 13:47   ` [LTP] [PATCH 2/2 v2] " Matus Marhefka
2014-09-04 14:21     ` Jan Stancek
2014-10-02 13:47       ` Cyril Hrubis
     [not found]         ` <1080778288.46330076.1412258911538.JavaMail.zimbra@redhat.com>
2014-10-15 12:39           ` Cyril Hrubis
2014-09-24  8:14     ` chrubis
2014-10-02 12:29   ` [LTP] [PATCH 2/2 v3] " Matus Marhefka
2014-08-29 13:46 ` [LTP] [PATCH 1/2 v2] containers: added mountns/mountns03.c Matus Marhefka
2014-09-04 14:13   ` Jan Stancek
2014-09-11 15:09     ` Jiri Jaburek
2014-09-12 12:59       ` Jan Stancek [this message]
2014-09-12 13:41         ` Jiri Jaburek
2014-09-12 14:19           ` Jan Stancek
2014-09-24  7:56   ` chrubis
     [not found]     ` <273164774.30346037.1411649870605.JavaMail.zimbra@redhat.com>
     [not found]       ` <461070711.43439951.1411650253035.JavaMail.zimbra@redhat.com>
2014-09-29  8:14         ` chrubis
2014-10-02 12:28 ` [LTP] [PATCH 1/2 v3] " Matus Marhefka

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=1194817182.22301656.1410526772686.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=jjaburek@redhat.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.