Commit Graph

2077 Commits

Author SHA1 Message Date
Karel Zak 7595bed189 Merge branch 'maybe-for-v2.32' of https://github.com/rudimeier/util-linux
* 'maybe-for-v2.32' of https://github.com/rudimeier/util-linux:
  tests: use pgrep instead of ps --ppid ...
  misc: fix typos using codespell
  lsns: fix clang compiler warning
  tests: add udevadm settle to sfdisk/resize
  build-sys: disable bz2 tarball and fix some am warnings
2018-02-16 11:25:22 +01:00
Ruediger Meier 73afd3f8e8 misc: fix typos using codespell
Some more funny typos, please review carefully.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-02-16 11:12:52 +01:00
Ruediger Meier 58b29eedb0 lsns: fix clang compiler warning
../sys-utils/lsns.c:360:8: warning: comparison of integers of different signs: '__u32' (aka 'unsigned int') and 'int' [-Wsign-compare]
        if (!(NLMSG_OK(nlh, reslen)
              ^~~~~~~~~~~~~~~~~~~~~
/usr/include/linux/netlink.h:90:24: note: expanded from macro 'NLMSG_OK'
                           (nlh)->nlmsg_len <= (len))
                           ~~~~~~~~~~~~~~~~ ^   ~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-02-16 11:12:44 +01:00
Riku Voipio dd9b4cb320 lscpu-arm: add Faraday And Brahma cores
Add a handful of more rare cores. Broadcom Brahma cores are
used in Access Points and Faraday was used on some Network
Storage Devices.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2018-02-13 15:25:20 +02:00
Karel Zak dd83526ae3 dmesg: use xstrdup() in xalloc.h based util
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-13 10:52:57 +01:00
Karel Zak 8e782a8395 mount: add note about "already mounted" behavior
Addresses: https://github.com/karelzak/util-linux/issues/448
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-05 12:18:49 +01:00
Karel Zak fd777151bf sys-utils: use errexec()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 15:44:25 +01:00
Karel Zak 3bf6c44462 fstrim: don't include exitcodes.h
The code uses generic and libmount return codes only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 14:49:49 +01:00
Karel Zak 63bf2439eb zramctl: use xstrdup()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 12:21:03 +01:00
Libor Bukata a3612b81fe Added the support for lz4hc, deflate, and 842
compression algorithms in zramctl utility.

Signed-off-by: Libor Bukata <lbukata@gmail.com>
2018-01-24 17:10:09 +01:00
Mike Frysinger 0aade1d319 mount(8): drop redundant filesystem-specific sections
Add a new section to the top of the filesystem-specific chapter to point
people generally to the filesystem-specific man pages.  This way we can
delete all the redundant subsections that say the same thing.

These subsections are deleted because they offer no options.  Which is
the same as all the filesystems the kernel supports but this man page
doesn't explicitly list (of which there are a few).
  coherent minix ramfs romfs squashfs sysv xenix

These subsections are deleted because they simply point to the respective
<fs>(5) or mount.<fs>(8) page which we now document at the top.  Some also
discuss the syscall ABI, but that doesn't seem appropriate for this page.
  btrfs cifs ext2 ext3 ext4 nfs nfs4 proc smbfs tmpfs xfs

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2018-01-24 13:24:33 +01:00
Ruediger Meier 40defd0c4d rfkill: provide RFKILL_TYPE_FM if undefined
As discussed last year it's nice to be compatible to 2.6.32
https://www.spinics.net/lists/util-linux-ng/msg13963.html

BTW also re-define NUM_RFKILL_TYPES if needed, although we are
not really using it.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-24 12:53:36 +01:00
Karel Zak 6776ab6f60 Merge branch 'patch-2' of https://github.com/sourcejedi/util-linux
* 'patch-2' of https://github.com/sourcejedi/util-linux:
  mount(8): umount does not (anymore?) say `none busy'
2018-01-22 14:01:42 +01:00
Karel Zak 267b44e6ee mount: be more accurate in man page about propagation flags
Addresses: https://github.com/karelzak/util-linux/issues/565
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-22 13:54:49 +01:00
Karel Zak af808dfa6d lscpu: (arm) cleanup code
* check for strtol() errors
* fix indention
* fix coding style

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-22 13:20:51 +01:00
Karel Zak 8229df2093 lscpu: move ARM decoding to lscpu-arm.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-22 13:08:11 +01:00
Karel Zak 7106169441 lscpu: move struct lscpu_desc header file
The lscpu code is growing and it seems better to allow to make code
more structured.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-22 13:04:12 +01:00
Karel Zak 7b0926acb0 Merge branch 'arm-cpus' of https://github.com/suihkulokki/util-linux
* 'arm-cpus' of https://github.com/suihkulokki/util-linux:
  lscpu: Decode ARM CPUs
2018-01-22 12:47:47 +01:00
J William Piggott ff4e18bd2d hwclock: add --ul-debug implementing debug.h
Undocumented at this time, because it is a skeleton
implementation.  More debugging points are to be added after
refactoring is complete, or ad hoc in the mean time.

When fully implemented, enough time may have passed that the
deprecated --debug could be used to replace --ul-debug.

[kzak@redhat.com: - use __UL_INIT_DEBUG_FROM_STRING() to initialize the mask
                  - add hwclock_init_debug()]

Coauthored-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-22 11:10:22 +01:00
Alan Jenkins c72fa620b0
mount(8): umount does not (anymore?) say `none busy'
The closest I can get is with `mount`, so refer to that instead.

    # mount none -t proc /proc 
    mount: /proc: none already mounted or mount point busy.
    # umount /proc
    umount: /proc: target is busy.
    # (cd /root; umount proc)
    umount: /proc: target is busy.

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
2018-01-21 16:41:17 +00:00
Riku Voipio 744d62ee0c lscpu: Decode ARM CPUs
Since the kernel developers have refused to make /proc/cpuinfo user
understandable, implement mapping in userspace. lscpu is available for
most users via util-linux, so store the information here.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2018-01-19 17:14:19 +02:00
Mike Frysinger 8fb096b2a7 mount(8): point people to the proc(5) page for mount options
This page is out of date wrt proc mount options, so point it to the
proc(5) page which is kept up to date.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2018-01-19 11:14:00 +01:00
Karel Zak a15dca2f6d include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()
Let's make it possible to use debug.h without environment variables.

Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-17 13:58:29 +01:00
J William Piggott de4568f757 hwclock: rename --debug option to --verbose
Warn on --debug; do not fallthrough because
the message is lost in the verbose output.

Coauthored-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-17 13:29:11 +01:00
Karel Zak 6d00cfb233 include/debug: don't print pointer address for SUID programs
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing

* use __UL_DEBUG_FL_NOADDR when SUID

* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
  to provide access to the current mask from ul_debugobj(). It's better
  than modify all ul_debugobj() calls and use the global mask as
  argument.

* remove never used UL_DEBUG_DEFINE_FLAG

Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-12 11:01:26 +01:00
Karel Zak b0feeab5e2 Merge branch 'fixes' of https://github.com/rudimeier/util-linux 2018-01-11 10:09:48 +01:00
Ruediger Meier 845dac5f8e misc: fix printf i386 compiler warnings
sys-utils/lsns.c:683:2: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘ino_t’ [-Werror=format=]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-09 23:12:19 +01:00
Sami Kerola c8ff2e5562 rtcwake: wait stdin to settle down before entering a system sleep
This can delay entering to system sleep up to 0.28 seconds while discarding
input, when stdin is interactive device.

[kzak@redhat.com: - add note to the man page]

Reference: https://github.com/karelzak/util-linux/issues/527
See-also: a85c390134
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-02 15:14:37 +01:00
Yuri Chornoivan e2215a8545 Fix minor typo: priorty -> priority 2017-12-31 13:07:43 +02:00
Karel Zak cf9b16f1d4 build-sys: don't check for swapon() number of arguments
The syscall swapon() with two arguments is supported since Linux 1.3.2
and it's really long time ago... Let's assume that all libc header files
have been already fixed.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-18 13:57:20 +01:00
Karel Zak 50695114be Merge branch '2017wk48' of https://github.com/kerolasa/lelux-utiliteetit 2017-12-11 16:03:39 +01:00
Sami Kerola 2b798ecde9
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>
2017-12-10 10:50:32 +00:00
J William Piggott 6cdc7b9c02 lib/timeutils.c: warn format_iso_time() overflow
Print a message when the format_iso_time() buffer is exceeded, because
there is more than one type of failure that returns -1.

Also remove the corresponding message from hwclock.c.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-12-09 18:43:29 -05:00
Sami Kerola cbfa144276 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>
2017-12-04 13:04:16 +01:00
Karel Zak 09cb6b42c9 fallocate: remove typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-29 15:13:24 +01:00
Karel Zak 173ef88237 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>
2017-11-29 15:01:39 +01:00
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
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 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 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 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 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 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 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