]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
8 years agolibblkid: fix typo
Karel Zak [Fri, 24 Mar 2017 10:46:33 +0000 (11:46 +0100)] 
libblkid: fix typo

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agobuild-sys: add missing header file
Karel Zak [Thu, 23 Mar 2017 14:59:58 +0000 (15:59 +0100)] 
build-sys: add missing header file

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: prevent OOB access while probing HFS+
Tobias Stoeckmann [Wed, 15 Mar 2017 21:12:00 +0000 (22:12 +0100)] 
libblkid: prevent OOB access while probing HFS+

It is possible to perform out of boundary read accesses due to
insufficient boundary checks in probe_hfsplus.

The first issue occurs if the leaf count in a B-node is too
small. The second happens while parsing a unicode description which
is longer than 255 UTF-8 characters. The length is stored in a 16 bit
integer, but the array in the struct is limited to 255 * 2, which is
in sync with Apple's Open Source HFS+ implementation (HFSUniStr255).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 years agotests: refresh fincore test
Karel Zak [Thu, 23 Mar 2017 14:28:39 +0000 (15:28 +0100)] 
tests: refresh fincore test

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofincore: fix error on open()
Karel Zak [Thu, 23 Mar 2017 14:28:05 +0000 (15:28 +0100)] 
fincore: fix error on open()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofincore: add --raw and --json
Karel Zak [Thu, 23 Mar 2017 13:34:12 +0000 (14:34 +0100)] 
fincore: add --raw and --json

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofincore: add --output
Karel Zak [Thu, 23 Mar 2017 13:27:42 +0000 (14:27 +0100)] 
fincore: add --output

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofincore: add --bytes and --noheadings
Karel Zak [Thu, 23 Mar 2017 13:17:46 +0000 (14:17 +0100)] 
fincore: add --bytes and --noheadings

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofincore: use libsmartcols
Karel Zak [Thu, 23 Mar 2017 13:09:20 +0000 (14:09 +0100)] 
fincore: use libsmartcols

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofincore: cleanup return codes
Karel Zak [Thu, 23 Mar 2017 12:06:34 +0000 (13:06 +0100)] 
fincore: cleanup return codes

Don't use EXIT_* macros as functions return code.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agobash-completion: add a function for fincore command
Masatake YAMATO [Tue, 7 Mar 2017 02:33:52 +0000 (11:33 +0900)] 
bash-completion: add a function for fincore command

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
8 years agotests: add cases for testing fincore command
Masatake YAMATO [Tue, 7 Mar 2017 02:33:51 +0000 (11:33 +0900)] 
tests: add cases for testing fincore command

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
8 years agoman: add a page for fincore command
Masatake YAMATO [Tue, 7 Mar 2017 02:33:50 +0000 (11:33 +0900)] 
man: add a page for fincore command

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
8 years agofincore: new command for counting pages of file contents in core
Masatake YAMATO [Tue, 7 Mar 2017 02:33:49 +0000 (11:33 +0900)] 
fincore: new command for counting pages of file contents in core

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge remote-tracking branch 'jwpi/hwclock-date7'
Karel Zak [Thu, 23 Mar 2017 11:36:47 +0000 (12:36 +0100)] 
Merge remote-tracking branch 'jwpi/hwclock-date7'

* jwpi/hwclock-date7:
  lib: add parse-date documentation
  hwclock: use parse_date function
  build-sys: add parse-date.y
  lib: add parse-date.y

8 years agoFix menu spelling in cfdisk debug messages
Karel Zak [Wed, 22 Mar 2017 09:43:55 +0000 (10:43 +0100)] 
Fix menu spelling in cfdisk debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: fix compiler warning [-Wsign-compare]
Karel Zak [Thu, 16 Mar 2017 09:01:54 +0000 (10:01 +0100)] 
libfdisk: fix compiler warning [-Wsign-compare]

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: refresh lscpu tests
Karel Zak [Wed, 15 Mar 2017 10:49:22 +0000 (11:49 +0100)] 
tests: refresh lscpu tests

.. due to libsmartcols use for the default output. The output does not
contain extra unnecessary blank space anymore.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolscpu: add --json
Karel Zak [Tue, 14 Mar 2017 14:32:53 +0000 (15:32 +0100)] 
lscpu: add --json

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolscpu: use libsmartcols to print summary too
Karel Zak [Tue, 14 Mar 2017 14:19:12 +0000 (15:19 +0100)] 
lscpu: use libsmartcols to print summary too

Addresses: https://github.com/karelzak/util-linux/issues/419
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofdisk, sfdisk: avoid non-ANSI function declarations [smatch scan]
Sami Kerola [Mon, 20 Feb 2017 22:12:42 +0000 (22:12 +0000)] 
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>
8 years agoblkid: add messages to translations
Sami Kerola [Sun, 5 Mar 2017 20:52:25 +0000 (20:52 +0000)] 
blkid: add messages to translations

Without obvious reason blkid has managed to be part of this project for
pretty long time without getting translations.  Lets change that.  In same
go use the usual error printing facilities instead of fprintf(stderr, ...);

[kzak@redhat.com: - use errtryh(),
                  - cleanup "unsupported output format"]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoblkid: add curly braces to do-while statement
Sami Kerola [Sun, 5 Mar 2017 20:52:24 +0000 (20:52 +0000)] 
blkid: add curly braces to do-while statement

Some say people read do-while statements are easily as while statements and
get wrong impression.  This happens because do-whiles are not common.
Adding braces should make it easier to read the code.

Reference: http://www.spinics.net/lists/linux-kernel-janitors/msg02018.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibfdisk: fix potentially NULL pointer usage
Karel Zak [Mon, 13 Mar 2017 14:20:56 +0000 (15:20 +0100)] 
libfdisk: fix potentially NULL pointer usage

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agodocs: improve boilerplate.c options example
Sami Kerola [Sun, 5 Mar 2017 20:52:31 +0000 (20:52 +0000)] 
docs: improve boilerplate.c options example

Make usage() translations to contain complete option help in single
translation unit.  And make -z option example complete.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoinclude: fix compiler warning
Sami Kerola [Sun, 5 Mar 2017 20:52:28 +0000 (20:52 +0000)] 
include: fix compiler warning

./include/optutils.h:12:18: warning: null pointer dereference [-Wnull-dereference]
  for (o = opts; o->name; o++)
                 ~^~~~~~
In file included from libfdisk/src/dos.c:12:0:
./include/pt-mbr.h:25:47: warning: potential null pointer dereference [-Wnull-dereference]
  return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
         ~^~~

Well these should be impossible, so add assert() to catch possible bugs.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibblkid: ensure uninitialized variable is not used [clang]
Sami Kerola [Sun, 5 Mar 2017 20:52:23 +0000 (20:52 +0000)] 
libblkid: ensure uninitialized variable is not used [clang]

Following condition can be true if minix file system is corrupt, and versio
number is found to be greater than 3.  It is fair to say described scenario
is unlikely.

libblkid/src/superblocks/minix.c:107:13: warning: variable 'zone_size' is
used uninitialized whenever
      'if' condition is false [-Wsometimes-uninitialized]
        } else if (version == 3) {
                   ^~~~~~~~~~~~
libblkid/src/superblocks/minix.c:121:6: note: uninitialized use occurs here
        if (zone_size != 0 || ninodes == 0 || ninodes == UINT32_MAX)
            ^~~~~~~~~

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibblkid: avoid overflow when initializing array
Sami Kerola [Sun, 5 Mar 2017 20:52:22 +0000 (20:52 +0000)] 
libblkid: avoid overflow when initializing array

libblkid/src/superblocks/drbdmanage.c:38:42: warning: too long
initializer-string for array of char(no space for nul char)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibmount: fix use of preprocessor identifier
Sami Kerola [Sun, 5 Mar 2017 20:52:21 +0000 (20:52 +0000)] 
libmount: fix use of preprocessor identifier

libmount/src/context_mount.c:990:5: warning: undefined preprocessor
identifier 'USE_LIBMOUNT_SUPPORT_MTAB'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agomisc: stop mixing declarations and code
Sami Kerola [Sun, 5 Mar 2017 20:52:20 +0000 (20:52 +0000)] 
misc: stop mixing declarations and code

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolib/colors: assert rathen than overflow [-Wnull-dereference]
Karel Zak [Mon, 13 Mar 2017 13:44:22 +0000 (14:44 +0100)] 
lib/colors: assert rathen than overflow [-Wnull-dereference]

lib/colors.c: In function 'colors_read_schemes':
lib/colors.c:412:7: warning: potential null pointer dereference [-Wnull-dereference]

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolast: use domain string more carefully
Karel Zak [Mon, 13 Mar 2017 11:55:44 +0000 (12:55 +0100)] 
last: use domain string more carefully

Use xstrcpy() to explicitly terminate the domain string.

Reported-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agologin: prevent OOB read on illegal /etc/hushlogins
Tobias Stoeckmann [Sun, 12 Mar 2017 16:49:45 +0000 (17:49 +0100)] 
login: prevent OOB read on illegal /etc/hushlogins

If the file /etc/hushlogins exists and a line starts with '\0', the
login tools are prone to an off-by-one read.

I see no reliability issue with this, as it would clearly need a
hostile action from a system administrator. But for the sake of
correctness, I've sent this patch nonetheless.

8 years agolibblkid: Fix blkid.conf parsing
Tobias Stoeckmann [Sun, 12 Mar 2017 16:48:44 +0000 (17:48 +0100)] 
libblkid: Fix blkid.conf parsing

The SEND_UEVENT=yes|no line is not properly parsed, because the offset
jumps one byte too far behind the equal sign. Therefore, every
configuration that contains the line "SEND_UEVENT=yes" still does not
send an uevent.

The fix is simple: adjust the offset to be "12" instead of "13".

8 years agolib: add parse-date documentation
J William Piggott [Sat, 4 Mar 2017 20:03:44 +0000 (15:03 -0500)] 
lib: add parse-date documentation

* Documentation/parse-date.txt - new file
* sys-utils/hwclock.8.in
Fix the --date option description.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: use parse_date function
J William Piggott [Sat, 4 Mar 2017 16:04:10 +0000 (11:04 -0500)] 
hwclock: use parse_date function

* hwclock.c: replace interpret_date_string() with parse_date().
   Eliminates shell injection vulnerability from popen() date(1).
   Removes system dependency on date(1).
   Reduction in hwclock execution time.
   Significant cleanup of hwclock.c code.

* Bug fix for "hwclock --predict --date 'bad_date'" printing:
    hwclock: No usable set-to time.  Cannot set clock.

  The message now matches date(1) for an invalid --date argument.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agobuild-sys: add parse-date.y
Karel Zak [Sat, 4 Mar 2017 16:01:56 +0000 (11:01 -0500)] 
build-sys: add parse-date.y

* add lib/parse-date.y to build system
* add necessary autotools stuff to generate .c on the fly
  (autotools are smart enough to add generated file to tarball)
* check for bison version by ./autogen.sh
* add non-wanted junk to .gitignore

With some modification by J William Piggott with regard to
moving the parse-date API into timeutils.h

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agolib: add parse-date.y
J William Piggott [Sat, 4 Mar 2017 15:49:41 +0000 (10:49 -0500)] 
lib: add parse-date.y

* include/timeutils.h
    Add parse-date API

* lib/parse-date.y - new file
    Lib function that parses a date string into a timespec struct.
    Derived from gnulib-dd7a871 parse-datetime.y with these changes:
            * reduced to a single function API renamed to parse_date()
            * removed gnulib dependencies
            * removed debugging
            * converted to util-linux coding style

* include/cctype.h - new file
    Like ctype.h only hard coded to the 'C' locale.
    Used by lib/parse-date.y.
    Derived from gnulib-dd7a871 c-ctype.h with these changes:
            * removed gnulib dependencies
            * converted to util-linux coding style
            * add requisite util-linux constants

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agolibsmartcols: allow to add column to already used table
Karel Zak [Fri, 3 Mar 2017 09:37:37 +0000 (10:37 +0100)] 
libsmartcols: allow to add column to already used table

Now it's impossible to add new column if the table already contains
lines with data. This patch forces library to realloc cell array in
the lines to accept a new column.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: support columns separators greater than one output cell
Karel Zak [Thu, 2 Mar 2017 15:56:39 +0000 (16:56 +0100)] 
libsmartcols: support columns separators greater than one output cell

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosfdisk: note about small partition in man page
Karel Zak [Thu, 2 Mar 2017 12:51:40 +0000 (13:51 +0100)] 
sfdisk: note about small partition in man page

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosfdisk: add note about alignment to man page
Karel Zak [Thu, 2 Mar 2017 12:44:26 +0000 (13:44 +0100)] 
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>
8 years agocolumn: make more obvious what is default behavior
Karel Zak [Wed, 1 Mar 2017 11:25:16 +0000 (12:25 +0100)] 
column: make more obvious what is default behavior

The man page contains mistakes. The default is to fill columns before
lines:

$ printf 'aaaaaaaaaaaaaaaaaaaaaa\nBBBBBBBBBBBBBBBBBBBBB\nXXXXXXX\nYYYYYYYYYYY\nZZZZZ' > data

$ column --columns 80 < data
aaaaaaaaaaaaaaaaaaaaaa XXXXXXX ZZZZZ
BBBBBBBBBBBBBBBBBBBBB YYYYYYYYYYY

$ column  --fillrows --columns 80 < data
aaaaaaaaaaaaaaaaaaaaaa BBBBBBBBBBBBBBBBBBBBB XXXXXXX
YYYYYYYYYYY ZZZZZ

The patch also rename functions in the code to make it more obvious
for code readers.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibmount: cosmetic change to mnt_table_find_srcpath()
Karel Zak [Tue, 28 Feb 2017 13:47:02 +0000 (14:47 +0100)] 
libmount: cosmetic change to mnt_table_find_srcpath()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibmount: return tab entry for default node
Petr Vorel [Thu, 23 Feb 2017 18:25:13 +0000 (19:25 +0100)] 
libmount: return tab entry for default node

This is useful for lsblk.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
8 years agosetterm: fix bitfield warning [smatch]
Sami Kerola [Sat, 25 Feb 2017 17:35:17 +0000 (17:35 +0000)] 
setterm: fix bitfield warning [smatch]

term-utils/setterm.c:179:27: warning: dubious bitfield without explicit
`signed' or `unsigned'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibfdisk: (dos) add ID related debug messages
Karel Zak [Mon, 27 Feb 2017 12:44:08 +0000 (13:44 +0100)] 
libfdisk: (dos) add ID related debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: add version to debug output
Karel Zak [Mon, 27 Feb 2017 12:16:18 +0000 (13:16 +0100)] 
libfdisk: add version to debug output

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoagetty: fix a memory leak when parsing \S in issue files
Matthias Gerstner [Mon, 27 Feb 2017 11:03:57 +0000 (12:03 +0100)] 
agetty: fix a memory leak when parsing \S in issue files

8 years agounshare: add note about sysfs and procfs
Karel Zak [Mon, 27 Feb 2017 11:09:35 +0000 (12:09 +0100)] 
unshare: add note about sysfs and procfs

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1390057
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agodocs: add note about branches to README
Karel Zak [Fri, 24 Feb 2017 13:19:04 +0000 (14:19 +0100)] 
docs: add note about branches to README

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoblkzone: add count option to bash-completion
Karel Zak [Fri, 24 Feb 2017 11:05:13 +0000 (12:05 +0100)] 
blkzone: add count option to bash-completion

and fix typo in man page

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoblkzone: use optutils.h to check mutually exclusive options
Karel Zak [Fri, 24 Feb 2017 10:59:53 +0000 (11:59 +0100)] 
blkzone: use optutils.h to check mutually exclusive options

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoblkzone: Add --count option
Damien Le Moal [Fri, 24 Feb 2017 06:45:31 +0000 (15:45 +0900)] 
blkzone: Add --count option

The length option is used to specify the number of zones to
operate on. To be more consistent with other tools, have this
option use a number of sectors and introduce the --count option
to allow users to specify a number of zones.
The --count and --length options cannot be used together on
the command line.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
8 years agoblkzone: Improve zone information print
Damien Le Moal [Fri, 24 Feb 2017 03:47:29 +0000 (12:47 +0900)] 
blkzone: Improve zone information print

Add "0x" to the zone start, length and write pointer print
to make it always clear that the values are Hexadecimal.

Also update the zone condition string and associated comments
to match more closely the wording in the standard document.
The man page is also updated to match the new wording.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
8 years agoblkzone: Report all zones if length is not specified
Damien Le Moal [Fri, 24 Feb 2017 03:36:08 +0000 (12:36 +0900)] 
blkzone: Report all zones if length is not specified

Report all zones of the block device when length is not specified
on the command line. To do this, introduce an inner loop in
blkzone_report to repeatedly issue report zone ioctl to the
device.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
8 years agoblkzone: Reset all zones when length is not specified
Damien Le Moal [Fri, 24 Feb 2017 02:48:45 +0000 (11:48 +0900)] 
blkzone: Reset all zones when length is not specified

If length is 0, operate on all zones starting from offset.
This also fix the maximum length calculation from offset.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
8 years agoblkreport, blkreset: remove in favour of blkzone
Karel Zak [Thu, 23 Feb 2017 16:03:26 +0000 (17:03 +0100)] 
blkreport, blkreset: remove in favour of blkzone

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoblkzone: add bash-completion
Karel Zak [Thu, 23 Feb 2017 16:01:29 +0000 (17:01 +0100)] 
blkzone: add bash-completion

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoblkzone: add new command (merge blkreport and blkreset)
Karel Zak [Thu, 23 Feb 2017 15:43:51 +0000 (16:43 +0100)] 
blkzone: add new command (merge blkreport and blkreset)

This new command is based on the original implementation of blkreport
and blkreset command.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agobuild-sys: simplify UL_ENABLE_ALIAS() semantic
Karel Zak [Tue, 21 Feb 2017 10:00:19 +0000 (11:00 +0100)] 
build-sys: simplify UL_ENABLE_ALIAS() semantic

Let's follow only $enable_ variables. In this case the MASTERNAME
(e.g. [schedutils] for --enable-schedutils) has to be without
UL_BUILD_INIT.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agobuild-sys: fix --disable-all-programs --enable-schedutils
Karel Zak [Mon, 20 Feb 2017 13:17:37 +0000 (14:17 +0100)] 
build-sys: fix --disable-all-programs --enable-schedutils

* add UL_ENABLE_ALIAS(NAME, MASTERNAME) to initialize $enable_<name>
  according to MASTERNAME. Note that we have to use $build_<mastername>,
  the $enable_<mastername> is just AC_ARG_ENABLE() stuff only. The
  $build_ is evaluated and modified by our UL_...() functions.

* add enable-schedutils.conf to have build-system regression test for
  this use-case

Addresses: https://github.com/karelzak/util-linux/issues/415
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: another improvement to the sfdisk wipe test
Karel Zak [Mon, 20 Feb 2017 12:22:55 +0000 (13:22 +0100)] 
tests: another improvement to the sfdisk wipe test

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: remove unnecessary 'static' keyword
Karel Zak [Mon, 20 Feb 2017 12:08:30 +0000 (13:08 +0100)] 
libblkid: remove unnecessary 'static' keyword

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofindmnt: fix couple memory leaks [cppcheck]
Sami Kerola [Sun, 12 Feb 2017 20:42:49 +0000 (20:42 +0000)] 
findmnt: fix couple memory leaks [cppcheck]

In both cases FILE *f was leaked.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibblkid: declare across file variables in blkidP.h [smatch scan]
Sami Kerola [Sun, 12 Feb 2017 18:48:21 +0000 (18:48 +0000)] 
libblkid: declare across file variables in blkidP.h [smatch scan]

Else these variables will cause following warning:

libblkid/src/superblocks/superblocks.c:165:29: warning: symbol
'superblocks_drv' was not declared.  Should it be static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolib/idcache: add void to function declaration [smatch scan]
Sami Kerola [Sun, 12 Feb 2017 08:25:03 +0000 (08:25 +0000)] 
lib/idcache: add void to function declaration [smatch scan]

lib/idcache.c:29:29: warning: non-ANSI function declaration of function
'new_idcache'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agomisc: add static keyword to where needed [smatch scan]
Sami Kerola [Sun, 12 Feb 2017 00:19:33 +0000 (00:19 +0000)] 
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>
8 years agomisc: do not use plain 0 as NULL [smatch scan]
Sami Kerola [Sat, 11 Feb 2017 20:23:26 +0000 (20:23 +0000)] 
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>
8 years agocfdisk: avoid use of VLA in combination with sizeof() [smatch scan]
Sami Kerola [Sat, 11 Feb 2017 19:01:08 +0000 (19:01 +0000)] 
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>
8 years agotests: make sfdisk wipe partition optional
Karel Zak [Fri, 17 Feb 2017 15:24:35 +0000 (16:24 +0100)] 
tests: make sfdisk wipe partition optional

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: add sample-fdisk-mkpart binary
Karel Zak [Fri, 17 Feb 2017 15:15:03 +0000 (16:15 +0100)] 
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>
8 years agolibfdisk: (dos) make it possible to create primary/logical by template
Karel Zak [Fri, 17 Feb 2017 15:11:37 +0000 (16:11 +0100)] 
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>
8 years agolibfdisk: (gpt) make sure it's GPT in public API
Karel Zak [Fri, 17 Feb 2017 13:47:00 +0000 (14:47 +0100)] 
libfdisk: (gpt) make sure it's GPT in public API

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: verify partno from template
Karel Zak [Fri, 17 Feb 2017 12:15:09 +0000 (13:15 +0100)] 
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>
8 years agotests: (sfdisk) tell kernel about new partition
Karel Zak [Fri, 17 Feb 2017 09:28:53 +0000 (10:28 +0100)] 
tests: (sfdisk) tell kernel about new partition

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: add udevadm settle to sfdisk wipe
Karel Zak [Thu, 16 Feb 2017 14:30:45 +0000 (15:30 +0100)] 
tests: add udevadm settle to sfdisk wipe

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agobuild-sys: add missing file
Karel Zak [Thu, 16 Feb 2017 14:27:07 +0000 (15:27 +0100)] 
build-sys: add missing file

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: add --show-diff
Karel Zak [Thu, 16 Feb 2017 13:14:54 +0000 (14:14 +0100)] 
tests: add --show-diff

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agobuild-sys: add non-widechar.conf
Karel Zak [Thu, 16 Feb 2017 12:47:34 +0000 (13:47 +0100)] 
build-sys: add non-widechar.conf

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agocfdisk: use buffer editor for ui_get_string()
Karel Zak [Thu, 16 Feb 2017 12:46:26 +0000 (13:46 +0100)] 
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>
8 years agolib/mbsedit: add simple buffer editor
Karel Zak [Thu, 16 Feb 2017 12:04:26 +0000 (13:04 +0100)] 
lib/mbsedit: add simple buffer editor

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: use swap in sfdisk wipe test
Karel Zak [Thu, 16 Feb 2017 10:01:35 +0000 (11:01 +0100)] 
tests: use swap in sfdisk wipe test

and add "udevadm settle".

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agorename: add --no-act to bash-completion
Karel Zak [Wed, 15 Feb 2017 12:45:02 +0000 (13:45 +0100)] 
rename: add --no-act to bash-completion

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agorename: add --no-act option
Alexander F Rødseth [Mon, 13 Feb 2017 12:44:38 +0000 (13:44 +0100)] 
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>
8 years agotests: add sfdisk --wipe and --wipe-partition tests
Karel Zak [Wed, 15 Feb 2017 11:48:06 +0000 (12:48 +0100)] 
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>
8 years agolibblkid: (gpt) fix force flag
Karel Zak [Wed, 15 Feb 2017 10:30:58 +0000 (11:30 +0100)] 
libblkid: (gpt) fix force flag

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofdisk: improve --wipe functionality
Karel Zak [Tue, 14 Feb 2017 14:11:35 +0000 (15:11 +0100)] 
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>
8 years agosfdisk: improve --wipe functionality
Karel Zak [Tue, 14 Feb 2017 14:11:35 +0000 (15:11 +0100)] 
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>
8 years agolibblkid: fix BLKID_PARTS_FORCE_GPT usage
Karel Zak [Tue, 14 Feb 2017 13:57:24 +0000 (14:57 +0100)] 
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>
8 years agolibfdisk: (dos) debug what we read from first sector
Karel Zak [Tue, 14 Feb 2017 13:46:19 +0000 (14:46 +0100)] 
libfdisk: (dos) debug what we read from first sector

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: classify collision type
Karel Zak [Tue, 14 Feb 2017 13:23:45 +0000 (14:23 +0100)] 
libfdisk: classify collision type

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: check for collisions when create new label
Karel Zak [Tue, 14 Feb 2017 12:07:54 +0000 (13:07 +0100)] 
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>
8 years agolib/randutils: glibc 2.25 has getrandom(2) declaration
Sami Kerola [Sat, 11 Feb 2017 18:04:14 +0000 (18:04 +0000)] 
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>
8 years agobash-completion: add blkreset and blkreport completion
Sami Kerola [Sat, 11 Feb 2017 14:10:52 +0000 (14:10 +0000)] 
bash-completion: add blkreset and blkreport completion

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoman: improve blkreport(8) and blkreset(8) manual pages
Sami Kerola [Sat, 11 Feb 2017 14:10:51 +0000 (14:10 +0000)] 
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>
8 years agoblkreport, blkreset: small code clean ups
Sami Kerola [Sat, 11 Feb 2017 14:10:50 +0000 (14:10 +0000)] 
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>
8 years agodocs: Fix word repetitions
Yuri Chornoivan [Fri, 10 Feb 2017 11:05:04 +0000 (13:05 +0200)] 
docs: Fix word repetitions

8 years agofindmnt: use line separator for --poll output
Karel Zak [Fri, 10 Feb 2017 16:28:07 +0000 (17:28 +0100)] 
findmnt: use line separator for --poll output

Addresses: https://github.com/karelzak/util-linux/issues/409
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: fix fdisk_set_wipe_area() calls
Karel Zak [Fri, 10 Feb 2017 15:45:18 +0000 (16:45 +0100)] 
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>