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>
blkdiscard: fix underflow when offset is greater than device size
If offset (range[0]) is greater than device size (blksize), the variable 'end'
will be greater than blksize, and range[1] (length) will be recalculated.
The underflow happens when subtracting range[0] (offset) from blksize, thus
range[1] will be the result of an underflow. The bug leads to unwanted behavior
from the program, where range[1] is likely to be a high number and then will
discard a considerable amount of blocks from the device. The fix consists of
exitting the program with an error message when the condition stated above is
true. Spotted while auditing the code.
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Helmut Grohne [Tue, 7 Oct 2014 21:07:19 +0000 (23:07 +0200)]
build-sys: check for libtoolize rather than libtool
The system libtool program has architecture dependent behaviour. It is
therefore unavailable in cross build environments. The only place it was
used in util-linux is autogen.sh to determine the availability of
libtool. All other places correctly use libtoolize or
$(top_builddir)/libtool.
Karel Zak [Thu, 9 Oct 2014 10:10:36 +0000 (12:10 +0200)]
libfdisk: (dos) follow explicit sizes
* 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.