Commit Graph

10710 Commits

Author SHA1 Message Date
Karel Zak 6cd398642b libsmartcols: commit missing file
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 11:18:18 +02:00
Karel Zak ff471d89a1 libsmartcols: support multi-line cells based on line breaks
Now libsmartcols completely control when and how wrap long
lines/cells. This is sometimes user unfriendly and it would be nice to
support multi-line cells where wrap is based on \n (new line char).

This patch add new column flag SCOLS_FL_WRAPNL.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 10:51:25 +02:00
Karel Zak a55d646bd3 lib/randutils: add xsrand() and rand_get_number()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 10:19:52 +02:00
Karel Zak d4a90151e3 sfdisk: add --no-tell-kernel
The option forces sfdisk to not call re-read partitions ioctl after
write PT.

Requested-by: Scott Moser <smoser@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-02 11:20:06 +02:00
Karel Zak 2862bda919 tests: update sfdisk output strings
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-01 11:43:42 +02:00
Karel Zak ad8cd66adf sfdisk: make non-interactive output more readable
# echo -e ',1M\n,2M' | sfdisk /dev/sdc

Old version:

  >>> Created a new DOS disklabel with disk identifier 0x8fc7d065.
  Created a new partition 1 of type 'Linux' and of size 1 MiB.
  /dev/sdc2: Created a new partition 2 of type 'Linux' and of size 2 MiB.
  /dev/sdc3:

New version:

  >>> Created a new DOS disklabel with disk identifier 0x9afe17c0.
 /dev/sdc1: Created a new partition 1 of type 'Linux' and of size 1 MiB.
 /dev/sdc2: Created a new partition 2 of type 'Linux' and of size 2 MiB.
 /dev/sdc3: Done.

Addresses: https://github.com/karelzak/util-linux/issues/337
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 15:51:11 +02:00
Karel Zak b54439cbad libsmartcols: use SCOLS_FL_RIGHT in sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 15:51:03 +02:00
Karel Zak 51962c95e3 libsmartcols: add maxout sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 15:15:28 +02:00
Karel Zak 5e6421ee07 libsmartcols: fix minimal column width calculation
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 15:13:06 +02:00
Karel Zak f067de4495 libsmartcols: fix non-tty output for 'maxout' columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 13:01:48 +02:00
Karel Zak a593128fd0 libsmartcols: fix title output on non-tty
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 12:42:38 +02:00
Karel Zak 066779c67b libsmartcols: fix scols_table_enable_colors() usage in samples
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 12:05:48 +02:00
Karel Zak d7cda881d5 libsmartcols: don't print title color is colors disabled
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 12:05:21 +02:00
Tobias Stoeckmann cb129d9cc4 lib/loopdev: Set errno in is_loopdev on error
The function is_loopdev does not set errno if the supplied string does
not reference a valid loop device. Fix this to avoid an error message
like this one:

  losetup: /: failed to use device: Success

I prefer this one:

  losetup: /: failed to use device: No such device

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2016-08-31 09:49:01 +02:00
Karel Zak 2480b52743 mount: add note about paths verification to mount.8
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 09:48:43 +02:00
Rostislav Skudnov f98b563268 libblkid: [exfat] Limit maximum number of iterations in find_label
Do not hang if there is a cluster chain loop in rootdir

[kzak@redhat.com: - add return NULL]

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-30 13:50:51 +02:00
Karel Zak 4db236f7e4 libblkid: ignore empty MBR on LVM device
It's possible to use boot sector and empty MBR on LVM physical volume
to make LVM disk bootable. In this case MBR should be ignored and disk
reported as LVM.

Just for the record, this is ugly non-default LVM setup maintained for
backward compatibility (yes, LVM guys don't like it too).

Unfortunately people still use it. The proper way is to use regular
partitioned disk.

Reported-by: Xen <list@xenhideout.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-30 12:07:40 +02:00
Karel Zak a1df9c9d4e libblkid: remove unused function
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-30 11:22:30 +02:00
Karel Zak 29ad8689b8 umount: cleanup umount.8 about mtab
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-30 10:41:05 +02:00
Karel Zak d00eb87ba2 umount: fix obsolete info about loop= in umount.8
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1370959
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-30 10:25:44 +02:00
Tobias Stoeckmann 8fa57ab0b5 libblkid: Avoid OOB access on illegal ZFS superblocks
64 bit systems can trigger an out of boundary access while performing
a ZFS superblock probe.

This happens due to a possible integer overflow while calculating
the remaining available bytes. The variable is of type "int" and the
string length is allowed to be larger than INT_MAX, which means that
avail calculation can overflow, circumventing the "avail < 0" check and
therefore accessing memory outside the "buff" array later on.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2016-08-29 13:22:24 +02:00
Tobias Stoeckmann 1037269fec libfdisk: Distinguish between first LBA sector and partition
An insufficient check leads to an invalid free space output, as seen here:

$ dd if=/dev/zero of=cfdisk.iso bs=1M count=1
$ losetup -f cfdisk.iso
$ echo w | fdisk /dev/loop0
$ echo '1,1' | sfdisk /dev/loop0 --append
$ echo '3,' | sfdisk /dev/loop0 --append
$ sfdisk --list-free /dev/loop0
Start End Sectors Size
    1   2       2   1K
$ _

In this case, libfdisk fails to notice that it tries to calculate space
between two partitions, not between start of disk and first partition.
Currently, the code tries to achieve that by checking the address of the
last "partition", which is the first_lba block.  Now if the first
partition is merely 1 block in size, the "last" address is still equal
to the first_lba block, which renders the check in libfdisk for the next
partition invalid.

I chose to use "nparts == 0" for this check, because the partitions are
properly sorted before iterating over them.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2016-08-29 13:22:24 +02:00
Tobias Stoeckmann 8480181838 libfdisk: Fix assert error in free space handling
An off-by-one issue exists in fdisk_get_freespaces. It can trigger an
assert, as seen here:

$ dd if=/dev/zero of=cfdisk.iso bs=1M count=1
$ losetup -f cfdisk.iso
$ echo w | fdisk /dev/loop0
$ echo '1,2' | sfdisk /dev/loop0 --append
$ echo '3,' | sfdisk /dev/loop0 --append
$ sfdisk --list-free /dev/loop0
Aborted
$ _

Problem here is an invalid "grain" processing. A grain is considered
expected free space between partitions which can be required for proper
alignment. Normally, it's 1 MB but in this case our iso is merely 1 MB
so the grain is reduced to 1 byte.

The if-condition in question checks for "last + grain <= pa->start" and
therefore even triggers if there is no space between them (due to equal
check). Eventually, the start block address is higher than the end block
address which triggers the assert().

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2016-08-29 13:22:24 +02:00
Karel Zak e132ae59ca lib/pager: fix test
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-26 17:47:01 +02:00
Karel Zak a9fcbf6f6a lib/pager: restore signals setting by pager_close()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-26 13:02:37 +02:00
Karel Zak 8d2f449818 fdisk: use PAGER for 'l' command.
The list of the partition types is too long. Let's try to use $PAGER.

Reported-by: Bruce Dubbs <bruce.dubbs@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-26 12:15:38 +02:00
Karel Zak e215d467ca lib/pager: cleanup and extend API
* clean up function names

* add functions to temporary redirect to the pager and then restore
  original terminal output

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-26 12:07:25 +02:00
Karel Zak c424fd834b su, runuser, setpriv: create links between man pages
.. and add notes about differences between the utuils.

Reported-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-18 11:12:44 +02:00
Karel Zak 0e0e167704 tests: fix losetup tests for --nooverlap
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-17 13:54:34 +02:00
Karel Zak d8ba61fcb4 losetup: allow to use --nooverlap when device specified
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-17 13:52:22 +02:00
Stanislav Brabec 912d50b3be tests: Add losetup-loop test suite
Add losetup loop test suite that tests proper behavior of conflicting and
re-used loop devices.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-17 13:02:35 +02:00
Stanislav Brabec f27d989c67 losetup: Prevent AUTOCLEAR detach race
Kernel needs some time to delete a device after losetup --detach. If
the losetup --find --nooverlay is called just after losetup --delete,
it can sometimes attempt to recycle the device that is just being
released.  To prevent this race, clear the AUTOCLEAR flag of the
device.

[kzak@redhat.com: - rebase to the new version of the code]

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-17 12:58:12 +02:00
Stanislav Brabec bfd4e1f758 loopdev: Implememt loopcxt_set_status()
Implement stand-alone loopcxt_set_status(). It allows manipulation with some
loop device parameters even if it is initialized.

Its function is limited by the kernel implementation, and only a small subset of
changes is allowed.

For more see linux/drivers/block/loop.c:loop_set_status()

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-17 12:49:06 +02:00
Karel Zak 9a94b634a3 losetup: add --nooverlap options
This patch introduces overlap detections and loop devices
re-use for losetup(8). We already support this feature for mount(8)
where it's enabled by default (because we mount filesystems and it's
always mistake to share the same filesystem between more loop
devices).

Stanislav has suggested to enable this feature also for losetup by
default. I'm not sure about it, IMHO it's better to keep losetup(8)
simple and stupid by default, and inform users about possible problems
and solutions in the man page.

The feature forces losetup to scan all loop devices always when new
one is requested. This maybe disadvantage (especially when we use
control-loop  to avoid /sys or /dev scans) on system with huge number
of loop devices.

Co-Author: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-17 12:28:33 +02:00
Karel Zak f066f32aae tests: keep 'hppa' in fdisk/bsd test too
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-16 13:40:44 +02:00
Karel Zak f319e301a9 build-sys: add parisc to define ARCH_
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-16 13:39:07 +02:00
Helge Deller 569ad28288 tests: really fix fdisk/bsd for hppa
Finally fix the bsd testcase on the hppa architecture.

Commit 1b7be556e5 tried to fix it,
but missed the fact that "uname -m" returns "parisc" or "parisc64"
instead of "hppa*".

Signed-off-by: Helge Deller <deller@gmx.de>
Cc: 827225@bugs.debian.org
2016-08-16 13:36:12 +02:00
Michał Bartoszkiewicz 2b8889c44b lsns: support cgroup namespaces
Signed-off-by: Michał Bartoszkiewicz <mbartoszkiewicz@gmail.com>
2016-08-16 13:36:12 +02:00
Karel Zak 090d8c763a include/closestream: define exit codes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-16 13:35:06 +02:00
Karel Zak 05d8868d86 include/env: minor fixes and clean ups
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-16 12:35:57 +02:00
Karel Zak 64ffc95b0f Merge branch 'misc' of https://github.com/kerolasa/lelux-utiliteetit
* 'misc' of https://github.com/kerolasa/lelux-utiliteetit:
  pg: stop building the command by default
  kill: remove pid command-name to option alias
  misc: always check setenv(3) return value
2016-08-16 12:09:00 +02:00
Rostislav Skudnov 9d89a95e88 libblkid: Check that cluster size is nonzero when probing exFAT
This should prevent division by zero in find_label()

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
2016-08-16 12:08:46 +02:00
Karel Zak 3082f8518f lsns: missing ns/<name> is not error
For example user namespace is optional it does not make sense to
ignore process completely if the ns/user file is missing.

Reported-by: Michał Bartoszkiewicz <mbartoszkiewicz@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-15 11:02:18 +02:00
Sami Kerola 00971cca8a
pg: stop building the command by default
The pg command is marked deprecated in POSIX since 1997, and this project
has thought the same since Feb 2013.  Time has come to stop shipping this
binary by default.

Reference: 956e582874
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-08-14 13:30:36 +01:00
Sami Kerola 0be3ad70ad
kill: remove pid command-name to option alias
Removal was promised to happen in March 2016 and the time has come to get
rid of this unexpected feature.

Reference: c5b057b342
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-08-14 13:30:16 +01:00
Sami Kerola 984a60965a
misc: always check setenv(3) return value
At least glibc setenv(3) can fail when system runs out of memory.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-08-12 21:25:36 +01:00
Karel Zak 8c4ae2fd48 tests: mark build-in paths test as optional
The test makes sense only if you know what are you doing (see
 #ifdef(s) in the include/pathnames.h.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-12 10:13:22 +02:00
Karel Zak b8c65bd0b8 Merge branch 'pathnames_fbsd' of https://github.com/fichtner/util-linux 2016-08-12 10:05:00 +02:00
Karel Zak 1ef66ace16 Merge branch 'blkdev_fbsd_11' of https://github.com/fichtner/util-linux 2016-08-12 10:04:35 +02:00
Ruediger Meier 160eef814a travis: fix OSX, glibtoolize could not find sed
Since a few days travis OSX seems to have a bad libtool package:
$ glibtoolize --version
/usr/local/bin/glibtoolize: line 406: /usr/local/Library/ENV/4.3/sed: No such file or directory

Exporting SED is a simple fix. Otherwise we could have also re-installed libtool:
  brew uninstall libtool
  brew install libtool

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-08-11 18:04:00 +02:00