Commit Graph

9511 Commits

Author SHA1 Message Date
Sami Kerola b09feab9e4 script: use correct input type, move comment, and so on
Minor corrections.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:36 +01:00
Sami Kerola 8353549e02 script: replace strftime() workaround with CFLAGS = -Wno-format-y2k
Nowadays, gcc(1) provides the -Wno-format-y2k option to prevent the
warning, so that the above workaround is no longer required.

Reference: http://man7.org/linux/man-pages/man3/strftime.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:36 +01:00
Sami Kerola a8896ad5b7 script: move do_io() content to small functions
The do_io() got to be a bit long with relatively deep indentation.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:34 +01:00
Sami Kerola 076ffa48f3 script: add 'Script started' line always to capture file
The scriptreplay(1) will expect capture file always to have header.
Before this change the --quiet option together with timing caused
following replay error.

$ script --quiet --timing=timing
[...]
$ scriptreplay timing typescript
[...]
scriptreplay: unexpected end of file on typescript

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:52:51 +01:00
Sami Kerola 89a859d433 script: remove io vs signal race
Make do_io() to run poll() until all streams are empty.  This should
remove the signal from child versus io handling race for good.

Addresses: https://github.com/karelzak/util-linux/pull/62
Addresses: https://bugs.launchpad.net/bugs/264967
Addresses: https://bugs.debian.org/305808
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:52:51 +01:00
Sami Kerola 6ddf53a5b4 script: merge doinput() and output() functions to do_io()
One item to poll() more is a lot less work for system than separete input
and output processes.

Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:52:36 +01:00
Sami Kerola cf470183ea script: use poll() rather than select()
Finalize the signalfd() change by adding file descriptors to poll() loop.

Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:53:56 +01:00
Sami Kerola cc1a88fb59 script: use signalfd() to catch signals
This is incomplete change.  Working command requires the subsequent
select() to poll() change as well.

Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:53:55 +01:00
Sami Kerola edc7e42076 script: add struct script_control and remove global variables
Fix also couple indentation issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:53:50 +01:00
Sami Kerola 93af8d8bf3 script: remove function prototypes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:36:46 +01:00
Sami Kerola 6a40c65f81 tests: check script options work as expected
Options --flush and --timing remain unchecked, as I do not have an idea
how to check them reliably.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:36:38 +01:00
Sami Kerola d9f50441e1 tests: add script output buffering race check
Regression check to a fix by Stanislav Brabec.

Reference: 0b285b84b2
CC: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:35:19 +01:00
Karel Zak 6a768b5516 libsmartcols: keep JSON field names lower-case
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 11:58:42 +02:00
Karel Zak b3a2e889df lslocks: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 10:45:15 +02:00
Karel Zak 4827093d4b losetup: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 10:30:52 +02:00
Karel Zak 8449f2cb59 findmnt: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 09:47:59 +02:00
Karel Zak 4a102a4871 lsblk: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-04 15:49:52 +02:00
Karel Zak 2a6cfc1361 libsmartcols: add JSON output format
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-04 15:47:21 +02:00
Ronny Chevalier 1280109fdc libmount: (docs) fix wording
Signed-off-by: Ronny Chevalier <chevalier.ronny@gmail.com>
2015-06-03 13:21:52 +02:00
Ronny Chevalier 8b1333423a libmount: (docs) fix typo
Signed-off-by: Ronny Chevalier <chevalier.ronny@gmail.com>
2015-06-03 13:06:59 +02:00
Karel Zak 362f5d2035 losetup: print more usable error message on failed -f
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1215370
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-03 12:05:09 +02:00
Karel Zak 28cdf9c612 libmount: do not call umount helper on --fake
The umount.<type> helpers does not support --fake option and it does
not make sense to call the helpers at all. All we need is to remove
mtab/utab entries.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1172297
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-03 11:02:25 +02:00
Karel Zak 6d9b1c19ea lscpu: add warning for __SANITIZE_ADDRESS__
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-02 14:55:52 +02:00
Cristian Rodríguez a680b2abe7 sys-utils: lscpu segfaults when built with -fsanitize=address
This is expected and a false positive, exclude the vmware detection
trick when __SANITIZE_ADDRESS__ is defined.
2015-06-02 11:58:53 +02:00
Stanislav Brabec a79b7cab66 lsblk.8: Fix description of output format
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2015-06-02 11:58:53 +02:00
Karel Zak 08e193e1e4 libmount: fix mnt_monitor_event_cleanup()
We have to call epoll to drain mountinfo events too. The problem is
visible if the monitor epoll FD is within another (top-level) epoll.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-01 13:17:41 +02:00
Karel Zak 92441d5c1e lsblk: use internally sysfs devnames
It seems better to keep the strange sysfs devnames internally and
translate to real devnames only on output or when we read from /dev.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-29 10:55:01 +02:00
Karel Zak d5dbd57b22 docs: fix gtk-docs related warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-28 12:28:23 +02:00
Karel Zak 6c62abc42b lib/sysfs: rename devname functions, cleanup
Well, I don't have mental power to use function names like

 sysfs_devname_to_dev_name()

so this patch renames to

 sysfs_devname_sys_to_dev()
 sysfs_devname_dev_to_sys()

It also cleanups usage of the functions. We have to be sure that
sysfs.c code returns regular devnames. The existence of the sysfs
devnames (with '!') should be completely hidden in sysfs specific
code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-28 12:09:41 +02:00
Stanislav Brabec 759b120d85 lib/sysfs: Fix /dev to /sys node name translation
d0dc6c1 introduced translation of /sys names to /dev names, as required
by the kernel linux/drivers/base/core.c: device_get_devnode(). But there
are other places of code that use /dev names in /sys. They need reverse
translation from '/' to '!'.

For example, fdisk -l returns empty list since a22c6eb for device nodes
in subdirectories (used e. g. by cciss driver).

Introduce yet another helper sysfs_dev_name_to_devname() and use it where
appropriate.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2015-05-28 10:27:20 +02:00
Stanislav Brabec 97c68d4204 libfdisk: Use predictable /dev/mapper partition names for /dev/dm-N
It is impossible to predict /dev/dm-N partition names. Use predictable
and better readable /dev/mapper names instead.

[kzak@redhat.com: - remove if-before-free]

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-28 10:25:58 +02:00
Stanislav Brabec 8b5940be96 Use correct partition names for /dev/mapper
The default configuration of multipath-tools appends "-partN" to
partition nodes. Follow this conventions and do the same.

It fixes for example fdisk -l /dev/mapper/name_of_the_device.

Note that the current implementation only partially fixes the problem. It
does not reflect any udev configuration changes, as udev does not provide
any function to return names of future (or current) partitions of a
particular device. It also does not fix fdisk -l /dev/dm-0.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2015-05-26 11:42:38 +02:00
Stanislav Brabec d0dc6c17c5 Fix /sys to /dev node name translation
linux/drivers/base/core.c: device_get_devnode() defines a translation of
'!' in sysfs nodes to '/' in /dev nodes. The same translation has to be
done to properly support device nodes with slash (e. g. device nodes of
cciss driver and several other drivers).

Introduce new helper sysfs_devname_to_devno() and use it where
appropriate.

Fixes for example lsblk -f on devices using cciss driver.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2015-05-26 11:42:38 +02:00
Karel Zak 687cc5d589 hwclock: don't allow non-root access
Fortunately very few people are crazy enough to install hwclock as
setuid. Some comments in code and unfortunately also man page
advertising that setuid is no problem. That's pretty stupid promise.

The code quality is poor and it's obviously not designed to be secure
(things like popen() without drop privileges, etc.).

This patch removes all notes about "setuid support" and for sure
disable hwclock execution for non-root users.

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=786804
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-26 10:32:38 +02:00
Karel Zak d681e0956c sulogin: don't use strcpy(), enlarge pwd line buffer
* according to "man getpwnam" 16384 bytes is enough to store one
  passwd entry (let's use 2*BUFSIZE to avoid magic numbers in code)

* don't use strcpy() to set empty password

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-25 15:24:13 +02:00
Karel Zak 17d710346a build-sys: add --without-* for all libs
It's necessary for people who want to compile util-linux in very
unusual environment and disable as much as possible dependencies.
For example distro bootstrap.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1223894
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-22 12:43:33 +02:00
Karel Zak 5ec4a890a1 blkid: another hint to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-21 13:13:49 +02:00
Karel Zak f36522da5f blkid: be more precise in the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-21 12:37:18 +02:00
Karel Zak f8098e2b2c blkid: don't ignore info about partitions on non-formated devices
# blkid -p /dev/sdc1; echo $?
 2

but libblkid provides information about partition, fixed version:

 # blkid -p /dev/sdc1; echo $?
 /dev/sdc1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="4c1e518c-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="1021952" PART_ENTRY_DISK="8:32"
 0

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-21 12:14:55 +02:00
Karel Zak 6ddccd0d6e docs: update TODO
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-19 14:40:42 +02:00
Georg Schiesser fddfd4e08b build-sys: support unshare.static
This patch adds support for building a static version of unshare.
We need to add unshare to the list of possible static programs, and
provide build flags for the compiler and linker, which are equivalent to
the flags of the non-static program, except additional static linking.
See also: commit 2fa60c5 build-sys: support nsenter.static

Signed-off-by: Georg Schiesser <georg.schiesser@opentech.at>
2015-05-18 11:46:05 +02:00
Sami Kerola c5ad7b59ac cal: fix January 1753 week number printout
Earlier output was clearly broken.

$ cal -w 1 1753
      January 1753
   Su Mo Tu We Th Fr Sa
51     1  2  3  4  5  6
52  7  8  9 10 11 12 13
52 14 15 16 17 18 19 20
52 21 22 23 24 25 26 27
52 28 29 30 31

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-05-18 11:41:48 +02:00
Karel Zak bffc9174b8 zramctl: add MEM-LIMIT, MEM-USED and MIGRATED columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-18 11:30:56 +02:00
Karel Zak 5388c86260 zramctl: support /sys/block/zram<id>/mm_stat
Linux >= 4.1 provides all memory related statistics by one file.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-18 11:13:44 +02:00
Karel Zak 548b9714e8 lib/strv: add new functions (from systemd)
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-15 14:57:04 +02:00
Stanislav Brabec 8fdc064ac3 script: Fix mangled EOF and hang on big endian
On s390 and other big endian machines, doinput() sends NUL instead of
EOF to the tty master. NUL does not even reach the slave, and it is
waiting for more data forever.

If STDIN is not a tty, the bug caused "^@" being into the log, and since
commit 032228c it also causes hang.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2015-05-15 12:56:46 +02:00
Karel Zak a19876310e Merge branch 'test-fixes' of https://github.com/rudimeier/util-linux
* 'test-fixes' of https://github.com/rudimeier/util-linux:
  tests: fix kill/all_processes
  tests: add $top_builddir to $PATH
2015-05-13 15:08:04 +02:00
Karel Zak 9200391d41 tests: update lscpu tests (due to CPU flags in output)
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-13 15:06:22 +02:00
WANG Chao ee1f1057e2 lscpu: add cpu flags entry to summary output
It'd be convenient to have unified cpu "Flags: " entry in the summary
output.

Signed-off-by: WANG Chao <wcwxyz@gmail.com>
2015-05-13 11:27:16 +02:00
Karel Zak c1be496a93 libfdisk: keep FDISK_FIELD_CYLINDERS independent on context mode
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-11 13:01:26 +02:00