Commit Graph

12253 Commits

Author SHA1 Message Date
Sami Kerola 6ce4256ecd 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>
2017-11-28 14:39:19 +01:00
Sami Kerola 0b7e477188 lib/signames: remove unused function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:17 +01:00
Sami Kerola bfcd327541 man: use long options in text and add example to uuidgen
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:15 +01:00
Sami Kerola fcf841f8d3 misc: fix typos
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:13 +01:00
Karel Zak 57358f50f3 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>
2017-11-28 13:19:20 +01:00
Karel Zak 68433f1e31 tests: add set-x to lsns test
.. just to see why does it fail on Travis.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-28 12:00:58 +01:00
Karel Zak 29f966a57b tests: better lsns report on fail
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-28 11:17:18 +01:00
Karel Zak c3487d5955 tests: make lsns test more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-28 10:58:37 +01:00
Karel Zak b9e4ee42c2 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>
2017-11-28 10:53:35 +01:00
Karel Zak aec01d7211 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>
2017-11-28 10:45:06 +01:00
Karel Zak 4b328279ce build-sys: lsns requires libmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-27 17:44:43 +01:00
Karel Zak f593e2797e 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>
2017-11-27 17:40:56 +01:00
Karel Zak 5a0d3030ca tests: fix lsns perms
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-27 17:33:28 +01:00
Karel Zak deb3f5180c lsns: rename notruns to no_trunc
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-27 17:13:50 +01:00
Karel Zak 7eda2400db 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>
2017-11-27 17:13:50 +01:00
Masatake YAMATO 7817b2ad08 lsns: (man) write about using multi-line in NSFS cell of lsns
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-11-27 17:13:40 +01:00
Masatake YAMATO 94d4ccd7a2 lsns: add a case for testing nsfs column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-11-27 15:54:57 +01:00
Masatake YAMATO 0a32d39a0b 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>
2017-11-27 15:54:56 +01:00
Masatake YAMATO 74d2056ae8 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>
2017-11-27 15:54:55 +01:00
Masatake YAMATO 5d075a7828 lsns: add a case for testing netnsid column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-11-27 15:54:54 +01:00
Masatake YAMATO 7a360346d3 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>
2017-11-27 15:54:52 +01:00
Masatake YAMATO 4195756e03 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>
2017-11-27 15:54:49 +01:00
Karel Zak e72027dada 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>
2017-11-27 12:37:53 +01:00
Karel Zak d1bf0ce5fa libsmartcols: fix mem-leaks in samples
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-23 15:24:59 +01:00
Karel Zak 07b447d473 tests: allow to use memory checks for libsmartcols
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-23 15:24:36 +01:00
Karel Zak 26777ac30e docs: update TODO file
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-23 15:02:32 +01:00
Karel Zak b97cc9a829 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>
2017-11-23 14:59:05 +01:00
Karel Zak d3f58f8aee tests: rename --memcheck to --memcheck-valgrind
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-23 14:03:23 +01:00
Karel Zak 02ae505fd4 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>
2017-11-23 13:44:53 +01:00
Karel Zak 800e447741 hwclock: revert ioctl test
This commit reverts 1d5cffa16a.

(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>
2017-11-23 10:30:27 +01:00
Karel Zak afeb646550 tests: update columns test due to dda229c7b2
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-22 17:16:21 +01:00
Karel Zak dda229c7b2 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>
2017-11-22 14:43:36 +01:00
Karel Zak 365ed9f639 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>
2017-11-22 14:41:10 +01:00
Karel Zak 9fb4ab8e14 mount: add hint about -t and root perms to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-22 12:45:33 +01:00
Karel Zak 06a27566e1 lsblk: add hint about perms to man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-22 12:31:58 +01:00
Karel Zak 6e08d4d9f8 Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Fix parsing UDF revision
2017-11-21 12:42:35 +01:00
Karel Zak ae6fd6802c libmount: add nsfs between pseudo filesystems
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-21 12:11:56 +01:00
Steven Smith d23597a88c 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>
2017-11-21 10:54:39 +01:00
Andy Grover f024c96c34 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>
2017-11-21 10:43:09 +01:00
Pali Rohár 3999e62a72 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>
2017-11-20 18:16:59 +01:00
Karel Zak 07306a0303 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
2017-11-20 13:30:20 +01:00
J William Piggott af54dbd929 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>
2017-11-17 20:25:40 -05:00
J William Piggott 01d971945c hwclock: use reentrant time conversion functions
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-11-16 19:43:16 -05:00
Pali Rohár 3ea60856ee libblkid: udf: Update copyright
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2017-11-16 19:53:59 +01:00
Pali Rohár 2f6184ca2c 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>
2017-11-16 19:45:16 +01:00
Pali Rohár 06d9f4763f 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>
2017-11-16 18:53:52 +01:00
Karel Zak 75f03badd7 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>
2017-11-16 16:27:32 +01:00
Karel Zak d9a388d30c build-sys: add missing include
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-16 14:41:01 +01:00
Karel Zak f9dc7fd135 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
2017-11-16 14:18:16 +01:00
Mikhail Vorobyov 9e6ccaab5b 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.
2017-11-16 14:11:19 +01:00