[Toybox] Recursive bind mounts.

Rob Landley rob at landley.net
Thu Jul 28 05:18:28 PDT 2022


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


More information about the Toybox mailing list