Commit Graph

71 Commits

Author SHA1 Message Date
Karel Zak 92296e9ba2 wipefs: print all signature permutations
The same FS/RAID/PT signature may be detected by more ways and on more
places on the device. The libblkid returns only the first detected
signature by default. This patch use blkid_probe_hide_range() to
re-scan device for all possible permutations of the same signature.

For example the default wipefs(8) output as well as --no-act output will
contains primary as well as backup GPT signature now.

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-28 10:28:41 +02:00
Ruediger Meier b305445495 misc: consolidate all --help option descriptions
Now we are always using the same text also for commands
which had still hardcoded descriptions or where we can't
use the standard print_usage_help_options macro.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:28:36 +02:00
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Karel Zak 6f1507f135 wipefs: exit on failed erase
The current behavior is to report error and continue, it seems strange:

	# blockdev --setro /dev/sdc

	# wipefs -a /dev/sdc
	wipefs: /dev/sdc: failed to erase xfs magic string at offset 0x00000000: Operation not permitted
	/dev/sdc: 4 bytes were erased at offset 0x00000000 (xfs): 58 46 53 42
                          ^^^^^^^^^^^
                           not true

The patch calls err() to exit.

Reported-by: Vratislav Podzimek <vpodzime@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-21 10:53:28 +02:00
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer

Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.

Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Yuri Chornoivan a7349ee315 docs: Fix word repetitions 2017-02-13 14:10:12 +01:00
Karel Zak 11e88c8699 wipefs: unused parameter [-Wunused-parameter]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-05 12:38:43 +01:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Karel Zak 949e5c9600 wipefs: force GPT detection
The library libblkid (as well as fdisks) requires protective MBR when
probe for GPT by default.  This is unnecessary for wipefs where we're
more promiscuous and we want to delete as much as possible. This patch
enables BLKID_PARTS_FORCE_GPT for wipefs.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1326474
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-13 14:41:47 +02:00
Ruediger Meier fdbd7bb940 misc: again fixing many printf format strings
This is again a huge patch regarding printf format strings to
fix compiler warnings seen on clang/OSX.

I'm trying to follow these rules strictly:

 #type      #format   #cast
 uintmax_t   %ju      -
 intmax_t    %jd      -
 uint64_t    PRIu64   -
 int64_t     PRId64   -
 size_t      %zu      -
 ssize_t     %zd      -
 ino_t       %ju      (uintmax_t)
 off_t       %jd      (intmax_t)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 23:16:04 +01:00
Ruediger Meier 8acff75afc wipefs, sfdisk: include libgen.h for basename(3p)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 21:25:36 +01:00
Bill Pemberton 11290b849f wipefs: Allow b to be used as the short option for backup
'b' is documented as the short option for backup but b was not added
to the optstring on the getopt_long call.  Add it.

Signed-off-by: Bill Pemberton <wfp5p@worldbroken.com>
2015-12-11 11:05:45 +01:00
Karel Zak f1b64c1c1f wipefs: fix FD leak on error [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 12:42:58 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Sami Kerola db433bf737 textual: use usage() text element macros
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:26 +02:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Benno Schulenberg 09af3db48e textual: fix some typos and inconsistencies in various messages
Fixing plain typos, miswordings, inconsistent periods, some missing
angular brackets, and a proper pluralization (even when it involves
a constant, because for some languages the precise value matters).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-23 08:56:00 +02:00
Lauri Nurmi a5c523a0e7 Fix typo "ioclt" in various files. 2014-07-11 22:52:09 +03:00
Karel Zak 24ed078184 wipefs: don't erase nested partition tables by default
It's possible the partition contains a partition table (BSD, or hybrid
boot images). It could be unexpected for users that the lost all (or
another) partitions when work with non-whole disk device. Let's
require --force.

For example:

 # wipefs --all /dev/sdb

erases all including partition table, but on hybrid disk where the
first partition starts at first sector (so partition table is within
the first partition):

 # wipefs --all /dev/sdb1
 /dev/sdb1: ignore nested "dos" partition table on non-whole disk device
 wipefs: Use the --force option to force erase.

asks for --force.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1077310
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-24 13:42:54 +02:00
Karel Zak 1577b2592e libsmartcols: add columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Karel Zak 081dc33b46 wipefs: call BLKRRPART when erase partition table
It's better to be smart than make things inconsistent (without
BLKRRPART kernel still uses the erased PT and udev-db still contains
obsolete information).

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-20 12:16:47 +01:00
Karel Zak 90faf9eb07 wipefs: add comments to code 2014-01-16 16:33:16 +01:00
Benno Schulenberg 1619e3e741 wipefs: pluralize one message
Reported-by: Petr Písař <petr.pisar@atlas.cz>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:30 +02:00
Gabriel de Perthuis 02f3c12a5f wipefs: Also wipe superblocks with bad checksums
[kzak@redhat.com: - move BLKID_SUBLKS_BADCSUM login to
                    blkid_probe_verify_csum()]

Signed-off-by: Gabriel de Perthuis <g2p.code@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-11 16:36:16 +02:00
Karel Zak 1666c15588 wipefs: clean up code
This is C, use int & bits for boolean stuff rather than army of
variables.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-26 12:43:31 +02:00
Ondrej Oprala 7e658c15a2 wipefs: add --backup
[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>
2013-04-26 12:27:37 +02:00
Karel Zak 05ba8c8483 wipefs: make do_wipe() more readable [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:34:11 +01:00
Karel Zak 4e6fc1139b wipefs: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:25:30 +01:00
Karel Zak 38db00f178 wipefs: add -f to getopt_long()
Reported-by: Dan Horák <dhorak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-19 22:53:16 +01:00
Karel Zak e421313dc2 textual: use UTIL_LINUX_VERSION everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-25 12:05:26 +01:00
Richard W.M. Jones 2968c3fc73 wipefs: Add --force option to force it to erase.
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>
2012-11-20 10:01:20 +01:00
Karel Zak c550f728f7 wipefs: use O_EXCL
Address: https://bugzilla.redhat.com/show_bug.cgi?id=865961
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-15 12:38:09 +02:00
Karel Zak abb7b98ca3 wipefs: use err_exclusive_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 09:24:50 +02:00
Sami Kerola 58f0252a18 wipefs: use exclusive_option()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:59 +02:00
Sami Kerola 4f0537374f wipefs: use symbolic value for markup mode
In case mode value is found to be out of bounds program will crash.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 22:06:05 +02:00
Karel Zak db41a4298f misc-utils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:44:37 +02:00
Petr Uzel e12c9866b5 include: rename writeall.h to all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:27 +02:00
Sami Kerola c05a80ca63 misc-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:56:48 +02:00
Karel Zak 99727496ed wipefs: use strtosize_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-30 16:17:49 +02:00
Milan Broz 24df2633d3 wipefs: Fix mismatch if more -o options used.
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>
2012-03-08 16:11:36 +01:00
Karel Zak 86ace3f407 wipefs: always print devname
It seems too smart to print devname according to number of devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-01 15:44:04 +01:00
Milan Broz c10695f8a4 wipefs: support more device arguments for wipefs
[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>
2012-03-01 15:36:45 +01:00
Milan Broz 0fd93af697 wipefs: add quiet flag (-q)
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-01 15:24:05 +01:00
Sami Kerola 7cebf0bb4f docs: corrections to FSF license files, and postal address
The COPYING and Documentation/licenses/COPYING* files are being
replaced by files from GNU web site.

http://www.gnu.org/licenses/gpl-2.0.txt
http://www.gnu.org/licenses/lgpl-2.1.txt

Postal addresses to FSF in other files are updated to match with the
address in license files.

Reference: http://lists.gnu.org/archive/html/freefont-announce/2005-04/msg00001.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-24 14:13:35 +01:00
Davidlohr Bueso a2f5c22173 wipefs: use xalloc lib
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-12-16 12:42:40 +01:00
Karel Zak f126cd4694 wipefs: add -t <list> option
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-15 15:19:28 +01:00
Karel Zak 44765fdd84 libblkid: export info about PT magic strings
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-13 21:25:12 +01:00
Karel Zak 6611a3dd78 wipefs: improve -a, use blkid_do_wipe()
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>
2011-11-11 12:48:38 +01:00
Karel Zak dcd16b0fb0 dmesg: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 13:02:00 +02:00
Benno Schulenberg 11295cd102 wipefs: change option -v to -V for --version; add it to man page
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-08 11:58:47 +02:00