]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
storage: prefix all nbd paths
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 1 Jul 2017 21:33:18 +0000 (23:33 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 2 Jul 2017 12:40:05 +0000 (14:40 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/bdev/lxcnbd.c

index 4a55e9fff37a75791a17878b7626ed097b918746..e6ce59038ec92d00ccfcaa9897c6d3a92d60b3d2 100644 (file)
@@ -117,17 +117,21 @@ int nbd_detect(const char *path)
 int nbd_mount(struct bdev *bdev)
 {
        int ret = -1, partition;
+       char *src;
        char path[50];
 
        if (strcmp(bdev->type, "nbd"))
                return -22;
+
        if (!bdev->src || !bdev->dest)
                return -22;
 
        /* nbd_idx should have been copied by bdev_init from the lxc_conf */
        if (bdev->nbd_idx < 0)
                return -22;
-       partition = nbd_get_partition(bdev->src);
+
+       src = lxc_storage_get_path(bdev->src, bdev->type);
+       partition = nbd_get_partition(src);
        if (partition)
                ret = snprintf(path, 50, "/dev/nbd%dp%d", bdev->nbd_idx,
                                partition);
@@ -152,14 +156,13 @@ int nbd_mount(struct bdev *bdev)
 
 int nbd_umount(struct bdev *bdev)
 {
-       int ret;
-
        if (strcmp(bdev->type, "nbd"))
                return -22;
+
        if (!bdev->src || !bdev->dest)
                return -22;
-       ret = umount(bdev->dest);
-       return ret;
+
+       return umount(bdev->dest);
 }
 
 bool requires_nbd(const char *path)