]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
10 years agobuild-sys: remove deprecated elvtune command
Karel Zak [Tue, 13 Aug 2013 13:55:52 +0000 (15:55 +0200)] 
build-sys: remove deprecated elvtune command

The command is deprecated for years and useless with 2.6.x kernels.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: enable mesg(1) by default
Karel Zak [Tue, 13 Aug 2013 12:11:12 +0000 (14:11 +0200)] 
build-sys: enable mesg(1) by default

It seems that our mesg(1) implementation is compatible with sysvinit,
let's use it by default in mainstream distros.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agowall: make banner sysvinit compatible
Karel Zak [Tue, 13 Aug 2013 10:23:21 +0000 (12:23 +0200)] 
wall: make banner sysvinit compatible

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agowall: allow to specify <message> on command line
Karel Zak [Tue, 13 Aug 2013 09:45:54 +0000 (11:45 +0200)] 
wall: allow to specify <message> on command line

wall(1) from sysvinit supports

   # wall I love this company!

semantic, This patch add this functionally to the util-linux wall.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolast: add link to util-linux to last.1
Karel Zak [Tue, 13 Aug 2013 08:26:28 +0000 (10:26 +0200)] 
last: add link to util-linux to last.1

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolast: coding style clean up
Karel Zak [Tue, 13 Aug 2013 08:22:50 +0000 (10:22 +0200)] 
last: coding style clean up

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolast: use xalloc.h, err.h, nls.h and EXIT_ macros
Karel Zak [Mon, 12 Aug 2013 12:10:42 +0000 (14:10 +0200)] 
last: use xalloc.h, err.h, nls.h and EXIT_ macros

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolast: consolidate btmp/wtmp file paths
Karel Zak [Mon, 12 Aug 2013 11:42:25 +0000 (13:42 +0200)] 
last: consolidate btmp/wtmp file paths

 .. so share the paths with another utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolast: add long options, improve usage()
Karel Zak [Mon, 12 Aug 2013 11:39:11 +0000 (13:39 +0200)] 
last: add long options, improve usage()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: fix last stuff
Karel Zak [Mon, 12 Aug 2013 10:59:52 +0000 (12:59 +0200)] 
build-sys: fix last stuff

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: improbe UL_CONFLICT_BUILD macro
Karel Zak [Mon, 12 Aug 2013 10:59:22 +0000 (12:59 +0200)] 
build-sys: improbe UL_CONFLICT_BUILD macro

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolast: clean up the begin of the file
Karel Zak [Mon, 12 Aug 2013 10:26:03 +0000 (12:26 +0200)] 
last: clean up the begin of the file

 .. and improve last(1) stuff in configure script.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolast: merge sysvinit last/lastb
Ondrej Oprala [Tue, 6 Aug 2013 16:19:37 +0000 (18:19 +0200)] 
last: merge sysvinit last/lastb

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoagetty: -L accepts optional argument
Karel Zak [Tue, 6 Aug 2013 13:39:11 +0000 (15:39 +0200)] 
agetty: -L accepts optional argument

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolosetup: use loop-control to explicitly ask for device
Karel Zak [Tue, 6 Aug 2013 09:04:35 +0000 (11:04 +0200)] 
losetup: use loop-control to explicitly ask for device

Now we use LOOP_CTL_GET_FREE ioctl to ask for free device, for example

  losetup -f foo.img

Unfortunately, losetup(8) allows to ask for specified device

  losetup /dev/loop100 foo.img

and in this case we assume that the device already exists in the
system. This is incorrect, we should be able to use loop-control
LOOP_CTL_ADD ioctl to ask for the specified device.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoblkdiscard: use fstat() rather than stat() [coverity scan]
Karel Zak [Tue, 6 Aug 2013 08:29:04 +0000 (10:29 +0200)] 
blkdiscard: use fstat() rather than stat() [coverity scan]

 Calling function "open(char const *, int, ...)" that uses "path" after
 a check function. This can cause a time-of-check, time-of-use race
 condition.

.. well, in blkdiscard context it's mostly cosmetic change.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolosetup: fix loop device name usage
Karel Zak [Mon, 5 Aug 2013 14:03:15 +0000 (16:03 +0200)] 
losetup: fix loop device name usage

The code is not paranoid enough, loopcxt_set_device() only set the
device name to loopdev struct, but it does not check if the device
really exists.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: be robust when work with loopdev backing file paths
Karel Zak [Mon, 5 Aug 2013 13:24:30 +0000 (15:24 +0200)] 
libmount: be robust when work with loopdev backing file paths

It's usually unnecessary as we compare devno and ino, but let's
use absolute paths for situations when it's necessary to compare
paths as strings.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolosetup: make -j <path> more robust
Karel Zak [Mon, 5 Aug 2013 13:24:30 +0000 (15:24 +0200)] 
losetup: make -j <path> more robust

It's usually unnecessary as we compare devno and ino, but let's
use absolute paths for situations when it's necessary to compare
paths as strings.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: canonicalize for conversion from loopdev backing file
Karel Zak [Mon, 5 Aug 2013 11:58:01 +0000 (13:58 +0200)] 
libmount: canonicalize for conversion from loopdev backing file

  # mount foo.img /mnt
  # umount foo.img
  umount: foo.img: not mounted

The loopdev code (and sysfs backing_file) uses absolute paths, but
libmount does not canonicalize the path before lookup for the backing file.

References: https://bugzilla.redhat.com/show_bug.cgi?id=950497
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agocal: set statically defined data read-only
Sami Kerola [Sat, 3 Aug 2013 23:15:21 +0000 (00:15 +0100)] 
cal: set statically defined data read-only

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomore: make output redirection more efficient
Sami Kerola [Sat, 3 Aug 2013 23:15:20 +0000 (00:15 +0100)] 
more: make output redirection more efficient

Especially with large inputs the change improves performance
considerably.

old> time more /boot/vmlinuz >/dev/null
real    0m0.224s

new> more /boot/vmlinuz >/dev/null
real    0m0.009s

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agocolumn: use variable lenght printf field width to wprint blanks
Sami Kerola [Sat, 3 Aug 2013 23:15:19 +0000 (00:15 +0100)] 
column: use variable lenght printf field width to wprint blanks

This makes program to run a little faster.  My test input show about 20%
speed improvement.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolibmount: fix typos
Ondrej Oprala [Fri, 2 Aug 2013 10:23:50 +0000 (12:23 +0200)] 
libmount: fix typos

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
10 years agomore: guarantee space for multibyte
Karel Zak [Thu, 1 Aug 2013 14:41:50 +0000 (16:41 +0200)] 
more: guarantee space for multibyte

.. to make the code more robust.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomore: check for buffer size when write multibyte char
Karel Zak [Thu, 1 Aug 2013 14:00:21 +0000 (16:00 +0200)] 
more: check for buffer size when write multibyte char

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomkswap: add note about swap header limit to the man page
Karel Zak [Thu, 1 Aug 2013 13:00:02 +0000 (15:00 +0200)] 
mkswap: add note about swap header limit to the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agorev: use string printing rather than character output
Sami Kerola [Sun, 28 Jul 2013 21:11:21 +0000 (22:11 +0100)] 
rev: use string printing rather than character output

Fliping a string in memory, and printing it with multibyte output
function makes the command about 1/3 quicker.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agobuild-sys: use backticks rather than $() for commands in configure
Sami Kerola [Sun, 28 Jul 2013 21:11:20 +0000 (22:11 +0100)] 
build-sys: use backticks rather than $() for commands in configure

The configure had both backticks and $() in use.  These command
susbstitutions are mutually interchangeable, so one should pick only one
form.  In this case backticks were favored because they are known with
greater range of shells, making the backticks to be more portable.

References: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Shell-Substitutions.html#index-g_t_0024_0028_0040var_007bcommands_007d_0029-1632
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agobuild-sys: prefer AS_IF rather than shell 'if'
Sami Kerola [Sun, 28 Jul 2013 21:11:19 +0000 (22:11 +0100)] 
build-sys: prefer AS_IF rather than shell 'if'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agobuild-sys: prefer AS_CASE rather than shell 'case'
Sami Kerola [Sun, 28 Jul 2013 21:11:18 +0000 (22:11 +0100)] 
build-sys: prefer AS_CASE rather than shell 'case'

References: http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Limitations-of-Builtins.html#case
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agobuild-sys: use m4 quoting consistently
Sami Kerola [Sun, 28 Jul 2013 21:11:17 +0000 (22:11 +0100)] 
build-sys: use m4 quoting consistently

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agosetarch: prefer preprocessor rather than autotools check
Sami Kerola [Sun, 28 Jul 2013 21:11:16 +0000 (22:11 +0100)] 
setarch: prefer preprocessor rather than autotools check

It seems to be pointless to spend time in ./configure phase when
preprocessor has to perform #ifndef check anyway.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolscpu: fix shadow declaration [smatch scan]
Sami Kerola [Sun, 28 Jul 2013 21:11:15 +0000 (22:11 +0100)] 
lscpu: fix shadow declaration [smatch scan]

sys-utils/lscpu.c:572:22: warning: symbol 'fd' shadows an earlier one

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomore: fix buffer overflow
Karel Zak [Thu, 1 Aug 2013 10:58:22 +0000 (12:58 +0200)] 
more: fix buffer overflow

The bug has been probably introduced by commit
1ac300932deab8dea2c43050921bbbdb36d62ff1.

Reported-by: "Dr. David Alan Gilbert" <dave@treblig.org>
References: https://bugzilla.novell.com/show_bug.cgi?id=829720
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosetsid: add an option to wait child return value
Daniel Kahn Gillmor [Mon, 22 Jul 2013 11:56:47 +0000 (12:56 +0100)] 
setsid: add an option to wait child return value

This change proposed in util-linux maillist by Damien Wyart in behalf of
Daniel Kahn Gillmor.  Sami Kerola changed the patch to use option rather
than makign the default behavior of the command to change.

Reported-by: Damien Wyart <damien.wyart@gmail.com>
Reference: http://markmail.org/message/2z6qh5auk7wjie3l
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=495881
CC: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolibmount: add missing declarations to libmount.h.in and documentation
Ondrej Oprala [Tue, 30 Jul 2013 12:25:31 +0000 (14:25 +0200)] 
libmount: add missing declarations to libmount.h.in and documentation

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
10 years agolibmount: change tailing to trailing in *_tailing_comments functions
Ondrej Oprala [Tue, 30 Jul 2013 12:17:46 +0000 (14:17 +0200)] 
libmount: change tailing to trailing in *_tailing_comments functions

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
10 years agodmesg: don't use pager for --follow
Karel Zak [Mon, 29 Jul 2013 11:48:20 +0000 (13:48 +0200)] 
dmesg: don't use pager for --follow

References: https://bugzilla.redhat.com/show_bug.cgi?id=984666
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolosetup: set errno for misaligned offsets
Karel Zak [Fri, 19 Jul 2013 15:05:31 +0000 (17:05 +0200)] 
losetup: set errno for misaligned offsets

References: https://bugs.archlinux.org/task/36189
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomount: update xfs docs
Karel Zak [Tue, 16 Jul 2013 09:23:51 +0000 (11:23 +0200)] 
mount: update xfs docs

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agohwclock: remove references to adjtimex from man page
Karel Zak [Mon, 15 Jul 2013 16:04:00 +0000 (18:04 +0200)] 
hwclock: remove references to adjtimex from man page

The adjtimex is optional on many distros.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosfdisk: don't use word 'disk'.
Karel Zak [Mon, 15 Jul 2013 10:14:10 +0000 (12:14 +0200)] 
sfdisk: don't use word 'disk'.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agouuidd: add missing initializer [clang-analyzer]
Karel Zak [Tue, 9 Jul 2013 12:45:41 +0000 (14:45 +0200)] 
uuidd: add missing initializer [clang-analyzer]

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: fix memory leak [clang-analyzer]
Karel Zak [Tue, 9 Jul 2013 12:39:49 +0000 (14:39 +0200)] 
libmount: fix memory leak [clang-analyzer]

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosulogin: fix compiler warning
Karel Zak [Tue, 9 Jul 2013 12:32:05 +0000 (14:32 +0200)] 
sulogin: fix compiler warning

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomore: use variable lenght printf field width to print blanks
Sami Kerola [Sun, 7 Jul 2013 19:54:49 +0000 (20:54 +0100)] 
more: use variable lenght printf field width to print blanks

This makes program to run a little faster.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agocolumn: dereference of null pointer [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:48 +0000 (20:54 +0100)] 
column: dereference of null pointer [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoul: use string printing function
Sami Kerola [Sun, 7 Jul 2013 19:54:47 +0000 (20:54 +0100)] 
ul: use string printing function

Use of for loop and printing a string character by character is slower
than to print whole string with single function.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoul: use correct types
Sami Kerola [Sun, 7 Jul 2013 19:54:46 +0000 (20:54 +0100)] 
ul: use correct types

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoagetty: fix memory leak [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:44 +0000 (20:54 +0100)] 
agetty: fix memory leak [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agosulogin: fix memory leak [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:43 +0000 (20:54 +0100)] 
sulogin: fix memory leak [clang-analyzer]

And make code a little bit more robust.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agosfdisk: assigned value is never read [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:42 +0000 (20:54 +0100)] 
sfdisk: assigned value is never read [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: assigned value is never read [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:35 +0000 (20:54 +0100)] 
chfn: assigned value is never read [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoeject: assigned value is never read [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:34 +0000 (20:54 +0100)] 
eject: assigned value is never read [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomkfs.cramfs: argument to free() is a constant address [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:33 +0000 (20:54 +0100)] 
mkfs.cramfs: argument to free() is a constant address [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoutmpdump: assigned values are never read [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:32 +0000 (20:54 +0100)] 
utmpdump: assigned values are never read [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomore: assigned value is never read [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:31 +0000 (20:54 +0100)] 
more: assigned value is never read [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolscpu: fix memory leak [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:30 +0000 (20:54 +0100)] 
lscpu: fix memory leak [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoipcs: assigned values are never read [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:29 +0000 (20:54 +0100)] 
ipcs: assigned values are never read [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolib/mbsalign: initializations values are never read [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:27 +0000 (20:54 +0100)] 
lib/mbsalign: initializations values are never read [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolib/loopdev: assigned value is never read [clang-analyzer]
Sami Kerola [Sun, 7 Jul 2013 19:54:26 +0000 (20:54 +0100)] 
lib/loopdev: assigned value is never read [clang-analyzer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodmesg: inform user --show-delta and iso8601 time format does not mix
Sami Kerola [Sun, 7 Jul 2013 19:54:25 +0000 (20:54 +0100)] 
dmesg: inform user --show-delta and iso8601 time format does not mix

References: http://marc.info/?l=util-linux-ng&m=137267606929951&w=2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodocs: add missing options to sfdisk manual
Sami Kerola [Sun, 7 Jul 2013 19:54:17 +0000 (20:54 +0100)] 
docs: add missing options to sfdisk manual

And improve what is said about four of the dangerous options.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agosfdisk: make unhiding as complete as possible
Sami Kerola [Sun, 7 Jul 2013 19:54:16 +0000 (20:54 +0100)] 
sfdisk: make unhiding as complete as possible

It is unlikely anyone will ever need this, but I like idea commands being
complete.  The partition id's that can be unhide after this change are;

Hidden HPFS/NTFS
Hidden W95 FAT32
Hidden W95 FAT32 (LBA)
Hidden W95 FAT16 (LBA)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoMerge branch 'patch-1' of https://github.com/kernc/util-linux
Karel Zak [Tue, 9 Jul 2013 09:16:28 +0000 (11:16 +0200)] 
Merge branch 'patch-1' of https://github.com/kernc/util-linux

* 'patch-1' of https://github.com/kernc/util-linux:
  Fixes "getty: unrecognized option '--loginpause'"

10 years agodocs: make description of --activate clearer on man page of sfdisk
Benno Schulenberg [Wed, 3 Jul 2013 10:09:10 +0000 (12:09 +0200)] 
docs: make description of --activate clearer on man page of sfdisk

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agodocs: fix wording and formatting of man page for dmesg
Benno Schulenberg [Wed, 3 Jul 2013 09:34:25 +0000 (11:34 +0200)] 
docs: fix wording and formatting of man page for dmesg

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agodocs: improve formatting and wording of man pages for fdisk and cfdisk
Benno Schulenberg [Sun, 16 Jun 2013 12:37:52 +0000 (14:37 +0200)] 
docs: improve formatting and wording of man pages for fdisk and cfdisk

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agounshare: add --mount-proc for pid namespaces
Karel Zak [Wed, 3 Jul 2013 10:28:16 +0000 (12:28 +0200)] 
unshare: add --mount-proc for pid namespaces

Based on patch from Mike Frysinger <vapier@gentoo.org>.

Mike Frysinger wrote:
 When it comes to pid namespaces, it's also useful for /proc to reflect
 the current namespace.  Again, this is easy to pull off, but annoying
 to force everyone to do it themselves.  So let's add a --mount-proc to
 do the magic for us.  The downside is that this also implies creating
 a mount namespace as mounting the new pid namespace /proc over top the
 system one will quickly break all other processes on the system.

Signed-off-by: Karel Zak <kzak@redhat.com>
Acked-by: Mike Frysinger <vapier@gentoo.or>
10 years agounshare: add --fork options for pid namespaces
Mike Frysinger [Fri, 28 Jun 2013 00:04:58 +0000 (20:04 -0400)] 
unshare: add --fork options for pid namespaces

The ability of unshare to launch a new pid namespace is a bit limited.
The first process in the namespace is expected to be the "init" for it.
When it's not, you get bad behavior.

For example, trying to launch a shell in a new pid namespace fails very
quickly:
$ sudo unshare -p dash
# uname -r
3.8.3
# uname -m
dash: 2: Cannot fork
# ls -ld /
dash: 3: Cannot fork
# echo $$
1324

For this to work smoothly, we need an init process to actively watch over
things.  But forcing people to re-use an existing init or write their own
mini init is a bit overkill.  So let's add a --fork option to unshare to
do this common bit of book keeping.  Now we can do:
$ sudo unshare -p --fork dash
# uname -r
3.8.3
# uname -m
x86_64
# ls -ld /
drwxr-xr-x 22 root root 4096 May  4 14:01 /
# echo $$
1

Thanks to Michael Kerrisk for his namespace articles on lwn.net

[kzak@redhat.com: - fix "forkif logic, remove --mount-proc]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoinclude/xalloc: add warn_unused_result to allocation functions
Karel Zak [Tue, 9 Jul 2013 08:44:06 +0000 (10:44 +0200)] 
include/xalloc: add warn_unused_result to allocation functions

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolsblk: use devno to check if the filesystem is mounted
Karel Zak [Mon, 8 Jul 2013 12:21:03 +0000 (14:21 +0200)] 
lsblk: use devno to check if the filesystem is mounted

The device (for example LVM logical volume) could be renamed and then
the device name from /proc/self/mountinfo does not match with reality.
So, we also need to check devno. Unfortunately we cannot completely
rely on devno, because for example btrfs uses psudo device numbers.

References: https://bugzilla.redhat.com/show_bug.cgi?id=980463
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolsblk: use devno to get mountpoint
Karel Zak [Mon, 8 Jul 2013 12:21:03 +0000 (14:21 +0200)] 
lsblk: use devno to get mountpoint

The device (for example LVM logical volume) could be renamed and then
the device name from /proc/self/mountinfo does not match with reality.
So, we also need to check devno. Unfortunately we cannot completely
rely on devno, because for example btrfs uses psudo device numbers.

References: https://bugzilla.redhat.com/show_bug.cgi?id=980463
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoFixes "getty: unrecognized option '--loginpause'"
kernc [Thu, 4 Jul 2013 15:02:57 +0000 (17:02 +0200)] 
Fixes "getty: unrecognized option '--loginpause'"

Usage incorrectly stated --loginpause is a valid option, where instead --login-pause is.

Also --no-hostname --> --nohostname.

10 years agofindmnt: avoid unused parameter warning
Karel Zak [Wed, 3 Jul 2013 10:42:06 +0000 (12:42 +0200)] 
findmnt: avoid unused parameter warning

Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: update libmount fstab full parse test
Karel Zak [Wed, 3 Jul 2013 09:23:39 +0000 (11:23 +0200)] 
tests: update libmount fstab full parse test

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: add functions to safely replace a fs table
Ondrej Oprala [Fri, 14 Jun 2013 11:00:49 +0000 (13:00 +0200)] 
libmount: add functions to safely replace a fs table

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
10 years agolibmount: add functions to handle comments in fs tables
Ondrej Oprala [Fri, 14 Jun 2013 10:41:30 +0000 (12:41 +0200)] 
libmount: add functions to handle comments in fs tables

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: add a generic append_string() function
Karel Zak [Tue, 2 Jul 2013 09:58:58 +0000 (11:58 +0200)] 
libmount: add a generic append_string() function

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: be more restrictive about valid tag names
Karel Zak [Tue, 2 Jul 2013 08:46:10 +0000 (10:46 +0200)] 
libmount: be more restrictive about valid tag names

 # mount DUMMY=filename.img /mnt

The 'DUMMY=filename.img' is a filename and should not be
interpreted as tag name. The valid tag names are LABEL, UUID,
PARTLABEL and PARTUUID only.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/canonical: use realpath() from libc
Karel Zak [Mon, 1 Jul 2013 14:13:46 +0000 (16:13 +0200)] 
lib/canonical: use realpath() from libc

.. after many many years it seems that we can follow libc code rather
than duplicate realpath(3) implementation.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofindmnt: make udev usage more robust
Karel Zak [Mon, 1 Jul 2013 13:59:16 +0000 (15:59 +0200)] 
findmnt: make udev usage more robust

 $ findmnt -rn --target /home/kzak/.bashrc -o UUID

uses libudev to ask for UUID, unfortunately /home/kzak is DM device
and libudev expects sysfs-like names (e.g. dm-0). We have to convert
the name to kernel devname.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agodmesg: make time stamps to be printed consistently
Sami Kerola [Sun, 30 Jun 2013 18:11:22 +0000 (19:11 +0100)] 
dmesg: make time stamps to be printed consistently

Earlier uptime determination, which was done with sysinfo(2), had one
second resolution, which made time stamps to be rounded unstable way
depending on when a dmesg command was executed.  In practical terms; the
command below was supposed not to differ but it did.

$ diff -q <(dmesg --ctime) <(sleep 0.5 ; dmesg --ctime)

[kzak@redhat.com: - add -lrt to Makemodule.am,
                  - fallback to sysinfo() based boot time
                  - use #ifdef]

CC: Kay Sievers <kay@vrfy.org>
References: https://lkml.org/lkml/2013/6/30/37
Buglink: https://github.com/karelzak/util-linux/issues/24
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosfdisk: fix typo
Karel Zak [Mon, 1 Jul 2013 12:06:16 +0000 (14:06 +0200)] 
sfdisk: fix typo

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoul: enhance command performance
Sami Kerola [Sun, 30 Jun 2013 08:44:00 +0000 (09:44 +0100)] 
ul: enhance command performance

Avoid reseting, time after time, the memory which was not used.  Effect
of the change is below in before and after timings.

$ time ./ul </etc/services >/dev/null
real    0m0.320s
user    0m0.307s
sys     0m0.010s

$ time ./ul </etc/services >/dev/null
real    0m0.068s
user    0m0.050s
sys     0m0.017s

[kzak@redhat.com: - add "else" and use maxcol]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoexec_shell: add a license and touch up func def
Mike Frysinger [Fri, 28 Jun 2013 00:05:18 +0000 (20:05 -0400)] 
exec_shell: add a license and touch up func def

When this file was created, the standard license header was missed.
Add it using the same one from unshare.c.

The noreturn attribute is not needed since we include the header
which has it on the prototype.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
10 years agodmesg: define is_timefmt() macro only once
Karel Zak [Mon, 1 Jul 2013 09:29:06 +0000 (11:29 +0200)] 
dmesg: define is_timefmt() macro only once

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agodmesg: fix --human color initialization
Karel Zak [Mon, 1 Jul 2013 09:17:17 +0000 (11:17 +0200)] 
dmesg: fix --human color initialization

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosfdisk: clean up unhide code
Karel Zak [Mon, 1 Jul 2013 09:11:24 +0000 (11:11 +0200)] 
sfdisk: clean up unhide code

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agohexdump: remove unnecessary global variables
Sami Kerola [Sun, 16 Jun 2013 18:53:55 +0000 (19:53 +0100)] 
hexdump: remove unnecessary global variables

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agosd-daemon: update files taken from systemd project
Sami Kerola [Sun, 16 Jun 2013 18:53:54 +0000 (19:53 +0100)] 
sd-daemon: update files taken from systemd project

Update sd-damoen.[hc] files from systemd upstream, using commit
fa3868c6d317b88715c55422b898f9070afe6575 as the sync point.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodmesg: regroup time related options close to each other
Sami Kerola [Sun, 16 Jun 2013 18:53:53 +0000 (19:53 +0100)] 
dmesg: regroup time related options close to each other

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodocs: add --time-format option and ISO-8601 format to manual
Sami Kerola [Sun, 16 Jun 2013 18:53:52 +0000 (19:53 +0100)] 
docs: add --time-format option and ISO-8601 format to manual

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodmesg: add iso-8601 time format
Sami Kerola [Sun, 16 Jun 2013 18:53:51 +0000 (19:53 +0100)] 
dmesg: add iso-8601 time format

The ISO-8601 should be welcomed by anyone who tries to parse dmesg time
stamp, and compare them across servers.  Time format tries to imitate
coreutils 'date --iso-8601=ns' output, but instead of having nanoseconds
the dmesg is using microseconds.

Reference: http://www.cs.tut.fi/~jkorpela/iso8601.html
Addresses: http://xkcd.com/1179/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodmesg: add --time-format option
Sami Kerola [Sun, 16 Jun 2013 18:53:50 +0000 (19:53 +0100)] 
dmesg: add --time-format option

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodmesg: convert time format bitfield to enum
Sami Kerola [Sun, 16 Jun 2013 18:53:49 +0000 (19:53 +0100)] 
dmesg: convert time format bitfield to enum

Foremost this commit makes time printing formats explicit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agosfdisk: replace my_warn() with warnx()
Sami Kerola [Sun, 16 Jun 2013 18:53:48 +0000 (19:53 +0100)] 
sfdisk: replace my_warn() with warnx()

This change adds program name in front of error messages.  Often that
helps user to know which command sent message, when the command is
executed as part of script.

Unfortunately the prefixing can break scripts, as someone might have
wrote automation which expects output in the format it has always been.
In programmer terms, the change has an ABI change, which some may find
annoying.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodocs: correct sfdisk --activate instructions
Sami Kerola [Sun, 16 Jun 2013 18:53:46 +0000 (19:53 +0100)] 
docs: correct sfdisk --activate instructions

The activate can be enabled by renaming the command to 'activate'.  Quite
confusingly the option and command arguments are interchangeable, and
depending on which one is defined as --activate option argument the
command will behave different rather different ways.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agosfdisk: use program_invocation_short_name to determine program name
Sami Kerola [Sun, 16 Jun 2013 18:53:45 +0000 (19:53 +0100)] 
sfdisk: use program_invocation_short_name to determine program name

Signed-off-by: Sami Kerola <kerolasa@iki.fi>