From fc08b4bb9d5997c0d65eec37b5c795ddbbbebd97 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 23 Apr 2009 15:09:04 +0200 Subject: [PATCH] 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 --- mount/lomount.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- 2.39.5