Based on
fix-hang-on-stale-nfs.diff
from SUSE src.rpm package.
It seems better to more precisely check for ENXIO rather than assume
that all LOOP_GET_STATUS errors mean that the device is not used.
Addresses-Novell-Bugzilla: #449646
Signed-off-by: Karel Zak <kzak@redhat.com>
is_loop_used(int fd)
{
struct loop_info li;
- return ioctl (fd, LOOP_GET_STATUS, &li) == 0;
+
+ errno = 0;
+ if (ioctl (fd, LOOP_GET_STATUS, &li) < 0 && errno == ENXIO)
+ return 0;
+ return 1;
}
static int