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>
Note that open_memstream() is POSIX-1.2008, so it's possible than not
all libc have already implemented this function.
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>
[kzak@redhat.com: - move paths to pathnames.h,
- use static path buffer]
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
In sys-utils/hwclock.c, set_hardware_clock_exact() has some problems when the
process gets pre-empted (for more than 100ms) before reaching the time for
which it waits:
1. The "continue" statement causes execution to skip the final tdiff
assignment at the end of the do...while loop, leading to the while condition
using the wrong value of tdiff, and thus always exiting the loop once
newhwtime != sethwtime (e.g., after 1 second). This masks bug # 2, below.
2. The previously-existing bug is that because it starts over waiting for the
desired time whenever two successive calls to gettimeofday() return values >
100ms apart, the loop will never terminate unless the process holds the CPU
(without losing it for more than 100ms) for at least 500ms. This can happen
on a heavily loaded machine or on a virtual machine (or on a heavily loaded
virtual machine). This has been observed to occur, preventing a machine from
completing the shutdown or reboot process due to a "hwclock --systohc" call in
a shutdown script.
The new implementation presented in this patch takes a somewhat different
approach, intended to accomplish the same goals:
It computes the desired target system time (at which the requested hardware
clock time will be applied to the hardware clock), and waits for that time to
arrive. If it misses the time (such as due to being pre-empted for too long),
it recalculates the target time, and increases the tolerance (how late it can
be relative to the target time, and still be "close enough". Thus, if all is
well, the time will be set *very* precisely. On a machine where the hwclock
process is repeatedly pre-empted, it will set the time as precisely as is
possible under the conditions present on that particular machine. In any
case, it will always terminate eventually (and pretty quickly); it will never
hang forever.
[kzak@redhat.com: - tiny coding style changes]
Signed-off-by: Chris MacGregor <chrismacgregor@google.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount/src/utils.c (BTRFS_TEST_MAGIC): Conditionally add define
which is used since commit v2.24-243-g6a52473.
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
The code currently always return EXIT_SUCCESS, that's strange. It
seems better to return 0 on success, 1 on complete failure and 64 on
partial success.
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>
The previous-file command is not :P but :p, and the back-to-where
command is not an acute accent but an apostrophe. Also condense
some of the descriptions and remove some useless comments.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>