prepare-root: Drop code mounting `/proc`
authorColin Walters <walters@verbum.org>
Wed, 19 Jul 2023 13:12:10 +0000 (09:12 -0400)
committerColin Walters <walters@verbum.org>
Wed, 19 Jul 2023 13:12:10 +0000 (09:12 -0400)
This must be done by the init process here; it was always
dead code in the initramfs path.

We keep the copy of this code in the now-forked -static.c.

src/switchroot/ostree-prepare-root.c

index e9075a68b7a7890788b91721851b1c0bede713f5..d0b58cc509d9a242e29aeb33cdcd8807b4c8857f 100644 (file)
@@ -270,27 +270,15 @@ int
 main (int argc, char *argv[])
 {
   char srcpath[PATH_MAX];
+  struct stat stbuf;
 
   const char *root_arg = NULL;
-  bool we_mounted_proc = false;
   g_autoptr (GError) error = NULL;
 
   if (argc < 2)
     err (EXIT_FAILURE, "usage: ostree-prepare-root SYSROOT");
   root_arg = argv[1];
 
-  struct stat stbuf;
-  if (stat ("/proc/cmdline", &stbuf) < 0)
-    {
-      if (errno != ENOENT)
-        err (EXIT_FAILURE, "stat(\"/proc/cmdline\") failed");
-      /* We need /proc mounted for /proc/cmdline and realpath (on musl) to
-       * work: */
-      if (mount ("proc", "/proc", "proc", MS_SILENT, NULL) < 0)
-        err (EXIT_FAILURE, "failed to mount proc on /proc");
-      we_mounted_proc = 1;
-    }
-
   /* This is the final target where we should prepare the rootfs.  The usual
    * case with systemd in the initramfs is that root_mountpoint = "/sysroot".
    * In the fastboot embedded case we're pid1 and will setup / ourself, and
@@ -301,13 +289,6 @@ main (int argc, char *argv[])
     err (EXIT_FAILURE, "realpath(\"%s\")", root_arg);
   char *deploy_path = resolve_deploy_path (root_mountpoint);
 
-  if (we_mounted_proc)
-    {
-      /* Leave the filesystem in the state that we found it: */
-      if (umount ("/proc"))
-        err (EXIT_FAILURE, "failed to umount proc from /proc");
-    }
-
   /* Query the repository configuration - this is an operating system builder
    * choice.  More info: https://github.com/ostreedev/ostree/pull/1767
    */