]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
11 years agohwclock: fix possible hang and other set_hardware_clock_exact() issues
Chris MacGregor [Thu, 27 Feb 2014 18:40:59 +0000 (10:40 -0800)] 
hwclock: fix possible hang and other set_hardware_clock_exact() issues

In sys-utils/hwclock.c, set_hardware_clock_exact() has some problems when the
process gets pre-empted (for more than 100ms) before reaching the time for
which it waits:

1. The "continue" statement causes execution to skip the final tdiff
assignment at the end of the do...while loop, leading to the while condition
using the wrong value of tdiff, and thus always exiting the loop once
newhwtime != sethwtime (e.g., after 1 second).  This masks bug # 2, below.

2. The previously-existing bug is that because it starts over waiting for the
desired time whenever two successive calls to gettimeofday() return values >
100ms apart, the loop will never terminate unless the process holds the CPU
(without losing it for more than 100ms) for at least 500ms.  This can happen
on a heavily loaded machine or on a virtual machine (or on a heavily loaded
virtual machine).  This has been observed to occur, preventing a machine from
completing the shutdown or reboot process due to a "hwclock --systohc" call in
a shutdown script.

The new implementation presented in this patch takes a somewhat different
approach, intended to accomplish the same goals:

It computes the desired target system time (at which the requested hardware
clock time will be applied to the hardware clock), and waits for that time to
arrive.  If it misses the time (such as due to being pre-empted for too long),
it recalculates the target time, and increases the tolerance (how late it can
be relative to the target time, and still be "close enough".  Thus, if all is
well, the time will be set *very* precisely.  On a machine where the hwclock
process is repeatedly pre-empted, it will set the time as precisely as is
possible under the conditions present on that particular machine.  In any
case, it will always terminate eventually (and pretty quickly); it will never
hang forever.

[kzak@redhat.com: - tiny coding style changes]

Signed-off-by: Chris MacGregor <chrismacgregor@google.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibmount: define BTRFS_TEST_MAGIC if missing
Bernhard Voelker [Wed, 5 Mar 2014 10:55:34 +0000 (11:55 +0100)] 
libmount: define BTRFS_TEST_MAGIC if missing

* libmount/src/utils.c (BTRFS_TEST_MAGIC): Conditionally add define
which is used since commit v2.24-243-g6a52473.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
11 years agochcpu: cleanup stdout/stderr usage
Karel Zak [Wed, 5 Mar 2014 10:23:16 +0000 (11:23 +0100)] 
chcpu: cleanup stdout/stderr usage

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agochcpu: cleanup return codes
Karel Zak [Wed, 5 Mar 2014 10:06:59 +0000 (11:06 +0100)] 
chcpu: cleanup return codes

The code currently always return EXIT_SUCCESS, that's strange. It
seems better to return 0 on success, 1 on complete failure and 64 on
partial success.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agobuild-sys: don't connect _DEPENDENCIES and _LIBADD
Karel Zak [Wed, 5 Mar 2014 09:20:10 +0000 (10:20 +0100)] 
build-sys: don't connect _DEPENDENCIES and _LIBADD

The _DEPENDENCIES has to be used for dependencies on another in-tree
files, but _LIBADD is to specify additional libs (including external
libs).

Reported-by: oleid <notifications@github.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoMerge branch 'master' of https://github.com/rudimeier/util-linux
Karel Zak [Wed, 5 Mar 2014 08:25:43 +0000 (09:25 +0100)] 
Merge branch 'master' of https://github.com/rudimeier/util-linux

* 'master' of https://github.com/rudimeier/util-linux:
  travis-ci: import travis yaml controller

11 years agodocs: fix two command representations in the man page of more
Benno Schulenberg [Fri, 21 Feb 2014 17:22:33 +0000 (18:22 +0100)] 
docs: fix two command representations in the man page of more

The previous-file command is not :P but :p, and the back-to-where
command is not an acute accent but an apostrophe.  Also condense
some of the descriptions and remove some useless comments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
11 years agologger: allow user to send structured journald messages
Sami Kerola [Fri, 21 Feb 2014 19:25:30 +0000 (19:25 +0000)] 
logger: allow user to send structured journald messages

This feature is hopefully mostly used to give MESSAGE_ID labels for
messages coming from scripts, making search of messages easy.  The
logger(1) manual page update should give enough information how to use
--journald option.

[kzak@redhat.com: - add missing #ifdefs
                  - use xalloc.h]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agohexdump: color unit may now be longer than the corresponding format unit
Ondrej Oprala [Fri, 21 Feb 2014 14:34:45 +0000 (15:34 +0100)] 
hexdump: color unit may now be longer than the corresponding format unit

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
11 years agolscpu: read_hypervisor_dmi: only fallback to memory scan on x86/x86_64
Stewart Smith [Tue, 4 Mar 2014 04:39:41 +0000 (15:39 +1100)] 
lscpu: read_hypervisor_dmi: only fallback to memory scan on x86/x86_64

As the comment in the code says, this method is really only valid
on x86 and x86_64, so add a #ifdef for those architectures around
that code block.

This was causing "Program lscpu tried to access /dev/mem between f0000->100000."
warnings on some ppc64 machines.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
11 years agolscpu: don't assume filesystem supports d_type when searching for NUMA nodes
Stewart Smith [Tue, 4 Mar 2014 04:27:27 +0000 (15:27 +1100)] 
lscpu: don't assume filesystem supports d_type when searching for NUMA nodes

Not all file systems support the d_type field and simply checking for
d_type == DT_DIR in is_node_dirent would cause the test suite to fail
if run on (for example) XFS.

The simple fix is to check for DT_DIR or DT_UNKNOWN in is_node_dirent.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
11 years agoswitch_root: make dirent d_type usage more robust
Karel Zak [Tue, 4 Mar 2014 10:45:44 +0000 (11:45 +0100)] 
switch_root: make dirent d_type usage more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolib/sysfs: make dirent d_type usage more robust
Karel Zak [Tue, 4 Mar 2014 10:30:03 +0000 (11:30 +0100)] 
lib/sysfs: make dirent d_type usage more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agopartx: make dirent d_type usage more robust
Karel Zak [Tue, 4 Mar 2014 10:27:46 +0000 (11:27 +0100)] 
partx: make dirent d_type usage more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibmount: cgroup magic already defined
Karel Zak [Mon, 3 Mar 2014 11:10:08 +0000 (12:10 +0100)] 
libmount: cgroup magic already defined

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoumount: don't use mountinfo if possible
Karel Zak [Mon, 3 Mar 2014 09:36:15 +0000 (10:36 +0100)] 
umount: don't use mountinfo if possible

The umount(8) always parses /proc/self/mountinfo to get fstype and to
merge kernel mount options with userspace mount options from
/run/mount/utab. This behavior is overkill in many cases and it's
pretty expensive as kernel has to always compose *whole* mountinfo.
This performance disadvantage is visible for crazy use-cases with huge
number of mountpoints and frequently called umount(8).

It seems that we can bypass /proc/self/mountinfo by statfs() to get
filesystem type (statfs.f_type magic) and analyze /run/mount/utab
before we parse mountinfo.

This optimization is not used when:

 * umount(8) executed by non-root (as user= in utab is expected)
 * umount --lazy / --force (target is probably unreachable NFS, then
   use statfs() is pretty bad idea)
 * target is not a directory (e.g. umount /dev/sda1)
 * there is (deprecated) writeable mtab

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agodocs: refresh TODO
Karel Zak [Thu, 27 Feb 2014 12:34:36 +0000 (13:34 +0100)] 
docs: refresh TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotravis-ci: import travis yaml controller
Ruediger Meier [Wed, 26 Feb 2014 16:08:41 +0000 (17:08 +0100)] 
travis-ci: import travis yaml controller

.travis.yml is used for automatic builds on travis build farm
(https://travis-ci.org/) if the travis service hook is enabled for the
repo on github.

This inital yaml controller will run 2 different compilers (gcc, clang).
The test suite currently fails, that's why we don't abort yet.

11 years agomore: fix double free crash
Sami Kerola [Fri, 21 Feb 2014 10:17:11 +0000 (10:17 +0000)] 
more: fix double free crash

Commit b9579f1f44b46c9f12f1e01b01c02d82ae1cf728 moved fclose() to
checkf(), but missed removing file closure in magic().  Ironically the
cause of regression is in previous commit message.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agoscript: clean up files usage
Karel Zak [Fri, 21 Feb 2014 12:39:14 +0000 (13:39 +0100)] 
script: clean up files usage

 * don't initialize timingfd (to stderr) when -t not specified

 * care about timingfd dooutput() rather in main()

 * make timingdf gloval like fscript FILE

 * close all in done()

 * close irrelevant things in subshell and input processes

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoscript: Also flush writes to timing file.
Jesper Dahl Nyerup [Tue, 18 Feb 2014 19:48:45 +0000 (20:48 +0100)] 
script: Also flush writes to timing file.

If both -f and -t are given, flush the timing fd on each write, similar
to the behavior on the script fd. This allows playback of still-running
sessions, and reduces the risk of ending up with empty timing files when
script(1) exits abnormally.

Signed-off-by: Jesper Dahl Nyerup <nyerup@one.com>
11 years agofindmnt: add --bytes to print sizes in bytes
Karel Zak [Fri, 21 Feb 2014 11:27:58 +0000 (12:27 +0100)] 
findmnt: add --bytes to print sizes in bytes

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agomkfs: mark this wrapper as DEPRECATED
Karel Zak [Fri, 21 Feb 2014 11:04:18 +0000 (12:04 +0100)] 
mkfs: mark this wrapper as DEPRECATED

Theodore Ts'o:

 I'll add that I've never been convinced that the mkfs front end is all
 that useful.  It's probably better for people to explicitly run
 /sbin/mkfs.xfs, /sbin/mkfs.ext4, etc.., so you don't have to worry
 about which options get passed down to the file system specific mkfs
 program, and which ones are interpreted by /sbin/mkfs --- and I don't
 believe /sbin/mkfs adds enough (err, any?) value that using
 "/sbin/mkfs -t xxx" vs "/sbin/mkfs.xxx" makes any sense whatsoever.

... and I absolutely agree.

Reported-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agomore: improve formatting and wording of man page and help text
Benno Schulenberg [Sun, 9 Feb 2014 10:26:49 +0000 (11:26 +0100)] 
more: improve formatting and wording of man page and help text

Also, slice up the usage text for ease of translation.

Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
11 years agolibmount: FS id and parent ID could be zero
Karel Zak [Thu, 20 Feb 2014 15:59:11 +0000 (16:59 +0100)] 
libmount: FS id and parent ID could be zero

It seems that linux 3.14 is able to produce things like:

  19 0 8:3 / / rw,relatime - ext4 /dev/sda3 rw,data=ordered
     ^

Reported-by: Mantas Mikulėnas <grawity@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofallocate: fix missing sentinel for is_nul()
Karel Zak [Wed, 19 Feb 2014 13:26:52 +0000 (14:26 +0100)] 
fallocate: fix missing sentinel for is_nul()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: add extra checks to XFS prober
Karel Zak [Wed, 19 Feb 2014 12:27:56 +0000 (13:27 +0100)] 
libblkid: add extra checks to XFS prober

The current code rely on XFS magic string only. It seems too fragile.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofallocate: code optimalizations
Karel Zak [Wed, 19 Feb 2014 09:48:16 +0000 (10:48 +0100)] 
fallocate: code optimalizations

Based on Pádraig Brady review:

 * use is_nul() from coreutils rather then memcmp()

 * always call skip_hole() (SEEK_DATA)

 * fix possible overflows

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofallocate: use POSIX_FADV_DONTNEED to discard cached data
Karel Zak [Tue, 18 Feb 2014 12:01:52 +0000 (13:01 +0100)] 
fallocate: use POSIX_FADV_DONTNEED to discard cached data

The patch discard cached data in 1MiB (or bigger) steps.

Thanks to Pádraig Brady.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofallocate: use SEEK_DATA on already sparse files
Karel Zak [Tue, 18 Feb 2014 10:11:56 +0000 (11:11 +0100)] 
fallocate: use SEEK_DATA on already sparse files

It's more efficient to skip already known holes by SEEK_DATA (seek to
the next area with data).

Thanks to Pádraig Brady.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofallocate: fix man page synopsis
Karel Zak [Mon, 17 Feb 2014 14:34:08 +0000 (15:34 +0100)] 
fallocate: fix man page synopsis

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agobuild-sys: enable parallel tests for make check
Karel Zak [Mon, 17 Feb 2014 14:07:41 +0000 (15:07 +0100)] 
build-sys: enable parallel tests for make check

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: make tests to run parallel
Sami Kerola [Sun, 16 Feb 2014 23:54:15 +0000 (23:54 +0000)] 
tests: make tests to run parallel

Unarguably this change makes test output to be more messy, but when I
compare run time tells with clear numbers parallel is quicker.  For me
the quickness is important factor.  Running test suite always after a
change is preferrably quick, and if something is indicated to be broken
it is ok to spend time in drilling down what happen.

$ time ./tests/run.sh --parallel=5
[...]
real    1m48.037s

Same without parallelization.

$ time ./tests/run.sh
real    3m16.687s

The default is changed to be parallel, where job count is same as number
of CPUs.

[kzak@redhat.com: - propagate --parallel into function.sh
                  - don't use extra title for non-parallel execution
                  - disable by default]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: fdisk now prints SGI system partitions too
Karel Zak [Mon, 17 Feb 2014 13:34:31 +0000 (14:34 +0100)] 
tests: fdisk now prints SGI system partitions too

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: update libmount tabdiff tests
Karel Zak [Mon, 17 Feb 2014 13:32:22 +0000 (14:32 +0100)] 
tests: update libmount tabdiff tests

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: update ionice test
Karel Zak [Mon, 17 Feb 2014 13:30:03 +0000 (14:30 +0100)] 
tests: update ionice test

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoisosize: make --divisor to require argument
Sami Kerola [Sun, 16 Feb 2014 23:54:22 +0000 (23:54 +0000)] 
isosize: make --divisor to require argument

Silly bug, only the short option -d allowed divisor argument.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agotests: add isosize --sectors and --divisor tests
Sami Kerola [Sun, 16 Feb 2014 23:54:21 +0000 (23:54 +0000)] 
tests: add isosize --sectors and --divisor tests

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agoisosize: move file name printing after error determination
Sami Kerola [Sun, 16 Feb 2014 23:54:20 +0000 (23:54 +0000)] 
isosize: move file name printing after error determination

Earlier the filename printing was buffered, and exit at error made output
to appear in front of prompt.  Output below demonstrates the brokenness.

prompt> isosize /etc /
isosize: /etc: might not be an ISO filesystem
isosize: read error on /etc: Is a directory
/etc: prompt>

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agoswaplabel: wrong version number in check
Sami Kerola [Sun, 16 Feb 2014 23:54:19 +0000 (23:54 +0000)] 
swaplabel: wrong version number in check

$ swaplabel /dev/sda2
swaplabel: /dev/sda2: unsupported swap version '1'

The mkswap does not allow any other version, so swaplabel(8) must be
wrong.

Reference: https://github.com/karelzak/util-linux/blob/master/disk-utils/mkswap.c#L520
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agotests: align last.1 with recent phantom detection
Sami Kerola [Sun, 16 Feb 2014 23:54:18 +0000 (23:54 +0000)] 
tests: align last.1 with recent phantom detection

None existing account is not still-logged-in but gone mysteriously,
assuming wtmp logout markup is missing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agodocs: make hexdump.1 color specification easier to understand
Sami Kerola [Sun, 16 Feb 2014 23:54:17 +0000 (23:54 +0000)] 
docs: make hexdump.1 color specification easier to understand

Fix also spacing, input line lenghts, and troff table for data that is a
table.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agotools: add usage information to checkconfig.sh
Sami Kerola [Sun, 16 Feb 2014 23:54:16 +0000 (23:54 +0000)] 
tools: add usage information to checkconfig.sh

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agotests: avoid executing dirname(1) command
Sami Kerola [Sun, 16 Feb 2014 23:54:14 +0000 (23:54 +0000)] 
tests: avoid executing dirname(1) command

Bash parameter expansion does the same thing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agotests: fix trailing spaces in cal(1) stuff
Karel Zak [Mon, 17 Feb 2014 12:40:03 +0000 (13:40 +0100)] 
tests: fix trailing spaces in cal(1) stuff

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibmount: initialize *root to NULL in mnt_table_get_root_fs
Thomas Bächler [Sun, 16 Feb 2014 13:58:06 +0000 (14:58 +0100)] 
libmount: initialize *root to NULL in mnt_table_get_root_fs

mnt_table_get_root_fs only works when *root is set to NULL. This
is not only undocumented, but also unintuitive. Fix it by initializing
*root inside mnt_table_get_root_fs.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agosu: don't use kill(0, ...) when propagate signal
Karel Zak [Mon, 17 Feb 2014 12:22:30 +0000 (13:22 +0100)] 
su: don't use kill(0, ...) when propagate signal

The current code uses kill(0, caught_signal) after regular
signal cleanup and before exit (all just to make shells happy).

Unfortunately, kill(0, ...) is a bad idea. It seems better to use
kill(getpid(), ...) otherwise we kill our parent process too.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1063887
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibmount: make the mountinfo parser more robust
Karel Zak [Mon, 17 Feb 2014 12:17:47 +0000 (13:17 +0100)] 
libmount: make the mountinfo parser more robust

... sorry, the previous change to the parser was too stupid.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibmount: accept (deleted) path suffix in mountinfo file
Karel Zak [Mon, 17 Feb 2014 12:12:23 +0000 (13:12 +0100)] 
libmount: accept (deleted) path suffix in mountinfo file

Addresses: debian bug #711183
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoionice: add the way to specify the target processes with pgid and uid
Masatake YAMATO [Thu, 30 Jan 2014 14:52:38 +0000 (23:52 +0900)] 
ionice: add the way to specify the target processes with pgid and uid

ioprio_get and ioprio_set system call accept not only process ID but
also process group ID(pgid) and user ID(uid) to specify the target
process(es).  However, ionice command accepts only process ID.  With
this patch a user can specify the target processes with pgid(-P
option) and uid(-u option).

[kzak@redhat.com: - tiny cleanup in usage()]

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofallocate: improve --dig-holes
Karel Zak [Mon, 17 Feb 2014 09:55:56 +0000 (10:55 +0100)] 
fallocate: improve --dig-holes

 * don't use --length to specify hole size, always use stat.st_blksize

 * use --offset and --length to specify offset within the file (like
   another fallocate operations)

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofallocate: add --verbose, clean up usage()
Karel Zak [Fri, 14 Feb 2014 13:37:51 +0000 (14:37 +0100)] 
fallocate: add --verbose, clean up usage()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofallocate: Add "--dig-holes" option
Rodrigo Campos [Sun, 26 Jan 2014 15:06:50 +0000 (15:06 +0000)] 
fallocate: Add "--dig-holes" option

This option tries to detect chunk of '\0's and punch a hole, making the file
sparse in-place.

[kzak@redhat.com: - fix coding style, use xalloc.h and err.h]

Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofallocate: Hide #ifdef tricks to call fallocate in a function
Rodrigo Campos [Sat, 25 Jan 2014 19:17:27 +0000 (19:17 +0000)] 
fallocate: Hide #ifdef tricks to call fallocate in a function

Future patches will add more calls to fallocate(), so it will be useful to have
all these tricks inside a function.

The error message when fallocate is not supported is slightly changed: the file
name is not printed as a prefix because is not available in the context of the
function. Also, to only print one of the two possible errors (as happens when
using directly exit()), an else clause was added.

Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
11 years agofallocate: Clarify that space can also be deallocated
Rodrigo Campos [Sat, 25 Jan 2014 19:17:26 +0000 (19:17 +0000)] 
fallocate: Clarify that space can also be deallocated

The functionality is already there, with --punch-hole, but the text was for the
preallocation case only.

Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
11 years agoscriptreplay: Add --maxdelay option.
Jesper Dahl Nyerup [Mon, 10 Feb 2014 10:53:18 +0000 (11:53 +0100)] 
scriptreplay: Add --maxdelay option.

This option caps the delay between updates, to avoid long pauses in
transcript playback.

Signed-off-by: Jesper Dahl Nyerup <nyerup@one.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agocal: remove unnecessary static variables
Sami Kerola [Sun, 9 Feb 2014 17:20:29 +0000 (17:20 +0000)] 
cal: remove unnecessary static variables

Not in use since commit 95f4adde867492563167b11ba94dba67f93809aa.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agorenice: correct max priority in renice man page
Phillip Susi [Sat, 8 Feb 2014 18:22:10 +0000 (13:22 -0500)] 
renice: correct max priority in renice man page

The man page stated that the PRIO_MAX is 20.  While this
is correct, the header definition is wrong and the max
value is actually 19.

[kzak@redhat.com: - remove PRIO_MAX from man page, kernel syscalls
                    use hardcoded numbers for the priority limits]

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agomount: remove obsolete and confusing statement from mount.8
Phillip Susi [Sat, 8 Feb 2014 16:44:02 +0000 (11:44 -0500)] 
mount: remove obsolete and confusing statement from mount.8

The wording was confusing and suidperl has gone the way
of the dodo, and really didn't need mentionting in mount.8.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
11 years agofix mkfs --verbose and man page
Phillip Susi [Fri, 7 Feb 2014 22:01:20 +0000 (17:01 -0500)] 
fix mkfs --verbose and man page

mkfs did not actually accept the long form --verbose option.
Also the man page seemed to indicate that version/verbose/help
options were passed to the filesystem specific utility when this
is not the case.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
11 years agohwclock: internationalizing the message of the used interface
Benno Schulenberg [Sun, 26 Jan 2014 21:32:15 +0000 (22:32 +0100)] 
hwclock: internationalizing the message of the used interface

In addition, do it in a single sentence instead of in two fragments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
11 years agogetopt.1: The usual doc dir is /usr/share/doc, not .../docs
Ville Skyttä [Sat, 25 Jan 2014 12:23:49 +0000 (14:23 +0200)] 
getopt.1: The usual doc dir is /usr/share/doc, not .../docs

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
11 years agosetpriv: Fix --apparmor-profile
Andy Lutomirski [Fri, 24 Jan 2014 20:02:59 +0000 (12:02 -0800)] 
setpriv: Fix --apparmor-profile

There were two bugs.  First, trying to access /proc/self/attr/exec
with O_CREAT | O_EXCL has no chance of working.  Second, it turns
out that the correct command to send is "exec", not "changeprofile".
Of course, there was no way to know this until:

    commit 3eea57c26e49a5add4c053a031cc2a1977b7c48e
    Author: John Johansen <john.johansen@canonical.com>
    Date:   Wed Feb 27 03:44:40 2013 -0800

        apparmor: fix setprocattr arg processing for onexec

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
11 years agolast: make session gone determination more robust
Sami Kerola [Tue, 21 Jan 2014 22:05:05 +0000 (22:05 +0000)] 
last: make session gone determination more robust

Earlier determination that used kill with signal zero to pid was prone to
false positive reports, due reuse of pid space and unrelated processes.
New function is_phantom() tries do a little bit better job, but fails to
be perfect.  It seems linking to gether utmp session start time or
terminal id with /proc/<pid>/ information is not as simple as one might
hope.

Reported-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agohexdump: add highlighting support
Ondrej Oprala [Tue, 21 Jan 2014 16:13:56 +0000 (17:13 +0100)] 
hexdump: add highlighting support

[kzak@redhat.com: - fix coding style,
                  - use xalloc in all code,
  - fix strtol usage]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolib/color: add colorscheme parser
Karel Zak [Mon, 10 Feb 2014 13:50:12 +0000 (14:50 +0100)] 
lib/color: add colorscheme parser

11 years agoMerge branch 'master' of https://github.com/micha137/util-linux
Karel Zak [Mon, 10 Feb 2014 10:07:01 +0000 (11:07 +0100)] 
Merge branch 'master' of https://github.com/micha137/util-linux

11 years agolsblk: add PARTTYPE tag
Michael Marineau [Tue, 14 Jan 2014 21:19:50 +0000 (13:19 -0800)] 
lsblk: add PARTTYPE tag

To stay in sync with blkid add PARTTYPE as an available output column.

11 years agotests: automatic whitespace trimming broke earlier commit
Sami Kerola [Wed, 15 Jan 2014 20:15:53 +0000 (20:15 +0000)] 
tests: automatic whitespace trimming broke earlier commit

Setting in .gitconfig to do 'git apply --whitespace=fix' automatically
turned automation against user.

Frankencommit: 4d2f0d08f67707b6d44d4a45fb6e21876c02c731
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agotests: cal(1) is year is limited to signed 32 bit value
Sami Kerola [Wed, 15 Jan 2014 20:15:52 +0000 (20:15 +0000)] 
tests: cal(1) is year is limited to signed 32 bit value

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agocal: limit year to 32 bit value
Sami Kerola [Wed, 15 Jan 2014 20:15:51 +0000 (20:15 +0000)] 
cal: limit year to 32 bit value

This is done to keep things simple, when considering tests, for both 64
and 32 bit architectures.  Setting the upper limit of a year value to to
2^31-1 (2147483646) should be enough for anyone.

Reported-by: Mike Frysinger <vapier@gentoo.org>
Reference: http://www.spinics.net/lists/util-linux-ng/msg08662.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agofsck: don't return error if fsck.<type> does not exist
Karel Zak [Thu, 6 Feb 2014 15:42:26 +0000 (16:42 +0100)] 
fsck: don't return error if fsck.<type> does not exist

The error message is expected for "really wanted" set of filesystems
(extN, ..), otherwise it does not make sense for filesystems like
btrfs or xfs.

Reported-by: Tom Gundersen <teg@jklm.no>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agonsenter: fix set{gid,uid} order,drop supplementary groups
Karel Zak [Thu, 6 Feb 2014 13:14:50 +0000 (14:14 +0100)] 
nsenter: fix set{gid,uid} order,drop supplementary groups

.. always, always setgid() before setuid()!

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1061751
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agodmesg: -w output not line-buffered
Karel Zak [Thu, 6 Feb 2014 10:48:40 +0000 (11:48 +0100)] 
dmesg: -w output not line-buffered

when writing to e.g. a pipe, output from dmesg -w can come many
minutes late due to buffering.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1060925
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolosetup: wait for udev
Karel Zak [Fri, 24 Jan 2014 12:58:40 +0000 (13:58 +0100)] 
losetup: wait for udev

On system with /dev/lop-control the udevd creates /dev/loopN nodes.
It seems better to wait a moment after unsuccessful open(/dev/loopN)
and try it to open again.

The problem is pretty visible on systems where udevd also modifies
permission for loopN devices, then open() fails with EACCES when
losetup executed by non-root user (but user who is in "disk" group).

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1045432
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoinclude/c.h: prefer nanosleep() over usleep()
Karel Zak [Fri, 24 Jan 2014 12:04:14 +0000 (13:04 +0100)] 
include/c.h: prefer nanosleep() over usleep()

Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.

The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.

The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoflock: Change the 'exit status' man page section to make more sense
Wieland Hoffmann [Thu, 16 Jan 2014 00:06:32 +0000 (01:06 +0100)] 
flock: Change the 'exit status' man page section to make more sense

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
11 years agowipefs: call BLKRRPART when erase partition table
Karel Zak [Mon, 20 Jan 2014 11:07:35 +0000 (12:07 +0100)] 
wipefs: call BLKRRPART when erase partition table

It's better to be smart than make things inconsistent (without
BLKRRPART kernel still uses the erased PT and udev-db still contains
obsolete information).

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: detect alone PMBR
Karel Zak [Mon, 20 Jan 2014 09:51:00 +0000 (10:51 +0100)] 
libblkid: detect alone PMBR

wipefs(8) has to also erase PMBR, not GPR header only, otherwise the
device could be still interpreted as a device with a partition table.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1054186
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: update build-sys tests
Karel Zak [Fri, 17 Jan 2014 14:00:55 +0000 (15:00 +0100)] 
tests: update build-sys tests

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agobuild-sys: fstrim depends on libmount
Karel Zak [Fri, 17 Jan 2014 13:34:53 +0000 (14:34 +0100)] 
build-sys: fstrim depends on libmount

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agomkswap: fix compiler warning [-Wunused-variable]
Karel Zak [Fri, 17 Jan 2014 13:33:31 +0000 (14:33 +0100)] 
mkswap: fix compiler warning [-Wunused-variable]

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: no more probe for btrfs backup superblock
Karel Zak [Thu, 16 Jan 2014 15:38:30 +0000 (16:38 +0100)] 
libblkid: no more probe for btrfs backup superblock

 * Linux kernel cares about the first superblock only

 * backup superblock are FS specific stuff and there is no reason to
   care about it in generic tools

 * the problem with broken btrfs utils has been already fixed (it was
   possible to use the utils on filesystem with erased primary
   superblok without any warning message).

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agowipefs: add comments to code
Karel Zak [Thu, 16 Jan 2014 15:33:16 +0000 (16:33 +0100)] 
wipefs: add comments to code

11 years agoscript: use all-io.h to make the code more robust
Karel Zak [Thu, 16 Jan 2014 13:44:37 +0000 (14:44 +0100)] 
script: use all-io.h to make the code more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoscript: fix inconsistent -q, use poll() rather then O_NONBLOCK
Karel Zak [Thu, 16 Jan 2014 12:18:24 +0000 (13:18 +0100)] 
script: fix inconsistent -q, use poll() rather then O_NONBLOCK

 - don't suppress "Script done" message in typescript file by -q
   (note that -q has no effect to "Script started" message)

 - simplify the code by poll()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoscript: don't wait for empty descriptors if child is dead
Karel Zak [Thu, 16 Jan 2014 11:22:13 +0000 (12:22 +0100)] 
script: don't wait for empty descriptors if child is dead

The current code waits for empty file master and slave descriptors,
but it makes sense only if there is child process that cares (read)
about data in the descriptors.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoionice: Fix output for case ioclass==0
Michael Bunk [Wed, 15 Jan 2014 16:38:37 +0000 (17:38 +0100)] 
ionice: Fix output for case ioclass==0

output "none" instead of "unknown"

11 years agopartx: use blkid_partlist_get_partition_by_partno()
Karel Zak [Wed, 15 Jan 2014 09:52:47 +0000 (10:52 +0100)] 
partx: use blkid_partlist_get_partition_by_partno()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: add blkid_partlist_get_partition_by_partno()
Karel Zak [Wed, 15 Jan 2014 09:52:16 +0000 (10:52 +0100)] 
libblkid: add blkid_partlist_get_partition_by_partno()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolib/sysfs: fix scanf format string [coverity scan]
Karel Zak [Tue, 14 Jan 2014 17:02:06 +0000 (18:02 +0100)] 
lib/sysfs: fix scanf format string [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibmount: fix scanf format string [coverity scan]
Karel Zak [Tue, 14 Jan 2014 17:00:14 +0000 (18:00 +0100)] 
libmount: fix scanf format string [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agorename: fix mem leak [coverity scan]
Karel Zak [Tue, 14 Jan 2014 16:56:47 +0000 (17:56 +0100)] 
rename: fix mem leak [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agocolumn: fix mem leak [coverity scan]
Karel Zak [Tue, 14 Jan 2014 16:53:22 +0000 (17:53 +0100)] 
column: fix mem leak [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agomore: fix mem leak [coverity scan]
Karel Zak [Tue, 14 Jan 2014 16:49:34 +0000 (17:49 +0100)] 
more: fix mem leak [coverity scan]

... the code is so soo ugly.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agopylibmount: import directly from pylibmount in tests
Karel Zak [Tue, 14 Jan 2014 16:34:08 +0000 (17:34 +0100)] 
pylibmount: import directly from pylibmount in tests

This change does not have any impact to in a standard way installed
libmount impact. It's simplification for in-tree tests.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agopylibmount: remove unncessary subdirectory
Karel Zak [Tue, 14 Jan 2014 13:57:44 +0000 (14:57 +0100)] 
pylibmount: remove unncessary subdirectory

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: update lscpu tests
Karel Zak [Tue, 14 Jan 2014 12:58:38 +0000 (13:58 +0100)] 
tests: update lscpu tests

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolscpu: sort NUMA nodes to keep output human readable
Karel Zak [Tue, 14 Jan 2014 12:56:27 +0000 (13:56 +0100)] 
lscpu: sort NUMA nodes to keep output human readable

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agodocs: add lslogins(1) to TODO
Karel Zak [Tue, 14 Jan 2014 09:17:16 +0000 (10:17 +0100)] 
docs: add lslogins(1) to TODO

Signed-off-by: Karel Zak <kzak@redhat.com>