return NULL;
}
-static const struct bdev_type *bdev_query(struct lxc_conf *conf, const char *src)
+static const struct bdev_type *bdev_query(struct lxc_conf *conf,
+ const char *src)
{
size_t i;
- if (conf->rootfs.bdev_type)
+ if (conf->rootfs.bdev_type) {
+ DEBUG("config file specified rootfs type \"%s\"",
+ conf->rootfs.bdev_type);
return get_bdev_by_name(conf->rootfs.bdev_type);
+ }
for (i = 0; i < numbdevs; i++) {
int r;
if (i == numbdevs)
return NULL;
+
+ DEBUG("detected rootfs type \"%s\"", bdevs[i].name);
+
return &bdevs[i];
}
#include <string.h>
#include <unistd.h>
#include <linux/loop.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include "bdev.h"
int loop_detect(const char *path)
{
+ int ret;
+ struct stat s;
+
if (strncmp(path, "loop:", 5) == 0)
return 1;
+
+ ret = stat(path, &s);
+ if (ret < 0)
+ return 0;
+
+ if (__S_ISTYPE(s.st_mode, S_IFREG))
+ return 1;
+
return 0;
}
{
int ret, loopfd;
char loname[MAXPATHLEN];
+ char *src = bdev->src;
if (strcmp(bdev->type, "loop"))
return -22;
+
if (!bdev->src || !bdev->dest)
return -22;
- loopfd = lxc_prepare_loop_dev(bdev->src + 5, loname, LO_FLAGS_AUTOCLEAR);
+ /* skip prefix */
+ if (!strncmp(bdev->src, "loop:", 5))
+ src += 5;
+
+ loopfd = lxc_prepare_loop_dev(src, loname, LO_FLAGS_AUTOCLEAR);
if (loopfd < 0)
return -1;
DEBUG("prepared loop device \"%s\"", loname);