[PATCH] xfs_mkfs: wipe old signatures from the device
Karel Zak
kzak at redhat.com
Tue Feb 12 05:31:52 CST 2013
On Tue, Feb 12, 2013 at 12:06:55PM +0100, Lukas Czerner wrote:
> +wipe_signatures(
> + char *device,
> + int dryrun)
> +{
> + blkid_probe pr = NULL;
> + int ret = 0;
> + int fd;
> +
> + pr = blkid_new_probe_from_filename(device);
> + if (!pr)
> + goto out;
> +
> + fd = open(device, O_RDWR|O_CLOEXEC);
> + if (fd < 0) {
> + ret = -1;
> + goto out;
> + }
> + ret = blkid_probe_set_device(pr, fd, 0, 0);
This does not make sense. The blkid_new_probe_from_filename() also
opens (read-only) the device ;-)
You need:
pr = blkid_new_probe();
if (!pr)
goto out;
fd = open(device, O_RDWR|O_CLOEXEC);
if (fd < 0) {
ret = -1;
goto out;
}
ret = blkid_probe_set_device(pr, fd, 0, 0);
Maybe you also need something like
AC_CHECK_LIB(blkid, blkid_do_wipe, [have_blkidwipe=yes], [have_blkidwipe=no])
or so, because old libblkid versions does not contain wipe stuff. See also
m4/package_blkid.m4 in xfsprogs where is already check for blkid topology
stuff.
Karel
--
Karel Zak <kzak at redhat.com>
http://karelzak.blogspot.com
More information about the xfs
mailing list