[kzak@redhat.com: - don't wipe if failed to create a backup file
- use ts_scsi_debug_init in the regression tests]
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Commit c550f728f7 added O_EXCL when
opening the thing to erase. This broke the wipefs utility when used
on anything which isn't an unmounted filesystem. eg. If you use it on
a block device containing partitions, then it won't work because the
kernel recognizes the partitions and so thinks the device is in use.
This change adds the --force option which, when used, undoes the above
flag change. However you still have to use --force most of the time
when erasing something that isn't a plain unmounted filesystem.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
If there are more offset options specified, some could be lost.
Try
pvcreate /dev/sd[bcde]
mdadm -C -l 5 -n4 /dev/md0 /dev/sd[bcde]
mdadm --stop /dev/md0
wipefs -n -o 0x1000 -o 0x218 /dev/sdb
- LVM2 signature remains there
wipefs -n -o 0x218 -o 0x1010 /dev/sdb
- no report about ignored signature
Signed-off-by: Milan Broz <mbroz@redhat.com>
[kzak@redhat.com: - print devname only if more devices specified]
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Some filesystems (e.g. FAT) is possible to detect in many ways -- for
example if a magic string is stored on more places on the device. The
current implementation always removes from the device only the firstly
detected possibility.
# wipefs /dev/sdb1
offset type
----------------------------------------------------------------
0x36 vfat [filesystem]
UUID: D203-A7F4
# wipefs -a /dev/sdb1
8 bytes [46 41 54 31 36 20 20 20] erased at offset 0x36 (vfat)
# wipefs /dev/sdb1
offset type
----------------------------------------------------------------
0x0 vfat [filesystem]
UUID: D203-A7F4
This patch fixes this issue:
# wipefs -a /dev/sdb1
8 bytes were erased at offset 0x00000036 (vfat): 46 41 54 31 36 20 20 20
1 bytes were erased at offset 0x00000000 (vfat): eb
2 bytes were erased at offset 0x000001fe (vfat): 55 aa
Signed-off-by: Karel Zak <kzak@redhat.com>
Solaris lacks err, errx, warn and warnx. This also means the err.h header
doesn't exist. Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Currently wipefs process only first device argument and silently ignores
remaining. Print error instead because it can be quite confusing.
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch replaces a few functions used throughout the source:
* Renames getnum (from schedutils) to strtol_or_err
* Moves strtosize (from lib/strtosize.c)
* Moves xstrncpy (from include/xstrncpy.h)
* Adds strnlen, strnchr and strndup if not available (remove it from libmount utils)
A few Makefile.am files were modified to compile accordingly along with trivial renaming
in schedutils source code.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>