Commit Graph

11219 Commits

Author SHA1 Message Date
Masatake YAMATO c1cc045d12 tests: add cases for testing fincore command
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-03-23 12:46:40 +01:00
Masatake YAMATO ffbfa7fbaf man: add a page for fincore command
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-03-23 12:46:38 +01:00
Masatake YAMATO a921a7dea9 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>
2017-03-23 12:46:09 +01:00
Karel Zak 7e26832d70 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
2017-03-23 12:36:47 +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
Karel Zak bb6762035a libfdisk: fix compiler warning [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-16 10:01:54 +01:00
Karel Zak 999448d866 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>
2017-03-15 11:49:22 +01:00
Karel Zak 19a5510b96 lscpu: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-14 15:32:53 +01:00
Karel Zak c82b12a0a2 lscpu: use libsmartcols to print summary too
Addresses: https://github.com/karelzak/util-linux/issues/419
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-14 15:19:12 +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 f5a2b07e8c 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>
2017-03-13 15:34:18 +01:00
Sami Kerola 126d8cf35b 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>
2017-03-13 15:24:57 +01:00
Karel Zak b2b5292541 libfdisk: fix potentially NULL pointer usage
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-13 15:20:56 +01:00
Sami Kerola 6cb55736cb 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>
2017-03-13 14:48:16 +01:00
Sami Kerola fdf8e1f595 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>
2017-03-13 14:48:14 +01:00
Sami Kerola 57f1539592 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>
2017-03-13 14:48:12 +01:00
Sami Kerola c88f7aee8f 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>
2017-03-13 14:48:10 +01:00
Sami Kerola 08cce2e1cc 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>
2017-03-13 14:48:07 +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 ab7093775f 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>
2017-03-13 14:44:22 +01:00
Karel Zak bd2aece45e 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>
2017-03-13 12:55:44 +01:00
Tobias Stoeckmann b0f97de5a4 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.
2017-03-13 12:46:49 +01:00
Tobias Stoeckmann 55a5fbbc33 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".
2017-03-13 12:46:47 +01:00
J William Piggott b80d6d4be8 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>
2017-03-04 15:03:44 -05:00
J William Piggott 7a3000f7ba 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>
2017-03-04 11:04:10 -05:00
Karel Zak 30d7f61f4f 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>
2017-03-04 11:01:56 -05:00
J William Piggott 7088bd8832 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>
2017-03-04 10:49:41 -05:00
Karel Zak 1765814521 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>
2017-03-03 10:37:37 +01:00
Karel Zak c14224b374 libsmartcols: support columns separators greater than one output cell
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-02 16:56:39 +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
Karel Zak 3e094e5fe2 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>
2017-03-01 12:25:16 +01:00
Karel Zak 7bb9ee99da libmount: cosmetic change to mnt_table_find_srcpath()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-28 14:47:02 +01:00
Petr Vorel 443be11396 libmount: return tab entry for default node
This is useful for lsblk.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
2017-02-28 14:41:42 +01:00
Sami Kerola e9f62f3881 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>
2017-02-28 14:38:22 +01:00
Karel Zak 168950e3ce libfdisk: (dos) add ID related debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-27 13:44:08 +01:00
Karel Zak ea4ea332a8 libfdisk: add version to debug output
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-27 13:16:18 +01:00
Matthias Gerstner 1db2468106
agetty: fix a memory leak when parsing \S in issue files 2017-02-27 12:31:28 +01:00
Karel Zak 86b6d7f434 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>
2017-02-27 12:09:35 +01:00
Karel Zak 7ab6461fae docs: add note about branches to README
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-24 14:19:04 +01:00
Karel Zak 830043212f blkzone: add count option to bash-completion
and fix typo in man page

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-24 12:05:13 +01:00
Karel Zak c16970f794 blkzone: use optutils.h to check mutually exclusive options
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-24 11:59:53 +01:00
Damien Le Moal f1b8b84d34 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>
2017-02-24 11:53:45 +01:00
Damien Le Moal a7f742069e 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>
2017-02-24 11:53:45 +01:00
Damien Le Moal 6e1958d8dd 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>
2017-02-24 11:53:45 +01:00
Damien Le Moal 72a7310233 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>
2017-02-24 11:53:45 +01:00
Karel Zak 22fae330d9 blkreport, blkreset: remove in favour of blkzone
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-23 17:03:26 +01:00
Karel Zak 6324d0f494 blkzone: add bash-completion
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-23 17:01:29 +01:00
Karel Zak 1ad8ef9187 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>
2017-02-23 16:43:51 +01:00
Karel Zak fc72f51e1f 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>
2017-02-21 11:00:19 +01:00