From: Karel Zak Date: Thu, 23 Apr 2009 13:09:04 +0000 (+0200) Subject: losetup: mount endless loop hang X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc08b4bb9d5997c0d65eec37b5c795ddbbbebd97;p=util-linux losetup: mount endless loop hang 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 --- diff --git a/mount/lomount.c b/mount/lomount.c index 6b102925..d62198ef 100644 --- a/mount/lomount.c +++ b/mount/lomount.c @@ -97,7 +97,11 @@ static int 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