From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756299AbcFHITI (ORCPT ); Wed, 8 Jun 2016 04:19:08 -0400 Received: from knopper.net ([85.214.68.145]:58290 "EHLO knopper.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756278AbcFHITE (ORCPT ); Wed, 8 Jun 2016 04:19:04 -0400 X-Greylist: delayed 1451 seconds by postgrey-1.27 at vger.kernel.org; Wed, 08 Jun 2016 04:19:04 EDT Date: Wed, 8 Jun 2016 09:50:40 +0200 From: "Prof. Dipl.-Ing. Klaus Knopper" To: linux-kernel@vger.kernel.org Subject: Fwd: Bug#826328: util-linux: losetup -d disfunctional for cloop and similar loop-compatible block devices Message-ID: <20160608075040.GH14586@knopper.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Organization: Knopper Networks User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, As recommended by the Debian package maintainer, I'm forwarding this as upstream bug report to the kernel list. Package: util-linux Version: 2.28-5 Severity: normal Tags: upstream Losetup was able to setup compressed loopback (cloop) devices, which have a similar ioctl API, until recently the code in sys-utils/losetup.c and lib/loopdev.c was changed to only accept devices with loopbacks major device id. While attaching a file to a cloop device still works (no check here), detaching with -d fails with error message: losetup: /dev/cloop7: failed to use device: Success The reason for this is: --- sys-utils/losetup.c: case 'd': act = A_DELETE; if (!is_loopdev(optarg) || loopcxt_set_device(&lc, optarg)) err(EXIT_FAILURE, _("%s: failed to use device"), optarg); break; --- lib/loopdev.c: int is_loopdev(const char *device) { struct stat st; if (!device) return 0; return (stat(device, &st) == 0 && S_ISBLK(st.st_mode) && major(st.st_rdev) == LOOPDEV_MAJOR); } --- Because of this, losetup from util-linux no longer works for cloop devices. Using busybox losetup for now. Suggestion: Remove the check for major(st.st_rdev) == LOOPDEV_MAJOR); in is_loopdev() in lib/loopdev.c. Regards -Klaus Knopper