Skip to content

Commit

Permalink
Check /proc/self to find out if /proc is already mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Jun 28, 2023
1 parent bfebf93 commit 040fdbc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions initvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ int main(int argc, char* argv[], char* env[])
int retval;
char buf[BUFSIZ], *build_dir;

/* Docker builds get /proc mounted */
/* Docker builds get /proc mounted, so test for /proc/self */
struct stat sb;
if (stat("/.dockerenv", &sb)) {
if (lstat("/proc/self", &sb)) {
/* mount proc filesystem if it isn't already. */
if (mount("proc", "/proc", "proc", MS_MGC_VAL, NULL) == -1) {
if (errno != EBUSY) {
Expand Down

0 comments on commit 040fdbc

Please sign in to comment.