Karel Zak [Thu, 25 Jun 2015 09:56:02 +0000 (11:56 +0200)]
Merge branch 'script'
* script: (25 commits)
script: add note to BUGS man page section
script: fix EOF problems
script: improve poll debugging
script: cleanup signals usage
script: debug poll() results
script: add support for SCRIPT_DEBUG=
script: remove magic constants from poll code
script: rename control struct members
script: close timingfp also when -e
tests: add scriptreplay test
script: move timing file opening close to use of it
script: add noreturn function attributes
script: use gettime_monotonic() to get timing file timestamps
script: use correct input type, move comment, and so on
script: replace strftime() workaround with CFLAGS = -Wno-format-y2k
script: move do_io() content to small functions
script: add 'Script started' line always to capture file
script: remove io vs signal race
script: merge doinput() and output() functions to do_io()
script: use poll() rather than select()
...
Karel Zak [Fri, 19 Jun 2015 10:17:45 +0000 (12:17 +0200)]
libmount: improve monitor to be usable for non-root users
The current implementation calls mkdir and open(O_CREATE) to
initialize /run/mount/utab.lock before it starts to monitor the file.
Unfortunately it makes the monitor useless for non-root processes
(e.g. systemd --user).
The new implementation adds inotify watch for the last existing
component in the path (/run/mount/utab.lock) and re-initialize
after a change. It makes the monitor robust enough for mkdir/rmdir
when monitor is already active.
Romain Bouvier [Wed, 17 Jun 2015 15:59:18 +0000 (15:59 +0000)]
libuuid: return correct value for uuid_generate_time_safe
Make return value consistent for consecutive calls. If you call
uuid_generate_time_safe, it should always return -1 if it can't guarantee
uniqueness. Without this patch, on consecutive calls where it can't guarantee
uniqueness, the first call returns -1, but later calls return 0.
Reported-by: Romain Bouvier <skunnyk@alteroot.org> Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Karel Zak [Wed, 17 Jun 2015 11:25:46 +0000 (13:25 +0200)]
script: cleanup signals usage
* don't call anything from assert()
* fork() block cleanup to make it more readable
* restore original signal mask in child (do_shell())
* close signal FD in child (do_shell())
Karel Zak [Tue, 16 Jun 2015 09:53:18 +0000 (11:53 +0200)]
Merge branch 'script3' of git://github.com/kerolasa/lelux-utiliteetit into script
* 'script3' of git://github.com/kerolasa/lelux-utiliteetit:
tests: add scriptreplay test
script: move timing file opening close to use of it
script: add noreturn function attributes
script: use gettime_monotonic() to get timing file timestamps
script: use correct input type, move comment, and so on
script: replace strftime() workaround with CFLAGS = -Wno-format-y2k
script: move do_io() content to small functions
script: add 'Script started' line always to capture file
script: remove io vs signal race
script: merge doinput() and output() functions to do_io()
script: use poll() rather than select()
script: use signalfd() to catch signals
script: add struct script_control and remove global variables
script: remove function prototypes
tests: check script options work as expected
tests: add script output buffering race check
Karel Zak [Wed, 10 Jun 2015 12:19:45 +0000 (14:19 +0200)]
fstrim: de-duplicate by mount source too
Now fstrim de-duplicates by target (mountpoint). This patch adds
de-duplication according to mount source (device) to avoid bind mounts
or devices mounted more than once. Note that the patch also check FS
root, the different FS roots of the same multi-root FS (e.g. btrfs)
maybe mounted on different places.
# mount --bind /home/wine /mnt/test
old version:
# fstrim -av
/mnt/test: 0 B (0 bytes) trimmed <---
/home/wine: 0 B (0 bytes) trimmed <---
/boot: 0 B (0 bytes) trimmed
/home: 0 B (0 bytes) trimmed
/: 0 B (0 bytes) trimmed
new version:
# fstrim -av
/mnt/test: 0 B (0 bytes) trimmed <---
/boot: 0 B (0 bytes) trimmed
/home: 171.8 MiB (180113408 bytes) trimmed
/: 0 B (0 bytes) trimmed
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1162213 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 9 Jun 2015 13:53:20 +0000 (15:53 +0200)]
libblkid: (nilfs2) check size for backup superblock only
The size of the device seems irrelevant for the primary superblock.
The primary superblock is stored on fixed offset, possible collision
between last partition and whole-disk is possible only for backup
superblock only.
Karel Zak [Tue, 9 Jun 2015 08:37:11 +0000 (10:37 +0200)]
libblkid: (nilfs2) check devise size
Unfortunately, nilfs2 have the same problem like many RAIDs. It uses
the end of the device to store (backup) superblock. The end of the
last partition is the same location as the end of the whole-disk. It
means that the superblock seems valid for the last partitions as well
as for whole-device.
Fortunately, nilfs2 superblock contains size of the device, so we can
distinguish between whole-disk and partition device.
Reported-by: Heinz Diehl <htd+ml@fritha.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Tue, 30 Dec 2014 23:03:32 +0000 (23:03 +0000)]
script: use gettime_monotonic() to get timing file timestamps
This moves the previous time to script control structure, and does
timeval calculation with timersub() that is more appropriate than
making a timeval to a double.
Sami Kerola [Fri, 26 Dec 2014 17:57:46 +0000 (17:57 +0000)]
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
The patch also improves fdisk_align_lba_in_range() to not align sizes
smaller than grain (default 1MiB) to make it possible to create really
small partitions.
Reported-by: Tom Yan <tom.ty89@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Guillem Jover [Sat, 6 Jun 2015 04:19:05 +0000 (06:19 +0200)]
lib/fileutils: Add new dup_fd_cloexec function
This function duplicates and marks a file descriptor as close-on-exec.
Takes care of build and run-time support for the fcntl F_DUPFD_CLOEXEC
command, and other errors.
Boris Egorov [Tue, 2 Jun 2015 17:59:01 +0000 (23:59 +0600)]
bash-completion: handle comma-separated options
This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:
Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.
Few issues remained:
* completion interrupts after encountering ':' in listed option,
like in 'MAJ:MIN' in lsblk, losetup.
* lscpu completion is broken: it inserts space after '--extended',
but lscpu assumes there is no space after this option. It also
doesn't complete '--parse' option.
* some completion options are outdated (for example, lscpu MMHZ). We
need to sync them with code. Fix for lscpu follows.
Karel Zak [Wed, 3 Jun 2015 08:59:35 +0000 (10:59 +0200)]
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>
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.
Stanislav Brabec [Wed, 27 May 2015 13:12:08 +0000 (15:12 +0200)]
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.
Stanislav Brabec [Mon, 25 May 2015 19:17:52 +0000 (21:17 +0200)]
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.
Stanislav Brabec [Mon, 25 May 2015 16:21:36 +0000 (18:21 +0200)]
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.
Karel Zak [Tue, 26 May 2015 08:32:38 +0000 (10:32 +0200)]
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>
Karel Zak [Fri, 22 May 2015 10:43:33 +0000 (12:43 +0200)]
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>
Georg Schiesser [Tue, 5 May 2015 11:19:51 +0000 (13:19 +0200)]
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>
Stanislav Brabec [Thu, 14 May 2015 15:55:56 +0000 (17:55 +0200)]
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.