[CRIU] [PATCH 1/2] mnt: add matching on fs kernel subtypes

Tycho Andersen tycho.andersen at canonical.com
Thu Apr 9 11:39:20 PDT 2015


On Thu, Apr 09, 2015 at 09:36:28PM +0300, Pavel Emelyanov wrote:
> On 04/09/2015 08:32 PM, Tycho Andersen wrote:
> > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> > ---
> >  mount.c | 22 +++++++++++++++++++++-
> >  1 file changed, 21 insertions(+), 1 deletion(-)
> > 
> > diff --git a/mount.c b/mount.c
> > index fff7eb4..aec41dc 100644
> > --- a/mount.c
> > +++ b/mount.c
> > @@ -1127,12 +1127,32 @@ struct fstype *find_fstype_by_name(char *fst)
> >  	 * anything is wrong, almost every fs has its own features)
> >  	 * 2nd -- save some space in the image (since we scan all
> >  	 * names anyway)
> > +	 *
> > +	 * The kernel reports "subtypes" sometimes and the valid
> > +	 * type-vs-subtype delimiter is the dot symbol. Here we also collect
> > +	 * the subtype if present so we can match against that as well.
> >  	 */
> > +	char subtype[1024];
> > +	bool has_subtype = false;
> >  
> > -	for (i = 0; i < ARRAY_SIZE(fstypes); i++)
> > +	for (i = 0; fst[i] && i < sizeof(subtype) - 1; i++) {
> > +		if (fst[i] == '.') {
> > +			has_subtype = true;
> > +			break;
> > +		}
> > +		subtype[i] = fst[i];
> 
> Thus the subtype is the part of type prior to '.' ...
> 
> > +	}
> > +
> > +	subtype[i] = 0;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(fstypes); i++) {
> >  		if (!strcmp(fstypes[i].name, fst))
> >  			return fstypes + i;
> >  
> > +		if (has_subtype && !strcmp(fstypes[i].name, subtype))
> > +			return fstypes + i;
> 
> ... so for fuse.foo-s we will have two strcmp-s -- one for "fuse.foo" and then
> for "fuse", while we only need the 2nd one always.

You're right, I think we only need to compare on the chopped off part,
and we can get rid of the has_subtype flag all together.

> The subtype (part after dot) is just informational. When we will support fuse
> (or any other fs with subtypes) we will have to save the subtype in the image
> and pass one back to mount(). Right now we can just throw one away and only
> strcmp() on the type (part before dot).

Sorry, the variable is probably misnamed. That's what this patch does,
I just called it "subtype" instead of whatever it should really be
called, which is...? :)

Tycho

> > +	}
> > +
> >  	return &fstypes[0];
> >  }
> >  
> > 
> 


More information about the CRIU mailing list