[Toybox] Recursive bind mounts.

Yi-yo Chiang yochiang at google.com
Tue Aug 2 07:28:25 PDT 2022


I would prefer a standalone '--rbind' option, so people who care about this
subtle difference have a choice.

--bind -> MS_BIND
--rbind -> MS_BIND|MS_REC
<nothing> -> could default to --bind or --rbind? IMO the default doesn't
matter much if we can override with explicit --bind & --rbind.

>From Android perspective, there are non-trivial amount of both use cases (
https://cs.android.com/search?q=%22MS_BIND%22%20%20-f:test%20-f:%5E(external%7Cbionic%7Cprebuilts)%2F&sq=&ss=android%2Fplatform%2Fsuperproject).
I imagine having both `mount --bind` & `mount --rbind` at hand is
beneficial for development, because developer can test both MS_BIND and
MS_BIND|MS_REC with the `mount` command directly without needing to write
an entire test procedure/program/suite.


On Thu, Jul 28, 2022 at 11:10 PM enh <enh at google.com> wrote:

> +Yi-yo Chiang <yochiang at google.com> who might have an opinion from the
> Android side...
>
> On Thu, Jul 28, 2022 at 5:11 AM Rob Landley <rob at landley.net> wrote:
>
>> Toybox mount is autodetecting --bind based on the types of source and dest
>> (mounting a file on a file or a directory on a directory is a bind
>> mount), but
>> there's also --rbind which _recursively_ bind mounts. I.E. the bind
>> mounts under
>> this directory are also bind mounted into the destination.
>>
>> I THINK what I want to do is just:
>>
>> @@ -184,7 +188,7 @@ static void mount_filesystem(char *dev, char *dir,
>> char *type,
>>          && ((S_ISREG(stdev.st_mode) && S_ISREG(stdir.st_mode))
>>              || (S_ISDIR(stdev.st_mode) && S_ISDIR(stdir.st_mode))))
>>      {
>> -      flags |= MS_BIND;
>> +      flags |= MS_BIND|MS_REC;
>>      } else fp = xfopen("/proc/filesystems", "r");
>>    } else if (!strcmp(type, "ignore")) return;
>>    else if (!strcmp(type, "swap"))
>>
>> I.E. have the existing bind mount behavior automatically be recursive.
>> But I
>> wanted to ask for a second opinion here. (I could also implement --rbind
>> and
>> have it be different than --bind but nobody's come to me with this use
>> case,
>> it's just me digging through container nonsense coming up with edge
>> cases...)
>>
>> Rob
>> _______________________________________________
>> Toybox mailing list
>> Toybox at lists.landley.net
>> http://lists.landley.net/listinfo.cgi/toybox-landley.net
>>
>

-- 

Yi-yo Chiang
Software Engineer
yochiang at google.com

I support flexible work schedules, and I’m sending this email now because
it is within the hours I’m working today. Please do not feel obliged to
reply straight away - I understand that you will reply during the hours you
work, which may not match mine.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20220802/4cde533d/attachment-0001.htm>


More information about the Toybox mailing list