The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed. So say so. Also make
two very similar messages equal to this one.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
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>
==18922==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x49d12b in __interceptor_malloc (/home/src/util-linux/.libs/lt-mkswap+0x49d12b)
#1 0x7faf2a5069c9 in __GI___strdup (/usr/lib/libc.so.6+0x819c9)
#2 0xffff96e7e33 (<unknown module>)
SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).
And another one that valgrind found.
==6316== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
==6316== at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==6316== by 0x5E3F9C9: strdup (in /usr/lib/libc-2.20.so)
==6316== by 0x43A25F: size_to_human_string (strutils.c:495)
==6316== by 0x42B35C: main (mkswap.c:488)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Use correct data type in page_bad(), and add information to error message
how many bad pages were seen.
In check_blocks() move initialization to variable introduction, fix typo,
and avoid memset() when array initializer can do the job.
In main() use correct initializer for pointer. Move swap file specific
actions to same location, and add warning when request too --check is
dismissed by command. At the end remove momory leak.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Since kernel version 2.3.4 (June 1999) all architectures has used
uint32_t as maximum number or pages in a swap device or file, there is no
longer need to support systems earlier than that.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Both swapon and mkswap need to know what is valid device signature, so
share the value.
[kzak@redhat.com: - use SWAP_SIGNATURE_SZ properly in write_signature()]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
If software archeolgists want to know how the old, and unused, swap
header looked they can dig it from the revision history.
[kzak@redhat.com: - use sizeof() for SWAP_HEADER_SIZE]
Reference: 4c85aa3a4c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
The usage output changes too often making unnecessarily expected output
in test unstable. Besides in this case the usage ouput does not even
help user, because invalid swap target size error cannot be fixed by
specificing an option.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Historically mkswap avoids wiping any signature on "whole disk",
until force option is given.
While the idea is that it should not wipe possible boot loader,
in reality it leads to many situations where e.g. LUKS device
is overwritten but still can be detected as LUKS (but unusable).
Patch chnges behaviour that only if partition table is detected,
signatures are not wiped.
Also it removes check for block device - loop device can now
map partitions in-kernel, so using mkswap on disk image in file
should behave the same as on disk.
Also it adds warning that know signature was wiped.
Signed-off-by: Milan Broz <mbroz@redhat.com>
disk-utils/mkswap.c:366:57: warning: declaration of 'is_blkdev' shadows a global declaration [-Wshadow]
./include/blkdev.h:92:5: warning: shadowed declaration is here [-Wshadow]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Currently, attempt to create swap on mounted partition results
with "/dev/sdXy: Device or resource busy" message being printed.
Change this to explicitly telling the user that the device is mounted.
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Currently, mkswap does not allow swap to be created on /dev/hda and
/dev/hdb. There is no reason why /dev/hda and /dev/hdb should be treated
differently.
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=491021
Cc: Russell Coker <russell@coker.com.au>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
mkswap(8) zaps the begin of the device (1024 bytes) only. This is not
enough, because for example ReiserFS superblock is outside this area.
This patch add blkid_do_wipe() call to mkswap(8) and all block device
is scanned and all signature are removed.
Reported-by: Martin Pitt <martin.pitt@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch produces the program to warn if the given device is misaligned.
[kzak@redhat.com: - call the check for block devices only]
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>