[CRIU] [PATCH 6/9] mntns: rework validation to support non-root shared bind-mounts

Pavel Emelyanov xemul at parallels.com
Wed Nov 5 10:51:14 PST 2014


>> OK, so for each mount in t (widest) we try to find a mount in m (the one being
>> validated now), that is a) equal and b) has path visible in t, right?
>>
>> If so, two questions:
>>
>> a) why the logic is inverted? Shouldn't we scan for m's mounts and find the
>>    respective image in t?
> 
> Look at the answer on the second question. We want to get an empty
> children list at the end.
> 
>>
>> b) why tossing the m's children list? Why not just find the respective mount
>>    and leave it in?
> 
> We need to compare two unsorted lists. We enumirate all elements from
> one of them, then find a proper element in a second list and remove it
> from there.
> 
> At the end we check that a second list is empty. Otherwise it contains
> elements, which don't exist in a first list.

Let's make it more math-style :) You have two sets A and B. What
do you want to check:

A == B, i.e. each element in A has the same in B _and_ vice versa
A in B, i.e. each element in A has the same in B

?

>From your explanation I think that we need "A in B" and solve this by

1) Take element from B
2) Find the same in A
3) If found -- remove from A
4) Check A is empty at the end

but this task has simpler solution

1) Take element from A
2) Find the same in B

Provided no two elements from A can have the same "same" in B the
2nd algorithm is much simpler :)

Thanks,
Pavel



More information about the CRIU mailing list