]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
10 years agoFix /sys to /dev node name translation
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.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
10 years agohwclock: don't allow non-root access
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>
10 years agosulogin: don't use strcpy(), enlarge pwd line buffer
Karel Zak [Mon, 25 May 2015 13:24:13 +0000 (15:24 +0200)] 
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>
10 years agobuild-sys: add --without-* for all libs
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>
10 years agoblkid: another hint to the man page
Karel Zak [Thu, 21 May 2015 11:13:49 +0000 (13:13 +0200)] 
blkid: another hint to the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoblkid: be more precise in the man page
Karel Zak [Thu, 21 May 2015 10:37:18 +0000 (12:37 +0200)] 
blkid: be more precise in the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoblkid: don't ignore info about partitions on non-formated devices
Karel Zak [Thu, 21 May 2015 10:14:32 +0000 (12:14 +0200)] 
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>
10 years agodocs: update TODO
Karel Zak [Tue, 19 May 2015 12:40:42 +0000 (14:40 +0200)] 
docs: update TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: support unshare.static
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>
10 years agocal: fix January 1753 week number printout
Sami Kerola [Sun, 17 May 2015 17:27:42 +0000 (18:27 +0100)] 
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>
10 years agozramctl: add MEM-LIMIT, MEM-USED and MIGRATED columns
Karel Zak [Mon, 18 May 2015 09:30:56 +0000 (11:30 +0200)] 
zramctl: add MEM-LIMIT, MEM-USED and MIGRATED columns

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agozramctl: support /sys/block/zram<id>/mm_stat
Karel Zak [Mon, 18 May 2015 09:13:44 +0000 (11:13 +0200)] 
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>
10 years agolib/strv: add new functions (from systemd)
Karel Zak [Fri, 15 May 2015 12:57:04 +0000 (14:57 +0200)] 
lib/strv: add new functions (from systemd)

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: Fix mangled EOF and hang on big endian
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.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
10 years agoMerge branch 'test-fixes' of https://github.com/rudimeier/util-linux
Karel Zak [Wed, 13 May 2015 13:08:04 +0000 (15:08 +0200)] 
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

10 years agotests: update lscpu tests (due to CPU flags in output)
Karel Zak [Wed, 13 May 2015 13:06:22 +0000 (15:06 +0200)] 
tests: update lscpu tests (due to CPU flags in output)

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolscpu: add cpu flags entry to summary output
WANG Chao [Wed, 13 May 2015 03:15:05 +0000 (11:15 +0800)] 
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>
10 years agolibfdisk: keep FDISK_FIELD_CYLINDERS independent on context mode
Karel Zak [Mon, 11 May 2015 11:01:26 +0000 (13:01 +0200)] 
libfdisk: keep FDISK_FIELD_CYLINDERS independent on context mode

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofdisk: provide more information by 'i'nfo command
Karel Zak [Mon, 11 May 2015 10:45:21 +0000 (12:45 +0200)] 
fdisk: provide more information by 'i'nfo command

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add fdisk_label_get_fields_ids_all()
Karel Zak [Mon, 11 May 2015 10:42:24 +0000 (12:42 +0200)] 
libfdisk: add fdisk_label_get_fields_ids_all()

The current fdisk_label_get_fields_ids() is too smart as it
differentiate between details mode etc. It's useful for default
output, but in some cases it's better to provide all output fields.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofdisk: add the 'i'nfo command
Jean-Loup 'clippix' Bogalho [Sat, 9 May 2015 21:15:23 +0000 (23:15 +0200)] 
fdisk: add the 'i'nfo command

Add the 'i'nfo command to fdisk that prints details about a specific partition.
Details are everything the function 'fdisk_label_get_field' can return.

Signed-off-by: Jean-Loup 'clippix' Bogalho <clippix@lse.epita.fr>
10 years agotests: add hexdump from GPT
Karel Zak [Mon, 11 May 2015 10:18:12 +0000 (12:18 +0200)] 
tests: add hexdump from GPT

* use hardcoded UUIDs for partitions in sfdisk GPT test
* output hexdump of the GPT header (it would be possible to use MD5
  sum, but from hexdump it's more obvious where is problem)

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (gpt) fix attributes endianess
Ruediger Meier [Fri, 8 May 2015 11:39:53 +0000 (13:39 +0200)] 
libfdisk: (gpt) fix attributes endianess

The new libfdisk/gpt test (4a4a0927) discovered that we read and write
partition attributes wrongly on BE systems.

Our temporarily used char[8] bits are always LE and do not need to be
converted.

CC: Michael Marineau <michael.marineau@coreos.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: fix kill/all_processes
Ruediger Meier [Thu, 7 May 2015 13:20:47 +0000 (15:20 +0200)] 
tests: fix kill/all_processes

We have to wait for the killed helper.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: add $top_builddir to $PATH
Ruediger Meier [Mon, 13 Apr 2015 13:51:02 +0000 (15:51 +0200)] 
tests: add $top_builddir to $PATH

Since we have dropped some more hardcoded search paths we should
make sure that our tested binaries would use the right helpers
from our build directory.

See 07b51567 and follow-up commits.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agoRevert "travise: try to add coverity_scan"
Karel Zak [Wed, 6 May 2015 14:43:35 +0000 (16:43 +0200)] 
Revert "travise: try to add coverity_scan"

This reverts commit 3053e14997194849b17a7dae3d4a0366a52c6b45.

10 years agotravise: try to add coverity_scan
Karel Zak [Wed, 6 May 2015 14:16:17 +0000 (16:16 +0200)] 
travise: try to add coverity_scan

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoflock: NULL deref
Brad Forschinger [Tue, 5 May 2015 01:51:24 +0000 (11:51 +1000)] 
flock: NULL deref

cmd_argv[2] will be initialised only if it's specificed with -c.  NULL
deref otherwise resulting in crash.

Signed-off-by: Brad Forschinger <bnjf@bnjf.id.au>
10 years agobuild-sys: fix parallel builds w/setarch links
Mike Frysinger [Mon, 4 May 2015 03:51:04 +0000 (23:51 -0400)] 
build-sys: fix parallel builds w/setarch links

The symlink generation tries to write to the sys-utils/ subdir but does
not make sure that dir exists.  This can sometimes lead to parallel build
failures when building out-of-tree like:
...
echo ".so man8/setarch.8" > sys-utils/linux64.8
/bin/bash: sys-utils/linux64.8: No such file or directory
Makefile:11503: recipe for target 'sys-utils/linux64.8' failed
make: *** [sys-utils/linux64.8] Error 1

References: https://bugs.gentoo.org/511812
Signed-off-by: Mike Frysinger <vapier@chromium.org>
10 years agolibfdisk: (gpt) add API for raw partition attributes
Michael Marineau [Sat, 2 May 2015 22:52:48 +0000 (15:52 -0700)] 
libfdisk: (gpt) add API for raw partition attributes

The existing APIs can only toggle individual bits or get and set bits in
a complex text representation, making it impractical to use libfdisk for
manipulating the GPT partition attribute field in more complex ways such
as updating a value that is multiple bits wide. For example priority
based partition selection originally designed for ChromeOS includes two
integer values that are 4-bits wide.

http://www.chromium.org/chromium-os/chromiumos-design-docs/disk-format#TOC-Trusting-the-GPT

[kzak@redhat.com: - add new symbols to .sym file and docs
                  - remove unused variables from test program]

Signed-off-by: Michael Marineau <michael.marineau@coreos.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (gpt) fix check for beginning of protective partition
Michael Marineau [Sat, 2 May 2015 04:44:33 +0000 (21:44 -0700)] 
libfdisk: (gpt) fix check for beginning of protective partition

Search for the protective partition before attempting to validate that
it covers the GPT header. Some hybrid MBRs list partitions out of order.
For example, CoreOS images ship with a hybrid MBR that lists the boot
partition first and the protective partition second in order to maintain
compatibility with old versions of Xen's PV-GRUB.

Signed-off-by: Michael Marineau <michael.marineau@coreos.com>
10 years agofsck: Fix parsing of -r
Stanislav Brabec [Wed, 29 Apr 2015 16:49:47 +0000 (18:49 +0200)] 
fsck: Fix parsing of -r

Fix regression introduced by commit 658c089: -r cannot be used as a last
option:

fsck -r /dev/sda1
fsck: invalid argument -r: '/dev/sda1'

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
10 years agodocs: fix TODO typos
Karel Zak [Tue, 28 Apr 2015 12:04:15 +0000 (14:04 +0200)] 
docs: fix TODO typos

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agodocs: update TODO
Karel Zak [Tue, 28 Apr 2015 12:00:28 +0000 (14:00 +0200)] 
docs: update TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofsck: print errors on invalid -r argument
Karel Zak [Tue, 28 Apr 2015 11:43:14 +0000 (13:43 +0200)] 
fsck: print errors on invalid -r argument

The patch also add support for -r 0.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofsck: implement fsck -r {fd}
Stanislav Brabec [Mon, 27 Apr 2015 15:20:55 +0000 (17:20 +0200)] 
fsck: implement fsck -r {fd}

Make possible sending of statistics to a dedicated file descriptor.

Rationale: When UI is calling fsck from a remote terminal, fsck progress
needs to be sent to stdout. It is mixed there with output of statistics,
and it is impossible to parse the output to get the statistics.

Now it will be possible e. g. with "fsck -C -r 3 /dev/sda1"

Note: Code in if and else is intentionally partially duplicated. Current
human readable output of floats does not conform to locale conventions,
and may be changed in future. But we want to keep machine readable output
exactly same as it is now.

[kzak@redhat.com: - don't use report_stats_fd globally]

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agohwclock: fix spelling, punctuation and formatting mistakes in the man page
Benno Schulenberg [Wed, 8 Apr 2015 08:22:43 +0000 (10:22 +0200)] 
hwclock: fix spelling, punctuation and formatting mistakes in the man page

Also improve some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agohwclock: clean up man page header
Karel Zak [Tue, 28 Apr 2015 10:27:18 +0000 (12:27 +0200)] 
hwclock: clean up man page header

We already use .TQ in another man pages for years and nobody
complains, so I guess the fallback is unnecessary.

The patch also minimize in-header change-log. We have git for this
purpose.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agohwclock: remove an untrue phrase from the man page
Benno Schulenberg [Tue, 17 Mar 2015 20:34:51 +0000 (21:34 +0100)] 
hwclock: remove an untrue phrase from the man page

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agofsck: use PATH or fallback to /sbin
Karel Zak [Mon, 27 Apr 2015 08:51:33 +0000 (10:51 +0200)] 
fsck: use PATH or fallback to /sbin

It's overkill to support all the obscure paths like /sbin/fs.d. We
have PATH for customization, that's enough.

It still seems like a good idea to keep fsck robust, because it's used
by boot scripts/systemd. For this reason fsck fallbacks to "/sbin" if
PATH is undefined or empty.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoswapon: search for mkswap via PATH
Mike Frysinger [Sun, 12 Apr 2015 09:06:52 +0000 (05:06 -0400)] 
swapon: search for mkswap via PATH

Rather than hardcode /sbin/mkswap all the time, use a normal PATH search.
This matches the normal behavior of other tools, and makes local testing
easier.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
10 years agomkfs: drop hardcoded search path
Mike Frysinger [Sun, 12 Apr 2015 09:06:51 +0000 (05:06 -0400)] 
mkfs: drop hardcoded search path

Rather than maintain a hardcoded search path for looking up tools and
override the user's PATH env setting, respect whatever the user has.
This matches the convention of just about every other tool out there.

It might break on systems that don't have /sbin in their PATH and they
try to run /sbin/mkfs directly, but so be it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
10 years agohwclock: flush stdout in hwclock -c
Alexey Galakhov [Thu, 16 Apr 2015 15:26:27 +0000 (17:26 +0200)] 
hwclock: flush stdout in hwclock -c

This allows using hwclock -c in automated test scripts that parse
its output line-by-line. The standard output is flushed before
each 10 second delay.

Signed-off-by: Alexey Galakhov <agalakhov@gmail.com>
10 years agohwclock: Remove TZUTC
J William Piggott [Thu, 23 Apr 2015 23:53:58 +0000 (19:53 -0400)] 
hwclock: Remove TZUTC

commit d53f8ecfbf036eddb2aef737dc0973a613d80ced
introduced the TZUTC environment variable to
facilitate use of the zoneinfo 'right' database.
This was incorrect. Either the TZDIR environment
variable should be used or a system-wide
configuration for the 'right' database should be
used.

See hwclock(8) POSIX vs 'RIGHT' for more details.

TZUTC was undocumented and should be safe to remove.

The commit also caused a regression when using
musl libc, because when TZUTC is unset getenv()
returns a NULL pointer.
Reported-by: Isaac Dunham <ibid.ag@gmail.com>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
10 years agotest_uuidd: add comment
Karel Zak [Fri, 24 Apr 2015 15:09:17 +0000 (17:09 +0200)] 
test_uuidd: add comment

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotest_uuidd: add pid, tid and idx back to object
Karel Zak [Fri, 24 Apr 2015 13:53:28 +0000 (15:53 +0200)] 
test_uuidd: add pid, tid and idx back to object

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotest_uuidd: make objdump more robust
Karel Zak [Fri, 24 Apr 2015 13:01:23 +0000 (15:01 +0200)] 
test_uuidd: make objdump more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotest_uuidd: fix include
Karel Zak [Fri, 24 Apr 2015 12:54:09 +0000 (14:54 +0200)] 
test_uuidd: fix include

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotest_uuidd: don't exit on failed pthread_create()
Karel Zak [Fri, 24 Apr 2015 12:47:49 +0000 (14:47 +0200)] 
test_uuidd: don't exit on failed pthread_create()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotest_uuidd: don't exit on failed pthread_create()
Karel Zak [Fri, 24 Apr 2015 12:47:09 +0000 (14:47 +0200)] 
test_uuidd: don't exit on failed pthread_create()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotest_uuidd: improve readability
Karel Zak [Fri, 24 Apr 2015 12:25:30 +0000 (14:25 +0200)] 
test_uuidd: improve readability

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotest_uuidd: cleanup counters names
Karel Zak [Fri, 24 Apr 2015 11:39:17 +0000 (13:39 +0200)] 
test_uuidd: cleanup counters names

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotest_uuidd: cleanup pid usage
Karel Zak [Fri, 24 Apr 2015 11:35:54 +0000 (13:35 +0200)] 
test_uuidd: cleanup pid usage

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotest_uuidd: cleanup used types
Karel Zak [Fri, 24 Apr 2015 11:28:12 +0000 (13:28 +0200)] 
test_uuidd: cleanup used types

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotest_uuidd: err messages, argv[] parsing and another cleanups
Karel Zak [Fri, 24 Apr 2015 10:40:51 +0000 (12:40 +0200)] 
test_uuidd: err messages, argv[] parsing and another cleanups

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: add uuidd test program
Huschaam Hussain [Fri, 24 Apr 2015 09:28:47 +0000 (11:28 +0200)] 
tests: add uuidd test program

References: https://bugzilla.redhat.com/show_bug.cgi?id=678306
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: fix sfdisk GPT test
Karel Zak [Thu, 23 Apr 2015 13:08:26 +0000 (15:08 +0200)] 
tests: fix sfdisk GPT test

The test uses too large last partition, libfdisk checks this problem
now.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (gpt) add extra check for First/Last LBA
Karel Zak [Thu, 23 Apr 2015 10:32:36 +0000 (12:32 +0200)] 
libfdisk: (gpt) add extra check for First/Last LBA

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: add sfdisk resize tests for GPT
Karel Zak [Thu, 23 Apr 2015 09:37:00 +0000 (11:37 +0200)] 
tests: add sfdisk resize tests for GPT

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (gpt) fix end sector calculation on resize
Karel Zak [Thu, 23 Apr 2015 09:34:05 +0000 (11:34 +0200)] 
libfdisk: (gpt) fix end sector calculation on resize

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: add sfdisk resize regression tests for MBR
Karel Zak [Wed, 22 Apr 2015 15:15:39 +0000 (17:15 +0200)] 
tests: add sfdisk resize regression tests for MBR

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: fix scriptk parser to support alone signs
Karel Zak [Wed, 22 Apr 2015 15:14:28 +0000 (17:14 +0200)] 
libfdisk: fix scriptk parser to support alone signs

for example echo "- - - *" | sfdisk /dev/sda1 -N1

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: allow to move start to first usable LBA
Karel Zak [Wed, 22 Apr 2015 15:13:48 +0000 (17:13 +0200)] 
libfdisk: allow to move start to first usable LBA

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add warning to resize function
Karel Zak [Tue, 21 Apr 2015 13:51:45 +0000 (15:51 +0200)] 
libfdisk: add warning to resize function

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: support resize operation in fdisk_set_partition()
Karel Zak [Tue, 21 Apr 2015 12:36:24 +0000 (14:36 +0200)] 
libfdisk: support resize operation in fdisk_set_partition()

Note that the resize is not exported by API yet, the only way to use
it is sfdisk-like scripts.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add fdisk_table_get_partition_by_partno()
Karel Zak [Tue, 21 Apr 2015 12:35:18 +0000 (14:35 +0200)] 
libfdisk: add fdisk_table_get_partition_by_partno()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: fix script parser to support resize operations
Karel Zak [Tue, 21 Apr 2015 12:32:31 +0000 (14:32 +0200)] 
libfdisk: fix script parser to support resize operations

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: don't resize in label drivers
Karel Zak [Tue, 21 Apr 2015 12:30:11 +0000 (14:30 +0200)] 
libfdisk: don't resize in label drivers

The resize operation has to be implemented on upper layer.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (gpt) fix LE usage
Karel Zak [Wed, 22 Apr 2015 09:52:24 +0000 (11:52 +0200)] 
libfdisk: (gpt) fix LE usage

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/strutils: fix string_add_to_idarray() int vs. size_t
Karel Zak [Wed, 22 Apr 2015 09:08:05 +0000 (11:08 +0200)] 
lib/strutils: fix string_add_to_idarray() int vs. size_t

The function uses "int" as argument, but for array size (and index) is better
to use unsigned type (size_t). If we mix "size_t" in util (e.g. fdisk)
and "int" in lib/strutils.c then result is unexpected behavior on
ppc64.

# sfdisk --list -o DEVICE,START,SIZE /dev/sdb
Disk /dev/sdb: 50 MiB, 52428800 bytes, 102400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 32768 bytes
Disklabel type: gpt
Disk identifier: 3B8559DB-33AF-43E9-BEFC-C331D829B539
lt-sfdisk: libfdisk/src/label.c:178: fdisk_label_get_field: Assertion `id > 0' failed.

The patch cleanup all code to use size_t everywhere.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofdisk, sfdisk: fix -o <list> backend
Karel Zak [Wed, 22 Apr 2015 08:20:31 +0000 (10:20 +0200)] 
fdisk, sfdisk: fix -o <list> backend

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoMerge branch 'tests-refactor-loop-cleanup' of https://github.com/rudimeier/util-linux
Karel Zak [Wed, 22 Apr 2015 08:03:12 +0000 (10:03 +0200)] 
Merge branch 'tests-refactor-loop-cleanup' of https://github.com/rudimeier/util-linux

* 'tests-refactor-loop-cleanup' of https://github.com/rudimeier/util-linux:
  tests: never use -o pipefail
  tests: loop tests, don't call ts_die() with DEVICE parameter
  tests: scsi_debug tests, don't call ts_die() with DEVICE parameter
  tests: introduce TS_LOOP_DEVS for cleanup
  tests: introduce ts_cleanup_on_exit()

10 years agoMerge branch 'test-fix' of https://github.com/rudimeier/util-linux
Karel Zak [Wed, 22 Apr 2015 07:56:47 +0000 (09:56 +0200)] 
Merge branch 'test-fix' of https://github.com/rudimeier/util-linux

10 years agotests: config.h lives in build directory
Ruediger Meier [Wed, 22 Apr 2015 06:05:47 +0000 (08:05 +0200)] 
tests: config.h lives in build directory

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agohwclock: remove dead code
J William Piggott [Tue, 21 Apr 2015 20:46:23 +0000 (16:46 -0400)] 
hwclock: remove dead code

Removes never used #ifdef dead code.

Reported-by: Karel Zak <kzak@redhat.com>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
10 years agohwclock: regression fix
J William Piggott [Tue, 21 Apr 2015 20:43:41 +0000 (16:43 -0400)] 
hwclock: regression fix

Commit ab8f402952301106ad0bd5c5a51dc8646d1bff64 regression
where synchronize_to_clock_tick_rtc() only returns the correct
value for a select() time out if using debug mode. This caused
hwclock to have invalid output when select() timed out in
normal mode.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
10 years agotests: never use -o pipefail
Ruediger Meier [Tue, 21 Apr 2015 08:41:01 +0000 (10:41 +0200)] 
tests: never use -o pipefail

It was hard to find out that pipefail was the reason why our
test-suite could have random failures for aribtrary tests,
for example the ones which are using ts_device_has_uuid() or
ts_mount().

Bash's pipefall option is evil! It may return error for such a
simple line like this one
$ echo -e "xxx\nyyy" | grep -q "xxx"
because the left echo command will get SIGPIPE when grep exits after
the first match. So the command line above could return an error
eventhough it does exactly what we want.

This patch removes any pipefail from our tests. The funny thing is
that I couldn't find any case where we relied on this feature anyway.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agosfdisk: don't use BLKRRPART to check loopdev usage
Karel Zak [Fri, 17 Apr 2015 08:32:48 +0000 (10:32 +0200)] 
sfdisk: don't use BLKRRPART to check loopdev usage

It seesm that kernel always returns EINVAL for BLKRRPART on loop
devices, we call the ioctl to check if nobody else uses the device.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: add old dump for sfdisk
Karel Zak [Thu, 16 Apr 2015 16:01:32 +0000 (18:01 +0200)] 
tests: add old dump for sfdisk

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosfdisk: accept empty partitions from dump
Karel Zak [Thu, 16 Apr 2015 15:40:28 +0000 (17:40 +0200)] 
sfdisk: accept empty partitions from dump

Old sfdisk uses:
  dev/sdc2 : start=        0, size=        0, Id= 0

for undefined MBR partitions. Let's follow this behaviour.

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: fix logger device pathname too long
Ruediger Meier [Tue, 14 Apr 2015 12:54:52 +0000 (14:54 +0200)] 
tests: fix logger device pathname too long

$TS_OUTDIR may be too long for sockaddr_un.sun_path. Noticed on travis
in distcheck.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: loop tests, don't call ts_die() with DEVICE parameter
Ruediger Meier [Tue, 31 Mar 2015 12:35:07 +0000 (14:35 +0200)] 
tests: loop tests, don't call ts_die() with DEVICE parameter

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: scsi_debug tests, don't call ts_die() with DEVICE parameter
Ruediger Meier [Tue, 31 Mar 2015 12:23:30 +0000 (14:23 +0200)] 
tests: scsi_debug tests, don't call ts_die() with DEVICE parameter

This was almost useless anyway.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: introduce TS_LOOP_DEVS for cleanup
Ruediger Meier [Tue, 31 Mar 2015 12:19:40 +0000 (14:19 +0200)] 
tests: introduce TS_LOOP_DEVS for cleanup

We are maintaining an array TS_LOOP_DEVS to de-initialize devices
always on exit. Until now there was no cleanup in ts_skip().

The downside is that we can't execute ts_device_init() in a subshell
anymore. The device is returned via global variable TS_LODEV, similar
like we do already in ts_scsi_debug_init().

Tests which don't use ts_device_init() to create loop devices may use
ts_register_loop_device() to get them cleaned up later.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: introduce ts_cleanup_on_exit()
Ruediger Meier [Tue, 31 Mar 2015 08:54:56 +0000 (10:54 +0200)] 
tests: introduce ts_cleanup_on_exit()

ts_cleanup_on_exit() is always called on exit, e.g. after ts_skip,
ts_die, ts_finalize ...

A first usage example is the cleanup of TS_SUID_PROGS which is now also done
on ts_skip. Later we want to fix some left loop devices.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agoMerge branch 'tests-logger' of https://github.com/rudimeier/util-linux
Karel Zak [Tue, 14 Apr 2015 09:52:06 +0000 (11:52 +0200)] 
Merge branch 'tests-logger' of https://github.com/rudimeier/util-linux

* 'tests-logger' of https://github.com/rudimeier/util-linux:
  travis: install socat >= 1.7.2
  tests: add subtests for invalid logger devive
  tests: logger/errors does not use --no-act
  tests: logger, validate written socket data
  tests: logger with socat device
  tests: simplify common logger options
  logger: --stderr and --no-act turn "auto-errors" on

10 years agounshare: allow persisting mount namespaces
Karel Zak [Thu, 9 Apr 2015 09:48:07 +0000 (11:48 +0200)] 
unshare: allow persisting mount namespaces

We can create a reference (bind mount) to the new namespace after
unshare(2), but it does not make sense to do it within unshared
namespace. (And if I read kernel fs/namespace.c: do_loopback()
correctly than copy mount bind mounts of /proc/<pid>/ns/mnt between
namespaces is unsupported.)

This patch bypass this problem by fork() where parent continue as
usually (call unshare(2), setup another things, etc.), but child
waits for /proc/[ppid]/ns/mnt inode number change (the ino is
changed after parent's unshare(2)) and then it bind mounts the new
namespaces and exit.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agounshare: allow persisting namespaces
Karel Zak [Thu, 9 Apr 2015 09:34:02 +0000 (11:34 +0200)] 
unshare: allow persisting namespaces

For nsenter(1) we already support namespace specification by file
(e.g. bind mount to namespace /proc/[pid]/ns/[type] file). For
example:

  # nsenter --uts=/some/path

This patch extends unshare(1) to setup the bind mount for specified
namespace, for example

  # touch /some/path
  # unshare --uts=/some/path hostname FOO
  # nsenter --uts=/some/path hostname
  FOO

Note that the problem is mount namespace, because create bind mount
to ns/mount file within unshared namespace does not make sense.

Based on patch from Lubomir Rintel <lkundrak@v3.sk>.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/sysfs.c: use fcntl(..F_DUPFD_CLOEXEC) instead of dup(2)
Cristian Rodríguez [Fri, 10 Apr 2015 18:57:58 +0000 (15:57 -0300)] 
lib/sysfs.c: use fcntl(..F_DUPFD_CLOEXEC) instead of dup(2)

"The two descriptors do not share file descriptor flags (the
close-on-exec flag).  The close-on-exec flag  for the duplicate descriptor is off"

10 years agotests: make libmount python context tests sensitive to USE_LIBMOUNT_FORCE_MOUNTINFO
Karel Zak [Tue, 14 Apr 2015 09:26:54 +0000 (11:26 +0200)] 
tests: make libmount python context tests sensitive to USE_LIBMOUNT_FORCE_MOUNTINFO

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: make libmount context tests sensitive to USE_LIBMOUNT_FORCE_MOUNTINFO
Karel Zak [Tue, 14 Apr 2015 09:26:54 +0000 (11:26 +0200)] 
tests: make libmount context tests sensitive to USE_LIBMOUNT_FORCE_MOUNTINFO

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofdisk: fix typo
Karel Zak [Mon, 13 Apr 2015 16:11:38 +0000 (18:11 +0200)] 
fdisk: fix typo

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofdisk: add --protect-boot
Karel Zak [Mon, 13 Apr 2015 15:24:45 +0000 (17:24 +0200)] 
fdisk: add --protect-boot

Now fdisk erases the begin of the device when create a new disk label, it seems
like disadvantage for some use-cases.

Reported-by: Jean-Loup 'clippix' Bogalho <clippix@lse.epita.fr>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotravis: install socat >= 1.7.2
Ruediger Meier [Mon, 13 Apr 2015 11:29:26 +0000 (13:29 +0200)] 
travis: install socat >= 1.7.2

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: add subtests for invalid logger devive
Ruediger Meier [Fri, 10 Apr 2015 06:28:26 +0000 (08:28 +0200)] 
tests: add subtests for invalid logger devive

Note --journald should not complain about invalid sockets.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: logger/errors does not use --no-act
Ruediger Meier [Thu, 9 Apr 2015 18:14:51 +0000 (20:14 +0200)] 
tests: logger/errors does not use --no-act

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agosfdisk: enable bootbits protection
Karel Zak [Mon, 13 Apr 2015 11:41:10 +0000 (13:41 +0200)] 
sfdisk: enable bootbits protection

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1210428
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: support bootbits protection from (p)MBR
Karel Zak [Mon, 13 Apr 2015 11:40:25 +0000 (13:40 +0200)] 
libfdisk: support bootbits protection from (p)MBR

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: logger, validate written socket data
Ruediger Meier [Thu, 9 Apr 2015 18:14:50 +0000 (20:14 +0200)] 
tests: logger, validate written socket data

Actually there should be no data written to the socket because
we are always using --no-act.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: logger with socat device
Ruediger Meier [Thu, 9 Apr 2015 15:12:34 +0000 (17:12 +0200)] 
tests: logger with socat device

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>