libbb/loop: don't try to re-use existing loop device
authorKevin Wallace <k@igneous.io>
Wed, 4 Feb 2015 00:17:29 +0000 (16:17 -0800)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 7 Feb 2015 18:13:57 +0000 (19:13 +0100)
loopinfo.lo_file_name is not enough to uniquely identify a file on a system with
multiple mount namespaces.  We could conceivably change this to dedup on
(lo_rdevice, lo_inode), but, as the comment above the deleted code notes, this
whole approach of reusing devices is racy anyway, so it seems better to stop
doing it entirely.

Signed-off-by: Kevin Wallace <k@igneous.io>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/loop.c

index c96c5e0700d527189a6d98e0798b9b9b9e59e2f7..d30b378d7541d5ab4bff00a0b12082f317b57486 100644 (file)
@@ -154,16 +154,7 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
                                else
                                        ioctl(dfd, LOOP_CLR_FD, 0);
                        }
-
-               /* If this block device already set up right, re-use it.
-                * (Yes this is racy, but associating two loop devices with the same
-                * file isn't pretty either.  In general, mounting the same file twice
-                * without using losetup manually is problematic.)
-                */
-               } else
-               if (strcmp(file, (char *)loopinfo.lo_file_name) != 0
-                || offset != loopinfo.lo_offset
-               ) {
+               } else {
                        rc = -1;
                }
                close(dfd);