Commit Graph

13811 Commits

Author SHA1 Message Date
Karel Zak 916a3f8d29 libmount: don't access struct member, use API
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-18 16:19:15 +01:00
Sami Kerola beb61b07c2
nologin: silently ignore well known shell command-line options
nologin is typically used in /etc/passwd as a shell replacement.  Hence it
is reasonable to ignore well known command-line options silently to avoid
unwanted ugly error messages.

Addresses: https://github.com/karelzak/util-linux/issues/895
Requested-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-11-17 08:33:04 +00:00
Karel Zak 4631edaee2 lsblk: add FSVER to --fs
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-15 11:23:44 +01:00
Evan Green ae1e82e0b5 libfdisk: Space before first partition may not be aligned
libfdisk chooses a grain of 1MB fairly arbitrarily, and this granule
may not be honored by other utilities. GPT disks formatted elsewhere
may have space before the first partition, AND a partition that exists
solely below 1MB. If this occurs, cfdisk ends up adding a free space
region where end < start, resulting in a 16 Exabyte free region.

That's too many exabytes.

This happens because the start gets rounded up to the granule size in
new_freespace() but the end is left alone. The logs show it best:

23274: libfdisk:      CXT: [0x572d878]: initialized:  last=34, grain=2048
23274: libfdisk:      CXT: [0x572d878]: partno=10, start=64
23274: libfdisk:      CXT: [0x572d878]: freespace analyze: partno=10, start=64, end=64
23274: libfdisk:      CXT: [0x572d878]: LBA           34 aligned-up           2048 [grain=2048s]
23274: libfdisk:      CXT: [0x572d878]: LBA           63 aligned-down            0 [grain=2048s]
23274: libfdisk:      CXT: [0x572d878]: LBA           34 aligned-near            0 [grain=2048s]
23274: libfdisk:      CXT: [0x572d878]: 0 in range <2048..0> aligned to 2048
23274: libfdisk:     PART: [0x574bb98]: alloc
23274: libfdisk:      TAB: [0x5749d58]: adding freespace
23274: libfdisk:      TAB: [0x5749d58]: insert entry 0x574bb98 pre=0x574a820 [start=2048, end=63, size=18446744073709549632, freespace  ]

Avoid this by aligning the last value like new_freespace() does.

Signed-off-by: Evan Green <evangreen86@gmail.com>
2019-11-12 14:38:26 -08:00
Karel Zak 9cca1ef2d5 lsblk: add FSVER (filesystem version) column
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1764523
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-12 13:55:55 +01:00
Karel Zak 4e666fceda agetty: add --show-issue to review issue output
Let's make life easier for admins and allow to review issue file
output on the current terminal without all full agetty execution. Use
case is pretty simple:

 # $EDITOR /etc/issue
 # agetty --show-issue

Addresses: https://github.com/karelzak/util-linux/issues/828
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-12 11:24:40 +01:00
Karel Zak 456bcbca6b agetty: add support for /run/issue and /usr/lib/issue
Addresses: https://github.com/karelzak/util-linux/issues/828
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-12 10:26:35 +01:00
Karel Zak c2409b55a0 build-sys: introduce $sysconfstaticdir
The current situation is that distros differentiate between:

* host specific configuration -- usually /etc, maintained by admin

* distribution specific (static) configuration -- usually /usr/lib,
  maintained by ditro packages

Unfortunately autotools have clue about $sysconfdir (/etc) only. This
patch introduces $sysconfstaticdir (default $prefix/lib).

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-12 10:09:34 +01:00
Karel Zak 390ba85c78 renice: fix arguments description in --help
The --{pid,pgrp,user} options does not have arguments.

Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 11:32:18 +01:00
Karel Zak cb99f4ea79 renice: fix --help text
The option [-n] in the code has no any meaning and the value is used
as priority, not incrementally.

Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 11:22:57 +01:00
Andrew Price 48bb8522fe fallocate.1: List gfs2 as supporting punch-hole
Signed-off-by: Andrew Price <anprice@redhat.com>
2019-11-08 11:18:17 +01:00
Karel Zak 68a2ade7ed hwclock: add SPDX-License-Identifier(s)
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 11:12:13 +01:00
Karel Zak e98d95131f docs: add GPLv3 text
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 11:10:54 +01:00
Karel Zak 7999563138 lib/timeutils: add %Y-%m-%dT%H:%M:%S to parse_timestamp()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 10:42:03 +01:00
Karel Zak 8fb945185f lib: add missing license headers
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 10:40:42 +01:00
Karel Zak 4d1b9e02fc build-sys: .gitignore hwclock-parse-date.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-07 10:43:46 +01:00
Karel Zak 4e36662e52 lib: add missing license headers
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-07 09:38:06 +01:00
Karel Zak 8e1b131e0a build-sys: use parse-date() only for hwclock
The parse-date.y is used only for hwclock, let's keep it together.
Note that the file (originally from gnulib) has GPLv3 license, so it's
better to make it obvious that we use it really only for hwclock (also
GPL).

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-07 09:02:23 +01:00
Michal Suchanek 39f5af2598 libblkid: open device in nonblock mode.
When autoclose is set (kernel default but many distributions reverse the
setting) opening a CD-rom device causes the tray to close.

The function of blkid is to report the current state of the device and
not to change it. Hence it should use O_NONBLOCK when opening the
device to avoid closing a CD-rom tray.

blkid is used liberally in scripts so it can potentially interfere with
the user operating the CD-rom hardware.

[kzak@redhat.com: add O_NONBLOCK also to:
                  - wipefs
                  - blkid_new_probe_from_filename()
                  - blkid_evaluate_tag()]

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-06 09:55:49 +01:00
Karel Zak b4402de7a0 tests: commit add missing file
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-05 15:42:19 +01:00
Karel Zak be906b20f2 tests: add mount --all tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-05 15:14:17 +01:00
Karel Zak 6a735c2c5b libmount: make sure optsmode is initialized
Since 34333e5244 we apply fstab options
manually by mnt_context_apply_fs() on --all. The function does not
work correctly when optsmode is zero.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 13:51:29 +01:00
Karel Zak f2cb9359c1 mount: (man) document --target-prefix
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 34333e5244 libmount: allow use -o together with --all
For example:
	# mount --verbose --all -t xfs -o ro

will mount all all XFS filesystems from fstab, but read-only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 7a56878d4b libmount: move context fs merge to separate function
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak e5d2044407 libmount: fix mnt_context_next_remount()
The current implementation works, but the remount operation is done in
the cloned context and the original context (and calling application)
has no information about the final status/errors. This is mistake.

This new implementation works like mnt_context_next_mount(), it means
the same context (as used by application) is reused for all remounts.
The original setting is restored by mnt_context_apply_template().

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak e83c09d49e libmount: save current FS setting as template
This commit adds new functions to save and reuse the current FS
setting (mount options from command line, etc) after context reset.
It's usable for example in "mount --all" when we use the same context
for more times for more mount operations.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 7cbde88185 libfdisk: consolidate strdup() use
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak eee7ea558c libmount: use strdup_between_structs()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 787226dc28 include/strutils: add strdup_between_structs()
* improve strdup_to_offset() readability

* add strdup_between_offsets() and strdup_between_structs() to have
  better support for use-cases when we copy structs

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 779e3c97aa libmount: cleanup strdup() use in context, add reg.test
* don't ignore strdup() result
* cleanup mnt_context_prepare_helper() to have only one return point
  (due to mnt_context_switch_ns())
* add mnt_context_prepare_helper() test program

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak b231e0f71c mount: add --target-prefix
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 71ed3b8337 libmount: add target prefix support
* add set/get functions to context
* use prefix to detect already mounted filesystems
* use prefix when prepare target path

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak eea06b92dc lsblk: never fallback to udev/blkid on --sysroot
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-29 13:12:18 +01:00
Karel Zak 05842a92d8 libmount: don't use /proc/mounts fallback if filename specified
The current solution is to use /proc/mounts if previous attempt to
open /proc/self/mountinfo failed. The fallback should not be used when
mount table path is explicitly specified by application. The default
is NULL, only in this case libmount should be try to be smart.

Reported-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-29 12:59:08 +01:00
Karel Zak bdc3cc65ab su: fix error message
Reported-by: Pedro Albuquerque <palbuquerque73@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-29 10:04:29 +01:00
Karel Zak c07c41cd5f Merge branch 'blkid-sparc' of https://github.com/mator/util-linux
* 'blkid-sparc' of https://github.com/mator/util-linux:
  tests: fixes blkid/md-raidX-whole on Sparc
2019-10-23 13:14:45 +02:00
Anatoly Pugachev a43665128c tests: fixes blkid/md-raidX-whole on Sparc
Since SPARC is using 'sun' partition table by default, make test not to
assume that disk has 'dos' partition table, so write 'dos' partition
table on disk, before proceeding any further.

Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
2019-10-23 11:26:19 +03:00
Vladimir Slavik 2bbc962288 lsblk: update man description of -f / --fs for current columns
see lsblk.c line 1930
2019-10-17 13:51:02 +02:00
Patrick Steinhardt b2a1a69155 lib/path: fix missing header for `struct stat`
In commit b1418ed14 (lib/path: add ul_path_stat(), fix absolute paths,
2019-10-15), a new function `ul_path_stat()` was added to "path.h". This
new function prototype causes a compiler warning on musl libc based
systems due to one of the parameters having the unknown type `struct
stat` due to the <sys/stat.h> header not being included.

Fix the warning by including the header.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2019-10-17 12:46:33 +02:00
Karel Zak c8a5422a7a Merge branch 'master' of https://github.com/smvoss/util-linux
* 'master' of https://github.com/smvoss/util-linux:
  wipefs: Allow explicitly enable/disablement
2019-10-17 11:03:16 +02:00
Merlin Büge b2de475c67 mount: (man) small typo fixes 2019-10-17 11:01:13 +02:00
Karel Zak 43db339b9a docs: remove implemented TODO items
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-17 10:54:15 +02:00
Karel Zak 70ff760d41 login: reduce file-descriptors cleanup overhead
Addresses: https://github.com/karelzak/util-linux/issues/883
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-17 10:45:16 +02:00
Karel Zak 488f65fcb8 lib/fileutils: add close_all_fds()
The classic way which is based on file-descriptors table size is
pretty expensive (due to table size) and forces code to do many
unnecessary close() calls. It seems better to use /proc/self/fds and
close used descriptors only.

Addresses: https://github.com/karelzak/util-linux/issues/883
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-17 10:44:57 +02:00
Karel Zak 93c2723772 tests: (lsblk) gather also udev attributes for new dumps
References: 7408a5d9c2
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-15 13:29:13 +02:00
Karel Zak 6f74ede50a lsblk: read also GROUP,OWNER and MODE from dumps
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-15 13:08:09 +02:00
Karel Zak 7408a5d9c2 lsblk: on --sysroot read attributes from /dev/<devname> text file
The option --sysroot is used to read information from dumps rather
than from the current system. This patch allows to read also udev
attributes from text file in location /sysroot/dev/<devname>. The file
is text file in format NAME=value\n.

Suggested-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-15 12:36:16 +02:00
Karel Zak b1418ed146 lib/path: add ul_path_stat(), fix absolute paths
* add ul_path_stat()

* make sure all paths for ul_path_..() functions are always
interpreted relatively to the context directory and prefix. This is
difference between ul_path_ API and standard libc "at" functions. We
do not use any exception for absolute paths. The reason is that we
need to read from prefixed paths although application assume absolute
path (/dev/sda1 means /prefix/dev/sda1 if a /prefix is defined).

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-15 11:59:16 +02:00
Sam Voss a76cd5f6ab wipefs: Allow explicitly enable/disablement
Currently if `--disable-all-packages` is set, there is no configure
option for re-enabling `wipefs`.

As the current default for `wipefs` is "enabled", add `--disable-` flag
to maintain backward compatibility.

Signed-off-by: Sam Voss <sam.voss@gmail.com>
2019-10-14 21:19:16 -05:00