script: don't call TIOCGWINSZ in signal handler

Signed-off-by: Karel Zak <kzak@redhat.com>
script: restore errno in signal handler

References: https://plus.google.com/+LennartPoetteringTheOneAndOnly/posts/gHSscCJkakd
Signed-off-by: Karel Zak <kzak@redhat.com>
tests: fix fdisk GPT test

There was a missing newline since cd05de50.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
mkfs.minix: fix fscanf() format string [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
lsblk: fix -D segfault

References: https://bugzilla.redhat.com/show_bug.cgi?id=1031262
Signed-off-by: Karel Zak <kzak@redhat.com>
unshare: add more hints about mount namespaces to the man page

There is also idea (by Lennart) to add --propagation=[shared|private|slave|off]
to unshare(1), but it seems unnecessary and too complex as everyone can call
mount(8) after unshare(1) to setup a proper namespace.

Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk: (sgi) generate partname according to partition position

The SGI drive currently counts only usable partitions, that's wrong as
Linux kernel counts all partition to generate partition number. For
example:

Kernel:
	sdb                                             8:16   0   600M  0 disk
	├─sdb9                                          8:25   0     2M  0 part
	└─sdb11                                         8:27   0 596.2M  0 part

Fdisk:
	Pt# Device    Info Start       End   Sectors Id System
	 9: /dev/sdb1          0      4095      4096  0 SGI volhdr
	11: /dev/sdb2          0   1220939   1220940  6 SGI volume

Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Merge branch 'fixes' of https://github.com/rudimeier/util-linux

* 'fixes' of https://github.com/rudimeier/util-linux:
  tests: fix fdisk GPT test
setpriv: simplify usage()

Let's keep usage() simple and details in the man page. The current
brief description in usage() seems confusing for some users.

Signed-off-by: Karel Zak <kzak@redhat.com>
mount: fix man mount page type

Slight grammatical error in the mount man page

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
fsck: add ext4 to list of filesystems with progress bars in fsck man page

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
libmount: add mnt_tag_is_valid()

Signed-off-by: Karel Zak <kzak@redhat.com>
mount: make NAME=value tags usable for non-root

The libmount does not care if we set source or target, it's able to
swap it, but the mount.c function sanitize_paths() does not work as
expected if we set NAME=value as target. It means that

 $ mount LABEL=foo

does not work for non-root users (since 51e3530cdcb1d4f3ab91ae953ebc5adcdc5f9239, v2.24).

This patch also checks if source or target is specified more
than once.

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid: fix memory leak in blkid_parse_tag_string()

Signed-off-by: Karel Zak <kzak@redhat.com>
umount: fix umount by tag for non-roots

 $ umount LABEL=foo

currently does not work for non-root users as umount uses the
LABEL= as a path in sanitize_path().

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk: fix usage(), -l [<disk>]

Add square brackets, <disk> is optional for -l.

Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk: fix nasty coding style

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk: don't care about partition type

fdisk allows to overwrite existing partition if the partition has
partition type set to zero (very unusual, but possible).

This is incorrect because such partition is pretty valid (and Linux
kernel does not care about the type at all). For example:

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048       22527       10240   83  Linux
/dev/sdb2           22528      227327      102400    0  Empty
                    ^^^^^                            ^^^^^^^^

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p):
Using default response p
Partition number (3,4, default 3):
First sector (22528-1228799, default 22528):
                                    ^^^^^^^

.. if user follows the default then the result are overlapping
partitions:

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048       22527       10240   83  Linux
/dev/sdb2           22528      227327      102400    0  Empty
/dev/sdb3           22528     1228799      603136   83  Linux
                    ^^^^^

... and if you call "mkfs /dev/sdb3" then you lost data on sdb2. Sad
thing.

Reported-by: Marc MERLIN <marc@merlins.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk: (gpt) more human readable info about free space

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid: fix sgi PT parser to report system partitions

... to be compatible with Linux kernel.

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