From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27289 invoked by alias); 17 Mar 2009 14:01:04 -0000 Received: (qmail 27123 invoked by uid 9699); 17 Mar 2009 14:01:02 -0000 Date: Tue, 17 Mar 2009 14:01:00 -0000 Message-ID: <20090317140102.27121.qmail@sourceware.org> From: mornfall@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/tools pvcreate.c Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00021.txt.bz2 CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2009-03-17 14:01:01 Modified files: tools : pvcreate.c Log message: Some extra (paranoid) checks on dev_is_{md,swap} result. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80 --- LVM2/tools/pvcreate.c 2009/03/17 13:59:57 1.79 +++ LVM2/tools/pvcreate.c 2009/03/17 14:00:58 1.80 @@ -46,6 +46,7 @@ struct physical_volume *pv; struct device *dev; uint64_t md_superblock, swap_signature; + int wipe_md, wipe_swap; /* FIXME Check partition type is LVM unless --force is given */ @@ -117,7 +118,7 @@ } /* Wipe superblock? */ - if (dev_is_md(dev, &md_superblock) && + if ((wipe_md = dev_is_md(dev, &md_superblock)) == 1 && ((!pp->idp && !pp->restorefile) || pp->yes || (yes_no_prompt("Software RAID md superblock " "detected on %s. Wipe it? [y/n] ", name) == 'y'))) { @@ -129,7 +130,13 @@ } } - if (dev_is_swap(dev, &swap_signature) && + if (wipe_md == -1) { + log_error("Fatal error while trying to detect software " + "RAID md superblock on %s", name); + return 0; + } + + if ((wipe_swap = dev_is_swap(dev, &swap_signature)) == 1 && ((!pp->idp && !pp->restorefile) || pp->yes || (yes_no_prompt("Swap signature detected on %s. Wipe it? [y/n] ", name) == 'y'))) { @@ -140,6 +147,12 @@ } } + if (wipe_swap == -1) { + log_error("Fatal error while trying to detect swap " + "signature on %s", name); + return 0; + } + if (sigint_caught()) return 0;