Skip to content

Commit

Permalink
Merge pull request #2943 from cgwalters/mount-cleanup
Browse files Browse the repository at this point in the history
prepare-root: Drop code mounting `/proc`
  • Loading branch information
jmarrero authored Jul 19, 2023
2 parents 253e775 + 41cda3b commit 5593616
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions src/switchroot/ostree-prepare-root.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*/
Expand Down

0 comments on commit 5593616

Please sign in to comment.