[CRIU] Sync TODO-s for mount.c work

Tycho Andersen tycho.andersen at canonical.com
Mon Apr 27 02:28:36 PDT 2015


Hi Pavel,

On Thu, Apr 23, 2015 at 08:17:29PM +0300, Pavel Emelyanov wrote:
> On 04/23/2015 08:01 PM, Tycho Andersen wrote:
> 
> >> E.g. the proc one. So if we have
> >> proc privately inherited from host and proc privately mounted inside then
> >> my checks will classify both as "private". While the former one should be
> >> bind-mounted and the latter one should be just mounted. So we also need to
> >> compare the super blocks, i.e. the devices. %)
> >>
> >> So...
> >>
> >> int is_not_external()
> >> {
> >>        if (master_is_external())
> >>              return false;
> >>
> >>        if (root_is_accessible())
> >>              return true;
> >>
> >>        return false;
> >> }
> >>
> >> where root_is_accessible() should also care for the superblocks, i.e.
> >>
> >> int root_is_accessible()
> >> {
> >>        if (device_is_visible())
> >>              return true;
> >>
> >>        if (root_path_is_visible())
> > 
> > The problem is that the root path can be / (which really means "the
> > external /"), but we think it is visible since it's visible from the
> > internal / as well.
> 
> Now -- yes. But I propose to mess with super-blocks, i.e. device-ids -- if the
> device we want to mount is "ours" then we can treat the mountpoint as internal,
> if it sits outside of our scope -- then the mountpoint is external regardless
> of what the root path is.
> 
> For example ext4-s will always be internally visible, as we can always mount
> any /dev/xxx device we need. At least try to. Pstores are always internal, as
> they are not (yet) virtualized. ProcFS is more complex, if the proc mount sb
> we want to mount will be given to us by plain mount() then it's internal,
> otherwise it's external. And all this is regardless of the mp->root path.

I see, so it looks something like:

bool root_is_accessable(struct mount_info *m)
{
    return device_id_supported(m->s_dev);
}

and we can make it visible via:

int make_root_accessible(struct mount_info *m, char *mount_path)
{

    if (!device_id_supported(m->s_dev))
        return -1;

    return mount_device_at(m->source, ..., mount_path);
}

and the test for is_external() (renaming from is_not_external to
remove one not from the stack):

bool is_external_mount(struct mount_info *m)
{
    /* has_external_peer checks both shared:n and master:n */
    if (has_external_peer(m) && !root_is_accessable(m))
        return false;

    return true;
}

Tycho


More information about the CRIU mailing list