Karel Zak [Thu, 13 Nov 2014 10:19:58 +0000 (11:19 +0100)]
cfdisk: remove [Load] from menu
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).
Karel Zak [Wed, 12 Nov 2014 10:15:06 +0000 (11:15 +0100)]
fdisk: add support for sfdisk scripts
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.
Karel Zak [Mon, 10 Nov 2014 13:01:09 +0000 (14:01 +0100)]
libfdisk: (gpt) don't offer first sector before the first partion
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.
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>
Karel Zak [Mon, 10 Nov 2014 11:22:55 +0000 (12:22 +0100)]
libfdisk: (gpt) make mode more readable
* 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
Sami Kerola [Sun, 2 Nov 2014 20:26:31 +0000 (20:26 +0000)]
mkswap: various minor improvement
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.
Sami Kerola [Sun, 2 Nov 2014 20:26:25 +0000 (20:26 +0000)]
mkswap: remove system architecture specific max swap size checks
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.
Karel Zak [Thu, 6 Nov 2014 11:50:27 +0000 (12:50 +0100)]
switch_root: improve statfs->f_type portability
__SWORD_TYPE is not available everywhere, for example it's not defined
by musl libc. It also seems that __SWORD_TYPE is not used for f_type
on some architectures (s390x).
Reported-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 3 Nov 2014 11:51:17 +0000 (12:51 +0100)]
include/debug: improve and cleanup
* use ul_debug_ prefix for all routines
* support <NAME>_DEBUG=all also for programs without debug mask names
(so we can avoid 0xffff mask in man pages)
* add function to print debug help
Mike Frysinger [Wed, 29 Oct 2014 04:19:03 +0000 (00:19 -0400)]
libmount: improve kernel command line parsing
The current command line parser will stop at the first occurrence of an
option, however the kernel does the opposite. So if you have:
root=/dev/sda1 root=/dev/sda2
When you look for "root", the kernel will use /dev/sda2, but util-linux
uses /dev/sda1.
Further, if args are passed to custom init programs, the parser will
pick those up as kernel options. So if you have:
root=/dev/sda1 -- /foo bar=yes
The kernel will stop at the "--" and pass the rest to userland. But if
you look for "bar", util-linux will incorrectly return "yes".
Ultimately, there's no way for util-linux to exactly parse the command
line the same way as the kernel -- we don't know exactly which ones the
kernel picks up and which it passes on to userland (either as env vars
or as command line args). The kernel passes all unrecognized options.
These updates are simple best effort.
URL: https://bugs.gentoo.org/526754 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Sami Kerola [Sun, 26 Oct 2014 22:07:08 +0000 (22:07 +0000)]
bash-completion: stop being clever when listing block devices
Various commands such as blkid, cfdisk, fdisk, delpart, and so on listed
only partitions and missed for example disks and volume groups. The
right thing to do is to list all block devices in all for all commands
performing operations with them. This might occasionally list unexpected
devices that I think is lesser bad than missing some.
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=764488 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Sun, 26 Oct 2014 22:07:07 +0000 (22:07 +0000)]
fstrim: initialize path variable
Reading the code this initialization is not necessary, so the change is
mostly about silencing a compiler warning and ensuring the program keeps
on working if there is a future bug that could make uninitialized 'path'
reachable to use.
sys-utils/fstrim.c:247: warning: 'path' may be used uninitialized in this
function
Sami Kerola [Sun, 26 Oct 2014 22:07:06 +0000 (22:07 +0000)]
sfdisk: return deterministic value from sfdisk_deinit()
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;
Mike Frysinger [Fri, 24 Oct 2014 16:26:12 +0000 (12:26 -0400)]
bash-completion: fix runuser install
The runuser symlink used to depend on su being enabled, but a refactoring
broke that. So if you build with runuser enabled but not su, you end up
with a broken symlink. Rework the logic so it works in both cases.
To facilitate the calculation of 'cold' vs 'warm' Hardware Clock drift
factor the limit on the update period needs to be less than 8 hours.
4 hours should be enough drift to allow calculations that are not
grossly out of range.
For example, with a workstation that is shutdown every night the cold
drift factor can be significantly different than a drift factor based on
a 24 hour period.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
There are cases where we need to refresh the
timestamps in the adjtime file without updating the
drift factor.
For example, with ntpd and an Eleven Minute Mode
kernel, we need to call systohc at shutdown to
facilitate drift correction. With the current
behavior hwclock will clobber the drift factor to
near zero, because the Hardware Clock and System
Clock are synced by Eleven Minute Mode. What
actually needs to be done is refresh the adjtime
file timestamps and not calculate a new drift
factor.
Because it is a manual process to craft a good
Hardware Clock drift factor, that is, there is no
automated method that will produce a good drift
factor, this patch changes the default drift
calculation behavior to off, and it is turned on
by using the --update-drift option. Once we have a good
drift factor for a given machine we do not want
anything clobbering it, including an administrator
forgetting to turn off recalculation. A system
administrator should make a concious effort in
telling hwclock with the --update-drift option that
(s)he wants to recalculate the drift factor.
Without using the --update-drift option with calibrate
operations only the timestamps are refreshed in
the adjtime file. With the --update-drift option the old
default behavior of refreshing the timestamps and
updating the drift factor is performed.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
When hctosys is used at boot time, making it the
first caller of settimeofday, the responsibility
of setting persistent_clock_is_local is thrust
upon it. Currently hctosys always leaves this
variable uninitialized. This causes a Hardware
Clock configured to use the local timescale to be
clobbered with the UTC timescale by the kernel's
NTP eleven minute mode.
This patch fixes this hctosys bug, by having it
properly set persistent_clock_is_local according
to the time scale configured for the Hardware
Clock.
It does this via the kernel warp_clock function
but this in inconsequential, because we set the
system time immediately afterward.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
More precise setting of the System Clock early in
the boot process when --adjust cannot be used
because the file system is not writeable.
Applies sub second drift corrections immediately,
where as --adjust cannot.
Reduces boot time by not calling hwclock multiple
times, e.g., --hctosys early before fsck when the
file system is read-only, then --adjust later when
the file system is read-write and --hctosys again
for drift correction.
Use of --adjust elsewhere may no longer be
necessary.
Part II
After the original submission of this patch I
realized that now all operations except --systz
require drift corrected Hardware Clock time.
Therefore, it should be done only once early in
the process. Upon implementation of that premise
many improvements were facilitated:
* Adds drift correction to --hctosys.
* Adds setting system time with sub-second precision.
* Adds --get, a drift corrected 'show' operation.
* Improves drift factor calculation precision while
greatly simplifying its algorithm.
* Fixes --show bug, printing integer sub-seconds, and
now uses a more intuitive positive value.
* Fixes --predict bug, drift correction must be
negated to predict future RTC time.
* Reduces the number of function arguments and
lines of code.
Signed-off-by: J William Piggott <elseifthen@gmx.com>