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.
Karel Zak [Thu, 17 Oct 2019 08:36:27 +0000 (10:36 +0200)]
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>
Karel Zak [Tue, 15 Oct 2019 10:36:16 +0000 (12:36 +0200)]
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>
Karel Zak [Tue, 15 Oct 2019 09:59:16 +0000 (11:59 +0200)]
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).
Karel Zak [Thu, 10 Oct 2019 06:57:30 +0000 (08:57 +0200)]
lib/pty-session: fix compilation
lib/test_pty-monotonic.o: In function `get_boot_time':
/home/travis/build/karelzak/util-linux/lib/monotonic.c:29: undefined reference to `clock_gettime'
lib/test_pty-monotonic.o: In function `gettime_monotonic':
/home/travis/build/karelzak/util-linux/lib/monotonic.c:56: undefined reference to `clock_gettime'
Karel Zak [Wed, 9 Oct 2019 10:31:28 +0000 (12:31 +0200)]
build-sys: cleanup prefixed used for tests
It's ugly to use the same TS_ prefix in tests as well as in
build-system (e.g. make check), because then some env. variable can be
interpreted by our regression tests. For example TS_PARALLEL=.
It's seems better to use TS_ exclusively for tests and TESTS_ for
build-system.
Karel Zak [Mon, 7 Oct 2019 10:24:43 +0000 (12:24 +0200)]
lib/pty-session: make wait_child callback optional
Now the code is duplicate on many places, but all we usually need is to
remember child status. It seems good enough to have very simple
callback child_die() to inform application about a change.
The patch also add PID to all signal related callbacks.
Karel Zak [Thu, 3 Oct 2019 12:33:25 +0000 (14:33 +0200)]
script: use lib/pty-session
This patch consolidate pseudo-terminal stuff in util-linux. From now
there is only one implementation used in su(1) --pty, scriptlive(1)
and script(1).
The new stuff is based on the original script(1) -- it means poll()
and signalfd() based.
Note that script(1) code does not provide fallback for systems/libc
where is no openpty().
Karel Zak [Tue, 30 Jul 2019 12:32:13 +0000 (14:32 +0200)]
scriptlive: run shell in PTY
After this change shell executed by scriptlive(1) is going to behave
like shell in script(1). It means that the shell stdin is a
pseudo-terminal rather than pipe. This allows live replay of
interactive applications, ssh sessions, etc.
Karel Zak [Tue, 2 Jul 2019 15:03:53 +0000 (17:03 +0200)]
scriptlive: add new command to re-execute script(1) typescript
The old good scriptreplay(1) just display your recorded session, the
scriptlive(1) uses stdin typescript (from new script(1)) to execute
your commands again.
Karel Zak [Thu, 20 Jun 2019 11:08:00 +0000 (13:08 +0200)]
scriptreplay: add --cr-mode
The stdin log does not contain line breaks as command line uses CR
between commands. This makes scriptreplay for stdin very
user-unfriendly, because it overwrites still the same line.
The new option --cr-mode provides opportunity to control this
behavior. The default for stdin logs is replace CR with line-break.
Karel Zak [Fri, 12 Apr 2019 14:27:54 +0000 (16:27 +0200)]
script: support multi-stream logging
* allow to use --log-in <infile> and --log-out <outfile> in the same time
* add --log-io <file> to log stdout and stdin to the one log file
* introduce a new timing file format with entry type identifirs
I <delay> <size> : info about input stream
O <delay> <size> : info about output stream
in the next commits it's possible to add 'S' for signals and 'H' for
extra (header) information.
* the new file format is optional and enabled only if multiple streams
logging is requested.
Karel Zak [Fri, 12 Apr 2019 10:47:03 +0000 (12:47 +0200)]
script: add option --log-timing
The current -t[=<file>] is pretty messy due to optional <file>
argument; and default is to output to stderr. The default output to
stderr is very unusual semantic. This path makes the old -t
deprecated.
The new option -T, --log-timing requires the file name.
Karel Zak [Wed, 3 Apr 2019 14:32:41 +0000 (16:32 +0200)]
script: log file usage refactoring
This commit does not add any new feature. It just prepare code for
future extensions only.
* introduce two new structs: script_stream and script_log
* define two streams: 'stdout' and 'stdin'
* allow associate log files (type script or timing file) with the stream
* support more log file formats
Karel Zak [Mon, 7 Oct 2019 10:57:43 +0000 (12:57 +0200)]
hwclock: report rtc open() errors on --verbose
Let's be more verbose and provide real open() error to make
debugging easier on --verbose.
For example:
$ hwclock --verbose
hwclock from util-linux 2.34.193-6bebea-dirty
System Time: 1570445823.701266
Trying to open: /dev/rtc0
hwclock: cannot open /dev/rtc0: Permission denied <---
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.
Addresses: https://github.com/karelzak/util-linux/issues/879 Signed-off-by: Karel Zak <kzak@redhat.com>
Elliott Mitchell [Thu, 29 Aug 2019 03:12:50 +0000 (20:12 -0700)]
fdisk: Correct handling of hybrid MBR
The traditional MBR has pretty well NO limitations on slices. They can
be a single misaligned sector if desired. While this is undesireable
for most real world uses, for the few places they're still used extra
limitations cause breakage not safety.
Karel Zak [Mon, 30 Sep 2019 11:11:17 +0000 (13:11 +0200)]
fdisk: use 'r' to return from MBR to GPT
The current code uses 'M' to switch between MBR and GPT, but it's not
intuitive to "go back" by 'M'. It seems more user-friendly to use 'r'
as in another places (for example when go from expert menu or from BRD
menu).
The 'M' to return to GPT is still supported for backward compatibility.
Addresses: https://github.com/karelzak/util-linux/pull/849 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 30 Sep 2019 09:12:35 +0000 (11:12 +0200)]
Merge branch 'nproc' of https://github.com/mator/util-linux
* 'nproc' of https://github.com/mator/util-linux:
Don't use `nproc --all` for getting cpu number. For example below, sparc64 is reporting 128 as a total, but only 32 is online. So use only online cpus for tests parallel runs.