[dm-devel] [PATCH v2 06/12] kpartx: dm_devn: return error for non-existent device

Martin Wilck mwilck at suse.com
Mon May 15 15:37:16 UTC 2017


For non-existent maps (ENXIO from ioctl()), dm_task_run and
dm_task_get_info return success. We need to check info.exists.

Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 kpartx/devmapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kpartx/devmapper.c b/kpartx/devmapper.c
index b7a7390c..6cee120d 100644
--- a/kpartx/devmapper.c
+++ b/kpartx/devmapper.c
@@ -295,7 +295,7 @@ dm_devn (const char * mapname, int *major, int *minor)
 	if (!dm_task_run(dmt))
 		goto out;
 
-	if (!dm_task_get_info(dmt, &info))
+	if (!dm_task_get_info(dmt, &info) || info.exists == 0)
 		goto out;
 
 	*major = info.major;
-- 
2.12.2




More information about the dm-devel mailing list