From 35ab48ad02d33143aa59653089f1a250e9b1fdd4 Mon Sep 17 00:00:00 2001 From: Sebastien Dabdoub Date: Mon, 4 Dec 2023 13:08:49 -0800 Subject: [PATCH] Make sure the new runtime dir exists before mounting. This seems to be required under some choices of runtime dir. Also clean up some redundant logging. Signed-off-by: Sebastien Dabdoub --- src/bindings.c | 5 +++++ src/bindings.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index 880198ae..61d45919 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -762,6 +762,11 @@ static int permute_prepare(void) return -1; } + if (!mkdir_p(new_runtime, 0755)) { + lxcfs_error("Failed to create dir %s\n", new_runtime); + return -1; + } + if (mount(runtime_path, new_runtime, NULL, MS_BIND, 0) < 0) { lxcfs_error("Failed to bind-mount %s into new root: %s.\n", runtime_path, strerror(errno)); return -1; diff --git a/src/bindings.h b/src/bindings.h index 15112ad4..7808a236 100644 --- a/src/bindings.h +++ b/src/bindings.h @@ -107,13 +107,13 @@ struct lxcfs_opts { bool swap_off; bool use_pidfd; bool use_cfs; - // As of opts version 2. - char runtime_path[PATH_MAX]; /* * Ideally we'd version by size but because of backwards compatability * and the use of bool instead of explicited __u32 and __u64 we can't. */ __u32 version; + // As of opts version 2. + char runtime_path[PATH_MAX]; }; typedef enum lxcfs_opt_t {