aboutsummaryrefslogtreecommitdiffstats
path: root/disk-utils/cfdisk.c
AgeCommit message (Collapse)AuthorFilesLines
2025-05-29lib/colors: call gettext() only when the argument of --color is invalidBenno Schulenberg1-2/+1
Instead of calling gettext() before starting to interpret the argument of option -L/--color, call it only when it's needed: when the argument is not recognized. Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2025-05-13treewide: add ul_ to parse_size() function nameKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2025-04-07Use the 'fallthrough' attributeMatteo Croce1-4/+4
C23[1] and CPP17[2] introduced the 'fallthrough' attribute to let the compiler know that we're intentionally falling through a case statement. This suppress a warning with new compilers when doing an implicit fallthrough. [1] https://en.cppreference.com/w/c/language/attributes/fallthrough [2] https://en.cppreference.com/w/cpp/language/attributes/fallthrough
2025-04-03cfdisk: fix memory leak and possible NULL dereference [gcc-analyzer]Karel Zak1-1/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2025-04-02fdisk,partx: avoid strcasecmp() for ASCII-only stringsKarel Zak1-1/+2
Use cctype.h for locale-independent string comparison and to avoid tricky string conversions like in tr_TR locales. Signed-off-by: Karel Zak <kzak@redhat.com>
2025-03-20misc: never include wchar.hKarel Zak1-5/+1
We have a portable "widechar.h" that follows --disable-widechar and provides portability. It is a bug to directly include libc's wchar.h or wctype.h. Fixes: https://github.com/util-linux/util-linux/issues/3470 Signed-off-by: Karel Zak <kzak@redhat.com>
2024-11-20Drop pointless bitfieldsZbigniew Jędrzejewski-Szmek1-4/+4
Bitfields have their uses, but the uses here didn't make any sense. Code generated to read or write bitfields is more complicated (and slower) because, well, the bits need to be manipulated with special instructions. So bitfields should be used when we have a structure that is repeated hundreds or thousands of times in memory and those saving are higher than the cost of having more complicated code. This can happen for example in the kernel code. But the code here has structures that are instantiated once or or at most few times. In addition, a bitfield often does not save any memory because of alignment requirements. In the majority of cases modified here, the bitfield was the last field in a structure, so no memory savings were made. $ size build*/{mkswap,more,ul,col,rtcwake,lsmem,lscpu,eject,dmesg,uuidd,taskset,login} text data bss dec hex filename 132014 1988 88 134090 20bca build/mkswap 129342 1852 88 131282 200d2 build2/mkswap 55161 1480 128 56769 ddc1 build/more 54265 1480 128 55873 da41 build2/more 14364 868 112 15344 3bf0 build/ul 14316 868 112 15296 3bc0 build2/ul 28547 1000 112 29659 73db build/col 28435 1000 112 29547 736b build2/col 46914 1960 112 48986 bf5a build/rtcwake 46834 1960 112 48906 bf0a build2/rtcwake 63419 1744 176 65339 ff3b build/lsmem 63403 1744 176 65323 ff2b build2/lsmem 159885 2864 464 163213 27d8d build/lscpu 159757 2864 464 163085 27d0d build2/lscpu 90041 1704 88 91833 166b9 build/eject 89737 1704 88 91529 16589 build2/eject 82150 5152 1032 88334 1590e build/dmesg 81846 5152 1032 88030 157de build2/dmesg 37601 1368 80 39049 9889 build/uuidd 37585 1368 80 39033 9879 build2/uuidd 58906 1336 56 60298 eb8a build/taskset 58890 1336 56 60282 eb7a build2/taskset 84761 2128 152 87041 15401 build/login 84672 2128 152 86952 153a8 build2/login (To be clear: those small savings are not particularly important. The motivation for this patch is to eradicate the antipattern of making things more complicated without any benefit.)
2024-11-18disk-utils: make pointer arrays constMax Kellermann1-2/+2
2024-10-14cfdisk: add --sector-size commanand line optionKarel Zak1-1/+14
* improves compatibility with fdisk * add ability to work with disk images where libfdisk defaults to 512 Signed-off-by: Karel Zak <kzak@redhat.com>
2024-06-24cfdisk: fix possible integer overflow [coverity scan]Karel Zak1-0/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2024-05-12cfdisk: Remove unused struct 'cfdisk_extra'Dr. David Alan Gilbert1-8/+0
'cfdisk_extra' looks unused since it's original commit (I think because it ended up using libscols instead). Remove it. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
2023-11-14cfdisk: properly handle out-of-order partitions during resizeThomas Weißschuh1-7/+6
Fixes #2580 Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-11-01disk-utils: add SPDX and Copyright noticesKarel Zak1-5/+7
Explicitly state the license (usually GPL-2.0-or-later; our default) and include copyright statements in all files to prevent false positive reports from license analysis tools. Add also add SPDX-License-Identifier tag to all files. Signed-off-by: Karel Zak <kzak@redhat.com>
2023-10-25Make the ways of using output stream consistent in usage()Masatake YAMATO1-2/+2
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-26cfdisk: fix menu behavior after writing changesKarel Zak1-0/+4
Florian wrote: after a successful write, cfdisk remains on the "Write" cursor and furthermore when navigating to "Quit" will continue to show "...without writing changes", despite there were writes. This patch addresses that. Based on patch from Florian Zimmermann <florian.zimmermann@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-12cfdisk: add hint about labels for bootable flagKarel Zak1-3/+4
Addresses: https://github.com/util-linux/util-linux/discussions/2220 Signed-off-by: Karel Zak <kzak@redhat.com>
2023-04-12cfdisk: ask y/n before wipeKarel Zak1-5/+12
Addresses: https://github.com/util-linux/util-linux/issues/2160 Signed-off-by: Karel Zak <kzak@redhat.com>
2022-11-22cfdisk: prevent unused variablesThomas Weißschuh1-0/+2
2022-03-17cfdisk: don't use NULL in printf [coverity scan]Karel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-25cfdisk: optimize mountpoint detection for PARTUUIDKarel Zak1-1/+27
Don't check fstab (and udev symplinks) for new UUIDs. Fixes: https://github.com/karelzak/util-linux/issues/1331 Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-22cfdisk: do not use atoi()Karel Zak1-3/+12
It's unnecessary to use atoi in this case. Addresses: https://github.com/karelzak/util-linux/issues/1358 Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-18libfdisk: add and fix __format__ attributesKarel Zak1-17/+32
Reported-by: Jan Pazdziora <jpazdziora@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-15cfdisk: warn if disk on useKarel Zak1-0/+2
Fixes: https://github.com/karelzak/util-linux/issues/1278 Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-05Merge branch 'disk-utils-document-resize' of https://github.com/vdmz/util-linuxKarel Zak1-0/+1
2021-01-05cfdisk: show Q option when choosing label typeChris Hofstaedtler1-1/+1
The new message is quite terse, but fits into 78 characters. Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=894555 Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
2021-01-04cfdisk: Implemented cfdisk's opening in read-only modeDmitriy Chestnykh1-4/+10
[kzak@redhat.com: - clean up the patch - add note "Changes will remain in memory only."] Addresses: https://github.com/karelzak/util-linux/issues/1209 Addresses: https://github.com/karelzak/util-linux/pull/1213 Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-02Show the 'r' option in the help menuVincent McIntyre1-0/+1
2020-09-30fdisk: always report fdisk_create_disklabel() errorsKarel Zak1-2/+18
This is fdisk, cfdisk and sfdisk change to inform user about fdisk_create_disklabel() issues. Addresses: https://github.com/karelzak/util-linux/issues/1147 Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-27cfdisk: add --lock and LOCK_BLOCK_DEVICEKarel Zak1-2/+20
Addresses: https://github.com/karelzak/util-linux/issues/921 Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-20[clang-tidy] do not use else after returnRosen Penev1-3/+7
Found with readability-else-after-return Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-01-15cfdisk: check mnt_table_parse_fstab() return code [coverity scan]Karel Zak1-1/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-24po: remove possibility to translate static option argumentsSami Kerola1-1/+2
These strings are expected to be wrote exactly as they are parsed, so make translating them impossible. Since mkfs.cramfs -N option arguments need this treatment use opportunity to slice usage() output to multiple lines. Addresses: https://bugs.debian.org/907568 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-06-11cfdisk: free libfdisk itemsKarel Zak1-0/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-11cfdisk: simplify codeKarel Zak1-3/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16misc: consolidate version printing and close_stdout()Karel Zak1-3/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-12fdisk: use 2 decimal places for size in disk summaryKarel Zak1-1/+2
In the disk summary it seems nice, but I'm not sure about lists (SIZE columns). It seems more readable to keep the lists with one decimal place only. New output: # sfdisk --list /dev/sda Old output: Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors New output: Disk /dev/sda: 223.58 GiB, 240057409536 bytes, 468862128 sectors The rest is unchanged: ... Device Start End Sectors Size Type /dev/sda1 2048 411647 409600 200M EFI System /dev/sda2 411648 821247 409600 200M Linux filesystem /dev/sda3 821248 274087935 273266688 130.3G Linux filesystem /dev/sda4 274087936 378945535 104857600 50G Linux filesystem /dev/sda5 378945536 468862094 89916559 42.9G Linux filesystem Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1673452 Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23cfdisk: fix compiler warnings [-Wcast-qual]Karel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-24cfdisk: fix compiler warnings, follow-up 7085f1e4 (#636)Ruediger Meier1-2/+2
Seen on OSX 10.13, xcode 9.3. disk-utils/cfdisk.c:1860:45: error: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] DBG(UI, ul_debug("get_size (default=%ju)", *res)); ~~~ ^~~~ %llu disk-utils/cfdisk.c:267:60: note: expanded from macro 'DBG' #define DBG(m, x) __UL_DBG(cfdisk, CFDISK_DEBUG_, m, x) ^ ./include/debug.h:67:4: note: expanded from macro '__UL_DBG' x; \ ^ disk-utils/cfdisk.c:1889:25: error: incompatible pointer types passing 'uint64_t *' (aka 'unsigned long long *') to parameter of type 'uintmax_t *' (aka 'unsigned long *') [-Werror,-Wincompatible-pointer-types] rc = parse_size(buf, &user, &pwr); /* parse */ ^~~~~ ./include/strutils.h:15:51: note: passing argument to parameter 'res' here extern int parse_size(const char *str, uintmax_t *res, int *power); ^ 2 errors generated. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-05-24cfdisk: use uint64_t to avoid compiler warningsKarel Zak1-11/+11
Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl> Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-11cfdisk: fix missing prototype for `get_wch`Patrick Steinhardt1-0/+4
The header <ncursesw/ncurses.h> defines the get_wch(3) function only when `NCURSES_WIDECHAR` is defined. This define is actually getting set in the same header file, but only in case `_XOPEN_SOURCE` is defined and has a value of 500 or higher. As we already have the precedence of defining `_XOPEN_SOURCE` to a value of 600 in some other files, simply define it to the minimum required value of 500 in "cfdisk.c". This silences a warning for `get_wch` being unknown. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2018-01-17include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()Karel Zak1-1/+1
Let's make it possible to use debug.h without environment variables. Suggested-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-26cfdisk: cleanup die-on-signal codeKarel Zak1-16/+47
Let's keep signal handler simple and don't cleanup terminal from the handler. Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-26cfdisk: make resize code more readableKarel Zak1-10/+10
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-15cfdisk: add missing 0x7F key mappingKarel Zak1-0/+1
Addresses: https://github.com/karelzak/util-linux/issues/499 Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-19cfdisk: add resize functionKarel Zak1-7/+49
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14cfdisk: use fdisk_reread_changes()Karel Zak1-1/+11
Let's make cfdisk usable for disks where some partitions are mounted. Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-29misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier1-2/+2
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>
2017-06-27misc: introduce print_usage_help_options()Ruediger Meier1-2/+1
Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26misc: cosmetics, remove argument from usage(FILE*)Ruediger Meier1-3/+4
This patch is trivial and changes nothing, because we were always using usage(stdout) Now all our usage() functions look very similar. If wanted we could auto-generate another big cosmetical patch to remove all the useless "FILE *out" constants and use printf and puts rather than their f* friends. Such patch could be automatically synchronized with the translation project (newlines!) to not make the translators sick. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-14misc: fix reassigned values before old ones has been used [cppcheck]Sami Kerola1-1/+1
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-31cfdisk: fix compiler warningKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17cfdisk: add hints for scanners [coverity scan]Karel Zak1-0/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-22Fix menu spelling in cfdisk debug messagesKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-13misc: stop mixing declarations and codeSami Kerola1-1/+3
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20misc: add static keyword to where needed [smatch scan]Sami Kerola1-3/+3
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20misc: do not use plain 0 as NULL [smatch scan]Sami Kerola1-1/+1
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-20cfdisk: avoid use of VLA in combination with sizeof() [smatch scan]Sami Kerola1-2/+5
disk-utils/cfdisk.c:1066:29: error: cannot size expression One should use sizeof() only when variable size can be known at time of compilation. That is not the case with variable length arrays. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-16cfdisk: use buffer editor for ui_get_string()Karel Zak1-53/+46
Addresses: https://github.com/karelzak/util-linux/issues/403 Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-02cfdisk: add copyright to helpKarel Zak1-1/+4
... to make it obvious this is a new cfdisk. Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-01cfdisk: support UI refresh on ^LKarel Zak1-2/+14
Addresses: https://github.com/karelzak/util-linux/issues/404 Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19Use --help suggestion on invalid optionKarel Zak1-0/+2
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-10-04cfdisk: fix mountpoint detectionKarel Zak1-21/+26
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-07cfisk: add /dev/vda as another default diskKarel Zak1-13/+23
And use array for all default alternative disks. Reported-by: Thierry Vignaud <thierry.vignaud@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-03cfdisk: use libsmartcols ASCII for non-widechar environmentKarel Zak1-0/+4
Reported-by: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-31misc: Fix various typosSebastian Rasmussen1-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>
2016-05-04build-sys: remove obsolete [cs]fdisk LDADDsKarel Zak1-4/+0
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-04sfdisk: add --wipe-partitions=auto|never|defaultKarel Zak1-33/+12
The option allows to remove filesystes/RAIDs from newly created partitions before the partition table is updated (and partition device created). The default is "auto" in this case wipe is enabled in interactive mode only and user's confirmation (yes/no dialog) is required. Note that keep filesystem signature on partition is pretty valid use-case, so we don't erase anything by default. Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-16fdisk, cfdisk, sfdisk: improve the grammar of three messagesBenno Schulenberg1-1/+1
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-02-18cfdisk: wipe device if create a new labelKarel Zak1-0/+8
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-07cfdisk: use new libsmartcols functionality to fix outputKarel Zak1-0/+1
Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-07Revert "cfdisk: make sure that output fits to terminal width"Karel Zak1-13/+2
This reverts commit ed99eac0e2a83a315c7cf5d8a461df16b3106596.
2015-08-05cfdisk, sfdisk: remove unused variablesKarel Zak1-9/+8
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04cfdisk: check return value [coverity scan]Karel Zak1-3/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-03textual: adjust grammar and punctuation of some messagesBenno Schulenberg1-1/+1
Also equalize three messages to one other one, and fix a typo in USE_COLORS_BY_DEFAULT. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-07-27cfdisk: don't print obsolete CHS addressesKarel Zak1-10/+0
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-27cfdisk: make sure that output fits to terminal widthKarel Zak1-2/+13
Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-27cfdisk: remove extra line between menu and info lineKarel Zak1-1/+1
Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-27cfdisk: spell "label" in lower caseBenno Schulenberg1-1/+1
To be less shouty. It is not an abbreviation like "UUID". Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-07-27cfdisk: allow an uppercase X to toggle the extra infoBenno Schulenberg1-0/+1
To make true the help text line that says that all commands can be entered with either upper or lower case. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-07-22cfdisk: make sure that extra info is refreshed/removedKarel Zak1-1/+3
For example when you move from a Partition to the FreeSapce then we need to remove old extra info and draw nothing. Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-22cfdisk: properly toggle extra info window, make it more robustKarel Zak1-9/+31
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-25cfdisk: fix condition logic [cppcheck]Boris Egorov1-1/+1
[disk-utils/cfdisk.c:1181] -> [disk-utils/cfdisk.c:1181]: (warning) Possible null pointer dereference: data - otherwise it is redundant to check it against null. Signed-off-by: Boris Egorov <egorov@linux.com>
2015-03-31cfdisk: cleanup extra partitions info for slangKarel Zak1-35/+18
The patch removes problem with getch() on slang, now the code is based on subwin() and extra info window is persistent. A new problem is that slang does not keep sub-window border persistent. I'm going to ignore this slang problem... use ncurses dude! Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-27cfdisk: provide extra partinfo with "x"Ondrej Oprala1-12/+356
The new 'extra' info provides: * filesystem information from libblkid (TYPE, UUID, LABEL) This feature is based on libblkid ability to probe specified area on the device. It allows to probe for filesystems although the partition devices (e.g. /dev/sda2) does not exist. For example from disk image: # cfdisk /home/archive/fs-images/disk.img * additional information from libfdisk (partition UUID, Name, ...) * mount information from libmount (from fstab or mountinfo) Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com> Co-Author: Karel Zak <kzak@redhat.com>
2015-02-25colors: cleanup man pages, add hint to usage()Karel Zak1-2/+4
cfdisk, fdisk, calm dmesg and hexdump Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-10cfdisk: improve create-label UIKarel Zak1-11/+15
Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-10cfdisk: also recognize a lowercase 'l' for loading a script fileBenno Schulenberg1-0/+1
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-10cfdisk: do not startle the user with a false message when --zero is usedBenno Schulenberg1-2/+3
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-03cfdisk: improve ui_get_size() warningsKarel Zak1-5/+10
- don't reset to default after error - clean previous warnings after users response - remove unnecessary warning Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-03libfdisk: fix issues with very small partitionsKarel Zak1-2/+3
- cfdisk: minimal partitions size is 1 sector - dos: when align last sector then don't set partition size to zero for very small partitions. - don't ignore tiny partitions before free space when define free-space start offset - improve some debug messages Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-03cfdisk: print "wrong order" warning after startup, colorize info messagesKarel Zak1-2/+9
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-03cfdisk: force main menu to default to Quit/New menu itemsKarel Zak1-8/+13
Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-02cfdisk: disable some KEY_* in ui_get_wqstring()Karel Zak1-0/+9
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-02cfdisk: default to Quit menu itemKarel Zak1-0/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-02cfdisk: make '?' an alias of 'h', to also show the help screenBenno Schulenberg1-0/+1
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02cfdisk: punctuate the bottombar messages consistentlyBenno Schulenberg1-6/+6
Also adjust the style of two comments and add another. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02cfdisk: improve wording and consistency of the size warningsBenno Schulenberg1-2/+2
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02cfdisk: remove the mistaken B from the explanation of size suffixesBenno Schulenberg1-2/+2
Also reword the explanation to be clearer. It is not necessary to be complete -- that is what the man page is for. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-28cfdisk: fix mem leak and main_menu_action() logic [coverity scan]Karel Zak1-6/+9
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-26cfdisk: actually translate the table headers and the bottom lineBenno Schulenberg1-2/+2
The printout of the table headers and the bottomline descriptions were lacking calls to gettext(). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26cfdisk: shorten the help screen to make it fit within 25 linesBenno Schulenberg1-14/+7
When the terminal has less than 32 lines, the new cfdisk ignored the fact that the help-screen text was longer and just skipped printing the remaining lines. Instead of introducing a minipager for the help screen, just condense its text and remove unneeded lines. Now the text occupies just 25 lines, which should fit on most terminals. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26cfdisk: don't mess up the help screen by printing the PO file headerBenno Schulenberg1-6/+5
Asking for the translation of the empty string ("") produces the header of the PO file corresponding to the current locale, which messes up the help screen. So, don't use empty strings in the array of help strings but (arbitrary) double spaces. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26textual: fix spellos and inconsistencies in several program messagesBenno Schulenberg1-2/+2
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-07maint: fix shadow declarationSami Kerola1-3/+3
This change fixes all shadow declarations. The worth while to mention fix is with libfdisk sun geometry. It comes from bitops.h cpu_to_be16 macro that further expands from include/bits/byteswap.h that has the shadowing. libfdisk/src/sun.c:961:173: warning: declaration of '__v' shadows a previous local [-Wshadow] libfdisk/src/sun.c:961:69: warning: shadowed declaration is here [-Wshadow] libfdisk/src/sun.c:961:178: warning: declaration of '__x' shadows a previous local [-Wshadow] libfdisk/src/sun.c:961:74: warning: shadowed declaration is here [-Wshadow] That could have caused earlier some unexpected results. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-06textual: add a docstring to most of the utilitiesBenno Schulenberg1-1/+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>
2015-01-05cfdisk: improve Dump dialogKarel Zak1-9/+6
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-05cfdisk: improve menu clean functionKarel Zak1-7/+8
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-05cfdisk: detect too small partition sizesKarel Zak1-6/+15
References: https://github.com/karelzak/util-linux/issues/136 Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-26libfdisk: rename and move functionKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-13cfdisk: cleanup menuitem draw functionsKarel Zak1-19/+55
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-13cfdisk: remove [Load] from menuKarel Zak1-13/+0
This functionality will be rarely used, so it does not make sense to waste screen space with this menu item. It's enough to provide this functionality in "Select label type" dialog (cfdisk --zero and then 'L' command). Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-12cfdisk: add support for sfdisk scriptsKarel Zak1-2/+110
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-24include/debug: fix typoKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-15libfdisk: make it possible to use zero for size and startKarel Zak1-1/+2
The zero may be valid size and start of the partition. This patch introduces: fdisk_partition_has_start() fdisk_partition_has_size() fdisk_partition_unset_size() fdisk_partition_unset_start() to make it possible to work with zero. The feature is internally implemented by magic constant ((type) -1) for undefined sizes and offsets. Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-09sfdisk: ask on EOFKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-09libfdisk: follow explicitly specified partition sizeKarel Zak1-3/+10
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07libfdisk: return partno when add new partitionKarel Zak1-1/+1
* improve the way how sfdisk report results * the API change simplify applications Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-01textual: use version printing macro everywhereSami Kerola1-2/+1
Only mount, umount, and blkid remains not using the macro because they are print also library references. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01cfdisk: don't modify ncurses LINES and COLSKarel Zak1-29/+37
On Sun, Sep 28, 2014 at 01:48:38AM -0700, pv4 wrote: If ncurses is build with --enable-reentrant, building util-linux-2.25.1 fails with the folllowing error: disk-utils/cfdisk.c: In function 'resize': disk-utils/cfdisk.c:202:9: error: lvalue required as left operand of assignment LINES = ws.ws_row; ^ disk-utils/cfdisk.c:203:8: error: lvalue required as left operand of assignment COLS = ws.ws_col; ^ man COLS gives the following: Depending on the configuration, these may be actual variables, or macros (see curs_threads(3X)) which provide read-only access to curses's state. In either case, applications should treat them as read-only to avoid confusing the library. Addresses: https://github.com/karelzak/util-linux/issues/125 Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-28libfdisk: use reference counting for contextKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-26cfdisk: fix typo in the previous commitKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-26cfdisk: wrong interpretation of yes in non-english languageKarel Zak1-2/+2
Reported-by: tnut@nutyx.org Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-15fdisk: use libfdisk public API onlyKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-15cfdisk: use only public libfdisk APIKarel Zak1-14/+20
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-14libfdisk: final parttype API cleanupKarel Zak1-13/+14
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-14libfdisk: move get_parttypes to label APIKarel Zak1-6/+8
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-14libfdisk: make it possible to get fields for all labesKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13libfdisk: cleanup fdisk_is_label stuffKarel Zak1-5/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13libfdisk: clean up API (context.c)Karel Zak1-10/+10
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13cfdisk: add libfdisk independent debug stuffKarel Zak1-33/+55
Now it's possible to use CFDISK_DEBUG=0xffff ./cfdisk to debug only cfdisk UI. Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13libfdisk: rename fdisk_column to fdisk_fieldKarel Zak1-31/+29
.. to make the API and fdisk(s) code more readable. Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13libfdisk: remove dependence on libsmartcolsKarel Zak1-7/+13
It's application business to convert libfdisk_table to string. Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-06cfdisk: move curs_set(1) to ui_end()Karel Zak1-2/+1
This is probably correct to have curs_set() in ui_end(), but according to Martin it does not work with slang library from signal handler. Reported-by: Martin Steigerwald <Martin@lichtvoll.de> Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-28cfdisk: reenable cursor when quittingAndreas Henriksson1-0/+1
After quitting cfdisk (built with slang) the cursor would be missing at the command prompt. Reported-by: Martin Steigerwald <Martin@Lichtvoll.de> Addresses-Debian-Bug: #755991 Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2014-07-23textual: fix some typos and inconsistencies in various messagesBenno Schulenberg1-3/+3
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-21cfdisk: actually translate the partition types in the menuBenno Schulenberg1-2/+2
[kzak@redhat.com: - translate also GPT types] Signed-off-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18cfdisk: use /dev/sda by defaultKarel Zak1-6/+20
.. this all is for backward compatibility. Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17cfdisk: make code more readable for analyzers [coverity scan]Karel Zak1-0/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17cfdisk: fix possible memory leak [coverity scan]Karel Zak1-0/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-15cfdisk: restore the license that was lost in JanuaryBenno Schulenberg1-0/+14
Signed-off-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-15cfdisk: fix warning usage, improve 's' helpKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-15cfdisk: accept 's' as well as 'S' for sectorsKarel Zak1-1/+1
Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-15cfdisk: make menus sensitive to ESCKarel Zak1-0/+2
Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-15cfdisk: use \n for messages on stdout and stderrKarel Zak1-4/+13
Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-15libfdisk: make disk sync() optionalKarel Zak1-1/+4
... this allows to avoid unnecessary sync() from cfdisk. Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-13cfdisk: add braces to ensure operation orderSami Kerola1-1/+1
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-01cfdisk: fix division by zero [clang-analyze]Karel Zak1-0/+6
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-20cfdisk: add --zero command line optionKarel Zak1-3/+9
The option has been supported by previous versions, we can easily support it too. Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-20cfdisk: don't offer BSDKarel Zak1-4/+4
BSD is nested within DOS partition, so for disk without any partition table it does not make any sense to offer BSD label. Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06libsmartcols: add debug messagesKarel Zak1-0/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-05cfdisk: resize UI on SIGWINCHKarel Zak1-7/+103
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-05cfdisk: add [Sort] operationKarel Zak1-2/+16
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13lib/colors: allow to temporary disable colorsKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13cfdisk: fix compiler warning [-Wsign-compare]Karel Zak1-1/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03libsmartcols: clean up flags usageKarel Zak1-3/+2
* rename flags functions to scols_table_enable_* * rename *_no_foo() functions to _nofoo() * output formats are mutually exclusive, so don't use flags there * don't assume symbols in scols_new_table(), use scols_table_set_symbols() Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03cfdisk: clean up scols usageKarel Zak1-7/+29
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03Use libsmartcols in libfdisk and cfdiskOndrej Oprala1-20/+29
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-21Merge branch 'fix-compile-color-cfdisk' of ↵Karel Zak1-1/+1
https://github.com/theonewolf/util-linux * 'fix-compile-color-cfdisk' of https://github.com/theonewolf/util-linux: cfdisk: fix compile-time error fixes #59
2014-03-21Merge branch 'cfdisk-fix-typo' of https://github.com/rudimeier/util-linuxKarel Zak1-2/+2
* 'cfdisk-fix-typo' of https://github.com/rudimeier/util-linux: cfdisk: fix typo (undeclared variable since b1f58330)
2014-03-21libfdisk: properly implement read-only modeKarel Zak1-2/+19
Don't use fallback to read-only mode in fdisk_context_assign_device(), it's application responsibility open the device in the right mode. The commands fdisk and cfdisk check (and report) read-only mode now. Reported-by: Maciej Małecki <me@mmalecki.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-21libfdisk: use new debug functionsKarel Zak1-29/+29
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-19cfdisk: fix compile-time error fixes #59Wolfgang Richter1-1/+1
+ For compile to work also needs pull request #56 applied
2014-03-14cfdisk: fix typo (undeclared variable since b1f58330)Ruediger Meier1-2/+2
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-03-11cfdisk: follow terminal-colors.dKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11cfdisk: fix colors initializationKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11cfdisk: fix slang usageKarel Zak1-5/+17
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11build-sys: ove fdisks to disk-utilsKarel Zak1-0/+1842
Signed-off-by: Karel Zak <kzak@redhat.com>
2006-12-07Imported from util-linux-2.9i tarball.v2.9iKarel Zak1-2560/+0
2006-12-07Imported from util-linux-2.8 tarball.v2.8Karel Zak1-62/+189
2006-12-07Imported from util-linux-2.7.1 tarball.v2.7.1Karel Zak1-200/+301
2006-12-07Imported from util-linux-2.5 tarball.v2.5Karel Zak1-3/+5
2006-12-07Imported from util-linux-2.2 tarball.v2.2Karel Zak1-0/+2330