[CRIU] [PATCH 1/5] mnt: add --ext-mount-map auto option

Andrew Vagin avagin at odin.com
Tue Apr 14 01:06:49 PDT 2015


On Mon, Apr 13, 2015 at 08:58:21AM -0600, Tycho Andersen wrote:
> On Mon, Apr 13, 2015 at 11:24:06AM +0300, Andrew Vagin wrote:
> > On Fri, Apr 10, 2015 at 02:34:37PM +0000, Tycho Andersen wrote:
> > > +static int resolve_external_mounts(struct mount_info *info)
> > > +{
> > > +	struct mount_info *m;
> > > +	struct ns_id *ns = NULL, *iter;
> > > +
> > > +	for (iter = ns_ids; iter->next; iter = iter->next) {
> > > +		if (iter->pid == getpid() && iter->nd == &mnt_ns_desc) {
> > > +			ns = iter;
> > > +			break;
> > > +		}
> > > +	}
> > > +
> > > +	if (!ns) {
> > > +		pr_err("Failed to find criu pid's mount ns!");
> > > +		return -1;
> > > +	}
> > > +
> > > +	for (m = info; m; m = m->next) {
> > > +		int ret, size;
> > > +		char *p;
> > > +		struct ext_mount *em;
> > > +		struct mount_info *match;
> > > +
> > > +		if (m->parent == NULL || m->is_ns_root)
> > > +			continue;
> > > +
> > > +		ret = try_resolve_ext_mount(m);
> > > +		if (ret < 0 && ret != -ENOTSUP) {
> > > +			return -1;
> > > +		} else if (ret == -ENOTSUP && !opts.autodetect_ext_mounts) {
> > > +			continue;
> > > +		} else if (ret == 0) {
> > > +			continue;
> > > +		}
> > > +
> > > +		match = find_best_external_match(ns->mnt.mntinfo_list, m);
> > > +		if (!match)
> > > +			continue;
> > > +
> > > +		size = strlen(match->mountpoint + 1) + strlen(m->root) + 1;
> > > +		p = xmalloc(sizeof(char) * size);
> > > +		if (!p)
> > > +			return -1;
> > > +
> > > +		ret = snprintf(p, size+1, "%s%s", match->mountpoint + 1, m->root);
> > 
> > Is it ok if match->root isn't /?
> 
> It should be, presumably that just means there were some extra steps
> to set up the external mount point. Am I missing something?

Maybe we need something like this:

snprintf(p, size+1, "%s%s", match->mountpoint + 1, m->root + strlen(match->root));

and check that strlen(match->root) <= strlen(m->root) in
find_best_external_match().

Thanks,
Andrew


More information about the CRIU mailing list