xfs
[Top] [All Lists]

Re: [PATCH] xfs_mkfs: wipe old signatures from the device

To: Lukas Czerner <lczerner@xxxxxxxxxx>
Subject: Re: [PATCH] xfs_mkfs: wipe old signatures from the device
From: Karel Zak <kzak@xxxxxxxxxx>
Date: Tue, 12 Feb 2013 12:31:52 +0100
Cc: xfs@xxxxxxxxxxx, sandeen@xxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1360667215-14701-1-git-send-email-lczerner@xxxxxxxxxx>
References: <1360667215-14701-1-git-send-email-lczerner@xxxxxxxxxx>
User-agent: Mutt/1.5.21 (2012-12-30)
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@xxxxxxxxxx>
 http://karelzak.blogspot.com

<Prev in Thread] Current Thread [Next in Thread>