From: Eric Sandeen <sandeen@sandeen.net>
To: Christoph Hellwig <hch@infradead.org>
Cc: Jim Meyering <meyering@redhat.com>,
Eric Sandeen <sandeen@redhat.com>,
xfs mailing list <xfs@oss.sgi.com>
Subject: Re: [PATCH v2] mkfs.xfs fix detection of empty devices
Date: Thu, 04 Feb 2010 21:41:26 -0600 [thread overview]
Message-ID: <4B6B9366.6020600@sandeen.net> (raw)
In-Reply-To: <20100204221822.GA26670@infradead.org>
Christoph Hellwig wrote:
> We currently fail to detect that a device does indeed not contain any
> signature and we are indeed fine to proceed with it due to mishandling
> the return value of blkid_do_fullprobe. Fix that up and add some
> better diagnostics of the blkid detection.
>
> from RH bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=561870
>
> # dd if=/dev/zero of=k bs=1MB count=2 seek=20; mkfs.xfs k
> # mkfs.xfs: probe of k failed, cannot detect existing filesystem.
> # mkfs.xfs: Use the -f option to force overwrite
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
we discussed keeping the 0-size check until libblkid copes better;
also the absense of ret = !ret looks more readable, thanks.
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
> Index: xfsprogs-dev/mkfs/xfs_mkfs.c
> ===================================================================
> --- xfsprogs-dev.orig/mkfs/xfs_mkfs.c 2010-02-04 20:30:26.000000000 +0000
> +++ xfsprogs-dev/mkfs/xfs_mkfs.c 2010-02-04 20:43:41.000000000 +0000
> @@ -322,24 +322,40 @@ check_overwrite(
> if (!pr)
> goto out;
>
> - if (blkid_probe_enable_partitions(pr, 1))
> + ret = blkid_probe_enable_partitions(pr, 1);
> + if (ret < 0)
> goto out;
>
> - if (blkid_do_fullprobe(pr))
> + ret = blkid_do_fullprobe(pr);
> + if (ret < 0)
> goto out;
>
> - ret = 0;
> + /*
> + * Blkid returns 1 for nothing found and 0 when it finds a signature,
> + * but we want the exact opposite, so reverse the return value here.
> + *
> + * In addition print some useful diagnostics about what actually is
> + * on the device.
> + */
> + if (ret) {
> + ret = 0;
> + goto out;
> + }
> +
> if (!blkid_probe_lookup_value(pr, "TYPE", &type, NULL)) {
> fprintf(stderr,
> _("%s: %s appears to contain an existing "
> "filesystem (%s).\n"), progname, device, type);
> - ret = 1;
> } else if (!blkid_probe_lookup_value(pr, "PTTYPE", &type, NULL)) {
> fprintf(stderr,
> _("%s: %s appears to contain a partition "
> "table (%s).\n"), progname, device, type);
> - ret = 1;
> + } else {
> + fprintf(stderr,
> + _("%s: %s appears to contain something weird "
> + "according to blkid\n"), progname, device);
> }
> + ret = 1;
>
> out:
> if (pr)
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2010-02-05 3:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-04 16:34 [PATCH] mkfs: don't try to detect filesystems on regular files via blkid Eric Sandeen
2010-02-04 16:46 ` Jim Meyering
2010-02-04 16:54 ` Eric Sandeen
2010-02-04 17:48 ` [PATCH V2] " Eric Sandeen
2010-02-04 19:43 ` Eric Sandeen
2010-02-04 19:40 ` [PATCH] mkfs.xfs fix detection of empty devices Christoph Hellwig
2010-02-04 20:15 ` Eric Sandeen
2010-02-04 22:18 ` [PATCH v2] " Christoph Hellwig
2010-02-05 3:41 ` Eric Sandeen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B6B9366.6020600@sandeen.net \
--to=sandeen@sandeen.net \
--cc=hch@infradead.org \
--cc=meyering@redhat.com \
--cc=sandeen@redhat.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.