[Toybox] Recursive bind mounts.

Rob Landley rob at landley.net
Tue Aug 2 19:11:06 PDT 2022


On 8/2/22 09:28, Yi-yo Chiang wrote:
> 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.

Ok. Try commit 1c6df98cb9de?

> 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
> <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.

I note that toybox mount has _always_ ignored --bind and -loop and figured out
when to do those based on the source and destination being files or directories.
(File on file is bind, dir on dir is bind, file on dir is loop, and dir on file
is an error although I vaguely recall some weird magic thing using that fourth
case and should go through my notes...)

I just added --bind/--rbind toggling the MS_REC flag (with the logic that we
invert it when we use it, so the default with nothing is we recurse. I.E. --bind
switches it ON and --rbind switches it OFF in the usual "last one wins" manner,
when then that gets inverted so the default is on).

-R adds a single instance of "rbind" to the -o list, at the end I believe. (The
order it occurs in vs --bind or --rbind or -o bind or -o rbind is not something
lib/args.c can really sanely pass through to a command_main(). If you can't
express it in the [+abc] groupings, order of operations is "everything was
already parsed before main got called"...)

I note that I have a dozen or so TODO entries in mount.c, and should cycle back
to filling it out at some point, but that's one of my big "once I have testing
working under mkroot" things...

Rob


More information about the Toybox mailing list