Sami Kerola [Sun, 25 May 2014 21:17:25 +0000 (22:17 +0100)]
rename: allow renaming in subdirectories
Earlier the rename(1) considered path as possible string to be renamed,
could lead to an issue with none existing destination. See below for
demonstration of this issue. After this change all directory elements
are ignored when the match finding happens.
$ cd $(mktemp -d)
$ mkdir aa ab
$ touch a{a,b}/aa
$ rename -v a x */aa
rename: aa/aa: rename to xa/aa failed: No such file or directory
Karel Zak [Thu, 17 Jul 2014 15:17:46 +0000 (17:17 +0200)]
lsblk: check number of used columns
The current code does not check size of the columns[] array when add
the next on command line specified column. We check the array size for
"-o <columns>" but not for another options.
Old version:
$ for x in $(seq 0 100); do echo "-t"; done | xargs lsblk
xargs: lsblk: terminated by signal 11
new version:
$ for x in $(seq 0 100); do echo "-t"; done | xargs lsblk
lsblk: too many columns specified, the limit is 83 columns.
docs: bring four more man pages closer to standard formatting
In the IPC man pages strictly adhere to the memory, queue, semaphore
order, to reduce disorientation. And for 'ipcmk', the arguments for
-M and -S and -p are not optional. Add --version for 'mountpoint'.
Sami Kerola [Wed, 16 Jul 2014 20:54:57 +0000 (21:54 +0100)]
fallocate: avoid unnecessary computation
Where POSIX_FADV_SEQUENTIAL and HAVE_POSIX_FADVISE are not available it
is waste of resources to have variables that are meaningful only for
posix_fadvise(). Also initialize the variables immediately to correct
values, and since cachesz is never changed mark it read only.
Using angular brackets around each individual argument, indenting a
continuation line, not using a space before =, improving some wordings,
and the argument of --queue is a value (a piece of data), not a signal.
Karel Zak [Mon, 14 Jul 2014 14:03:48 +0000 (16:03 +0200)]
Merge branch 'minor-fixes' of git://github.com/kerolasa/lelux-utiliteetit
* 'minor-fixes' of git://github.com/kerolasa/lelux-utiliteetit:
lscpu: avoid double free
libsmartcols: avoid variable dereference after release
libfdisk: do not do the same thing twice in single if statement
whereis: avoid printing uninitialized string
setpriv: avoid alloca() use xmalloc() instead
dmesg: avoid unnecessary variable assignment
fdisk: avoid code duplication
mkfs.cramfs: use defined failure name rather than magic value
fdformat: match variable and print format types
cfdisk: add braces to ensure operation order
lscpu: avoid use of bzero() in favor of memset()
setterm: remove unnecessary variable
cal: remove unnused structure and definition
textual: fix some typos
The Debian package checking tool lintian thinks that the script is
missing Requires on $remote_fs because it pokes at stuff under /usr
and it's probably right.
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Sami Kerola [Wed, 9 Jul 2014 20:49:03 +0000 (21:49 +0100)]
kill: use --queue option argument as sigval integer value
The sigqueue(3) takes two values, signal and sigval. Contents of the
signal can be altered with --signal option argument, so the --queue
argument should be reserved to affect sigval_int.
Sami Kerola [Sun, 13 Jul 2014 16:58:36 +0000 (17:58 +0100)]
setpriv: avoid alloca() use xmalloc() instead
The getgroups() can return up to NGROUPS_MAX supplementary groups, that
is (since kernel 2.6.3) 65536 in total. The git_t is 4 bytes, so maximum
request is 256 kilobytes. When a system happen to have memory preasure
alloca() may not be able to allocate enough memory, making debugging
unnecessarily difficult. IMHO 64 pages is significant enough amount of
memory to be properly error checked at a time of allocation.
Reference: http://www.gnu.org/software/libc/manual/html_node/Disadvantages-of-Alloca.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Eric Rannaud [Fri, 27 Jun 2014 05:18:48 +0000 (22:18 -0700)]
findmnt: use mnt_cache_set_targets() for non-kernel table
findmnt compares the user-supplied path <target> with each entry in the
parsed table. To do this comparison, libmount attempts to canonicalize
the target path of each table entry, when the entry does not originate
from the kernel (kernel supplied target paths are already
canonicalized). However, if one of these entries is an active mount
point, stat(2) or readlink(2) on the mount target path can hang (e.g.
unreachable NFS server).
If the main table is not a kernel table, we parse /proc/self/mountinfo
into a secondary table and call mnt_cache_set_targets(). This allows
libmount to check that the target path of each entry in the main table
is not an active mount point, so it can avoid canonicalizing it.
Eric Rannaud [Fri, 27 Jun 2014 05:17:18 +0000 (22:17 -0700)]
libmount: mnt_resolve_target: tiptoe around active mount points
Current code in mnt_fs_match_target() and mnt_table_find_target()
already does not canonicalize active mount points (when read from
mountinfo), because they are already canonicalized by the kernel.
Calling realpath(fs->target) on a mount point can hang -- e.g. if the
NFS server is unreachable.
This patch optionally extends this strategy to the general case, that is
when @fs does not directly come from the kernel through mountinfo (for
instance, it may have been parsed from /etc/fstab).
Given @mtab parsed from mountinfo, and if mnt_cache_set_targets(cache,
mtab) is used, then mnt_fs_match_target() and mnt_table_find_target()
check whether @fs->target is a known mount point in the cached
mountinfo, before attempting to canonicalize @fs->target, no matter
where @fs itself comes from. If found in the cached mountinfo,
@fs->target is not canonicalized.
[kzak@redhat.com: - don't allocate libmnt_iter,
- add docs for mnt_cache_set_targets(),
- fallback to mnt_resolve_path() if no cache->mtab specified,
- use streq_except_trailing_slash() to compare paths]
Signed-off-by: Eric Rannaud <e@nanocritical.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Eric Rannaud [Fri, 27 Jun 2014 05:17:17 +0000 (22:17 -0700)]
libmount: mnt_resolve_path: don't canonicalize fs->target for swap
This is how mnt_table_find_target() does it. It makes sense because
@fs->target is "none" for swap and is never a sensible match for a
user-specified target.