#include "error.h"
#include "parse.h"
#include "config.h"
-
-#include <lxc/conf.h>
-#include <lxc/log.h>
-#include <lxc/lxc.h> /* for lxc_cgroup_set() */
+#include "utils.h"
+#include "conf.h"
+#include "log.h"
+#include "lxc.h" /* for lxc_cgroup_set() */
lxc_log_define(lxc_conf, lxc);
}
pivotdir_is_temp = 1;
- }
- else {
- snprintf(path, sizeof(path), ".%s", pivotdir);
+ } else {
+
+ snprintf(path, sizeof(path), "%s/%s", rootfs, pivotdir);
+
+ if (access(path, F_OK)) {
+ if (mkdir_p(path, 0755)) {
+ SYSERROR("failed to create pivotdir '%s'", path);
+ return -1;
+ }
+
+ DEBUG("created '%s' directory", path);
+ }
}
- DEBUG("temporary mountpoint for old rootfs is '%s'", path);
+ DEBUG("mountpoint for old rootfs is '%s'", path);
/* pivot_root into our new root fs */
#include <sys/mount.h>
#include <dirent.h>
#include <fcntl.h>
+#include <libgen.h>
#include "log.h"
return 0;
}
+extern int mkdir_p(char *dir, mode_t mode)
+{
+ int ret;
+ char *d;
+
+ if (!strcmp(dir, "/"))
+ return 0;
+
+ d = strdup(dir);
+ if (!d)
+ return -1;
+
+ ret = mkdir_p(dirname(d), mode);
+ free(d);
+ if (ret)
+ return -1;
+
+ if (!access(dir, F_OK))
+ return 0;
+
+ if (mkdir(dir, mode)) {
+ SYSERROR("failed to create directory '%s'\n", dir);
+ return -1;
+ }
+
+ return 0;
+}
extern int lxc_copy_file(const char *src, const char *dst);
extern int lxc_setup_fs(void);
extern int get_u16(ushort *val, const char *arg, int base);
+extern int mkdir_p(const char *dir, mode_t mode);