Now sfdisk stops everything on I/O error when moving data. It seems
better to report the error to user and continue as it's better to have
one bad sector in the partition than inconsistent all partition.
Addresses: https://github.com/karelzak/util-linux/issues/984
Signed-off-by: Karel Zak <kzak@redhat.com>
The default partition table depends on system arch, for example on
Sparc it's SUN and on x86_64 it's MBR. This option forces fdisk to
keep the device empty and allow user to create non-default PT in more
elegant way.
Addresses: https://github.com/karelzak/util-linux/pull/994
Signed-off-by: Karel Zak <kzak@redhat.com>
Autotoolz does not define HAVE_LCHOWN when the condition is false,
so it is appropriate to use #ifdef/#ifndef as everywhere else.
Signed-off-by: Karel Zak <kzak@redhat.com>
* add list of supported aliases to 'l' and 'L' output
* support aliases in 't' dialog
For example (use 'swap' to set 0x82 partition type):
Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): swap
Changed type of partition 'Linux' to 'Linux swap / Solaris'.
Note that the aliases are evaluated as the last possibility if user's
input dues not match up with any partition type. This is necessary for
backward compatibility.
This patch does NOT introduce shortcuts (.e.g. 'S' for swap) to
fdisk(8) due to collisions with already used dialog keys.
Addresses: https://github.com/karelzak/util-linux/issues/958
Signed-off-by: Karel Zak <kzak@redhat.com>
* add support for aliases to sfdisk scripts
* add shortcuts and aliases to --part-type command
Note that --part-type evaluates shortcuts and aliases as the last
possibility (so after regular type string). This is necessary for
backward compatibility.
Example ('raid' type alias):
# sfdisk --part-type /dev/sdc 1 raid
# fdisk -l /dev/sdc
...
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 204799 202752 99M fd Linux raid autodetect
Example ('L' type shortcut):
# sfdisk --part-type /dev/sdc 1 L
# fdisk -l /dev/sdc
...
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 204799 202752 99M 83 Linux
Addresses: https://github.com/karelzak/util-linux/issues/958
Signed-off-by: Karel Zak <kzak@redhat.com>
- fix stupid typo (!has_container_or_unused(sf))
- use fdisk_is_partition_used() as fdisk_get_partition() returns
nothing for unused partition
- update tests
- add more hints to the man page
Addresses: https://github.com/calamares/calamares/issues/1332
Signed-off-by: Karel Zak <kzak@redhat.com>
sfdisk trying to be more smart than libfdisk when analyze if we can
append to the current PT. libfdisk is able to use unused partition
to create a new one (if partno not strictly specified), but sfdisk
assumes that we can add partition to extended partition only.
Addresses: https://github.com/calamares/calamares/issues/1332
Signed-off-by: Karel Zak <kzak@redhat.com>
This command allows to relocate GPT backup header behind last
partition (--relocate gpt-bak-mini) or to standard position
(--relocate gpt-bak-std).
Hint: use "fdisk --list-details" to see "Alternative LBA".
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's add "Arguments:" section to the --help output and describe
{K,M,G...}iB suffixes there.
Addresses: https://github.com/karelzak/util-linux/pull/917
Co-Author: ed <ed@s5h.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
- add sector-size between supported headers (already in --dump output)
- report unknown headers by -ENOTSUP
- ignore ENOTSUP in sfdisk (but print warning) and in fdisk_script_read_file()
Addresses: https://github.com/karelzak/util-linux/issues/949
Signed-off-by: Karel Zak <kzak@redhat.com>
* remove unnecessary and broken step alignment
* improve reported information in move log
* improve final progress bar update
Addresses: https://github.com/karelzak/util-linux/issues/938
Signed-off-by: Karel Zak <kzak@redhat.com>
The area we need to move does not have to be aligned to optimal I/O
size (step size) -- we need to be sure we do not move data
after/before the area.
Addresses: https://github.com/karelzak/util-linux/issues/938
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'master' of https://github.com/dsd/util-linux:
libblkid: improve identification of ISO9660 partition
isosize: move ISO size functions into a shared header
Change a HYPHEN-MINUS (code 0x55, 2D) to a minus (\-), if in front of
1) a name of an option
2) a negative number to be printed.
See man-pages(7) [Debian package "manpages"].
The output from "nroff" is unchanged.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Add a comma (,) after "e.g." and "i.e.", or use English words
(man-pages(7) [package "manpages"]).
Abbreviation points should be protected (usually with the
non-printing, zero width character '\&') from being interpreted as an
end of sentence, if they are not, and that independent of their current
place on the line.
This is important when typing, as one does not usually know in
advance when the editor jumps to a new line.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Two-fonts macros are made for two or more arguments.
Remove space at end of lines in the files "term-utils/{script.1,
scriptlive.1, scriptreplay.1}".
Put "\-\-summary" to the correct indent in the file
"term-utils/script.1"
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Move the helper functions that parse ISO data & sector size info into
a separate, shared header.
These will addtionally be used by libblkid's iso9660 parser.
Signed-off-by: Daniel Drake <drake@endlessm.com>
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.
Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
* current code overwrites hybrid MBR because EE partition
is expected from fist sector, this is not true for hybrid MBR
* print "The partition table has been altered." message also for
nested contexts
* remove "You have to sync the MBR manually" message
Addresses: https://github.com/karelzak/util-linux/issues/851
Signed-off-by: Karel Zak <kzak@redhat.com>
The current code uses 'M' to switch between MBR and GPT, but it's not
intuitive to "go back" by 'M'. It seems more user-friendly to use 'r'
as in another places (for example when go from expert menu or from BRD
menu).
The 'M' to return to GPT is still supported for backward compatibility.
Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
We do not use sector-size from dumps to create partition tables,
because it's always necessary to use real device specific settings.
The new sector-size value is usable when you use the dump as
a description of the device or disk image.
Addresses: https://github.com/karelzak/util-linux/issues/869
Signed-off-by: Karel Zak <kzak@redhat.com>
The log may be pretty huge and very probably not used by many users.
Let's make it optional.
The patch also clean up move-data output messages.
Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
The current implementation is too paranoid and tries to keep in
memory only data which are on disk too. It means very small step size
when move partition only a few sectors left/right.
This patch enlarge the buffer to at least 1MiB and aligned to optimal
I/O.
Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
We need to clear stdin errors otherwise it returns EOF forever after
CTRL+D.
Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Unfortunately methods I used to find and fix were based on quite manual
process that cannot be easily repeated so I do not see how this fix could be
turned into a tools/checkmans.sh addition. Well, lets hope doing this
manually twice every decade is good enough.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
The commit ab025087f9 has disabled error
message, but unfortunately it keeps wrong return code. This has been fixed
by commit 53ae7d60cf.
This commit add hit about it to docs and fix regression test too.
Signed-off-by: Karel Zak <kzak@redhat.com>
The errno ENXIO should be ignored, unfortunately the current code uses
variable 'rc' for ioctl return code as well as for final del_parts()
return value. So, failed ioctl (which should be ignored) affects all
del_parts() status.
# modprobe scsi_debug dev_size_mb=100
# partx -d --nr 1-1024 /dev/sdc; echo $?
1
The device dos not contains any partitions, so 0 return code is
expected in this case.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179
Signed-off-by: Karel Zak <kzak@redhat.com>
The unnamed-field format supports partition type shortcuts:
",1MiB,L'
but for named-field format it requires full type:
(mbr) "size=1MiB,type=83"
(gpt) "size=1MiB,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4"
This patch implements type shortcuts also for named-field format:
"size=1MiB,type=L"
to make it more user-friendly and unified.
Addresses: https://github.com/karelzak/util-linux/issues/837
Signed-off-by: Karel Zak <kzak@redhat.com>
It's seems people still follow old advices for SSD/4K devices. Let's
make CHS deprecation more visible at the begin of the man page...
Signed-off-by: Karel Zak <kzak@redhat.com>
Following warning is false positive. Size of the buffer is defined using
BUFSIZ, and so the strncpy() will never overwrite the last byte that is
initialized to zero in get_user_reply().
[disk-utils/sfdisk.c:137] -> [disk-utils/sfdisk.c:136]: (warning) Either the
condition 'bufsz!=0' is redundant or strncpy() argument nr 3 can have
invalid value. The value is -1 but the valid values are '0:'.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Let's consolidate the version printing code. It also seems better to
use exit() after --version, because it's handled in different way by
ASAN.
It's strange, but ASAN reports leaks after return in main(). Note that
we do not use free-before-exit.
Signed-off-by: Karel Zak <kzak@redhat.com>
This change fixes "warning: variable 'var' may be uninitialized when used
here [-Wconditional-uninitialized]" warnings reported in various files.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
It is not guaranteed that the returned string of readline() actually
contains as many bytes as buf can contain.
If bufsz is larger than the allocated memory by readline, an out of
boundary read occurs and leads to undefined behaviour. Most likely
that will be a crash.
This can be reproduced when readline-support is compiled in and when
you directly enter "quit" and "n" (to not write changes back to disk)
when sfdisk was called with any given device.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
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>
* don't duplicate info on two places -- let's keep only small note
in mkswap(8) man page, suggest to read swapon(8) man page
* add info about kernel versions for XFS and Btrfs swapfiles support
* use subsection in the NOTES
Addresses: https://github.com/karelzak/util-linux/issues/633
Signed-off-by: Karel Zak <kzak@redhat.com>
* report failed partition type parsing
* make sure partition types code (from user reply) for MBR is hex
Reported-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
The man page warns against fallocate on some filesystems and recommends
dd(1) as the most portable solution. So, let's use dd(1) also in the
example used in the same man page.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1203378
Signed-off-by: Karel Zak <kzak@redhat.com>
The "grain" variable is used to calculate partitions alignment. The
default is 1MiB (or minimal I/O size). The libfdisk provides API to overwrite
this default, but this feature has been nowhere accessible for
end-user.
This patch support for "grain: <size>" in libfdisk scripts.
Addresses: https://github.com/karelzak/util-linux/issues/688
Signed-off-by: Karel Zak <kzak@redhat.com>
A developmental version of "groff" issued a warning, for example with
"test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z":
troff: <logger.1>:299: warning: can't find font 't'
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Command (m for help): d
No partition is defined yet!
Could not delete partition 93840461057817 <--- !
Don't print 'Could not delete..' if no partition is defined yet.
Addresses: https://github.com/karelzak/util-linux/issues/667
Signed-off-by: Karel Zak <kzak@redhat.com>
[kzak@redhat.com: - add note to the man page
- add '-' to the dialog query
- cleanup functions names and libfdisk.sym]
Signed-off-by: Karel Zak <kzak@redhat.com>
util-linux-2.32.1/disk-utils/mkfs.cramfs.c:362]: (style) Redundant condition: If 'EXPR >= 16777216', the comparison 'EXPR' is always true.
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>