Bug 1110 reported that the LOOP_GET_STATUS ioctl apparently returnes non-zero
authorEric Andersen <andersen@codepoet.org>
Tue, 6 Mar 2001 19:35:58 +0000 (19:35 -0000)
committerEric Andersen <andersen@codepoet.org>
Tue, 6 Mar 2001 19:35:58 +0000 (19:35 -0000)
error messages, contrary to the documentation.  Whatever.  This patch from
zhaoway <zw@debian.org> looks safe enough.
 -Erik

utility.c

index 62af4a59f9a6b825d314184dedd6abf0d8066feb..2d27596e0975d6fd37a3735500bb74dd117088df 100644 (file)
--- a/utility.c
+++ b/utility.c
@@ -1507,7 +1507,7 @@ extern char *find_unused_loop_device(void)
                sprintf(dev, "/dev/loop%d", i);
                if (stat(dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) {
                        if ((fd = open(dev, O_RDONLY)) >= 0) {
-                               if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) == -1) {
+                               if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) != 0) {
                                        if (errno == ENXIO) {   /* probably free */
                                                close(fd);
                                                return strdup(dev);