Commit Graph

1228 Commits

Author SHA1 Message Date
Karel Zak 19e4cfef52 fdisk: support CTRL+C on change-partition-type dialog
Reported-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-10 11:26:05 +01:00
Karel Zak 4d09682b3c mkswap: use dd(1) in example rather than fallocate(1)
The man page warns against fallocate on some filesystems and recommends
dd(1) as the most portable solution. So, let's use dd(1) also in the
example used in the same man page.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1203378
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-12 12:14:39 +01:00
Noel Cragg 4850e97257 mkswap: fix page size warning message
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-29 11:38:41 +01:00
Karel Zak a77bd80d5a sfdisk: disable --activate for Hybrid GPT/MBR
Addresses: https://github.com/karelzak/util-linux/issues/699
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-10-04 14:06:45 +02:00
Karel Zak 49032ef7a4 sfdisk: be more verbose about PMBR on --activate
Addresses: https://github.com/karelzak/util-linux/issues/699
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-10-04 12:40:10 +02:00
Karel Zak 561472a40d mkfs.cramfs: properly copy disk name
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-10-03 17:07:37 +02:00
Karel Zak e4386c8cc0 libfdisk: accept grain script header
The "grain" variable is used to calculate partitions alignment. The
default is 1MiB (or minimal I/O size). The libfdisk provides API to overwrite
this default, but this feature has been nowhere accessible for
end-user.

This patch support for "grain: <size>" in libfdisk scripts.

Addresses: https://github.com/karelzak/util-linux/issues/688
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-12 13:26:18 +02:00
Karel Zak aef79c1f8e sfdisk: document script GPT headers
Add first-lba, last-lba and table-length to the sfdisk man page.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-12 12:26:06 +02:00
Karel Zak 6ec4760967 fdisk: add "Disk model:" to the print output
Addresses: https://github.com/karelzak/util-linux/issues/682
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-30 14:01:54 +02:00
Jakub Wilk b9c3b903fe Fix man page typos
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-08-16 11:09:15 +02:00
Bjarni Ingi Gislason 934a6fa80b man pages: Remove "left" (or change to "l") in the column formats of tables
A developmental version of "groff" issued a warning, for example with
"test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z":

troff: <logger.1>:299: warning: can't find font 't'

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-08-06 08:58:57 +02:00
Karel Zak dbcd1a4964 fdisk: fix error message on 'd' command
Command (m for help): d
	No partition is defined yet!
	Could not delete partition 93840461057817    <--- !

Don't print 'Could not delete..' if no partition is defined yet.

Addresses: https://github.com/karelzak/util-linux/issues/667
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-01 09:29:12 +02:00
Awal Garg 757cefbb61 libfdisk: Accept negative numbers for last sector input
[kzak@redhat.com: - add note to the man page
                  - add '-' to the dialog query
                  - cleanup functions names and libfdisk.sym]

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-31 14:54:12 +02:00
Karel Zak f2cfb2351a cfdisk: fix compiler warnings [-Wcast-qual]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23 13:08:56 +02:00
Karel Zak f11157e804 mkswap: fix compiler warnings [-Wcast-qual]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23 11:43:30 +02:00
Karel Zak 366edea76e mkfs.cramfs: remove redundant condition
util-linux-2.32.1/disk-utils/mkfs.cramfs.c:362]: (style) Redundant condition: If 'EXPR >= 16777216', the comparison 'EXPR' is always true.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-18 09:46:40 +02:00
Karel Zak 345ddd2828 blockdev: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 61bc5fd156 partx: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 7f8a406679 resizepart: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak efb17218ef libfdisk: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Andreas Henriksson aeda8dc3d0 partx: exit with error code when partition read failed
Make sure partx exits with a non-0 return code when
it runs into either code-path where getting the partition
table failed (or wasn't even attempted because of previous
error condition).

Change was tested using:
touch /tmp/foobar
partx -s - /tmp/foobar

Previously that was only printing an error/warning message
and then exiting with 0, but after this change it exits
with 1.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Reported-by: Juan Céspedes <cespedes@debian.org>
Addresses: https://bugs.debian.org/898426
2018-06-18 10:42:36 +02:00
Sami Kerola 1405658822 nls: remove translation strings
While looking earlier commit I noticed everything but formatting was removed
from a message in namei.c file.  That inspired me to look if there are more
strings that does not need translation project attention.  This change
removes at least some of them, if not all.

Reference: e19cc7b65b
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:36:38 +02:00
Ruediger Meier 333423163b cfdisk: fix compiler warnings, follow-up 7085f1e4 (#636)
Seen on OSX 10.13, xcode 9.3.

 disk-utils/cfdisk.c:1860:45: error: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
         DBG(UI, ul_debug("get_size (default=%ju)", *res));
                                             ~~~    ^~~~
                                             %llu
 disk-utils/cfdisk.c:267:60: note: expanded from macro 'DBG'
 #define DBG(m, x)       __UL_DBG(cfdisk, CFDISK_DEBUG_, m, x)
                                                           ^
 ./include/debug.h:67:4: note: expanded from macro '__UL_DBG'
                         x; \
                         ^
 disk-utils/cfdisk.c:1889:25: error: incompatible pointer types passing 'uint64_t *' (aka 'unsigned long long *') to parameter of type 'uintmax_t *' (aka 'unsigned long *') [-Werror,-Wincompatible-pointer-types]
                         rc = parse_size(buf, &user, &pwr);      /* parse */
                                              ^~~~~
 ./include/strutils.h:15:51: note: passing argument to parameter 'res' here
 extern int parse_size(const char *str, uintmax_t *res, int *power);
                                                   ^
 2 errors generated.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-05-24 16:31:43 +02:00
Karel Zak 7085f1e49b cfdisk: use uint64_t to avoid compiler warnings
Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-24 09:19:28 +02:00
Bjarni Ingi Gislason 0bb7e904d7 man: Use the correct macro for a font change of one argument
Use the correct macro (I, B) for the font change of one argument, not
those that are used for alternating two fonts, like "BR", "IR", "RB",
or "RI".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-05-23 10:43:27 +02:00
Karel Zak c9fdebcf54 Merge branch 'output-all' of https://github.com/kerolasa/lelux-utiliteetit
* 'output-all' of https://github.com/kerolasa/lelux-utiliteetit:
  zramctl: add --output-all option
  swapon: add --output-all option
  rfkill: add --output-all option
  partx: add --output-all option
  lsns: add --output-all option
  lsmem: add --output-all option
  lslogins: add --output-all option
  lslocks: add --output-all option
  lscpu: add --output-all option
  losetup: add --output-all option
  findmnt: add --output-all option
2018-05-10 12:15:32 +02:00
Vaclav Dolezal 36787f7a97 fdisk: fix typo in debug string
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-05-09 16:44:58 +02:00
Sami Kerola ba1c9075f4
partx: add --output-all option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-03 19:56:21 +01:00
Karel Zak 5653c982e8 fdisk: fix compiler warning [-Wmaybe-uninitialized]
Reported-by: L A Walsh <lkml@tlinx.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-03 10:31:09 +02:00
Patrick Steinhardt cc6ab5efb1 cfdisk: fix missing prototype for `get_wch`
The header <ncursesw/ncurses.h> defines the get_wch(3) function only
when `NCURSES_WIDECHAR` is defined. This define is actually getting set
in the same header file, but only in case `_XOPEN_SOURCE` is defined and
has a value of 500 or higher. As we already have the precedence of
defining `_XOPEN_SOURCE` to a value of 600 in some other files, simply
define it to the minimum required value of 500 in "cfdisk.c". This
silences a warning for `get_wch` being unknown.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2018-04-11 13:04:53 +02:00
Karel Zak cd42d02ff2 libfdisk: (docs) update year
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-20 18:55:49 +01:00
Tony Asleson 80ec018c6a libblkid: ignore private Stratis devices
[kzak@redhat.com: - tiny coding style changes]

References: 20e1c3dc03
Signed-off-by: Tony Asleson <tasleson@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-09 13:34:42 +01:00
Karel Zak ac52836781 fsck: cleanup find_fsck()
* remove static variable
* return 0 or 1
* optionally return allocated path to the program

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-19 13:05:45 +01:00
Karel Zak 7595bed189 Merge branch 'maybe-for-v2.32' of https://github.com/rudimeier/util-linux
* 'maybe-for-v2.32' of https://github.com/rudimeier/util-linux:
  tests: use pgrep instead of ps --ppid ...
  misc: fix typos using codespell
  lsns: fix clang compiler warning
  tests: add udevadm settle to sfdisk/resize
  build-sys: disable bz2 tarball and fix some am warnings
2018-02-16 11:25:22 +01:00
Ruediger Meier 73afd3f8e8 misc: fix typos using codespell
Some more funny typos, please review carefully.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-02-16 11:12:52 +01:00
Karel Zak 5b1c32b887 fsck: coding style cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-16 10:50:14 +01:00
Theodore Ts'o 8bad4fc0d5 fsck: use xasprintf to avoid buffer overruns with an insane fs type
This prevents a crash when running the command:

fsck -t AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA /dev/sda

Reported-by: Hornseth_Brenan@bah.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-02-16 10:50:03 +01:00
Ruediger Meier 68ac426949 fsck.cramfs: fix error message
errno is invalid in case that we just read(3) too short.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-24 12:53:34 +01:00
Ruediger Meier 2374b1ab75 fsck.cramfs: fix crash when superblock size is too small
This hopefully fixes the original problem addressed by the reverted
patch 7cb962c7.

The bug was introduced by myself in
    f991dbd3 "fsck.cramfs: allow smaller superblock sizes"

CC: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-24 12:53:31 +01:00
Ruediger Meier 919e372da8 Revert "fsck.cramfs: Fix bus error on broken file system."
This reverts commit 7cb962c770.

It can't be right that we mmap (start + super.size) bytes from a file
which is usually only super.size bytes large. The patch "fixed" a
problem when super.size is bad but now it fails for the correct case:

$ mkdir -p root/subdir
$ ./mkfs.cramfs -p root cramfs
$ ./fsck.cramfs cramfs
Bus error (core dumped)

We will fix the original problem later.

CC: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-24 12:53:28 +01:00
Karel Zak aefa920a79 sfdisk: add hint about udev and flock to the man page
Addresses: https://github.com/karelzak/util-linux/issues/563
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-17 16:30:06 +01:00
Karel Zak a15dca2f6d include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()
Let's make it possible to use debug.h without environment variables.

Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-17 13:58:29 +01:00
Karel Zak 7e95fd82b7 sfdisk: cleanup shortcuts in man page too
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-12 12:38:58 +01:00
Karel Zak 6ebc37854d libfdisk: (script) support R (RAID) and V (LVM) shortcuts
Addresses: https://github.com/karelzak/util-linux/issues/560
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-09 12:12:50 +01:00
Karel Zak 2dd2880f12 libfdisk: extend API to provide label specific geometry ranges
Now fdisk provides DOS specific geometry ranges in expert menu.

Addresses: https://github.com/karelzak/util-linux/issues/556
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-02 16:43:22 +01:00
Karel Zak a60d6b5217 sfdisk: wait before re-read
The original old (v2.13) fdisk had sleep(2) beany ideafore re-read ioctl. It
seems overkill, but short sleep is probably a good idea as we call
re-read on sfdisk start and at the end. It's possible that sfdisk is
too fast and the initial re-read is not gone yet.

It would be nice to have something more elegant than sleep, any idea?

Addresses: https://github.com/karelzak/util-linux/issues/557
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-02 14:48:01 +01:00
Karel Zak 42dea85c5a lib/md5: use ul_/UL_ prefix
The symbols names are too generic.

Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 12:06:15 +01:00
Karel Zak aae7bfc8b7 blockdev: be more explicit for BLKSSZ in blockdev.8
Addresses: https://github.com/karelzak/util-linux/issues/535
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-13 12:15:17 +01:00
Karel Zak 9d4081cd6d sfdisk: create empty label on 'write' command
Addresses: https://github.com/karelzak/util-linux/issues/528
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-03 19:34:49 +01:00
Tobias Stoeckmann 7cb962c770 fsck.cramfs: Fix bus error on broken file system.
The utility fsck.cramfs is prone to a bus error on file systems for
big endian systems with non-standard header sizes. While calculating
the crc32 checksum, it does not properly handle a possible offset
for bootcodes, resulting in out of boundary access of mmap'ed area.

You can trigger the issue with the following commands:

$ mkdir -p cramfs-poc/root/subdir
$ cd cramfs-poc
$ mkfs.cramfs -p -N big root cramfs
$ echo -ne \\00\\x4c | dd of=cramfs bs=1 seek=518 count=2 conv=notrunc
$ fsck.cramfs cramfs

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2017-11-02 13:56:14 +01:00
Karel Zak 8175ed3d74 sfdisk: allow to disable bootable flag on all partitions
Let use '-' rather than a partition number to disable the bootable flag
on all partitions:

 sfdisk --activate /dev/sdc -

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-02 13:50:30 +01:00
Karel Zak 5d5ca9deaf sfdisk: allow to use --activate for PMBR
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-02 13:19:22 +01:00
Karel Zak c48acf70f7 fdisk: (gpt) make PMBR accessible from main menu
Don't force users to go to expert menu to toggle between GPT and PMBR.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-02 11:17:24 +01:00
Karel Zak 502c5186d3 cfdisk: cleanup die-on-signal code
Let's keep signal handler simple and don't cleanup terminal from the
handler.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-26 12:47:50 +02:00
Karel Zak c431d9015a cfdisk: make resize code more readable
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-26 12:26:19 +02:00
Karel Zak 3da94b1114 swaplabel: fix --disable-libuuid compilation
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:30:40 +02:00
Philip Prindeville b443c1779e misc: replace magic number 37 with UUID_STR_LEN
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:49:21 +02:00
Vaclav Dolezal 6c183c283b fdisk: use strutils to trim whitespace from input
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2017-08-29 15:26:39 +02:00
Vaclav Dolezal 1d775aa260 fdisk: fix copy from readline and whitespace stripping
Bug fixed:
---
678: fdisk:      ASK: asking for number ['Partition number', <1,4>, default=1, range: 1-4]
678: fdisk:      ASK: asking for user replay [interactive]
Partition number (1-4, default 1): 12345
678: fdisk:      ASK: user's reply: >>>12345<<<
Value out of range.
678: fdisk:      ASK: asking for user replay [interactive]
Partition number (1-4, default 1): 1
678: fdisk:      ASK: user's reply: >>>12345<<<
Value out of range.
678: fdisk:      ASK: asking for user replay [interactive]
Partition number (1-4, default 1):
678: fdisk:      ASK: user's reply: >>>22345<<<
Value out of range.
---

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2017-08-28 14:06:15 +02:00
Vaclav Dolezal 3063670425 fdisk: minor fixes to make readline work
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2017-08-28 14:03:30 +02:00
Karel Zak ebfab541cf fdisk: add missing include
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-24 19:59:20 +02:00
Karel Zak c1154128db fdisk: fix readline interaction with signals
The high-level readline API is crazy to use with signals. Fortunately
the library provides low-level rl_callback_* API. In this case we can
use poll() to wait for input and control all signals, etc.

This patch also a little changes fdisk behavior on CTRL+C and CTRL+D.
The signals does not kill fdisk, but forces fdisk to return to the
main menu, if already in the main menu then exit. If the disk layout
has been modified than ask "Do you really want to exit...".

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-24 15:48:46 +02:00
Vaclav Dolezal 6c8c429d49 fdisk: handle SIGINT in dialogs as cancel
[kzak@redhat.com: - use sig_atomic_t]

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-24 13:08:22 +02:00
Vaclav Dolezal 55cf371609 fdisk: add wrap_fgets() for getting user input
make function wrapping rl_fgets() and fputs()&fgets() to remove
code duplication in get_user_reply().

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2017-08-24 11:27:18 +02:00
Karel Zak 1da83869cf isosize: usage() and coding style cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-21 11:16:51 +02:00
Karel Zak c380180289 isosize: iterate over all arguments even when something fails
Earlier the command exit too early if one of the arguments failed.  After
this change all arguments are examined, and command return value will have
information what happen during processing.

Based on patch from Sami Kerola <kerolasa@iki.fi>

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-21 11:11:11 +02:00
Karel Zak 6b1e439a0e cfdisk: add missing 0x7F key mapping
Addresses: https://github.com/karelzak/util-linux/issues/499
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-15 14:03:43 +02:00
Karel Zak 80701a7ace blockdev: document --setro more properly
Addresses: https://github.com/karelzak/util-linux/issues/498
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-14 11:30:37 +02:00
Karel Zak a351f2e504 cfdisk: add resize function
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-19 13:27:50 +02:00
Karel Zak 044ebc0c93 cfdisk: use fdisk_reread_changes()
Let's make cfdisk usable for disks where some partitions are mounted.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:34:55 +02:00
Karel Zak fadd8e0877 fdisk: use fdisk_reread_changes()
Let's make fdisk usable for disks where some partitions are mounted.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:34:55 +02:00
Karel Zak 87d04a3339 partx: move partx.h to include/
Let's make the ioctls usable also for libfdisk.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:34:55 +02:00
Karel Zak ea0acfc335 sfdisk: use fdisk_device_is_used()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:34:55 +02:00
Karel Zak 884659b32a libblkid: don't use CDROM_GET_CAPABILITY ioctl for DM devices
For some reason kernel commit e980f62353c697cbf0c4325e43df6e44399aeb64
add extra warning when the ioctl is used for DM devices. It seems we
can avoid this ioctl when the device has dm/uuid.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1469532
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-12 14:35:53 +02:00
Karel Zak dda4743b45 fdisk: reset context after failed script
Addresses: https://github.com/karelzak/util-linux/issues/481
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-10 12:34:47 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
changed in include/c.h and applied via sed:

  sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
  sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 16:54:33 +02:00
Ruediger Meier 43c960c8fa blockdev: correct man page name in --help
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 15:36:39 +02:00
Ruediger Meier 9f3d0fce66 docs: remove some old history from manpages
We assume that users will have a kernel >= 2.6.0 and removel
references to earlier kernels. There are still a few ones
left.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 12:56:22 +02:00
Ruediger Meier a861538cc8 blockdev: improve --help and man page
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:28:44 +02:00
Ruediger Meier b305445495 misc: consolidate all --help option descriptions
Now we are always using the same text also for commands
which had still hardcoded descriptions or where we can't
use the standard print_usage_help_options macro.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:28:36 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
Consolidate --help and --version descriptions. We are
now able to align them to the other options.

We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:26:19 +02:00
Ruediger Meier 86be6a32d3 misc: cosmetics, remove argument from usage(FILE*)
This patch is trivial and changes nothing, because
we were always using usage(stdout)

Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 5118d1be2a misc: never use usage(ERROR)
We are using better/shorter error messages and somtimes
also errtryhelp().

Here we fix all cases where the usage function took
an int argument for exit_code.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 9325dbfd20 misc: cleanup and fix --unknownopt issues
Fixed checkusage.sh warnings:

  rtcwake: --unknownopt, non-empty stdout

  rtcwake: --unknownopt, stderr too long: 21
  blockdev: --unknownopt, stderr too long: 28
  lsipc: --unknownopt, stderr too long: 77
  pg: --unknownopt, stderr too long: 23
  renice: --unknownopt, stderr too long: 18
  sulogin: --unknownopt, stderr too long: 17
  write: --unknownopt, stderr too long: 12

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Karel Zak c3a4cfc579 misc: consolidate usage() "Available columns"
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-26 14:09:53 +02:00
Karel Zak d6ec64e824 Merge branch '170622' of github.com:jwpi/util-linux
* '170622' of github.com:jwpi/util-linux:
  Docs: move option naming to howto-contribute.txt
  Docs: update howto-usage-function.txt
  Docs: add a comment for constants to boilerplate.c
  include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
2017-06-26 13:56:45 +02:00
Karel Zak dfdb1ca818 Merge branch 'fix-exit-codes' of https://github.com/rudimeier/util-linux
* 'fix-exit-codes' of https://github.com/rudimeier/util-linux:
  misc: fix optutils.h related exit codes
  misc: fix xalloc.h related exit codes
  misc: fix more strutils related exit codes
  lib: fix strutils.h, remove STRTOXX_EXIT_CODE
  misc: fix some broken exit codes
2017-06-26 13:47:04 +02:00
Ruediger Meier 300d702540 mkfs.cramfs: add --help and --version
Note, we were already using errtryhelp() without providing
a --help option.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-25 02:22:27 +02:00
J William Piggott 6e2d5a4460 include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
* login-utils/lslogins.c: all uses changed
* misc-utils/findmnt.c: likewise
* sys-utils/blkzone.c: likewise
* disk-utils/sfdisk.c: likewise
* sys-utils/lscpu.c: likewise
* sys-utils/lsmem.c: likewise
* sys-utils/wdctl.c: likewise

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-24 13:57:12 -04:00
Ruediger Meier 778ca2a0d4 misc: fix xalloc.h related exit codes
Found by:

grep -L "XALLOC_EXIT_CODE" $(grep -l "xalloc\.h" \
    $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 22:40:27 +02:00
Ruediger Meier 0b2b32e8a7 misc: fix more strutils related exit codes
Found by grep:

grep -l "\bEXIT_\|exit *( *[0-9][0-9] *)\|strutils\.h" $(grep -L \
    strutils_set_exitcode  $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))

The Command shows also some false positives (fstrim.c,
context_mount.c, ...)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 22:40:21 +02:00
Ruediger Meier 9c8b9fbacc lib: fix strutils.h, remove STRTOXX_EXIT_CODE
As discussed on the mailing list. We fix all places
where the non-working define STRTOXX_EXIT_CODE was used.

Regarding tunelp, also see 7e3c80a7.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 22:40:12 +02:00
Ruediger Meier 05691d9e88 misc: fix some broken exit codes
These tools have special exit codes. They got changed mistakenly.

See:
  findfs       0e1fa6b6
  fsck         658c0891
  fsck.cramfs  922ec175
  mkfs.cramfs  16154b1f
  tunelp       2ab428f6

FIXME: STRTOXX_EXIT_CODE doesn't work as it should.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:51:40 +02:00
Ruediger Meier 58745f3599 fsck: add --help and --version
Also cleanup usage() function, never write usage to stderr.

FIXME:
 - currently strtou32_or_err() exits with wrong exit code.
 - option -C does not use a safe strto*_err function

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:34:51 +02:00
Sami Kerola 1b5042636f misc: fix reassigned values before old ones has been used [cppcheck]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:19:20 +02:00
Sami Kerola e3e0054f5a isosize: avoid reading more data than what is needed
In same go fix error reporting when input file is not long enough.

$ touch empty
$ isosize empty
isosize: empty: might not be an ISO filesystem
isosize: read error on empty: Success

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:18:27 +02:00
Sami Kerola b1557fe981 misc: fix ggc-7 fallthrough warnings
(Original patch and commit message edited by Rudi.)

gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra.
This warning can be silenced by using comment /* fallthrough */
which is also recognized by other tools like coverity. There are
also other valid comments (see man gcc-7) but we consolidate this
style now.

We could have also used __attribute__((fallthrough)) but the comment
looks nice and does not need to be ifdef'ed for compatibility.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Suggested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 11:48:22 +02:00
Jakub Wilk fc747ee72a fdformat: clear progress message before printing "done"
Before:

    Formatting ... done1

After:

    Formatting ... done

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2017-06-02 23:54:10 +02:00
Karel Zak c71f5a568f cfdisk: fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-31 10:58:17 +02:00
Chris Morin b0ff9a76b7 sfdisk: disambiguate units of --show-size
[kzak@redhat.com: - use optutils.h]

Signed-off-by: Chris Morin <chris.morin2@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-22 11:29:10 +02:00
Karel Zak 780ce22cda misc: consolidate smartcols error messages
... just to keep translators happy

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-18 11:39:34 +02:00
Karel Zak 76ae3fe37a sfdisk: add hints for scanners [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 12:28:07 +02:00
Karel Zak d2f265d629 mkswap: use memcpy() for non-terminated string [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 12:27:59 +02:00
Karel Zak 82c7ab9cb8 fsck.minix: add hint for scanners [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 11:38:54 +02:00
Karel Zak 25d1a7e5a6 fdisk: check scols_line_refer_data() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 11:32:50 +02:00
Karel Zak 08099e41b9 cfdisk: add hints for scanners [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 11:26:54 +02:00
Sami Kerola 51b4b39870 fsck.minix: fix crash
disk-utils/fsck.minix.c:421:30: runtime error: index 513 out of bounds for
type 'unsigned short [512]'

Addresses: https://github.com/karelzak/util-linux/issues/373
Reported-by: Hanno Bock <hanno@gentoo.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-16 14:54:41 +02:00
Karel Zak 84111dbae4 fdisk: fix type dialog
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-11 15:53:07 +02:00
Karel Zak ddead341c5 fdisk: inform on 'p' about wiped partitions
The wipe operation is potentially dangerous. Let's inform about it
always by 'p' (list) command to make sure user knowns about it.

	Command (m for help): p
	...
	Device     Boot Start    End Sectors Size Id Type
	/dev/sdc1        2048 204799  202752  99M 83 Linux

	Filesystem/RAID signature on partition 1 will be wiped.

Addresses: https://github.com/karelzak/util-linux/issues/437
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-09 14:30:36 +02:00
Karel Zak a4aa4a6c9d fdisk: add to the man page missing option
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-09 13:05:26 +02:00
Sami Kerola 2cdaf94b55
partx: add --list-types option
Use libblkid as the source of truth what partition type names exist, and are
supported.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +01:00
Sami Kerola abec3cb1de
docs: try to convince open(2) O_DIRECT rather than using raw device
Tell in manual page that one should use open(2) O_DIRECT flag rather than
raw device.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +01:00
Sami Kerola 99d8ed0ac5
bash-completion: update disk-utils
fdformat:

	Add --from, --to, and --repair options.

	Commit: e0402441a1

fdisk:

	Add --output [1], --bytes [2], --wipe [3], --wipe-partition [4], and
	remove --geom- from from --cylinders, --heads, --sector options [5].

	Commit [1]: fff8ad5882
	Commit [2]: 354f8cc8cf
	Commit [3]: cb9a4b0033
	Commit [4]: ba465623d8
	Commit [5]: 4b4e391a28

fsck.cramfs:

	Broken since first commit.

	Commit: bf60993cf2

mkswap:

	Provide random uuid when completing --uuid argument.

partx:

	Add --sector-size option.  Fix also list of known partition types to
	match with libblkid blkid_idinfo names.  The fix is also applied to
	manual page.

	Commit: f8a4a0d4f2

	Reference: git grep -A 4 blkid_idinfo libblkid/src/partitions | grep name

sfdisk:

	Add --reoder, --delete, --mode-dataa, -no-tell-kernel, --wipe, and
	--wipe-partitions options.  In same go fix some option argument
	completions.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-17 18:12:10 +01:00
Karel Zak b607e5faca Fix menu spelling in cfdisk debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-22 10:43:55 +01:00
Sami Kerola 57ebfde291 fdisk, sfdisk: avoid non-ANSI function declarations [smatch scan]
Adding _FUNCTION_DEF definition will exclude compatibility type definitions
that do include void key word in empty argument list.

/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function
declaration of function 'Function'

These functions has been replaced by set of new ones in readline 4.2 (April
2001), and removed in 6.3 (February 2014).

Reference: https://cnswww.cns.cwru.edu/php/chet/readline/CHANGES
Rererence: https://blueslugs.com/blog/2016-10-23-updating-cppfunction-in-old-readline-consumers/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-14 14:01:14 +01:00
Sami Kerola c308e2050f misc: stop mixing declarations and code
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-13 14:48:04 +01:00
Karel Zak 208b2ef0b6 sfdisk: note about small partition in man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-02 13:51:40 +01:00
Karel Zak 86800f5d75 sfdisk: add note about alignment to man page
Addresses: https://github.com/karelzak/util-linux/issues/417
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-02 13:44:26 +01:00
Sami Kerola 2ba641e5f3 misc: add static keyword to where needed [smatch scan]
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer

Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.

Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Sami Kerola e948f4b616 cfdisk: avoid use of VLA in combination with sizeof() [smatch scan]
disk-utils/cfdisk.c:1066:29: error: cannot size expression

One should use sizeof() only when variable size can be known at time of
compilation.  That is not the case with variable length arrays.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:12 +01:00
Karel Zak 1b6d02fe8c cfdisk: use buffer editor for ui_get_string()
Addresses: https://github.com/karelzak/util-linux/issues/403
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-16 13:47:44 +01:00
Karel Zak 5635d19550 fdisk: improve --wipe functionality
* always (except --wipe=never) wipe old partition tables
* improve warn messages
* improve man page

Addresses: https://github.com/karelzak/util-linux/issues/410
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-14 15:13:35 +01:00
Karel Zak bb88152764 sfdisk: improve --wipe functionality
* always (except --wipe=never) wipe old partition tables
* improve warn messages
* improve man page

Addresses: https://github.com/karelzak/util-linux/issues/410
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-14 15:11:35 +01:00
Yuri Chornoivan a7349ee315 docs: Fix word repetitions 2017-02-13 14:10:12 +01:00
Karel Zak 91cce31a8e sfdisk: --quiet fixes
Addresses: https://github.com/karelzak/util-linux/issues/412
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-10 12:54:23 +01:00
Karel Zak e7e7697612 cfdisk: add copyright to help
... to make it obvious this is a new cfdisk.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-02 10:28:38 +01:00
Karel Zak 2f4eb047e5 cfdisk: support UI refresh on ^L
Addresses: https://github.com/karelzak/util-linux/issues/404
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-01 15:34:57 +01:00
Karel Zak f8a4a0d4f2 partx: add --sector-size option
/dev/sdc is 4K disk:

 # fdisk -l /dev/sdc
 Disk /dev/sdc: 100 MiB, 104857600 bytes, 25600 sectors
 ...
 Device     Boot Start   End Sectors Size Id Type
 /dev/sdc1        1024 25599   24576  96M 83 Linux

let's use it as disk image:

 # dd if=/dev/sdc of=~/sdc.img
 # losetup -f ~/sdc.img

old version:

 # partx --show /dev/loop0
 NR START   END SECTORS SIZE NAME UUID
 1  1024 25599   24576  12M      6a4ba75b-01

new version:

 # partx --show /dev/loop0 --sector-size 4096
 NR START    END SECTORS SIZE NAME UUID
  1  8192 204799  196608  96M      6a4ba75b-01

Addresses: https://github.com/karelzak/util-linux/issues/396
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-13 13:30:22 +01:00
Sami Kerola 12d69ae8bb man: fix couple tools/checkmans.sh warnings
<standard input>:407: warning: macro `fi.' not defined (possibly missing space after `fi')
From: cat ./disk-utils/fsck.8 | troff -mandoc -ww -z

<standard input>:71: warning: escape character ignored before `1'
From: cat ./disk-utils/partx.8 | troff -mandoc -ww -z

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-01-10 17:32:32 +01:00
Karel Zak 11e1097e6c sfdisk: unused parameter 'sf' [-Wunused-parameter]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-05 11:53:56 +01:00
Nate Clark b7b26945d1 disk-utils/mkfs.minix: Set ninodes after checking max
ninodes in the superblock needs to be set after inodes is checked
against MINIX_MAX_INODES otherwise a value larger than MINIX_MAX_INODES
can be attempted to be stored in the superblock.

Without this change the command "mkfs.minix -2 -i 65530 <dev>" would
write a minix superblock with ninodes set to 0.

Signed-off-by: Nate Clark <nate@neworld.us>
2017-01-04 14:42:59 -05:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Sébastien Helleu d673b74e9d docs: replace FTP by HTTPS in kernel.org URLs
The links to ftp://ftp.kernel.org/ are replaced by
https://www.kernel.org/.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 11:22:26 +01:00
Karel Zak 8fdd483c53 fdisk: don't be silent when list non-existing device
Addresses: https://github.com/karelzak/util-linux/issues/376
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-13 12:11:32 +01:00
Michael Kerrisk 46f057ed37 docs: various pages: Format pathnames as italic (.I)
In the majority of pages, pathnames are formatted as Italic,
which is the norm. However, there are several cases where they
are formatted as bold. This patch fixes a number of those
exceptions.

Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>
2016-12-09 13:45:09 +01:00
Ruediger Meier 223939d95b misc: spelling, always use "cannot" instead of "can not"
Just to be consistent ...

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-11-30 14:56:50 +01:00
Karel Zak 35ca511827 sfdisk: support empty label use-case
By default sfdisk creates partition table when a first partition is
specified, otherwise the device is not modified. This force users to
create at least one partition.

This commit allows to create empty label without partitions if "label:
<name>" header line is specified by script.

The commit also modifies "New situation:" output to list label name
and label identifier.

Addresses: https://github.com/karelzak/util-linux/issues/374
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-11-30 13:01:33 +01:00
Karel Zak c49b765a6e sfdisk: cleanup --dump error messages
old:
  # truncate -s 1G empty && ./sfdisk --dump empty
  sfdisk: failed to dump partition table: Success

new:
  # truncate -s 1G empty && ./sfdisk --dump empty
  sfdisk: empty: does not contain a recognized partition table.

Addresses: https://github.com/karelzak/util-linux/issues/375
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-11-30 10:57:39 +01:00
Karel Zak fed304837f sfdisk: don't be silent when list non-existing device
Addresses: https://github.com/karelzak/util-linux/issues/376
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-11-29 16:01:46 +01:00
Michael Kerrisk (man-pages) b2cc2a7fc6 Fix formatting errors in page cross references
These pages had errors such as

    .BR page (x) .

which should be

    .BR page (x).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-11-29 10:44:19 +01:00
Michael Kerrisk (man-pages) f053ff1e3a Place SEE ALSO entries in order
This patch does only the following:

* Order SEE ALSO entries first by section name, then alphabetically
  within section
* Adds one or two missing commas in SEE ALSO lists
* Removes one or two periods that were (inconsistently) used
  at the end of SEE ALSO lists.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-11-29 10:44:19 +01:00
Ruediger Meier 0f2eb577ac fdisk: fix memleak in list_disk_geometry()
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-10-27 11:03:16 +02:00
Karel Zak e4015b348f fdisk: fix compiler warning
disk-utils/fdisk-menu.c: In function ‘gpt_menu_cb’:
disk-utils/fdisk-menu.c:709: warning: passing argument 6 of ‘fdisk_ask_number’ from incompatible pointer type
./libfdisk/src/libfdisk.h:688: note: expected ‘uintmax_t *’ but argument is of type ‘long unsigned int *’

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-26 10:28:41 +02:00
Karel Zak bae57b5a3c misc: fix unsigned int usage for ctype.h functions
Reported-by: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-26 10:13:47 +02:00
Karel Zak 2687686cf4 cramfs: revert crc32 changes
We cannot use our crc32 without changes in the code, because our
ul_crc32() assumes that post-conditioning (xor) is done by
application. The zlib implementation does everything.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-19 13:33:15 +02:00
Karel Zak 98fd13a169 cramfs: add missing includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-19 12:17:19 +02:00
Gustavo Zacarias 7f0d4d56a2 lib/crc32: prefix public functions
Make the publicly-visible crc32 library functions prefixed by ul_, such
as crc32() -> ul_crc32().
This is because it clashes with the crc32() function from zlib.
For newer versions of glib (2.50+) zlib and libblkid are required
dependencies and otherwise results in build failure when building
statically.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
2016-10-19 12:11:59 +02:00
Karel Zak 17dd04c92a isosize: fix read() result check 2016-10-04 20:15:09 +02:00
Karel Zak 2d1fa4fdc3 sfdisk: cleanup before going out of scope [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-04 16:08:55 +02:00
Karel Zak 6387bf33db sfdisk: free before going out of scope [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-04 16:03:11 +02:00
Karel Zak 4c906abea2 isosize: don't ignore read() result [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-04 15:56:59 +02:00
Karel Zak 10c66b0b9e fsck.cramfs: don't ignore read() result [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-04 15:53:55 +02:00
Karel Zak cf9b302d46 cfdisk: fix mountpoint detection
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-04 15:02:00 +02:00
Karel Zak 37948503c9 libsmartcols: support LIBSMARTCOLS_DEBUG_PADDING=on
This env.variable forces libsmartcols to use visible padding chars.
The standard debug has to be enabled (to minimize overhead for
non-debug execution).

For example:

 $ LIBSMARTCOLS_DEBUG=all LIBSMARTCOLS_DEBUG_PADDING=on findmnt 2> ~/log

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-07 12:25:06 +02:00
Karel Zak 7208ef864b fsck: remove fs-specific options from man page
Let's force users to read fs-specific man pages rather than try to be
smart and maintain some non-fsck options in fsck.8.

Reported-by: Matej Cepl <mcepl@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 14:49:48 +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 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 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 090d8c763a include/closestream: define exit codes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-16 13:35:06 +02:00
Karel Zak 349ac67273 sfdisk: add show-pt-geometry to usage() and sfdisk.8
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-08 12:15:47 +02:00
Stanislav Brabec f7c6c31f08 sfdisk: Add --show-pt-geometry compatibility code
--show-pt-geometry existed since cf3f26bf (2006), and it is used by third party
tools. To prevent failure of these tools, add a minimal compatibility code.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-08 12:03:12 +02:00
Sami Kerola 74ce680a3e
misc: simplify if clauses [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Karel Zak 78e7f78896 Revert "sfdisk: exit with error if rereading partition table fails"
This reverts commit 14f644f386.

It seems we have mess in reread-after-write:

all old versions to v2.20  -- returns 0
from v2.20 to v2.26        -- returns 1
since v2.26                -- returns 0

I think re-read errors should not be interpreted as fatal errors,
because it's pretty common that you want to modify only one partition
(e.g. resize) and then another partitions are probably still in use
and re-read all PT does not make sense.

What we need is to improve granularity for re-read and calls it only
when really necessary (all PT modified) and otherwise call BLKPG
(add/delete/resize) ioctls.

Reported-by: Nikhil Valluru <vvnikhil@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-20 11:24:36 +02:00
Thierry Vignaud 04c163ed16 fdisk: make -l <dev ...> behaves like fdisk -l
aka having the same spacing between disks

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-14 12:04:04 +02:00
Karel Zak 6e51ab0c5c cfisk: add /dev/vda as another default disk
And use array for all default alternative disks.

Reported-by: Thierry Vignaud <thierry.vignaud@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-07 15:02:20 +02:00
Karel Zak 9907a95a7d cfdisk: use libsmartcols ASCII for non-widechar environment
Reported-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-03 12:20:24 +02:00
Karel Zak 65c74885df fsck.minix: fix endless loop and out of stack
It seems there is no elegant way how to recovery if a directory i_zone
(and i_size) is out of reality. Let's require human interaction to
avoid endless loop when executed with --auto, etc.

Addresses: https://github.com/karelzak/util-linux/issues/228
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-01 14:55:15 +02:00
Sebastian Rasmussen d1b7bfe506 fdisk: Fix typo RequiredPartiton -> RequiredPartition
This typo fix is backwards compatible in that fdisk will accept both
the GPT attribute RequiredPartition and RequiredPartiton with the typo.
Update documentation and tests to all use the new attribute name.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:51:07 +02:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Sebastian Rasmussen d35df4db5b docs: Fix various typos
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Tobias Stoeckmann 8f35b3a998 fsck.minix: Verify more fields in super-block.
The field s_ninodes in super-block is used for memory allocation and
division without verifications. The memory allocation increments the
unchecked value by 1, making it vulnerable to an integer overflow
on 32 bit systems with minix 3 file systems. I did not find a (good)
way to exploit this by crafting a malicious file system, so I consider
it as a reliability issue. If it's 0, a division by zero occurs when
"-v" has been used. A filesystem without any inodes is definitely
wrong, because it means that there's not even the root inode, which is
accessed unchecked later on.

The field s_firstdatazone has to be checked against s_(n)zones. If it
is larger than the highest allowed index, the file system is definitely
corrupted -- hard to say which value is wrong though, therefore I
decided to simply call die(). A maliciously created file system could
do more harm in this way: single bits inside the memory area could be
flipped because range checks would fail. Hard to consider it as a
security issue though, because these addresses are not arbitrarily
accessible without very careful crafting (if at all possible).

[kzak@redhat.com: - fix compiler warning (cast get_nzones()) [-Wsign-compare]]

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-31 13:18:06 +02:00
Mike Frysinger 5593132a90 man pages: fix spacing between man page name & section number
Most have standardized correctly, but fix a few latent ones.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-05-20 10:54:31 +02:00
Sassan Panahinejad 304cf9499d fdisk: Add support for altering GPT size
Adds an options (l) to the GPT menu to resize the GPT.
2016-05-18 13:46:35 +02:00
Victor Dodon 14f644f386 sfdisk: exit with error if rereading partition table fails
Use the return value of fdisk_reread_partition_table in write_changes so that
sfdisk exits with error if re-reading the partition table fails.

Signed-off-by: Victor Dodon <dodonvictor@gmail.com>
2016-05-05 11:43:07 +02:00
Karel Zak 832bbc73b2 build-sys: remove obsolete [cs]fdisk LDADDs
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-04 15:02:02 +02:00
Karel Zak 3d6db3fdb1 sfdisk: add --wipe-partitions=auto|never|default
The option allows to remove filesystes/RAIDs from newly created
partitions before the partition table is updated (and partition
device created).

The default is "auto" in this case wipe is enabled in interactive mode
only and user's confirmation (yes/no dialog) is required. Note that
keep filesystem signature on partition is pretty valid use-case, so we
don't erase anything by default.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-04 12:47:17 +02:00
Karel Zak ba465623d8 fdisk: add --wipe-partitions=auto|never|default
The option allows to remove filesystes/RAIDs from newly created
partitions before the partition table is updated (and partition
device created).

The default is "auto" in this case wipe is enabled in interactive mode
only and user's confirmation (yes/no dialog) is required. Note that
keep filesystem signature on partition is pretty valid use-case, so we
don't erase anything by default.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-04 12:43:35 +02:00
Yuriy M. Kaminskiy fc75981a22 fsck: fix racing between unlock/unlink and open
Process A	Process B	Process C
open()
[creates file]
lock()
[succeed]
		open()
		[open existing]
		lock()...
running()
close()
		[...succeed]
unlink()
		running()
				open()
				[creates file] {BAD!}
				lock()
				[succeed] {BAD!}
				running() {BAD!}
		close()

Cons: leaves empty (unlocked/harmless) .lock files in /run/fsck/
Signed-off-by: Yuriy M. Kaminskiy <yumkam@gmail.com>
2016-04-22 11:07:42 +02:00
Lubomir Rintel d97dc0ee25 mkswap: tolerate ENOTSUP when failing to relabel
It might be that the underlying filesystem just doesn't support SELinux
labeling. This fixes creating swap on vfat live media:

  # livecd-iso-to-disk.sh --msdos --swap-size-mb 666 ...

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2016-04-18 10:51:28 +02:00
Karel Zak c6121fec26 fdisk: remove dead assignment [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-29 14:13:22 +02:00
Karel Zak 2d47fa3921 partx: fix --nr usage
Reported-by: Serge van den Boom <serge+util-linux@vdboom.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-22 15:49:00 +01:00
Benno Schulenberg 49b7f95e43 docs: miscellaneous tiny tweaks of man pages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-17 12:18:54 +01:00
Benno Schulenberg 718b6f0cda fdisk: fix the grammar of an option description
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-17 12:18:54 +01:00
Benno Schulenberg b779c1aecb mount, umount, swapon, fsck, lsblk, findmnt: harmonize six error messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-16 10:39:38 +01:00
Benno Schulenberg cb19f5479b fdisk, cfdisk, sfdisk: improve the grammar of three messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-16 10:39:35 +01:00
Benno Schulenberg 1a60a5ecb0 sfdisk: improve the wording of seven error messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-16 10:39:34 +01:00
Karel Zak 785539baa3 Merge branch 'travis-osx' of https://github.com/rudimeier/util-linux
* 'travis-osx' of https://github.com/rudimeier/util-linux:
  travis: add OSX build
  travis: switch to Ubuntu 14.04 Trusty
  build-sys: improve uuidd and script build conditions
  build-sys: use AC_PROG_MKDIR_P and remove a few gnuisms
  build-sys: add missing "not found" strings
  build-sys: fix again UL_SCANF_TYPE_MODIFIER
  tests: don't use system's mount commands
  tests: improve skipping of old btrfs-tools
  tests: remove invalid argument in libmount/debug
  tests: skip old socat silently
  misc: fix icc/clang compiler warnings
  misc: fix printf i386 compiler warnings
2016-03-14 15:59:10 +01:00
Sami Kerola 5a2ed45309 isosize: stop unmeaningful printing errno message
Earlier printout had strange looking 'Success'.

$ isosize --sectors /dev/urandom
isosize: /dev/urandom: might not be an ISO filesystem
isosize: 733error: le=-1971599244 be=1633181607: Success
...

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-03-14 13:15:12 +01:00
Ruediger Meier 58c87bd045 misc: fix icc/clang compiler warnings
clang warning:
libmount/src/tab.c:1833:6: warning: variable 'rc' is used uninitialized whenever
      'if' condition is true [-Wsometimes-uninitialized]
        if (!mpc)
            ^~~~

icc printf warnings:
    libmount/src/monitor.c(348): warning #2279: printf/scanf format not a string literal and no format arguments
            DBG(MONITOR, ul_debugobj(mn, status == 1 ? " success" : " nothing"));
            ^
    login-utils/vipw.c(348): warning #2279: printf/scanf format not a string literal and no format arguments
                           : _("You are using shadow passwords on this system.\n"));
                                                                                  ^

icc enum warnings:
    disk-utils/fdisk-menu.c(150): warning #188: enumerated type mixed with another type
            .exclude = FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_BSD,
                       ^
    libsmartcols/src/table_print.c(750): warning #188: enumerated type mixed with another type
                            &width, align,
                                    ^

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-13 21:47:27 +01:00
Karel Zak 8e2e9144ef misc: remove duplicate includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-10 14:30:32 +01:00
Karel Zak 95aae4fcee sfdisk, fdisk: add fflush()
Let's add fflush(stdout) before we print to stderr to make output
order more deterministic.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-10 12:26:43 +01:00
Karel Zak 322e553a1c Merge branch 'port-osx' of https://github.com/rudimeier/util-linux
* 'port-osx' of https://github.com/rudimeier/util-linux:
  fdisk: fix warning, uninitialized variable
  logger: fix compiler warning, const facilitynames
  include/bitops: avoid fallbacks for more systems
  include/bitops: add casts to bswap functions
2016-03-09 13:12:50 +01:00
Ruediger Meier 056e622c91 fdisk: fix warning, uninitialized variable
This was a typo in 4afb337e.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-08 14:56:02 +01:00
Karel Zak 075d2c0754 include: move sys/sysmacros.h to c.h
The file is no portable (#ifdef HAVE_SYS_SYSMACROS_H is necessary),
but needed on many places. It seems better to keep it in c.h.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-08 14:29:45 +01:00
Karel Zak 3fe3f560b7 Revert "include sysmacros.h where used"
This reverts commit 46a40c0184.
2016-03-08 14:26:33 +01:00
Benno Schulenberg c805c36923 sfdisk: adjust more wordings and formatting in the man page
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-08 14:21:55 +01:00
Benno Schulenberg 589b69316c fdisk, sfdisk: adjust the wording of the --wipe option
Use "when" as argument, to match the argument of --color,
that can have the same three values.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-08 14:21:55 +01:00
Benno Schulenberg 7e3b3f4710 fdisk, sfdisk: adjust some formatting in the man pages
Only the optional argument should be in italics,
the literal = should be bold.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-08 14:21:55 +01:00