From: Christian Brauner Date: Mon, 27 Nov 2017 23:57:09 +0000 (+0100) Subject: storage: pass down storage type X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=577ec5e5f8361478bf5b1540567fad38a8ac367c;p=thirdparty%2Flxc.git storage: pass down storage type The configuration file parser now already detects the storage type so spare the work and pass it down to the storage drivers. Signed-off-by: Christian Brauner Signed-off-by: Adrian Reber --- diff --git a/src/lxc/storage/storage.c b/src/lxc/storage/storage.c index 2a91aab67..3c5d4c5a9 100644 --- a/src/lxc/storage/storage.c +++ b/src/lxc/storage/storage.c @@ -213,17 +213,27 @@ static const struct lxc_storage_type bdevs[] = { static const size_t numbdevs = sizeof(bdevs) / sizeof(struct lxc_storage_type); -static const struct lxc_storage_type *get_storage_by_name(const char *name) +static const struct lxc_storage_type *get_storage_by_name(const char *name, + const char *type) { + int ret; size_t i, cmplen; - cmplen = strcspn(name, ":"); + if (type) + cmplen = strlen(type); + else + cmplen = strcspn(name, ":"); if (cmplen == 0) return NULL; - for (i = 0; i < numbdevs; i++) - if (strncmp(bdevs[i].name, name, cmplen) == 0) + for (i = 0; i < numbdevs; i++) { + if (type) + ret = strncmp(bdevs[i].name, type, cmplen); + else + ret = strncmp(bdevs[i].name, name, cmplen); + if (ret == 0) break; + } if (i == numbdevs) return NULL; @@ -238,7 +248,7 @@ const struct lxc_storage_type *storage_query(struct lxc_conf *conf, size_t i; const struct lxc_storage_type *bdev; - bdev = get_storage_by_name(src); + bdev = get_storage_by_name(src, conf->rootfs.bdev_type); if (bdev) return bdev;