The struct fdisk_partition has special flag "end_follow_default" to
make the partition large as much as possible. This patch makes this
flag usable for fdisk_set_partition() function.
Command line example (enlarge the first partition):
# echo ',+' | ./sfdisk -N1 /dev/sdb
...
Disk /dev/sdb: 100 MiB, 104857600 bytes, 204800 sectors
...
Old situation:
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 22527 20480 10M 83 Linux
^^^^^
New situation:
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 204799 202752 99M 83 Linux
^^^^^^
Signed-off-by: Karel Zak <kzak@redhat.com>
==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>
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>
New commands 'I' and 'O' allows to read and write sfdisk compatible
scripts by fdisk. It means that you can save your work (partition
table) and later use it (in fdisk, sfdisk or cfdisk) to create a new
partition table.
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
disk-utils/sfdisk.c:222:9: warning: variable 'rc' is uninitialized when
used here [-Wuninitialized]
return rc;
disk-utils/sfdisk.c:208:8: note: initialize the variable 'rc' to silence
this warning
int rc;
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
regular disk label:
# sfdisk --list /dev/sdb
..
Disklabel type: gpt
Disk identifier: 9DF9A9F1-0654-4E7A-9A5E-36E66D60FD79
Device Start End Sectors Size Type
/dev/sdb1 2048 22527 20480 10M Linux filesystem
/dev/sdb2 22528 43007 20480 10M Linux swap
/dev/sdb3 43008 204766 161759 79M Linux filesystem
nested (PMBR):
# sfdisk --list --label-nested dos /dev/sdb
...
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sdb1 1 204799 204799 100M ee GPT
and for example:
# sfdisk --label-nested dos /dev/sdb <<EOF
1, 2047, ee
, 10M, L
, 10M, S
,,
creates hybrid GPT (PMBR partitions point to the same location as GPT)
Signed-off-by: Karel Zak <kzak@redhat.com>
The option --backup force sfdisk to store *all* fragments of the
partition table (including MBR partition tables store in the
extended partitions) to
$HOME/sfdisk-<devname>-<offset>.bak
The options -O, -backup-file <path> allows to override the default
path, but sfdisk still appends <devname>-<offset>.bak to the <path>.
The backup files always contain only raw data from the device, so it's
possible to use dd(1) to restore original data on the device.
The original sfdisk also supported -O <file>, but semantic was little
bit different:
- all was based on 512-byte sectors
- all sectors was stored to the one file in format
<offset>|<sector>|<offset>|...
this original concept makes the backup files specific to sfdisk and with
dependence on sector size.
The new concept is the same we already use for wipefs(8) backup files.
Example (disk with GPT):
# sfdisk /dev/sda --backup
Welcome to sfdisk (util-linux 2.25.202-f4deb-dirty).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Backup files:
PMBR (offset 0, size 512): /root/sfdisk-sda-0x00000000.bak
GPT Header (offset 512, size 512): /root/sfdisk-sda-0x00000200.bak
GPT Entries (offset 1024, size 16384): /root/sfdisk-sda-0x00000400.bak
Signed-off-by: Karel Zak <kzak@redhat.com>
The sfdisk does not care about compatibility with classic DOS
partitioning, and it does not warn about incompatibility with DOS at
all. It means that --Linux is default and it's unnecessary to use
this option.
It's the same situation like with "--unit S", these options are very
probably often used in scripts, and these all is default now. So for
backward compatibility new sfdisk accepts these options on command
line, but prints "option is deprecated" warning message.
Signed-off-by: Karel Zak <kzak@redhat.com>
Note that original sfdisk implementation suppressed warning
messages for --quiet.
Now we keep warning and error messages visible, but suppress
extra info messages only (for example to make it more usable in
scripts). IMHO suppress warnings is bad idea.
Signed-off-by: Karel Zak <kzak@redhat.com>
The patch also makes --{id,change-id,print-id} deprecated in favour
of --parttype. The original --id is too generic option name and the
--print-id and --change-id are unnecessary and inconsistent with
another sfdisk options (e.g. we don't have --change-bootable)
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
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>
* 'misc' of git://github.com/kerolasa/lelux-utiliteetit:
textual: share crypt() error message in sulogin and newgrp
newgrp: avoid use of obsolete getpass() function
newgrp: use libc function to read gshadow if it is available
setarch: use personality() system call when it is available
setarch: reindent code
hwclock: remove referal to deprecated keyboard interface
eject: make open_device() and select_speed() to use struct eject_control
eject: add struct eject_control to remove global variables
mountpoint: simplify if statement
mkfs.minix: fix couple compiler warnings
mountpoint: add struct mountpoint_control
last: improve code readability by renaming variable names
last: make is_phantom() when kernel config does not include audit support
lib: remove xgetpass()
include: simplify fputc_careful() in carefulputc.h
libuuid: add extern qualifiers to uuid/uuid.h system header
swapon - requires libmount and libblkid
swapoff - requires libmount
swaplabel - requires libblkid
This patch add lib/swapprober.c with blkid stuff for swap. It allows
to use and link libblkid only when necessary.
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/mkfs.minix.c:366:3: warning: ISO C forbids 'return' with
expression, in function returning void [-Wpedantic]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The fdisk_dump_* prefix will be used for sfdisk-like functionality.
The patch also add FDISK_ prefix to fdisk_get_unit() options.
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch restores the original fdisk behavior and always prints
information about misaligned partitions in 'p'print output.
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
This commit introduces a support for user configurable
from/to track and a basic repair mode for broken floppies.
It also fixes a recently introduced bug that causes
a line breakage when printing the track number.
Signed-off-by: Karel Zak <kzak@redhat.com>
This fixes the following compiler warning.
disk-utils/swaplabel.c:175:2: warning: implicit declaration of function
'get_swap_prober' [-Wimplicit-function-declaration]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
* don't use err(), but warn(), so don't stop after the first error
* display all errors when "-l <device> ..." specified
* display only EACCES errors when list whole disks from
/proc/partitions ("fdisk -l" )
Reported-by: Boian Bonev <bbonev@ipacct.com>
Addresses: https://github.com/karelzak/util-linux/pull/106
Signed-off-by: Karel Zak <kzak@redhat.com>
The xiafs filesystem was removed from the kernel fifteen years ago,
and any kernel that contained it reached end of life ten years ago.
It's time to stop mentioning it in the mount man page and elsewhere.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
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>
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>
The swapon(8) listing was almost complete, apart from label and uuid.
This change moves the code from swaplabel(8) to shared scope to be used
for printouts in other swap commands, such as swapon.
Adding this feature to lsblk(8) was a consideration, but lsblk is not
interested of swapfiles, so the swapon seems like a better option to add
this information.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
... this allows to avoid unnecessary sync() from cfdisk.
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
From manual page; 'On error, the value MAP_FAILED is returned, and errno
is set appropriately'.
Reference: http://man7.org/linux/man-pages/man2/mmap.2.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
It seems overkill to lock directly whole-disk device (for -l) when we use the
lock only to synchronize fsck instances.
It's fsck private business, so don't use system files, but let's use private
/run/fsck/<diskname>.lock file.
Addresses: https://bugs.freedesktop.org/show_bug.cgi?id=79576
Signed-off-by: Karel Zak <kzak@redhat.com>
Sometimes we use "behaviour" and "behavior" in the same text, let's
use "behavior" only everywhere.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1011068
Signed-off-by: Karel Zak <kzak@redhat.com>
Most of them catched on 32bit gcc and icc.
disk-utils/fsck.cramfs.c: printf format type
lib/boottime.c: unused variables
misc-utils/cal.c: set but never used
sys-utils/losetup.c: set but never used
sys-utils/lscpu-dmi.c: defined but not used
sys-utils/switch_root.c: comparison between signed and unsigned
tests/helpers/test_sysinfo.c: printf format type
Sfdisk prints out a warning about extended partition not
starting at a cylinder boundary. Since this is irrelevant
for linux, the -L option should suppress this warning.
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
We want to clean it up to compile it later per default (not only
if defined INCLUDE_FS_TESTS).
- Rename option --destination to --extract.
- DIR argument is now optional because we want to keep the use
case "test uncompression without writing files" ... but we
don't want it always.
- Remove shortopt -x because shortopts with optional args are
evil.
Changing the cmd interface is no compatibility issue here because
all affected options errored out per default in past.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We are already fine with checking for different endianess. Now we
also succeed if systems's page size does not match.
Note that page_size is only really used if INCLUDE_FS_TESTS is
defined, see followups.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
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>
FIXME
Units KB, MB, GB, etc. are ambiguous (not necessarily used here)
Prefixes kilo, mega, giga, etc. are ambiguous with the unit byte (ditto)
Change ' \- ' to ' \(en ' (an en-dash), if it is a dash (pause,
separation)
Change ' - ' to ' \(en ' (an en-dash), if it is a dash (pause,
separation)
Change '\-' to '-' (code "hyphen-minus", rendered with the glyph
hyphen in troff), if it is a part of a compound name.
A minus is not used in words. People using UTF-8 and copy-and-paste
can(?) (may?) use "info", "man --ascii" or the command "man" should
have an option to display the '-' ("hyphen-minus") in names of options
with the code (character name) "hyphen-minus" (u002D) instead of
"u2010" (code (character) name "hyphen").
Change '-' to '\-', if it indicates an option
Protect a full stop (.), that begins or ends a string, with \&
Correct space between sentences to two space characters (or begin
each sentence on a new line).
Change '--' to '\-\-', if it indicates an option
Add \~ (no-break space) around '|' (means "or")
Change ' -- ' to ' \(en ' (an en-dash), if it is a dash (pause,
separation)
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Add a space character around '|' (means "or")
Add "(hyphen-minus)" after "\-" to show character name for input
Change '\-\-' to '\en', when it is used as a dash (pause, separation)
Add a comma before "or" in a series of words (3 or more)
Change '-' to '\(en' (an en-dash), if it means a range
Protect a full stop (.), that begins or ends a string, with \&
Change '--' to '\-\-', if it indicates an option
Change '-' to '\-', if it indicates an option
Change '-' to '\-', if means a minus
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
-- changed to \(en (an en-dash) if it is a dash (pause, separation)
- changed to \- if it indicates an option
A full stop (.), that begins or ends a string, protected with \&
Space between sentences corrected to two word spaces
-- changed to \-\- if it indicates an option
Signed-off-by: Karel Zak <kzak@redhat.com>
The unit "MB" is ambigous. Use "MiB" if "M" does not mean 10^6.
Otherwise add "(M = 10^6)" after it.
Changes:
Unpaddable space (\ ) added between a number and an unit. A nuber
and a unit are not one word. Is "16MB" written "sixteenmegabytes"?
Signed-off-by: Karel Zak <kzak@redhat.com>
- changed to \- if it means an option
A full stop (.), that begins or ends a string, protected with \&
No line adjustment used for section "SEE ALSO" (.na/.ad)
Signed-off-by: Karel Zak <kzak@redhat.com>
A full stop (.), that begins or ends a string, protected with \&
A space between a number and an unit changed to an unpaddable space
"\ "
Signed-off-by: Karel Zak <kzak@redhat.com>
- between numbers changed to \(en if it means a range
A full stop (.), that begins or ends a string, protected with \&
Signed-off-by: Karel Zak <kzak@redhat.com>
The word "kilobytes" is ambiguous. Change it to "kibibytes" if kilo
does not mean 1000. Otherwise add "(1000 B)" after it.
A string, that begins or ends with a full stop (.), protected with \&
- changed to \- if it shows an option
-- change to \(en if it means a dash (pause, separation)
Space between sentences is two word spaces in *roff. Thus it is
better to begin each sentence on a new line when the file contains
formatting commands
--- changed to \(en if it means a dash (pause, separation)
Punctuation separated from a word with a space, if it is an argument
to a macro like "BR" (two font styles used alternately)
Adjusting inhibited for the section "SEE ALSO" with ".na/.ad"
Signed-off-by: Karel Zak <kzak@redhat.com>
\- changed to - (code "hyphen-minus", rendered with the glyph hyphen
in troff) if it is a part of a compound name. A minus is not used in
words. People using UTF-8 and copy-and-pase can(?) (may?) use "info",
"man --ascii" or the command "man" should have an option to display the
- in names of options with the code (character name) "hyphen-minus"
(u002D) instead of "u2010" (code (character) name "hyphen")
Signed-off-by: Karel Zak <kzak@redhat.com>
Macro, that alternately changes the input between two font styles,
changed to the macro for one font style change, if there is only one
argument
Text string, that begins or ends with a full stop (.) protected with \&
-- changed to \-\- if it is an option
- changed to \(en if it is a dash (pause, seperation)
Signed-off-by: Karel Zak <kzak@redhat.com>
* 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>