]> git.ipfire.org Git - thirdparty/util-linux.git/commit
wipefs: postpone BLKRRPART until all is done
authorKarel Zak <kzak@redhat.com>
Mon, 11 Jun 2018 10:21:56 +0000 (12:21 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 11 Jun 2018 10:36:32 +0000 (12:36 +0200)
commit921f63433ee62894908f7f8c0a622057478e6fa1
tree28e12cb313d197340a3e1bb63143d6a9c190eeb7
parent3b3f43748f55b1c17ad55beb9a6eb6be49a68c77
wipefs: postpone BLKRRPART until all is done

It's possible we erase from the whole device before we erase from the
partition on the same disk:

 # wipefs -a /dev/sdc /dev/sdc1

the current code calls re-read PT ioctl immediately after erase (so,
before sdc1 is processed). The result is that sdc1 node is no more
accessible:

  # wipefs -a /dev/sdc /dev/sdc1
  /dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
  /dev/sdc: calling ioctl to re-read partition table: Success
  wipefs: error: /dev/sdc1: probing initialization failed: No such file or directory

It seems the most simple solution is to postpone the re-read ioctl and
do it as the last thing.

  # wipefs -a  /dev/sdc /dev/sdc1
  /dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
  /dev/sdc1: 2 bytes were erased at offset 0x00000438 (ext4): 53 ef
  /dev/sdc: calling ioctl to re-read partition table: Success

The patch also adds a small delay before the re-read ioctl call. It's
not elegant, but without the usleep(25000) the first attempt returns
EBUSY.

Addresses: https://github.com/karelzak/util-linux/issues/598
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/wipefs.8
misc-utils/wipefs.c