Commit Graph

11161 Commits

Author SHA1 Message Date
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 1f519a90c1 tests: make sfdisk wipe partition optional
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-17 16:24:35 +01:00
Karel Zak 1c1d30c750 libfdisk: add sample-fdisk-mkpart binary
For example:
	# sample-fdisk-mkpart --device /dev/sdc 1M 2M 3M - 5M

	# fdisk -l /dev/sdc
	...
	Device     Boot Start    End Sectors Size Id Type
	/dev/sdc1        2048   4095    2048   1M 83 Linux
	/dev/sdc2        4096   8191    4096   2M 83 Linux
	/dev/sdc3        8192  14335    6144   3M 83 Linux
	/dev/sdc4       14336 204799  190464  93M  5 Extended
	/dev/sdc5       16384  26623   10240   5M 83 Linux

Addresses: https://github.com/karelzak/util-linux/issues/204
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-17 16:15:03 +01:00
Karel Zak 8d03f4af49 libfdisk: (dos) make it possible to create primary/logical by template
Let's check partition partno if specified to create logical or primary
partition.

Addresses: https://github.com/karelzak/util-linux/issues/204
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-17 16:11:37 +01:00
Karel Zak 21f1206aac libfdisk: (gpt) make sure it's GPT in public API
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-17 14:47:00 +01:00
Karel Zak e1cfb30466 libfdisk: verify partno from template
* verify partno from template when create a new partition
* remove unnecessary l->ext_offset check

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-17 13:17:48 +01:00
Karel Zak 9dc5644717 tests: (sfdisk) tell kernel about new partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-17 10:28:53 +01:00
Karel Zak 99d944bb2d tests: add udevadm settle to sfdisk wipe
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-16 15:30:45 +01:00
Karel Zak 8ad7f6b96a build-sys: add missing file
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-16 15:27:07 +01:00
Karel Zak 74fe554a41 tests: add --show-diff
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-16 14:14:54 +01:00
Karel Zak 1854d6dfc6 build-sys: add non-widechar.conf
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-16 13:47:44 +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 299ef2c457 lib/mbsedit: add simple buffer editor
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-16 13:47:44 +01:00
Karel Zak ab3d893784 tests: use swap in sfdisk wipe test
and add "udevadm settle".

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-16 11:01:35 +01:00
Karel Zak d86dc71427 rename: add --no-act to bash-completion
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-15 13:45:02 +01:00
Alexander F Rødseth 990bf1f048 rename: add --no-act option
[kzak@redhat.com: - rename --dry-run to --no-act]

Signed-off-by: Alexander F Rødseth <xyproto@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-15 13:41:46 +01:00
Karel Zak f0c60dff1a tests: add sfdisk --wipe and --wipe-partition tests
Addresses: https://github.com/karelzak/util-linux/issues/410
Addresses: https://github.com/karelzak/util-linux/issues/411
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-15 12:48:06 +01:00
Karel Zak e9e88bb8e9 libblkid: (gpt) fix force flag
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-15 11:30:58 +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
Karel Zak 74493d48d8 libblkid: fix BLKID_PARTS_FORCE_GPT usage
Now wipefs always inform about MBR as about PMBR. That's bug.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-14 14:57:24 +01:00
Karel Zak a1001292ae libfdisk: (dos) debug what we read from first sector
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-14 14:46:19 +01:00
Karel Zak 0cec78a3c4 libfdisk: classify collision type
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-14 14:23:45 +01:00
Karel Zak 37204dc60c libfdisk: check for collisions when create new label
We need to be sure that when create a new disklabel than the old label
will be removed.

Addresses: https://github.com/karelzak/util-linux/issues/410
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-14 13:07:54 +01:00
Sami Kerola b192dd6943 lib/randutils: glibc 2.25 has getrandom(2) declaration
Use correct header file to include the function.

Reference: http://git.kernel.org/cgit/docs/man-pages/man-pages.git/commit/?id=2cbb6fb4e926e56dc3985b19ac02389321a0af5d
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-13 14:14:28 +01:00
Sami Kerola d011b3dd66 bash-completion: add blkreset and blkreport completion
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-13 14:14:28 +01:00
Sami Kerola fc72452473 man: improve blkreport(8) and blkreset(8) manual pages
Tell in manual page what ZAC and ZBC acronyms mean.  Include explanation to
blkreport output, so that users do not need to search source code to
understand what the tool informed.  And fix couple dot double space issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-13 14:14:28 +01:00
Sami Kerola ee8268c245 blkreport, blkreset: small code clean ups
Set variables read-only where possible.  Fix few code style issues, mostly
with spacing.  Avoid initializing variables if they are never read before
next update.  Remove "ERR: %d -> %s" message that repeated system error
three times, twice in that message and once at end of main that is the only
of these three left in place.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-13 14:14:28 +01:00
Yuri Chornoivan a7349ee315 docs: Fix word repetitions 2017-02-13 14:10:12 +01:00
Karel Zak 7ccc1643ab findmnt: use line separator for --poll output
Addresses: https://github.com/karelzak/util-linux/issues/409
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-10 17:28:07 +01:00
Karel Zak bd3457b8d9 libfdisk: fix fdisk_set_wipe_area() calls
The function expects size in sectors rather than in bytes.

Addresses: https://github.com/karelzak/util-linux/issues/410
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-10 16:45:18 +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 6433fcad71 taskset: don't use zero PID in messages
The pid 0 is technically correct, but very confusing for end users. Use
getpid() in the messages.

Addresses: https://github.com/karelzak/util-linux/issues/413
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-10 11:46:37 +01:00
Karel Zak 6153d2977d blkreset: remove "LBA" from usage()
* "LBA" sounds confusing

Reported-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-10 10:56:02 +01:00
Karel Zak 3e30dc82d8 blkreport: remove "LBA" from usage() and unnecessary alignment check
* "LBA" sounds confusing

* alignment check is unnecessary for report ioctl

Reported-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-10 10:53:38 +01:00
Benno Schulenberg 07fd790875 blkreport: slice up option descriptions, fix typo, fix docstring
Each option plus its description should be a separate translatable
string.  And, if all is well, blkreport should not discard anything
-- that is: fix the cut-and-paste error from blkdiscard.

Additionally, tweak some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2017-02-10 10:35:39 +01:00
Shaun Tancheff 70bb534511 blkzonecmd, blkreport: Add new commands for ZAC/ZBC drives
This patch adds:
 - blkreset to issue Reset (Write Pointer) zone commands
 - blkreport to retrieve drive zone information

[kzak@redhat.com: - cleanup man page and usage()
                  - remove command line options aliases,
                  - use strtosize_or_err()
                  - remove unnecessary -ludev
                  - use blkdev.h stuff]

Signed-off-by: Shaun Tancheff <shaun@tancheff.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-09 13:19:44 +01:00
Karel Zak a18f17ad2b hwclock: remove if-if-condition 2017-02-09 11:42:01 +01:00
Karel Zak 1dc2aaadba Merge branch 'hwclock-jwp-reviewed' of git://github.com/kerolasa/lelux-utiliteetit
* 'hwclock-jwp-reviewed' of git://github.com/kerolasa/lelux-utiliteetit: (25 commits)
  hwclock: remove --compare option
  hwclock: remove trailing dot from messages that include system error message
  hwclock: make --date=argument less prone to injection
  hwclock: fix rtc atexit registration
  hwclock: clarify cmos inb and outb preprocessor directives
  hwclock: try RTCGET and RTCSET only when normal rtc fails
  hwclock: stream line synchronize_to_clock_tick_rtc()
  hwclock: improve coding style
  hwclock: remove division by zero [asan]
  hwclock: add debugging to open_rtc()
  hwclock: remove magic constants from interpret_date_string()
  hwclock: use symbolic magic values passed in between functions
  hwclock: initialize struct adjtime members
  hwclock: alloate date_resp parsing buffer in interpret_date_string()
  hwclock: simplify save_adjtime() execution flow
  hwclock: remove dead code and other minor fixes
  hwclock: move error messages to determine_clock_access_method()
  hwclock: clarify set_cmos_epoch() code
  hwclock: move command-line options to control structure
  hwclock: remove unnecessary type casts
  ...
2017-02-09 11:35:50 +01:00
Carlos Santos 4953018e23 build-sys: improve detection of the "isnan" function in uClibc
Since commit beceb14b45, MATH_LIBS is set
to "-lm" when the isnan function is detected. In uClibc, however, isnan
is a macro that calls __isnan, __isnanf, or __isnanl, depending on the
size of the argument (double, float or long double).

Fixes:
  http://autobuild.buildroot.net/results/2c2/2c29a78ed81ca844a87dcd076ab3e14ea080296d/
  http://autobuild.buildroot.net/results/404/404b10f359b2ae8a7216729fa1bab37fed2d3d4c/

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
2017-02-09 11:31:49 +01:00
Karel Zak 9e66fd30d7 umount: exclude selinuxfs from --all
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1417722
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-09 11:21:49 +01:00
Sami Kerola 92931ab28d
hwclock: remove --compare option
Compare functionality was printing nonsense values.  There is no knowledge
of anyone using this broken functionality.  Instead of deprecating the code
for months, and removing it after few release, it is removed immediately.
Needless to say this is unusual removal.

Reference: http://marc.info/?l=util-linux-ng&m=148396210506652&w=2
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola c9a86ff664
hwclock: remove trailing dot from messages that include system error message
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola 9c65888e82
hwclock: make --date=argument less prone to injection
This change should not improve security much.  One hopes hwclock --set is
restricted for root only.  Where hwclock is allowed to run via sudo, or has
setuid setup, there is a pretty easy privilege escalation via subshell.

$ sudo ./hwclock --set --date='2000-10-20$(touch /tmp/hwclock.inject)'

Reviewed-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola 926ffe7451
hwclock: fix rtc atexit registration
Commit 27f9db17bd missed a minus sign from
comparison.

Reviewed-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola 6b06669e2a
hwclock: clarify cmos inb and outb preprocessor directives
The cmos only works when architecture is i386, x86_64, or alpha.

Reviewed-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola fc35f2db79
hwclock: try RTCGET and RTCSET only when normal rtc fails
The RTCGET and RTCSET are in use for sparcs with sbus, so try them as
fallback rather than always.

Reference: https://github.com/torvalds/linux/blob/master/fs/compat_ioctl.c#L967-L974
Reviewed-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola 4bfd519eee
hwclock: stream line synchronize_to_clock_tick_rtc()
Flip if clauses to hit common case first.  This should be easier and quicker
to read and run.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola bd0786895d
hwclock: improve coding style
Make string constants to be symbolical declarations.  Use longer variable
name for rtc and cmos function pointer values.  Exclude code that is
architecture specific with preprocessor directives.  And remove message
duplication.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola 85932da89e
hwclock: remove division by zero [asan]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00