Skip to content

Commit

Permalink
Make sure the new runtime dir exists before mounting.
Browse files Browse the repository at this point in the history
This seems to be required under some choices of runtime dir. Also clean up some redundant logging.

Signed-off-by: Sebastien Dabdoub <[email protected]>
  • Loading branch information
sdab committed Jun 5, 2024
1 parent c6fad6a commit 35ab48a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 35ab48a

Please sign in to comment.