Eric Rannaud [Fri, 27 Jun 2014 05:18:48 +0000 (22:18 -0700)]
findmnt: use mnt_cache_set_targets() for non-kernel table
findmnt compares the user-supplied path <target> with each entry in the
parsed table. To do this comparison, libmount attempts to canonicalize
the target path of each table entry, when the entry does not originate
from the kernel (kernel supplied target paths are already
canonicalized). However, if one of these entries is an active mount
point, stat(2) or readlink(2) on the mount target path can hang (e.g.
unreachable NFS server).
If the main table is not a kernel table, we parse /proc/self/mountinfo
into a secondary table and call mnt_cache_set_targets(). This allows
libmount to check that the target path of each entry in the main table
is not an active mount point, so it can avoid canonicalizing it.
Eric Rannaud [Fri, 27 Jun 2014 05:17:18 +0000 (22:17 -0700)]
libmount: mnt_resolve_target: tiptoe around active mount points
Current code in mnt_fs_match_target() and mnt_table_find_target()
already does not canonicalize active mount points (when read from
mountinfo), because they are already canonicalized by the kernel.
Calling realpath(fs->target) on a mount point can hang -- e.g. if the
NFS server is unreachable.
This patch optionally extends this strategy to the general case, that is
when @fs does not directly come from the kernel through mountinfo (for
instance, it may have been parsed from /etc/fstab).
Given @mtab parsed from mountinfo, and if mnt_cache_set_targets(cache,
mtab) is used, then mnt_fs_match_target() and mnt_table_find_target()
check whether @fs->target is a known mount point in the cached
mountinfo, before attempting to canonicalize @fs->target, no matter
where @fs itself comes from. If found in the cached mountinfo,
@fs->target is not canonicalized.
[kzak@redhat.com: - don't allocate libmnt_iter,
- add docs for mnt_cache_set_targets(),
- fallback to mnt_resolve_path() if no cache->mtab specified,
- use streq_except_trailing_slash() to compare paths]
Signed-off-by: Eric Rannaud <e@nanocritical.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Eric Rannaud [Fri, 27 Jun 2014 05:17:17 +0000 (22:17 -0700)]
libmount: mnt_resolve_path: don't canonicalize fs->target for swap
This is how mnt_table_find_target() does it. It makes sense because
@fs->target is "none" for swap and is never a sensible match for a
user-specified target.
setterm: improve formatting and wording of usage text
Mainly: showing that the word color is a placeholder by writing
<color>, showing some numbers as optional, and message levels
and colors as not optional.
setterm: improve wording and formatting of the man page
The main changes are: showing the arguments of boolean options
as optional, improving the alphabetization, and restoring the
--half-bright option that went missing in 2011.
Karel Zak [Tue, 24 Jun 2014 08:32:25 +0000 (10:32 +0200)]
libfdisk: (dos) count fisrt usable LBA to total number of used sectors
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).
Thorsten Wilmer [Tue, 24 Jun 2014 07:38:30 +0000 (09:38 +0200)]
libfdisk: (dos) calculation of total size based on CHS in check function
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
Karel Zak [Mon, 23 Jun 2014 10:42:33 +0000 (12:42 +0200)]
libmount: special treatment for auto in fstype pattern
Let's support
mount -t ext2,auto /dev/sde /media/stick
Reported-by: Andreas Henriksson <andreas@fatal.se>
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506695 Signed-off-by: Karel Zak <kzak@redhat.com>
peppe [Sun, 22 Jun 2014 12:23:25 +0000 (14:23 +0200)]
hwclock: sometimes one day lasts 23 hours.
If less than 23 hours have passed since the last calibration, hwclock
says "Not adjusting drift factor because it has been less than a day since
the last calibration.", but in fact compares to 23 hours, not 24.
This was originally reported at:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689534
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
James Hunt [Sat, 21 Jun 2014 23:03:04 +0000 (01:03 +0200)]
script: --quiet option is not quiet.
Specifying 'script --quiet ...' still produces the 'Script started'
message in the typescript file. The --quiet option implies that the
script program should not log any of its output to the typescript file.
Originally reported at:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693966
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Karel Zak [Mon, 16 Jun 2014 13:47:50 +0000 (15:47 +0200)]
findmnt: add --nocanonicalize to avoid realpath()
* in some cases is realpath() overkill
* sometimes you want to search for explicitly specified paths (e.g.
"findmnt --fstab /mnt/symlink") rather than for real paths
* you want to avoid readlink() and stat() on NFS
Thomas Petazzoni [Thu, 12 Jun 2014 20:10:27 +0000 (22:10 +0200)]
Only move shared libraries to /lib if they exists
In several Makemodule.am, there is a install-exec-hook-<library>
target whose role is to move the shared library from /usr/lib to /lib,
while keeping a symbolic link /usr/lib/libuuid.so ->
../../lib/<library>.so.<version>.
However, when util-linux is built with --enable-static
--disable-shared (as is needed on noMMU platforms that don't support
shared libraries), no <library>.so is built, but the
install-exec-hook-libuuid creates an invalid /usr/lib/<library>.so
symbolic link, pointing to ../../lib (yes, the directory). This causes
troubles later one when other libraries/programs are compiled with
-l<library>, as gcc thinks a shared library is available because
there's a file named /usr/lib/<library>.so.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Karel Zak [Mon, 16 Jun 2014 12:37:39 +0000 (14:37 +0200)]
Merge branch 'tests-utmp' of https://github.com/rudimeier/util-linux
* 'tests-utmp' of https://github.com/rudimeier/util-linux:
tests: skip some last tests if no dns support
tests: split last into dns and nodns subtests
tests: add utmpdump-circle test (arch independent)
tests: provide missing test data for "last" on exotic archs
tests: skip utmpdump tests for exotic archs
tests: merge last/ and utmpdump/ into new utmp/ dir
utmpdump: fix localtime() error handling
Ruediger Meier [Wed, 11 Jun 2014 15:31:56 +0000 (17:31 +0200)]
utmpdump: fix localtime() error handling
If current TZ has no representation of a given time_t then localtime()
would return NULL and break the next strftime().
In practice this happens very likely on systems with 64bit time_t when
parsing broken binary data. Seen on aarch64 (and probably s390) using
our (incompatible) test wtmp data.
Ruediger Meier [Tue, 10 Jun 2014 16:44:08 +0000 (18:44 +0200)]
build-sys: fix autopoint gettext version fun
We avoid or fix many portability issues.
The first more generic "sort --version-sort" solution was almost
useless anyway because autopoint itself can also only deal with
a few hardcoded versions.
Karel Zak [Tue, 10 Jun 2014 10:16:59 +0000 (12:16 +0200)]
libblkid: ignore private LVM devices
The virtual private LVM devices do not contain any blkid relevant data
and it does not make any sense to scan for superblocks or partitions
on the devices, because we can interpret data from the devices in bad
way.
Unfortunately, for LVM has "private" very special meaning. The private
LVM devices are accessible and readable (according to LVM guys it's
feature, because debugging etc.).
The problem is pretty visible with LVM thin provisioning where a virtual
pool device contains segments from the top-level thin devices.
LVM uses special UUID suffixes for private devices. All devices with
uuid in format "LVM-<uuid>-<type>" are private.
This patch modifies libblkid to not scan such devices. The high-level
API ignores such devices at all now.
The low-level API allows to assign the device to blkid_prober, but all
scan functions always return nothing and library does not read
anything from the device. The another functionality (get parental
device, topology, sector sizes, etc.) still works as expected. The
change affects only probing code.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1101345 Signed-off-by: Karel Zak <kzak@redhat.com>