<div dir="ltr">Right, in systemd's case there's no access to the external namespaces, but being the first process in a container allows you to take a snapshot of /proc/1/mountinfo during initialization (the container runtime would have all the initial mountpoints ready by then), and store all these mountpoints and their parameters in a hash-map. That way, when an unmount arrives, you just need to compare it with your mountpoint DB to determine if they are "foreign" or "local".<div><br></div><div>In our particular case (Sysbox container runtime) the above simplistic approach was not enough coz, on top of the above, we also needed to prevent certain remount operations (read-only -> read-write) from succeeding ...</div><div><br></div><div>Hope it makes sense now.</div><div><br></div><div><div><div>cheers,</div><div><br></div><div>/Rodny<br><div><br></div><div><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 1, 2021 at 1:29 PM Lennart Poettering <<a href="mailto:lennart@poettering.net">lennart@poettering.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sa, 27.02.21 11:28, Rodny Molina (<a href="mailto:rodnymolina@gmail.com" target="_blank">rodnymolina@gmail.com</a>) wrote:<br>
<br>
> Thanks for your detailed answer / explanation Lennart, it's fully<br>
> consistent with my code-browsing findings.<br>
><br>
> I've been struggling myself with the problem that you alluded above to<br>
> identify "foreign" mountpoints. After banging my head against the wall for<br>
> a while i ended up implementing an heuristic based on the<br>
> major:minor-number field of the /proc/pid/mountinfo file: if the container<br>
> mountpoint being considered has a major:minor-id that matches those<br>
> major:minor-ids present in the host mount namespace, then this one is<br>
> likely a "foreign" mountpoint, and shouldn't be unmounted.<br>
<br>
Not sure I follow. We'd need this from inside the container, so that<br>
we don't even try to unmount the file system. But from "inside" we<br>
have no outside to the host mount namespace...<br>
<br>
Lennart<br>
<br>
--<br>
Lennart Poettering, Berlin<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">/Rodny</div>