While the header says C/H/S the actual numbers where printed as
C/S/H.
Addresses: http://bugs.debian.org/815847
Reported-by: "groups, freeman" <freeman_groups@reason.dyndns.org>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
These ones should be fixed:
libblkid/src/probe.c:393:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/probe.c:907:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/probe.c:1221:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:540:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1043:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1056:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1057:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1061:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1199:27: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1410:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1431:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/superblocks/linux_raid.c:151:8: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/linux_raid.c:155:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/superblocks.c:375:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/superblocks/xfs.c:141:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libsmartcols/src/table.c:333:24: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table.c:344:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table_print.c:753:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/ask.c:364:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/utils.c:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:435:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:730:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/script.c:557:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/dos.c:1791:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/gpt.c:813:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:140:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:551:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:640:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We were missing our nice compliler warnings for many programs
and libs. See next commits how many trivial and non-trival
warnings have to be fixed.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
This was a major showstopper when building on a system where
LTLIBINTL libs are needed (e.g. OSX). Maybe there are a few test
programs which wouldn't need LDADD ... never mind.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* 'port-osx' of https://github.com/rudimeier/util-linux:
include: fix sys/sysinfo.h
libblkid: don't include endian.h
lib: fix ismounted includes for FreeBSD
lib: remove unused variable
lsns: use xcalloc()
include: remove unused mntent.h
include: check for sys/sysmacros.h
lib: define LOGIN_NAME_MAX fallback
include: provide MAP_ANONYMOUS on OSX
lib: rename strmode() and setmode()
tests: fix ts_option helpers
build-sys: fix [g]libtoolize version for OSX
build-sys: check linker support for version scripts
build-sys: portable usage of find command
travis: minor cleanup
Now libfdisk warns if another filesystem/RAID/PT signature is detected
on the device. It seems better and user-friendly to make it possible to
wipe the signatures when we write a new disk label to the device.
This patch adds to the library API
fdisk_enable_wipe()
fdisk_has_wipe()
fdisk_get_collision()
to control this new feature. The device modification is done by
libblkid (the same we use in some mkfs-like utils).
Signed-off-by: Karel Zak <kzak@redhat.com>
I got a bit confused with the interaction below:
Command (m for help): p
Disk /dev/sda: 41 GiB, 43965677568 bytes, 85870464 sectors
...
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 1026047 1024000 500M 83 Linux
/dev/sda2 1026048 85868543 84842496 40.5G 8e Linux LVM
Command (m for help): n
To create more partitions, first replace a primary with an extended partition.
I knew I should have had two primary partitions available, but I did
not notice that the disk was seen as full (I was trying to grow it)
This change detects available primary partitions, and if so indicates
we are out of space, rather than out of partitions.
Signed-off-by: Ian Wienand <iwienand@redhat.com>
This patch introduces smart crc32 function that is able to exclude
specified. The advantage is that we does not have to modify GPT header
(set the current in-header crc field to zero) when we count crc32.
This allows to keep GPT header in read-only buffers and simplify code.
Signed-off-by: Karel Zak <kzak@redhat.com>
- verify that the new partition fits to the area if the size of the
has not been modified
- fix remaining space calculation (yes, brown-paper-bag bug..)
- offer also space before first partition as free space
Signed-off-by: Karel Zak <kzak@redhat.com>
For example:
# modprobe scsi_debug dev_size_mb=1000 opt_blks=65535 physblk_exp=3
creates a disk with:
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
where 33553920 % 4096 != 0, it means that use Optimal I/O size to
align partition results that partition is not aligned to physical
sector boundary.
Reported-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* removes list() label operation from internal API
The list() has been based on fdisk_info() it was useless for
anything else than print on stdout...
* add a new get_item() label operation and fdisk_get_disklabel_item() public API
The new API provides abstract and pretty simple way how to get label
specific disk label information, for example
fdisk_get_disklabel_item(cxt, GPT_LABELITEM_ENTRIESLBA, &iterm);
return LBA of the array with GPT entries.
Note that this patch does not implement public functions to get
data from the @item object.
* removes get_id() label operation -- it's subset of the new get_item()
* the new internal API is also used to implement backwardly compatible
fdisk_list_disklabel() and fdisk_get_disklabel_id()
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's create a disk with 33553920 bytes optimal I/O size:
# modprobe scsi_debug dev_size_mb=1000 opt_blks=65535
and try to create partition:
echo -e 'n\n\n\n\n+512M\np\nq\n' | fdisk /dev/sdc
old version:
Device Boot Start End Sectors Size Id Type
/dev/sdc1 65535 1114110 1048576 512M 83 Linux
The next partition will be expected on sector 1114110 + 1, but it's
not aligned to optimal I/O:
((1114110 + 1) * 512) % 33553920 = 8192
fixed version:
Device Boot Start End Sectors Size Id Type
/dev/sdc1 65535 1114094 1048560 512M 83 Linux
((1114094 + 1) * 512) % 33553920 = 0
Note that the same problem with alignment calculation has been fixed
in Linux kernel by commit b8839b8c55f3fdd60dc36abcda7e0266aff7985c
(Oct 2014).
The patch also improves fdisk_align_lba_in_range() to not align sizes
smaller than grain (default 1MiB) to make it possible to create really
small partitions.
Reported-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
It is impossible to predict /dev/dm-N partition names. Use predictable
and better readable /dev/mapper names instead.
[kzak@redhat.com: - remove if-before-free]
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
The default configuration of multipath-tools appends "-partN" to
partition nodes. Follow this conventions and do the same.
It fixes for example fdisk -l /dev/mapper/name_of_the_device.
Note that the current implementation only partially fixes the problem. It
does not reflect any udev configuration changes, as udev does not provide
any function to return names of future (or current) partitions of a
particular device. It also does not fix fdisk -l /dev/dm-0.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
The current fdisk_label_get_fields_ids() is too smart as it
differentiate between details mode etc. It's useful for default
output, but in some cases it's better to provide all output fields.
Signed-off-by: Karel Zak <kzak@redhat.com>
The new libfdisk/gpt test (4a4a0927) discovered that we read and write
partition attributes wrongly on BE systems.
Our temporarily used char[8] bits are always LE and do not need to be
converted.
CC: Michael Marineau <michael.marineau@coreos.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
The existing APIs can only toggle individual bits or get and set bits in
a complex text representation, making it impractical to use libfdisk for
manipulating the GPT partition attribute field in more complex ways such
as updating a value that is multiple bits wide. For example priority
based partition selection originally designed for ChromeOS includes two
integer values that are 4-bits wide.
http://www.chromium.org/chromium-os/chromiumos-design-docs/disk-format#TOC-Trusting-the-GPT
[kzak@redhat.com: - add new symbols to .sym file and docs
- remove unused variables from test program]
Signed-off-by: Michael Marineau <michael.marineau@coreos.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Search for the protective partition before attempting to validate that
it covers the GPT header. Some hybrid MBRs list partitions out of order.
For example, CoreOS images ship with a hybrid MBR that lists the boot
partition first and the protective partition second in order to maintain
compatibility with old versions of Xen's PV-GRUB.
Signed-off-by: Michael Marineau <michael.marineau@coreos.com>
Really stupid copy & past mistake. The libfdisk symbols should not be
prefixed by MOUNT_ suffix.
This change makes binaries linked with libfdisk 2.26 incompatible with
new libfdisk. Fortunately, 2.26 has been the first release and very
probably the library has been used for util-linux fdisks only.
Signed-off-by: Karel Zak <kzak@redhat.com>
The current sfdisk does not allow to create partition that
starts before the default libfdisk First LBA (~1MiB). It
means that
# sfdisk --dump /dev/sda > foo
# sfdisk /dev/sdb < foo
does not work on systems where 1st partition does not start at offset
2048.
This patch add new headers to scripts to inform libfdisk about different
First/Last LBA ranges. For example:
label: gpt
first-lba: 34
allows to override the library default.
Signed-off-by: Karel Zak <kzak@redhat.com>
- 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>
The current code in add_partition() de-increment number of partitions
on error when logical partition requested and add_logical() does the
same. The result is mess in partitions array.
The another fixed issue is that add_logical() is called if all primary
partitions are already used although 'pa->start' (the template) is
explicitly defined outside the extended partition. The right behavior
is to end with error message.
Signed-off-by: Karel Zak <kzak@redhat.com>
deleting an extended partition with cfdisk leaves its contained
partitions in existence
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
It's better to use exact and explicitly defined types (e.g. uint64_t)
rather than something like off_t to make code more portable.
[reported with gcc (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3)]
The patch also fixes one debug message.
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
Kay reported that Windows 8.1 installed does not recognize GPT created
by libfdisk, but parted works as expected.
It seems (according to the header hexdump) that the problem is
HeaderSize GPT field where libfdisk uses 512 (header + reserved area),
but parted uses 92. The both is pretty valid according to the current
EFI standard, but 92 is probably more backwardly compatible.
I also found places in code where libfdisk gpt driver is inconsistent
and uses sometimes all sector and simetimes sizeof(gpt_header) only.
The right solution is to read all sector (into zeroized memory) and
later write again all sector to the device.
Reported-by: Kay Sievers <kay@vrfy.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
The problem is how fdisk_partition_cmp_start() compare numbers, the
function returns result from "a->start - b->start", unfortunately the
numbers are uint64, but function returns "int".
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191
Signed-off-by: Karel Zak <kzak@redhat.com>
- symbols versioning
- SONAME from configure.ac
- library version to header file
- modify build-sys to compile and install shared lib
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
Was:
Mentioned function returns -1 if adding of primary partition is
impossible. Caller treats this value as size_t (res variable) and then
compares it for negative values, totally ignoring errors.
Becomes:
Now function takes address to variable and fills it with partition
number. Caller treats return value as int and use it appropriately.
[kzak@redhat.com: - don't mix return code and partno at all]
Signed-off-by: Boris Egorov <egorov@linux.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
The GPT first usable LBA is usually aligned to grain (1MiB), but for small
(<=4MiB) devices we strictly follow sector sizes.
In this case there is a small space in front of the aligned begin of
the first partition. This useless space should not be offered for the
next partitions.
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 32768 bytes
Disklabel type: gpt
Disk identifier: 041E2D54-AD0C-4C7E-A50D-363D23058D47
Device Start End Size Type
/dev/sdb1 40 2087 1M Linux filesystem
Command (m for help): n
Partition number (2-128, default 2):
First sector (34-8158, default 2088):
^^
first usable LBA is 34, but first aligned (recommended) LBA is 40, we
use it for the first partition. All this is correct, but the space
before the first partition should be ignored. Fixed version:
Command (m for help): n
Partition number (2-128, default 2):
First sector (2088-8158, default 2088):
^^^^
Note this problem does not exist for "normal" (large) devices where
first usable LBA is aligned to grain.
Reported-by: Boaz Harrosh <boaz@plexistor.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* use check_ prefix for checking functions
* use plural in function names where we work with more partitions than one
* always use "ents" when when we work with gpt entries array
Signed-off-by: Karel Zak <kzak@redhat.com>
The current offset of cxt->dev_fd may not be still 0, notably when
blkdev_get_size has to resort to using blkdev_find_size
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org
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>
* this patch add to dos driver support for fdisk_partition->size_explicit
to avoid unexpected last sector alignment for sizes explicitly specified
in sectors
* add support for small "first LBA", the current default is to use
1MiB offset for the first partition and for each EBR. This is not
backwardly compatible and it makes impossible to apply sfdisk
scripts/dumps from old systems, because original offset can be
smaller than 2048 sectors (old sfdisk default is 1 sector).
The solution is on the fly to detect this situation and change
fdisk_context->first_lba to 1 sector. Nasty.
Signed-off-by: Karel Zak <kzak@redhat.com>
* check if there is space for primary partitions, if no and extended
exists then create logical partitions
* create extended if @pa->type is extended partition
Signed-off-by: Karel Zak <kzak@redhat.com>
The zero index is absolutely valid for extended partition (it means
extended partition could be the first partition on the device).
Reported-by: Christoph Hoopmann <christophhoopmann@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
If you delete logical partition and then create a new one than fdisk
(and cfdisk) might write EBR to the first sector on the device. That's
wrong of course; because you will lost MBR (primary partitions).
(Probably introduced by commit bcddbe9688
where code completely clears EBR stuff.)
Reported-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
For example
$ LIBMOUNT_DEBUG=tab,cache findmnt
to debug only TAB and CACHE subsystem.
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
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>
Storage Spaces is Microsoft's logical volume management.
It has been around since Windows 8.
Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: Sergei Antonov <saproj@gmail.com>
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>
... this allows to avoid unnecessary sync() from cfdisk.
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'minor-fixes' of git://github.com/kerolasa/lelux-utiliteetit:
lscpu: avoid double free
libsmartcols: avoid variable dereference after release
libfdisk: do not do the same thing twice in single if statement
whereis: avoid printing uninitialized string
setpriv: avoid alloca() use xmalloc() instead
dmesg: avoid unnecessary variable assignment
fdisk: avoid code duplication
mkfs.cramfs: use defined failure name rather than magic value
fdformat: match variable and print format types
cfdisk: add braces to ensure operation order
lscpu: avoid use of bzero() in favor of memset()
setterm: remove unnecessary variable
cal: remove unnused structure and definition
textual: fix some typos
$ ~/util-linux/fdisk -b 4096 xxx
..
Segmentation fault
The buffer has to be reinitialized always when we apply a new
device properties (e.g. sector size).
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
The second argument was very likely meant to be 'be->offset'.
Maintainers review & sign-off will further verify this change being
correct.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The check() function counts number of used sectors, but it counts only
partitions. This is mistake, the area before the first partition is
also "used" place (boot loaders or we have to align the first partition
to disk I/O limits, etc).
Signed-off-by: Karel Zak <kzak@redhat.com>
Many people report a problem with the message if (cylinders <= 1024 &&
start != total) fprintf(stderr, _("Partition %d: previous sectors %d
disagrees with " "total %d\n"), n, start, total);
This message comes from the fact that the previous code caluclates the
total number of sectors in the wrong way.
The formula should be total = (real_c * heads + h) * sectors + real_s;
As a Cylinder consists of some heads * sectors A Head consists of some
sectors and finally sectors are the smallest unit
Signed-off-by: Karel Zak <kzak@redhat.com>
The function is no critical for fdisk functionality. The SUN label
verification will check for less issues. All the verification code is
optional ('v' fdisk command).
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>
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>
* 'common_debug' of https://github.com/ooprala/util-linux:
clean up redundant macros and defines
libfdisk: use include/debug.h
libblkid: use include/debug.h
libmount: further debug.h integration
libcommon: don't mention lib versions in debug macros
libcommon: define more debugging macros
libmount: use macros from include/debug.h
libcommon: add common debugging routines
* care about endianess
* don't use by compiler packed struct with bit array for GPT
attributes, it's more robust use it as bitmap stored in uint64_t.
Signed-off-by: Karel Zak <kzak@redhat.com>
- deallocate sector buffer and deincrement part_max when delete last
logical partition
- zap obsolete EBR on begin of the extended partition when no logical
partition defined
Signed-off-by: Karel Zak <kzak@redhat.com>
* use separate function to get free space
* allow to use label-specific get_freespace() function
(this is necessary for MBR extended partitions mess)
Signed-off-by: Karel Zak <kzak@redhat.com>
The include/tt.h has to be used only internally by the library (for
example to convert fdisk_table to string).
The fdisk_ask API should not be more used for complex tasks like print
partition table. The application has to use fdisk_get_table() and
fdisk_table_to_string() or something else.
Signed-off-by: Karel Zak <kzak@redhat.com>
* add generic fdisk_iter iterator
* use fdisk_table to convert partition table to human readable output
* clean up partition.c API (don't use reference to fdisk_context in
fdisk_partition struct)
* extern table.c API to use fdisk_iter iterator
* remove old fdisk_list_partitions()
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's use more generic:
fdisk_get_partition()
fdisk_partition_get_parttype()
rather than fdisk_get_partition_type().
The patch also improves fdisk_get_partition() semantic to allocate
a new partition struct if the argument is NULL.
Signed-off-by: Karel Zak <kzak@redhat.com>
This change adds a struct fdisk_column to provide generic description
for information about partitions. The struct is used for tt tables as
well as lists of possible columns for specified label driver.
We use the same concept in all applications linked with tt.c (lsblk,
findmnt, partx, ...) where is possible to dynamically change columns,
order of the columns etc. Now it will be possible to do the same with
fdisk.
And it's also possible to use FDISK_COL_* Ids to address data, for
example:
fdisk_partition_get_data(cxt, FDISK_COL_SIZE, 1, &data);
returns a string with human readable size (<num>{MGT}) of the second
partition.
Signed-off-by: Karel Zak <kzak@redhat.com>
The _DEPENDENCIES has to be used for dependencies on another in-tree
files, but _LIBADD is to specify additional libs (including external
libs).
Reported-by: oleid <notifications@github.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk allows to overwrite existing partition if the partition has
partition type set to zero (very unusual, but possible).
This is incorrect because such partition is pretty valid (and Linux
kernel does not care about the type at all). For example:
Device Boot Start End Blocks Id System
/dev/sdb1 2048 22527 10240 83 Linux
/dev/sdb2 22528 227327 102400 0 Empty
^^^^^ ^^^^^^^^
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
Partition number (3,4, default 3):
First sector (22528-1228799, default 22528):
^^^^^^^
.. if user follows the default then the result are overlapping
partitions:
Device Boot Start End Blocks Id System
/dev/sdb1 2048 22527 10240 83 Linux
/dev/sdb2 22528 227327 102400 0 Empty
/dev/sdb3 22528 1228799 603136 83 Linux
^^^^^
... and if you call "mkfs /dev/sdb3" then you lost data on sdb2. Sad
thing.
Reported-by: Marc MERLIN <marc@merlins.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
The SGI drive currently counts only usable partitions, that's wrong as
Linux kernel counts all partition to generate partition number. For
example:
Kernel:
sdb 8:16 0 600M 0 disk
├─sdb9 8:25 0 2M 0 part
└─sdb11 8:27 0 596.2M 0 part
Fdisk:
Pt# Device Info Start End Sectors Id System
9: /dev/sdb1 0 4095 4096 0 SGI volhdr
11: /dev/sdb2 0 1220939 1220940 6 SGI volume
Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Notes:
* fdisk don't sync hybrid MBR with GPT
* hybrid MBR is ignored and not overwritten by PBMR
* users is informed about expert command 'M' to toggle between MBR
and GPT mode. It's possible to manually modify hybrid MBR.
Signed-off-by: Karel Zak <kzak@redhat.com>
We already have all code to support this feature, unfortunately
it was not used in gpt_probe_label()...
References: https://bugzilla.redhat.com/show_bug.cgi?id=1022217
Signed-off-by: Karel Zak <kzak@redhat.com>
* GPT attributes defined by standard (e.g. legacy boot etc.)
* attributes (bits 48-63) reserved for GUID specific attributes (used for example
by MS Windows)
Signed-off-by: Karel Zak <kzak@redhat.com>
Unfortunately, fdisk_warn/info/.. function was not marked by
printf __attribute__.
We don't want to break gettext stuff now, so all compiler warnings
have been fixed by casts. This is temporary solution, after release it
will be necessary to fix all the strings.
Signed-off-by: Karel Zak <kzak@redhat.com>
.. to make 'D'ump expert command usable also for MBR.
Yes, we have -rc2 now and this is a new feature, but it's tiny change
without any interaction to the rest of the code and without gettext stuff.
Signed-off-by: Karel Zak <kzak@redhat.com>