From patchwork Fri Apr 8 05:34:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bmarzins@sourceware.org X-Patchwork-Id: 694291 Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3898g6M004280 for ; Fri, 8 Apr 2011 09:09:08 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p385YgPJ002300; Fri, 8 Apr 2011 01:34:43 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p385Yfhq008362 for ; Fri, 8 Apr 2011 01:34:41 -0400 Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.18]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p385Yalx022207 for ; Fri, 8 Apr 2011 01:34:36 -0400 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by mx1.redhat.com (8.14.4/8.14.4) with SMTP id p385YZjb003594 for ; Fri, 8 Apr 2011 01:34:35 -0400 Received: (qmail 1828 invoked by uid 9475); 8 Apr 2011 05:34:35 -0000 Date: 8 Apr 2011 05:34:35 -0000 Message-ID: <20110408053435.1818.qmail@sourceware.org> From: bmarzins@sourceware.org To: dm-cvs@sourceware.org, dm-devel@redhat.com X-RedHat-Spam-Score: -2.31 (RCVD_IN_DNSWL_MED,T_RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.18 X-loop: dm-devel@redhat.com Subject: [dm-devel] multipath-tools/kpartx kpartx.c X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Apr 2011 09:09:17 +0000 (UTC) CVSROOT: /cvs/dm Module name: multipath-tools Branch: RHEL5_FC6 Changes by: bmarzins@sourceware.org 2011-04-08 05:34:34 Modified files: kpartx : kpartx.c Log message: more work for 578109. The previous loop deleting fix didn't work if there were no partitions on the loop device. Now it handles that case as well. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/kpartx/kpartx.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.9.2.4&r2=1.9.2.5 --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel --- multipath-tools/kpartx/kpartx.c 2011/03/07 05:19:37 1.9.2.4 +++ multipath-tools/kpartx/kpartx.c 2011/04/08 05:34:33 1.9.2.5 @@ -182,7 +182,8 @@ int main(int argc, char **argv){ - int fd, i, j, k, n, op, off, arg; + int i, j, k, n, op, off, arg; + int fd = -1; struct slice all; struct pt *ptp; enum action what = LIST; @@ -342,8 +343,10 @@ printf("%s: %d slices\n", ptp->type, n); #endif - if (n > 0) + if (n > 0) { close(fd); + fd = -1; + } else continue; @@ -371,15 +374,6 @@ slices[j].size, device, slices[j].start); } - if (loopcreated && S_ISREG (buf.st_mode)) { - if (del_loop(device)) { - if (verbose) - printf("can't del loop : %s\n", - device); - exit(1); - } - printf("loop deleted : %s\n", device); - } break; case DELETE: @@ -457,6 +451,17 @@ if (n > 0) break; } + if (what == LIST && loopcreated && S_ISREG (buf.st_mode)) { + if (fd != -1) + close(fd); + if (del_loop(device)) { + if (verbose) + printf("can't del loop : %s\n", + device); + exit(1); + } + printf("loop deleted : %s\n", device); + } dm_lib_release(); dm_lib_exit();