]> xenbits.xensource.com Git - libvirt.git/commitdiff
Make check for /dev/loop device names stricter to avoid /dev/loop-control
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 9 Aug 2013 16:25:47 +0000 (17:25 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 9 Aug 2013 16:43:10 +0000 (17:43 +0100)
Recentish (2011) kernels introduced a new device called /dev/loop-control,
which causes libvirt's detection of loop devices to get confused
since it only checks for a prefix of 'loop'. Also check that the
next character is a digit

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/util/virfile.c

index 8f0eec3d64af0d8ba14b119bd2f6a0138184366a..2b07ac9255920791c5b902d964d1bc9de3b99c1c 100644 (file)
@@ -546,7 +546,11 @@ static int virFileLoopDeviceOpen(char **dev_name)
 
     errno = 0;
     while ((de = readdir(dh)) != NULL) {
-        if (!STRPREFIX(de->d_name, "loop"))
+        /* Checking 'loop' prefix is insufficient, since
+         * new kernels have a dev named 'loop-control'
+         */
+        if (!STRPREFIX(de->d_name, "loop") ||
+            !c_isdigit(de->d_name[4]))
             continue;
 
         if (virAsprintf(&looppath, "/dev/%s", de->d_name) < 0)