]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
7 years agodocs: improve setarch(8) manual page
Sami Kerola [Sun, 10 Dec 2017 10:50:32 +0000 (10:50 +0000)] 
docs: improve setarch(8) manual page

Add more information when and why one might want to use various options.

Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agotests: unlocks on failed ts_scsi_debug_init
Karel Zak [Thu, 7 Dec 2017 14:08:29 +0000 (15:08 +0100)] 
tests: unlocks on failed ts_scsi_debug_init

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: don't call tests with races in --parallel
Karel Zak [Thu, 7 Dec 2017 13:41:49 +0000 (14:41 +0100)] 
tests: don't call tests with races in --parallel

Some of the tests have a race by design (=wanted).

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: support multiple locks
Karel Zak [Thu, 7 Dec 2017 13:41:08 +0000 (14:41 +0100)] 
tests: support multiple locks

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: add mdadm locks
Karel Zak [Thu, 7 Dec 2017 11:31:41 +0000 (12:31 +0100)] 
tests: add mdadm locks

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: add debug messages when ignore useless devices
Karel Zak [Thu, 7 Dec 2017 11:15:34 +0000 (12:15 +0100)] 
libblkid: add debug messages when ignore useless devices

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: Add VDO superblock information into blkid
Sweet Tea Dorminy [Wed, 6 Dec 2017 23:26:59 +0000 (18:26 -0500)] 
libblkid: Add VDO superblock information into blkid

[kzak@redhat.com: - add tests/expected/blkid/low-probe-vdo
                  - enlarge the image (must be > 1024)]

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: use flock to modify fstab
Karel Zak [Wed, 6 Dec 2017 13:38:44 +0000 (14:38 +0100)] 
tests: use flock to modify fstab

Note that for btrfs test we need to use low-level ts_fstab_addline,
because we add multiple lines there.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: add lock on shared resources (e.g. scsi_debug)
Karel Zak [Wed, 6 Dec 2017 13:21:38 +0000 (14:21 +0100)] 
tests: add lock on shared resources (e.g. scsi_debug)

The patch enables flock for scsi_debug to avoid collision between
tests. The patch also adds ./run.sh --nolocks to disable this feature.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agosetarch: minor code clean up
Sami Kerola [Sun, 3 Dec 2017 12:51:17 +0000 (12:51 +0000)] 
setarch: minor code clean up

Remove global variable, skip unnecessary comparison, and remove version
printing function when a simple printf() can do the job.  In same go fix
compiler warning.

sys-utils/setarch.c:296:4: warning: null argument where non-null required
(argument 2) [-Wnonnull]
    execl("/bin/bash", NULL);

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorename: use access(3) to check if a file exists
Sami Kerola [Sun, 3 Dec 2017 12:51:15 +0000 (12:51 +0000)] 
rename: use access(3) to check if a file exists

This is more lightweight than calling stat(3).  In same go add a regression
test to ensure changes like this will not break --no-overwrite option.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agovipw: do not let editor to inherit open file descriptors
Sami Kerola [Sun, 3 Dec 2017 12:51:14 +0000 (12:51 +0000)] 
vipw: do not let editor to inherit open file descriptors

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agologin: add LOGIN_PLAIN_PROMPT to login.defs
Karel Zak [Mon, 4 Dec 2017 11:31:29 +0000 (12:31 +0100)] 
login: add LOGIN_PLAIN_PROMPT to login.defs

We have command line option -H to disable hostname in login prompt.
Unfortunately, in same cases (e.g. telnetd) it's impossible to specify
login(1) command line options due to hardcoded execl()...

This patch introduces LOGIN_PLAIN_PROMPT boolean for /etc/login.defs
to suppress hostname in the prompt.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agofallocate: remove typo
Karel Zak [Wed, 29 Nov 2017 14:13:24 +0000 (15:13 +0100)] 
fallocate: remove typo

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agofallocate: dig holes only in data extents
Karel Zak [Wed, 29 Nov 2017 13:26:42 +0000 (14:26 +0100)] 
fallocate: dig holes only in data extents

Based on patch from Vaclav Dolezal <vdolezal@redhat.com>, this
implementation is less invasive.

The patch adds a new while() for pread() call (so diff is mostly code
indention). The pread() is called for a real data only (addressed by
'off' and 'end') and we use SEEK_{DATA,HOLE} before the pread() to
skip already existing holes. The variables 'file_off' and 'file_end'
addresses area in the file as specified on fallocate command line.

Test:

$ truncate -s 10G testfile
$ dd if=/dev/zero of=testfile count=10 bs=1M conv=notrunc

old version:

$ time /usr/bin/fallocate --dig-holes --verbose testfile
testfile: 10 GiB (10737418240 bytes) converted to sparse holes.

real 0m3.013s
user 0m0.700s
sys 0m2.304s

new version:

$ time ./fallocate --dig-holes --verbose testfile
testfile: 10 MiB (10485760 bytes) converted to sparse holes.

real 0m0.026s
user 0m0.002s
sys 0m0.004s

The old version scans all file.

The change has minimal overhead for files without holes.

Addresses: https://github.com/karelzak/util-linux/issues/421
Co-Author: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agologin-utils: use free_getlogindefs_data()
Karel Zak [Tue, 28 Nov 2017 13:49:05 +0000 (14:49 +0100)] 
login-utils: use free_getlogindefs_data()

It seems better to deallocate logindefs.conf stuff in long time
running (=waiting) processes like login(1) and su(1).

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoeject: remove list_speeds() #ifdef CDROM_SELECT_SPEED protection
Sami Kerola [Sun, 26 Nov 2017 17:47:51 +0000 (17:47 +0000)] 
eject: remove list_speeds() #ifdef CDROM_SELECT_SPEED protection

The CDROM_SELECT_SPEED should be available practically everywhere.  Where
the define is missing an error message about path /proc/sys/dev/cdrom/info
cannot be opened is better error than a warnx() about kernel support.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agolib/signames: remove unused function
Sami Kerola [Sun, 26 Nov 2017 17:47:49 +0000 (17:47 +0000)] 
lib/signames: remove unused function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agoman: use long options in text and add example to uuidgen
Sami Kerola [Sun, 26 Nov 2017 17:27:21 +0000 (17:27 +0000)] 
man: use long options in text and add example to uuidgen

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agomisc: fix typos
Sami Kerola [Sun, 26 Nov 2017 17:27:20 +0000 (17:27 +0000)] 
misc: fix typos

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agotests: check for HAVE_LINUX_NET_NAMESPACE_H
Karel Zak [Tue, 28 Nov 2017 12:19:20 +0000 (13:19 +0100)] 
tests: check for HAVE_LINUX_NET_NAMESPACE_H

* use one cleanup function
* check if kernel headers support net namespace
* enable netnsid test

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: add set-x to lsns test
Karel Zak [Tue, 28 Nov 2017 11:00:58 +0000 (12:00 +0100)] 
tests: add set-x to lsns test

.. just to see why does it fail on Travis.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: better lsns report on fail
Karel Zak [Tue, 28 Nov 2017 10:17:18 +0000 (11:17 +0100)] 
tests: better lsns report on fail

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: make lsns test more robust
Karel Zak [Tue, 28 Nov 2017 09:58:37 +0000 (10:58 +0100)] 
tests: make lsns test more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agonsenter: fix compiler warning [-Wuninitialized]
Karel Zak [Tue, 28 Nov 2017 09:53:35 +0000 (10:53 +0100)] 
nsenter: fix compiler warning [-Wuninitialized]

sys-utils/nsenter.c: In function ‘is_same_namespace’:
sys-utils/nsenter.c:170:2: warning: ‘b_ino’ may be used uninitialized in this function [-Wuninitialized]
sys-utils/nsenter.c:170:2: warning: ‘a_ino’ may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agodmesg: fix compiler warning [-Wuninitialized]
Karel Zak [Tue, 28 Nov 2017 09:45:06 +0000 (10:45 +0100)] 
dmesg: fix compiler warning [-Wuninitialized]

sys-utils/dmesg.c: In function ‘print_record.constprop.12’:
sys-utils/dmesg.c:1039:14: warning: ‘mesg_size’ may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agobuild-sys: lsns requires libmount
Karel Zak [Mon, 27 Nov 2017 16:44:43 +0000 (17:44 +0100)] 
build-sys: lsns requires libmount

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolsns: initialize stuff when really necessary
Karel Zak [Mon, 27 Nov 2017 16:40:56 +0000 (17:40 +0100)] 
lsns: initialize stuff when really necessary

It's more robust to depend on list of the wanted columns than on
another variables.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: fix lsns perms
Karel Zak [Mon, 27 Nov 2017 16:33:28 +0000 (17:33 +0100)] 
tests: fix lsns perms

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolsns: rename notruns to no_trunc
Karel Zak [Mon, 27 Nov 2017 16:04:29 +0000 (17:04 +0100)] 
lsns: rename notruns to no_trunc

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolsns: nsfs stuff cleanup
Karel Zak [Mon, 27 Nov 2017 15:58:19 +0000 (16:58 +0100)] 
lsns: nsfs stuff cleanup

* don't use booleans
* use is_ prefix for boolean-like functions
* make nsfs_xasputs() more readable
* enable 'nowrap' together with 'raw' and don't test for "nowrap || raw"
* add missing 'W' to getopt_long()

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolsns: (man) write about using multi-line in NSFS cell of lsns
Masatake YAMATO [Fri, 24 Nov 2017 10:31:10 +0000 (19:31 +0900)] 
lsns: (man) write about using multi-line in NSFS cell of lsns

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: add a case for testing nsfs column
Masatake YAMATO [Fri, 24 Nov 2017 10:31:09 +0000 (19:31 +0900)] 
lsns: add a case for testing nsfs column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: add --nowrap(-W) option
Masatake YAMATO [Fri, 24 Nov 2017 10:31:08 +0000 (19:31 +0900)] 
lsns: add --nowrap(-W) option

This option forces lsns command not use
multi-line presentation when printing a cell.

Currently, it affects only NSFS column.

Implementing this option is suggested by Karl Zak.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: add nsfs column
Masatake YAMATO [Fri, 24 Nov 2017 10:31:06 +0000 (19:31 +0900)] 
lsns: add nsfs column

nsfs provides kernel level interface for assigning
logical name to a namespace. Following message is quoted
from git log of linux kernel:

    commit 0226f4923f6c9b40cfa1c1c1b19a6ac6b3924ead
    Author: Al Viro <viro@zeniv.linux.org.uk>
    Date:   Tue Dec 6 12:21:54 2011 -0500

vfs: take /proc/*/mounts and friends to fs/proc_namespace.c

rationale: that stuff is far tighter bound to fs/namespace.c than to
the guts of procfs proper.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
/proc/self/mountinfo lists the logical names for namespaces:
  ...
  652 81 0:3 net:[4026532579] /tmp/XYZ rw shared:192 - nsfs nsfs rw,seclabel
  ...

In the lines /tmp/XYZ is a logical name for 4026532579 of net
namespace.

This patch adds nsfs column. It seems that the logical name is
used only in "ip netns" now. So the column is disabled by default.
Use '--type=net' or '-o NSFS' options to enable it.

This feature and the way to implementation using multi lines in a column
is Suggested by Karel Zak.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: add a case for testing netnsid column
Masatake YAMATO [Fri, 24 Nov 2017 10:31:05 +0000 (19:31 +0900)] 
lsns: add a case for testing netnsid column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: disable netnsid column by default
Masatake YAMATO [Fri, 24 Nov 2017 10:31:04 +0000 (19:31 +0900)] 
lsns: disable netnsid column by default

Enable only when

* --type=net is given, or
* -o NETNSID is given.

Suggested by Karel Zak.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: add netnsid column
Masatake YAMATO [Fri, 24 Nov 2017 10:31:03 +0000 (19:31 +0900)] 
lsns: add netnsid column

Linux network subsystem assigns an unique integer to a network
namespace.

  term0# ip netns add UTIL-LINUX-LSNS-TEST-NS
  term0# ip netns list
  UTIL-LINUX-LSNS-TEST-NS
  term0# ip link add name lsns-vetha type veth peer name lsns-vethb
  term0 # ip link set lsns-vethb netns UTIL-LINUX-LSNS-TEST-NS
  term0# ip netns list
  UTIL-LINUX-LSNS-TEST-NS (id: 0)
  term0# ip link show dev lsns-vetha
  230: lsns-vetha@if229: <BROADCAST,MULTICAST> mtu 1500 qdisc noop ...
         link/ether 3e:27:68:ba:b3:95 brd ff:ff:ff:ff:ff:ff link-netnsid 0
In this example 0 is assigned to UTIL-LINUX-LSNS-TEST-NS net namespace.
The name, UTIL-LINUX-LSNS-TEST-NS, and it semantics is given and defined
by iproute2 in userland; and nothing to do with util-linux.

However, the id, 0, is managed in linux kernel. If lsns can show
the ids, it helps users understand the state of network namespaces.

This commit adds NETNSID column to the output.

Here is an example of session:

  term0# ip netns exec UTIL-LINUX-LSNS-TEST-NS cat

  (Open another terminal)

  term1# ./lsns --type net
          NS TYPE NPROCS   PID USER     NETNSID COMMAND
  4026531993 net     383     1 root  unassigned /usr/lib/systemd/...
  4026532433 net       1  1219 rtkit unassigned /usr/libexec/rtkit-daemon
  4026532562 net       1 18201 root           0 cat

0 is shown as NETNSID for the cat process.

For the initial name space, "unassigned" is printed.
For the namespaces other type than net, "n/a" is printed.
If an error occurred during getting the id, "n/a" is printed.

Changes in V2:

* Remove wrongly used & operators.
* Make netnsid field empty if value for the column is not available.
  Suggested by Karel Zak.
* Remove redundant condtion for checking the avaiablebility of netlink
  socket. Suggested by Karel Zak.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agortcwake: fix sys vs. rtc time delta usage
Karel Zak [Mon, 27 Nov 2017 11:37:53 +0000 (12:37 +0100)] 
rtcwake: fix sys vs. rtc time delta usage

srett commented:

 After some head scratching why relative wakeup using -s always works
 while -t didn't seem to work at all I discovered that the adjustment
 for time difference between sys and rtc is actually inverted when
 writing the alarm (code for -m show reading is fine), so if the RTC
 lags 10 minutes behind, the alarm will be shifted into the future by
 10 minutes, resulting in a wakeup that is 20 minutes late.

Addresses: https://github.com/karelzak/util-linux/issues/544
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibsmartcols: fix mem-leaks in samples
Karel Zak [Thu, 23 Nov 2017 14:24:59 +0000 (15:24 +0100)] 
libsmartcols: fix mem-leaks in samples

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: allow to use memory checks for libsmartcols
Karel Zak [Thu, 23 Nov 2017 14:24:36 +0000 (15:24 +0100)] 
tests: allow to use memory checks for libsmartcols

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agodocs: update TODO file
Karel Zak [Thu, 23 Nov 2017 14:02:32 +0000 (15:02 +0100)] 
docs: update TODO file

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agobuild-sys: add --enable-asan and --memcheck-asan for tests
Karel Zak [Thu, 23 Nov 2017 13:59:05 +0000 (14:59 +0100)] 
build-sys: add --enable-asan and --memcheck-asan for tests

The command ./configure --enable-asan adds -fsanitize=address
to the compiler command line. In the regression tests leaks detection
is disabled by default. You have to use --memcheck-asan on test
command line to enable.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: rename --memcheck to --memcheck-valgrind
Karel Zak [Thu, 23 Nov 2017 13:03:23 +0000 (14:03 +0100)] 
tests: rename --memcheck to --memcheck-valgrind

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: rename ts_valgrind to ts_run
Karel Zak [Thu, 23 Nov 2017 12:44:53 +0000 (13:44 +0100)] 
tests: rename ts_valgrind to ts_run

Let's make our tests more generic, so we can later hide more stuff
into ts_run call.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agohwclock: revert ioctl test
Karel Zak [Thu, 23 Nov 2017 09:30:27 +0000 (10:30 +0100)] 
hwclock: revert ioctl test

This commit reverts 1d5cffa16a0183175684809cf215294ec20b8fd9.

(I did this revert manually as there was another changes in the code
and git-revert does not work in this case.)

Addresses: https://github.com/karelzak/util-linux/issues/543
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: update columns test due to dda229c7b2b16a31fae8e99079ab4f4ae5bc8eac
Karel Zak [Wed, 22 Nov 2017 16:16:21 +0000 (17:16 +0100)] 
tests: update columns test due to dda229c7b2b16a31fae8e99079ab4f4ae5bc8eac

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agocolumn: use \x<hex> for invalid multibyte seq.
Karel Zak [Wed, 22 Nov 2017 13:43:36 +0000 (14:43 +0100)] 
column: use \x<hex> for invalid multibyte seq.

Addresses: https://github.com/karelzak/util-linux/issues/542
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolib/mbsalign: add mbs_invalid_encode()
Karel Zak [Wed, 22 Nov 2017 13:41:10 +0000 (14:41 +0100)] 
lib/mbsalign: add mbs_invalid_encode()

Like mbs_safe_encode(), but it does not care about control chars.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agomount: add hint about -t and root perms to the man page
Karel Zak [Wed, 22 Nov 2017 11:45:33 +0000 (12:45 +0100)] 
mount: add hint about -t and root perms to the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolsblk: add hint about perms to man page
Karel Zak [Wed, 22 Nov 2017 11:31:58 +0000 (12:31 +0100)] 
lsblk: add hint about perms to man page

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Tue, 21 Nov 2017 11:42:35 +0000 (12:42 +0100)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Fix parsing UDF revision

7 years agolibmount: add nsfs between pseudo filesystems
Karel Zak [Tue, 21 Nov 2017 11:11:56 +0000 (12:11 +0100)] 
libmount: add nsfs between pseudo filesystems

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoagetty: Fix a use of uninitialised memory in an agetty error path.
Steven Smith [Fri, 17 Nov 2017 16:44:33 +0000 (08:44 -0800)] 
agetty: Fix a use of uninitialised memory in an agetty error path.

get_logname() assumes that when it calls read() it initializes c and
errno, which isn't always true if we hit a whitelisted error or end of
file. This occasionally shows up as agetty going into an infinite
loop. Fix it by just delaying ten seconds and exiting when things go
wrong, similarly to the behavior after a non-whitelisted error.

[kzak@redhat.com: - interpret readres == 0 as c = 0
                  - ignore speed configurations for VCONSOLE]

Signed-off-by: Steven Smith <sos22@srcf.ucam.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: Mark char* params to blkid_dev_set_search as const
Andy Grover [Mon, 20 Nov 2017 20:09:50 +0000 (12:09 -0800)] 
libblkid: Mark char* params to blkid_dev_set_search as const

They are not changed by the function.

Signed-off-by: Andy Grover <agrover@redhat.com>
7 years agolibblkid: udf: Fix parsing UDF revision
Pali Rohár [Mon, 20 Nov 2017 17:16:59 +0000 (18:16 +0100)] 
libblkid: udf: Fix parsing UDF revision

UDF revision is stored as decimal number in hexadecimal format.
E.g. number 0x0150 is revision 1.50, number 0x0201 is revision 2.01.

Apparently all UDF test images have number which has same representation in
decimal and hexadecimal format, so problem was not detected.

This patch adds new test image with UDF revision 1.50. Internally number is
stored as 0x0150. In decimal format it is (incorrectly) 1.80, but in
hexadecimal correct 1.50.

$ dd if=/dev/zero of=udf-hdd-mkudffs-1.3-8.img bs=1M count=10
$ mkudffs -r 0x150 -b 512 udf-hdd-mkudffs-1.3-8.img

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
7 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Mon, 20 Nov 2017 12:30:20 +0000 (13:30 +0100)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Update copyright
  tests: Add UDF cd image created by mkudfiso 20100208
  libblkid: udf: Use UDF revision field from LVD domain id "*OSTA UDF Compliant" as a fallback value for ID_FS_VERSION when LVIDIU is missing

7 years agohwclock: fix debug regression
J William Piggott [Sat, 18 Nov 2017 01:25:40 +0000 (20:25 -0500)] 
hwclock: fix debug regression

commit f0a0ce7 makes debug mode implicit for the --test option.

Using the previous command syntax of --test and --debug
together invokes the undocumented Level 2 debugging when
setting the RTC. This can cause many thousands of lines of
output like:
1510967983.499968 < 1510967983.500000 (-0.000032)

Fix: bump Level 2 debugging to Level 9, just before the
other undocumented Level 10. This makes it improbable for
the development debug levels to be accessed unintentionally.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: use reentrant time conversion functions
J William Piggott [Sun, 22 Oct 2017 00:40:58 +0000 (20:40 -0400)] 
hwclock: use reentrant time conversion functions

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agolibblkid: udf: Update copyright
Pali Rohár [Thu, 16 Nov 2017 18:53:59 +0000 (19:53 +0100)] 
libblkid: udf: Update copyright

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
7 years agotests: Add UDF cd image created by mkudfiso 20100208
Pali Rohár [Thu, 16 Nov 2017 18:45:16 +0000 (19:45 +0100)] 
tests: Add UDF cd image created by mkudfiso 20100208

$ mkudfiso -v "Volume Label" . | tail -n +2 > udf-cd-mkudfiso-20100208.img

mkudfiso 20100208 creates UDF images without valid LVID (and LVIDIU), so it
is a good candidate for testing fallback code for ID_FS_VERSION.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
7 years agolibblkid: udf: Use UDF revision field from LVD domain id "*OSTA UDF Compliant" as...
Pali Rohár [Thu, 16 Nov 2017 17:53:52 +0000 (18:53 +0100)] 
libblkid: udf: Use UDF revision field from LVD domain id "*OSTA UDF Compliant" as a fallback value for ID_FS_VERSION when LVIDIU is missing

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
7 years agobash-completion: (umount) use findmnt, escape a space in paths
Karel Zak [Thu, 16 Nov 2017 15:27:32 +0000 (16:27 +0100)] 
bash-completion: (umount) use findmnt, escape a space in paths

 # mount /dev/sdc1 /mnt/test/foo\ bar
 # umount <tab>

has to return "/mnt/test/foo\ bar".

Changes:

 * don't use mount | awk output, we have findmnt
 * force compgen use \n as entries separator

Addresses: https://github.com/karelzak/util-linux/issues/539
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agobuild-sys: add missing include
Karel Zak [Thu, 16 Nov 2017 13:41:01 +0000 (14:41 +0100)] 
build-sys: add missing include

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Thu, 16 Nov 2017 13:18:16 +0000 (14:18 +0100)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Stop scanning Volume Descriptors after we found Terminating Descriptor
  libblkid: udf: Really try to read only first LVID

7 years agolibfdisk: (sun) enhance searching of free space
Mikhail Vorobyov [Thu, 9 Nov 2017 03:47:16 +0000 (06:47 +0300)] 
libfdisk: (sun) enhance searching of free space

Potential partition start should be aligned to cylinders. So fdisk
wouldn't consider partition's last cylinder remains as eligible space
for new partition start.

7 years agolibfdisk: (sun) move aligning of the first sector before availability check
Mikhail Vorobyov [Thu, 9 Nov 2017 03:37:28 +0000 (06:37 +0300)] 
libfdisk: (sun) move aligning of the first sector before availability check

So it will check a sector which would be actualy used as the first sector
of the partition.

7 years agolibmount: minimize utimensat() write test usage
Karel Zak [Thu, 16 Nov 2017 11:16:09 +0000 (12:16 +0100)] 
libmount: minimize utimensat() write test usage

utimensat() is pretty expensive when mounting parallel filesystems from
the same source. It's possible to ignore all this if mtab is not
writable.

Note that this change is irrelevant for default util-linux builds
where all around mtab is already disabled since v2.30 (commit
89958178f6d6ebe0944d423feaea66be521fff43).

This change is relevant only for users who still use --enable-libmount-support-mtab.

Reported-by: Douglas Jacobsen <dmjacobsen@lbl.gov>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: Add support for Micron mpool formatted drives
John Groves [Thu, 16 Nov 2017 05:01:39 +0000 (23:01 -0600)] 
libblkid: Add support for Micron mpool formatted drives

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolib: Add simple crc32c() function
John Groves [Thu, 16 Nov 2017 05:01:38 +0000 (23:01 -0600)] 
lib: Add simple crc32c() function

Source: freebsd/sys/libkern/crc32.c
This code is an unmodified fragment from the source.  Will fixup
comments / naming in next commit

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agomount: add more details about UUIDs and LABELs to the man page
Karel Zak [Thu, 16 Nov 2017 10:39:17 +0000 (11:39 +0100)] 
mount: add more details about UUIDs and LABELs to the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: udf: Stop scanning Volume Descriptors after we found Terminating Descriptor
Pali Rohár [Wed, 15 Nov 2017 17:12:50 +0000 (18:12 +0100)] 
libblkid: udf: Stop scanning Volume Descriptors after we found Terminating Descriptor

Terminating Descriptor is the last descriptor in Volume Descriptor
Sequence. After it there can be unrecorded or empty sectors which we do not
have to scan.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
7 years agolibblkid: udf: Really try to read only first LVID
Pali Rohár [Wed, 15 Nov 2017 17:05:52 +0000 (18:05 +0100)] 
libblkid: udf: Really try to read only first LVID

We do not want to scan whole LVID sequence.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
7 years agotests: GPT device resize test
Karel Zak [Tue, 14 Nov 2017 14:40:09 +0000 (15:40 +0100)] 
tests: GPT device resize test

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: (gpt) move backup header after device resize
Karel Zak [Tue, 14 Nov 2017 12:51:48 +0000 (13:51 +0100)] 
libfdisk: (gpt) move backup header after device resize

Addresses: https://github.com/karelzak/util-linux/issues/532
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: udf: Fix parsing LVID location
Pali Rohár [Tue, 14 Nov 2017 09:25:02 +0000 (10:25 +0100)] 
libblkid: udf: Fix parsing LVID location

And add comment about Logical Volume Integrity Sequence that we do not scan it fully.

7 years agolibblkid: udf: Fix reading Logical Volume Integrity Descriptor Implementation Use...
Pali Rohár [Mon, 13 Nov 2017 20:45:34 +0000 (21:45 +0100)] 
libblkid: udf: Fix reading Logical Volume Integrity Descriptor Implementation Use (LVIDIU)

LVIDIU is stored at the end of Logical Volume Integrity Descriptor (LVID),
after two variable length array of partitions. And number of partitions is
stored in LVID, not in Logical Volume Descriptor (LVD).

Length of LVIDIU is also stored in LVID, so add check that LVIDIU has
enough size.

Fixes commit db316767434c2c451ec1732861256d5729143e89.

7 years agocal: simplify leap year rule
Karel Zak [Mon, 13 Nov 2017 16:34:19 +0000 (17:34 +0100)] 
cal: simplify leap year rule

Gregorian rule for leap years has been adopted by reformation in year
1782 (Calendar Act 1750), but all tools (date, SQL servers, etc. etc.)
don't care about it and apply the new rule for all year -- including
years before the reformation.

It's better to be compatible with another tools than try to be perfect :-)

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1507271
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch '170925' of github.com:jwpi/util-linux
Karel Zak [Mon, 13 Nov 2017 15:25:21 +0000 (16:25 +0100)] 
Merge branch '170925' of github.com:jwpi/util-linux

* '170925' of github.com:jwpi/util-linux:
  tests: adjust for ISO timezone colon use
  lib/timeutils: add common ISO timestamp masks
  lib/timeutils: add get_gmtoff()
  lib/timeutils: ISO_8601_BUFSIZ too small
  hwclock: add iso-8601 overflow check

7 years agocolumn: allow to hide unnamed columns
Karel Zak [Mon, 13 Nov 2017 13:17:23 +0000 (14:17 +0100)] 
column: allow to hide unnamed columns

Addresses: https://github.com/karelzak/util-linux/pull/327
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agocolumn: add --table-noheadings
Karel Zak [Mon, 13 Nov 2017 11:56:21 +0000 (12:56 +0100)] 
column: add --table-noheadings

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch 'udf' of https://github.com/pali/util-linux
Karel Zak [Mon, 13 Nov 2017 11:32:03 +0000 (12:32 +0100)] 
Merge branch 'udf' of https://github.com/pali/util-linux

* 'udf' of https://github.com/pali/util-linux:
  test: Add UDF hdd image with final block size 4096 created by Linux mkudffs 1.3
  libblkid: udf: Optimize and fix probing when block size > 2048 bytes

7 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Mon, 13 Nov 2017 11:23:23 +0000 (12:23 +0100)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  libblkid: vfat: Fix reading labels which starts with byte 0x05

7 years agoblockdev: be more explicit for BLKSSZ in blockdev.8
Karel Zak [Mon, 13 Nov 2017 11:15:17 +0000 (12:15 +0100)] 
blockdev: be more explicit for BLKSSZ in blockdev.8

Addresses: https://github.com/karelzak/util-linux/issues/535
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotest: Add UDF hdd image with final block size 4096 created by Linux mkudffs 1.3
Pali Rohár [Sun, 12 Nov 2017 21:05:15 +0000 (22:05 +0100)] 
test: Add UDF hdd image with final block size 4096 created by Linux mkudffs 1.3

$ dd if=/dev/zero of=udf-hdd-mkudffs-1.3-7.img bs=1M count=10
$ mkudffs -l Label512 -b 512 udf-hdd-mkudffs-1.3-7.img
$ mkudffs -l Label4096 -b 4096 udf-hdd-mkudffs-1.3-7.img

Image file was first formatted with block size 512 and then reformatted
with block size 4096. Volume Recognition Sequence was overwritten and every
Volume Structure Descriptor is now 4096 bytes long. Trying to read second
VSD as 2048 bytes long will fail because 4069 bytes long VSD is padded with
zeros. To verify that image file was properly detected, it should have
label "Label4096" and not "Label512".

7 years agolibblkid: udf: Optimize and fix probing when block size > 2048 bytes
Pali Rohár [Sun, 12 Nov 2017 20:55:21 +0000 (21:55 +0100)] 
libblkid: udf: Optimize and fix probing when block size > 2048 bytes

Optimize probing and detecting for UDF. Do not read and try to detect VRS
(Volume Recognition Sequence) on same blocks more times. For specific VSD
(Volume Structure Descriptor) length do it only once.

Fix probing of devices which has block size larger then 2048 bytes. It is
not truth that VSD is always 2048 bytes long. Its size is minimum of the
disk block size and 2048 bytes. See ECMA-167 sections 2/8.4 and 2/9.1.
Therefore when block size is larger then 2048 bytes, VRS needs to be
scanned again.

In commit 501aeb60a4914d8e4b273eb1529d70bc6ffaa077 was removed check for
empty VSD identifier because it caused that UDF image with block size of
the 4096 bytes was not detected. Reason was that VRS was improperly scanned
as VSD was 4096 bytes long, with 2048 bytes zero padding.

Now when processing of devices with block size larger then 2048 bytes is
fixed we can correctly stop scanning VRS at first invalid VSD as specified
in ECMA-167 section 2/8.3.1.

7 years agotests: adjust for ISO timezone colon use
J William Piggott [Sun, 12 Nov 2017 14:08:43 +0000 (09:08 -0500)] 
tests: adjust for ISO timezone colon use

Fix several tests broken by adding a timezone colon in the
timeutils ISO format functions.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agolib/timeutils: add common ISO timestamp masks
J William Piggott [Sun, 15 Oct 2017 00:37:11 +0000 (20:37 -0400)] 
lib/timeutils: add common ISO timestamp masks

* Start the ISO format flags at bit 0 instead of bit 1.

* Remove unnecessary _8601 from ISO format flag names to
  avoid line wrapping and to ease readability.

* ISO timestamps have date-time-timzone in common, so move
  the TIMEZONE flag to bit 2 causing all timestamp masks
  to have the first three bits set and the last four bits
  as timestamp 'options'.

* Change the 'SPACE' flag to a 'T' flag, because it makes
  the code and comments more concise.

* Add common ISO timestamp masks.

* Implement the ISO timestamp masks in all applicable code
  using the strxxx_iso() functions.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agolib/timeutils: add get_gmtoff()
J William Piggott [Sun, 8 Oct 2017 20:06:24 +0000 (16:06 -0400)] 
lib/timeutils: add get_gmtoff()

This new function returns the GMT offset relative to its
argument. It is used in this patch to fix two bugs:

1) On platforms that the tm struct excludes tm_gmtoff,
   hwclock assumes a one hour DST offset. This can cause
   an incorrect kernel timezone setting. For example:

 Master branch tested with tm_gmtoff illustrates the correct offset:
$ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday
Calling settimeofday(1507494204.192398, -660)

 Master branch tested without tm_gmtoff has an incorrect offset:
$ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday
Calling settimeofday(1507494249.193852, -690)

 Patched tested without tm_gmtoff has the correct offset:
$ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday
Calling settimeofday(1507494260.194208, -660)

2) ISO 8601 'extended' format requires all time elements
   to use a colon (:).

Current invalid ISO 8601:
$ hwclock
2017-10-08 16:25:17.895462-0400

Patched:
$ hwclock
2017-10-08 16:25:34.141895-04:00

Also required by this change:
login-utils/last.c: increase ISO out_len and in_len by one to
                    accommodate the addition of the timezone colon.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agolib/timeutils: ISO_8601_BUFSIZ too small
J William Piggott [Tue, 26 Sep 2017 00:56:06 +0000 (20:56 -0400)] 
lib/timeutils: ISO_8601_BUFSIZ too small

Although iso-8601 specifies years as 4 digits, it allows
them to be wider.

The current POSIX year width is limited by 'int tm_year'
at 10 digits plus a negative sign.

That, and the possibility of nanosecond time makes the
widest POSIX iso-8601 time 41 characters. Plus the \0
string terminator yields a buffer size of 42.

Before truncated output:
/sbin/hwclock --utc --noadjfile --predict --date '-2147483765 years'
-2147481748-09-25 20:29:45.0000

Patched:
./hwclock --utc --noadjfile --predict --date '-2147483765 years'
-2147481748-09-25 20:17:21.000000-0456

./hwclock --utc --noadjfile --predict --date '-2147483766 years'
hwclock: invalid date '-2147483766 years'

Comparable to coreutils 'date' command:
date -Ins --date '-2147483765 years'
-2147481748-09-25T19:49:31,578899297-0456

date -Ins --date '-2147483766 years'
date: invalid date '-2147483766 years'

The 'date' output illustrates the full 41 character POSIX iso-8601

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: add iso-8601 overflow check
J William Piggott [Mon, 25 Sep 2017 23:30:24 +0000 (19:30 -0400)] 
hwclock: add iso-8601 overflow check

hwclock wasn't testing for strtimeval_iso() truncation:

/sbin/hwclock --utc --noadjfile --predict --date '7982 years'; echo $?
9999-09-25 19:33:01.000000-0400
0

/sbin/hwclock --utc --noadjfile --predict --date '7983 years'; echo $?
10000-09-25 19:33:10.000000-
0

Patched:
./hwclock --utc --noadjfile --predict --date '7982 years'; echo $?
9999-09-25 19:22:15.000000-0400
0

./hwclock --utc --noadjfile --predict --date '7983 years'; echo $?
hwclock: iso-8601 format truncated
1

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agonsenter: revert changes committed by accident
Karel Zak [Fri, 10 Nov 2017 13:02:51 +0000 (14:02 +0100)] 
nsenter: revert changes committed by accident

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: improve FreeBSD partitions parsing
Karel Zak [Fri, 10 Nov 2017 11:55:11 +0000 (12:55 +0100)] 
libblkid: improve FreeBSD partitions parsing

FreeBSD since version 10 uses relative offsets for nested partitions.
Based on Richard Narron changes in kernel:block/partitions/msdos.c.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: vfat: Fix reading labels which starts with byte 0x05
Pali Rohár [Thu, 9 Nov 2017 18:03:34 +0000 (19:03 +0100)] 
libblkid: vfat: Fix reading labels which starts with byte 0x05

When FAT directory entry has leading byte 0x05 it is interpreted as byte
0xE5. This is how FAT stores file name which starts with byte 0xE5 as
leading byte in 0xE5 in FAT directory entry means that file slot is empty.

Fixes: #533
7 years agolibmount: fix access() utab write test
Karel Zak [Wed, 8 Nov 2017 15:47:40 +0000 (16:47 +0100)] 
libmount: fix access() utab write test

The commit c08396c7691e1e6a04b6b45892e7e4612ceed8d7 replaces
open(O_CREATE) with ecaccess(). Unfortunately, another code depends on
the original behavior.

* let's make utab when really necessary rather than in the try_write() test

* __mnt_new_table_from_file() returns NULL if tab-file does not
 exists. This is incorrect for tab_update.c stuff. We need empty table
 in this case.

* we can check /run/mount/ directory for write access if
  eaccess(filename) return ENOENT (because file does not exist)

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibmount: Allow MNT_FORCE and MNT_DETACH at umount
Joshua Watt [Mon, 6 Nov 2017 22:25:36 +0000 (16:25 -0600)] 
libmount: Allow MNT_FORCE and MNT_DETACH at umount

MNT_FORCE and MNT_DETACH are orthogonal in the Linux kernel, so both may
be specified without any problems. Even if there were a problem with
this combination, it should be up to the kernel to take the correct
action or report an error.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
7 years agomd5: declare byteReverse as static
Luca Ceresoli [Tue, 7 Nov 2017 13:39:09 +0000 (14:39 +0100)] 
md5: declare byteReverse as static

byteReverse() is an internal function in md5.c, and is not exposed via
any header file, but it is not declared as static. This is a problem
with the md5.c file since it is copied more or less verbatim in other
programs (fontconfig and pjsip among others), causing a link error
when linking two of them together.

Fixes link failures such as:
  http://autobuild.buildroot.net/results/419ab2c0e034cc68991281c51caa8271b0fadbab/build-end.log

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
7 years agodocs: update TODO
Karel Zak [Wed, 8 Nov 2017 10:40:04 +0000 (11:40 +0100)] 
docs: update TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agosetsid: new option --fork
Karel Zak [Wed, 8 Nov 2017 10:38:26 +0000 (11:38 +0100)] 
setsid: new option --fork

Let's make semantic more predictable.

Addresses: https://github.com/karelzak/util-linux/issues/518
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agortcwake: add note about HW and sleep to the man page
Karel Zak [Tue, 7 Nov 2017 13:37:03 +0000 (14:37 +0100)] 
rtcwake: add note about HW and sleep to the man page

Addresses: https://github.com/karelzak/util-linux/issues/527
Signed-off-by: Karel Zak <kzak@redhat.com>