summaryrefslogtreecommitdiffstats
path: root/disk-utils/mkswap.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mkswap: fix page size warning messageNoel Cragg2018-11-291-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mkswap: fix compiler warnings [-Wcast-qual]Karel Zak2018-07-231-3/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: replace magic number 37 with UUID_STR_LENPhilip Prindeville2017-09-051-1/+1
| | | | Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-1/+1
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate all --help option descriptionsRuediger Meier2017-06-271-2/+3
| | | | | | | | 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>
* misc: never use usage(stderr)Ruediger Meier2017-06-261-5/+6
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* mkswap: use memcpy() for non-terminated string [coverity scan]Karel Zak2017-05-171-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-9/+9
| | | | | | | | | | 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>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-1/+1
| | | | | | | | 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>
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* mkswap: tolerate ENOTSUP when failing to relabelLubomir Rintel2016-04-181-1/+1
| | | | | | | | | It might be that the underlying filesystem just doesn't support SELinux labeling. This fixes creating swap on vfat live media: # livecd-iso-to-disk.sh --msdos --swap-size-mb 666 ... Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
* misc: never cast void* from malloc(3) and friendsRuediger Meier2016-03-071-1/+1
| | | | | | | | | | Such cast could hide serious compiler warnings in case we are missing includes (e.g. <stdlib.h> or "xalloc.h"). See http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: again fixing many printf format stringsRuediger Meier2016-03-071-2/+2
| | | | | | | | | | | | | | | | | | | 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>
* include: remove unused mntent.hRuediger Meier2016-02-181-1/+0Star
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* mkswap: add warnings for insecure device permissions/ownersWayne R. Roth2016-01-261-1/+10
| | | | | | Logic modified from sys-utils/swapon.c Signed-off-by: Wayne R. Roth <wayneroth42@gmail.com>
* mkswap: fix block device open raceSami Kerola2015-11-221-15/+6Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-021-1/+1
| | | | | | | | | 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>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+3
| | | | | | | | | 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>
* mkswap: remove memory leaks [LeakSanitizer] [valgrind]Sami Kerola2014-11-181-0/+2
| | | | | | | | | | | | | | | | | | | | | ==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>
* mkswap: make final report more human readableKarel Zak2014-11-071-10/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mkswap: device write code refactoringKarel Zak2014-11-071-13/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mkswap: device open code refactoringKarel Zak2014-11-071-43/+50
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mkswap: always use header from control structKarel Zak2014-11-071-19/+39
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mkswap: coding style improvementsKarel Zak2014-11-071-58/+39Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mkswap: various minor improvementSami Kerola2014-11-071-16/+17
| | | | | | | | | | | | | | 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>
* mkswap: set variable only when it's value is knownSami Kerola2014-11-071-10/+8Star
| | | | | | Avoid updating ctl->pagesize twice when user does specify page size. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* mkswap: make remaining functions to take control structure as argumentSami Kerola2014-11-071-12/+12
| | | | | | The wipe_device() and new_prober(). Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* mkswap: add struct mkswap_control to remove global variablesSami Kerola2014-11-071-114/+115
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* mkswap: use err() rather than perror() && exit()Sami Kerola2014-11-071-13/+6Star
| | | | | | | The messsages in err() are verified from po/util-linux.pot to be already part of translations. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* mkswap: remove unnecessary size checkSami Kerola2014-11-071-6/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* mkswap: remove system architecture specific max swap size checksSami Kerola2014-11-071-137/+3Star
| | | | | | | | 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>
* build-sys: remove obsolete wholedisk.cKarel Zak2014-06-171-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon, swapheader, mkswap: move swap signature to headerSami Kerola2014-05-061-2/+2
| | | | | | | | | | 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>
* mkswap: remove legacy swap structureSami Kerola2014-05-061-2/+1Star
| | | | | | | | | | | 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: 4c85aa3a4c26f2a2c33bf16960b548d5bbd5b4bf Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* mkswap, swaplabel: move version number to headerSami Kerola2014-05-041-5/+5
| | | | | | | Corrently only the swap version 1 is supported, which is a magic value so move it to header. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* mkswap: remove unnecessary usage outputSami Kerola2014-03-121-7/+5Star
| | | | | | | | | 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>
* mkswap: fix compiler warning [-Wunused-variable]Karel Zak2014-01-171-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mkswap: unify write check to a file descriptorSami Kerola2013-04-261-9/+7Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: spell and encode the name of Arkadiusz Miƛkiewicz correctlyBenno Schulenberg2013-02-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: tiny tweaks of some error messagesBenno Schulenberg2013-01-301-3/+3
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* mkswap: properly pluralize the bad-pages messageBenno Schulenberg2013-01-301-4/+1Star
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: gettextize several overlooked messagesBenno Schulenberg2013-01-251-5/+5
| | | | | | Also improve the clarity of some of them. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* mkswap: fix compiler warningsKarel Zak2012-12-201-1/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mkswap: wipe old signature if there is no part table by defaultMilan Broz2012-09-211-27/+20Star
| | | | | | | | | | | | | | | | | | | | 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>
* mkswap: fix shadow declarationSami Kerola2012-07-261-2/+2
| | | | | | | 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>
* disk-utils: cleanup strtoxx_or_err()Karel Zak2012-05-151-19/+13Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include: rename writeall.h to all-io.hPetr Uzel2012-05-151-1/+1
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* mkswap: improve diagnostics message if the device is mountedPetr Uzel2012-05-151-4/+5
| | | | | | | | 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>
* mkswap: allow creating swap on /dev/hd[ab]Petr Uzel2012-05-151-5/+0Star
| | | | | | | | | | 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>