struct stat st;
struct statfs stfs;
struct lxc_rootfs *rootfs = &conf->rootfs;
+ const char *type;
ret = lxc_storage_prepare(conf);
if (ret)
return syserror_set(-EINVAL, "Failed to prepare rootfs storage");
+ type = rootfs->storage->type;
+
+ if (!type)
+ return syserror_set(-EINVAL, "Storage type neither set nor automatically detected");
if (!is_empty_string(rootfs->mnt_opts.userns_path)) {
if (!rootfs->path)
return syserror_set(-EINVAL, "Idmapped rootfs currently only supported with separate rootfs for container");
- if (rootfs->bdev_type && !strequal(rootfs->bdev_type, "dir"))
+ if (type && !strequal(type, "dir"))
return syserror_set(-EINVAL, "Idmapped rootfs currently only supports the \"dir\" storage driver");
}
if (userns)
return log_trace(0, "Not pinning because container runs in user namespace");
- if (rootfs->bdev_type) {
- if (strequal(rootfs->bdev_type, "overlay") ||
- strequal(rootfs->bdev_type, "overlayfs"))
- return log_trace_errno(0, EINVAL, "Not pinning on stacking filesystem");
+ if (strequal(type, "overlay") ||
+ strequal(type, "overlayfs"))
+ return log_trace_errno(0, EINVAL, "Not pinning on stacking filesystem");
- if (strequal(rootfs->bdev_type, "zfs"))
- return log_trace_errno(0, EINVAL, "Not pinning on ZFS filesystem");
- }
+ if (strequal(type, "zfs"))
+ return log_trace_errno(0, EINVAL, "Not pinning on ZFS filesystem");
dfd_path = open_at(-EBADF, rootfs->path, PROTECT_OPATH_FILE, 0, 0);
if (dfd_path < 0)
if (current_config == conf)
current_config = NULL;
lxc_terminal_conf_free(&conf->console);
+ free(conf->rootfs.__bdev_type);
free(conf->rootfs.mount);
- free(conf->rootfs.bdev_type);
free(conf->rootfs.path);
put_lxc_rootfs(&conf->rootfs, true);
free(conf->logfile);
* @path : the rootfs source (directory or device)
* @mount : where it is mounted
* @buf : static buffer to construct paths
- * @bdev_type : optional backing store type
+ * @__bdev_type : optional backing store type
* @managed : whether it is managed by LXC
* @dfd_mnt : fd for @mount
* @dfd_dev : fd for /dev of the container
int dfd_dev;
char buf[PATH_MAX];
- char *bdev_type;
+ char *__bdev_type;
bool managed;
struct lxc_mount_options mnt_opts;
struct lxc_storage *storage;
return ret_errno(ENOMEM);
/* Split <storage type>:<container path> into <storage type> and
- * <container path>. Set "rootfs.bdev_type" to <storage type> and
+ * <container path>. Set "rootfs.__bdev_type" to <storage type> and
* "rootfs.path" to <container path>.
*/
tmp = strchr(dup, ':');
if (tmp) {
*tmp = '\0';
- ret = set_config_path_item(&lxc_conf->rootfs.bdev_type, dup);
+ ret = set_config_path_item(&lxc_conf->rootfs.__bdev_type, dup);
if (ret < 0)
return ret_errno(ENOMEM);
size_t i;
const struct lxc_storage_type *bdev;
const char *path = conf->rootfs.path;
- const char *type = conf->rootfs.bdev_type;
+ const char *type = conf->rootfs.__bdev_type;
bdev = get_storage_by_name(path, type);
if (bdev)
bool storage_lxc_is_dir(struct lxc_conf *conf)
{
struct lxc_storage *orig;
- char *type = conf->rootfs.bdev_type;
+ const char *type = conf->rootfs.__bdev_type;
bool bret = false;
if (type)
* trust the config file. If the config file key
* lxc.rootfs.path is set to <storage type>:<container path>
* the confile parser will have split this into <storage type>
- * and <container path> and set the <bdev_type> member in the
+ * and <container path> and set the <__bdev_type> member in the
* lxc_rootfs struct to <storage type> and the <path> member
* will be set to a clean <container path> without the <storage
* type> prefix. This is the new, clean way of handling storage