[lxc-devel] [lxc/master] lvm: fix thinpool logical volumes

brauner on Github lxc-bot at linuxcontainers.org
Sat Sep 23 20:33:32 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170923/ba83d467/attachment.bin>
-------------- next part --------------
From 4280c0e46dc821d183651de4a82de2d72b7e8cad Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 23 Sep 2017 22:32:25 +0200
Subject: [PATCH] lvm: fix thinpool logical volumes

Closes #1827.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/storage/lvm.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/lxc/storage/lvm.c b/src/lxc/storage/lvm.c
index 6ceab1dea..105377890 100644
--- a/src/lxc/storage/lvm.c
+++ b/src/lxc/storage/lvm.c
@@ -264,17 +264,18 @@ int lvm_umount(struct lxc_storage *bdev)
 int lvm_compare_lv_attr(const char *path, int pos, const char expected)
 {
 	struct lxc_popen_FILE *f;
-	int ret, len, status;
+	int ret, status;
+	size_t len;
 	char *cmd;
 	char output[12];
-	int start=0;
+	int start = 0;
 	const char *lvscmd = "lvs --unbuffered --noheadings -o lv_attr %s 2>/dev/null";
 
-	len = strlen(lvscmd) + strlen(path) - 1;
+	len = strlen(lvscmd) + strlen(path) + 1;
 	cmd = alloca(len);
 
 	ret = snprintf(cmd, len, lvscmd, path);
-	if (ret < 0 || ret >= len)
+	if (ret < 0 || (size_t)ret >= len)
 		return -1;
 
 	f = lxc_popen(cmd);
@@ -283,6 +284,7 @@ int lvm_compare_lv_attr(const char *path, int pos, const char expected)
 		return -1;
 	}
 
+	ret = 0;
 	if (!fgets(output, 12, f->f))
 		ret = 1;
 


More information about the lxc-devel mailing list