Commit Graph

11430 Commits

Author SHA1 Message Date
Sami Kerola b6b5272b03 col: avoid extra newline if no input
BSD fix missed for 22 years, and all util-linux releases so far.

Backported-from: 2a15260a2a
Addresses: https://github.com/karelzak/util-linux/issues/422
Reported-by: Pavel Raiskup <praiskup@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-10 10:53:28 +02:00
Sami Kerola c6b0cbdd95 lib/mbsedit: fix typo in comment
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-10 10:53:28 +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 29f2e825d8 libfdisk: add fdisk_partition_has_wipe()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-09 14:30:02 +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
Karel Zak 577d1a663c lscpu: reuse the same buffer
Now we use libsmartcols for the default output and all is allocated in
the smartcols table. So, we can reuse the same buffer for all
sprintf/scanf calls.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-09 12:31:52 +02:00
Karel Zak 89222b17fc lscpu: make cpu_{max,min}_mhz() usage more elegant
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-09 12:29:24 +02:00
Mamatha Inamdar fc07d9f5ab lscpu: Read available CPUs max and min frequencies
Problem:"lscpu frequency-info" command was always reading CPU0
max and min frequencies. If CPU0 is guarded or offline then it used to
display max and min frequencies as NULL.

This patch will read overall CPU max and min frequencies.

Test Results:

Before Patch:

    #lscpu (CPU0 is guarded/offline)
    Architecture:          ppc64le
    Byte Order:            Little Endian
    CPU(s):                120
    On-line CPU(s) list:   8-127
    Thread(s) per core:    8
    Core(s) per socket:    3
    Socket(s):             4
    NUMA node(s):          4
    Model:                 2.1 (pvr 004b 0201)
    Model name:            POWER8E (raw), altivec supported
    CPU max MHz:           (null)
    CPU min MHz:           (null)
    L1d cache:             64K
    L1i cache:             32K
    L2 cache:              512K
    L3 cache:              8192K
    NUMA node0 CPU(s):     8-31
    NUMA node1 CPU(s):     32-63
    NUMA node16 CPU(s):    64-95
    NUMA node17 CPU(s):    96-127

With Patch:

    # ./lscpu
    Architecture:          ppc64le
    Byte Order:            Little Endian
    CPU(s):                120
    On-line CPU(s) list:   8-127
    Thread(s) per core:    8
    Core(s) per socket:    3
    Socket(s):             4
    NUMA node(s):          4
    Model:                 2.1 (pvr 004b 0201)
    Model name:            POWER8E (raw), altivec supported
    CPU max MHz:           4322.0000
    CPU min MHz:           2061.0000
    L1d cache:             64K
    L1i cache:             32K
    L2 cache:              512K
    L3 cache:              8192K
    NUMA node0 CPU(s):     8-31
    NUMA node1 CPU(s):     32-63
    NUMA node16 CPU(s):    64-95
    NUMA node17 CPU(s):    96-127

[kzak@redhat.com: - cpu_{max,min}_mhz() refactoring]

Signed-off-by: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-09 12:23:37 +02:00
Karel Zak 626aa65180 sulogin: add missing type
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-09 11:59:53 +02:00
Karel Zak b1f1fe3dff Merge branch '2017wk16' of git://github.com/kerolasa/lelux-utiliteetit
* '2017wk16' of git://github.com/kerolasa/lelux-utiliteetit:
  chfn, chsh: use readline(3) to receive user input
  findfs: use getopt_long() to parse options
  logger: make month names, login name, and tag read-only objects
  sulogin: reduce vulnerability surface
  partx: add --list-types option
  libblkid: add blkid_partitions_get_name()
  docs: try to convince open(2) O_DIRECT rather than using raw device
  blkid: add long options
  lsipc: fix options parsing and sync with man page
2017-05-09 11:58:23 +02:00
Karel Zak da06d42197 column: be robust on empty table
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 13:56:40 +02:00
Karel Zak cb3fdf2ae9 column: require column names for JSON
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 12:49:51 +02:00
Alexey Gladkov dc46610bf5 blkid: fix return code when display the version
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
2017-05-05 12:22:09 +02:00
Karel Zak c467fdaf80 column: use libsmartcols to avoid circular dependences
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 12:13:15 +02:00
Karel Zak eebf2dd89b libsmartcols: add scols_line_is_ancestor()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 12:12:43 +02:00
Karel Zak 60102db546 column: add note that circular dependencies are ignored
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 11:52:04 +02:00
Karel Zak 435846ef99 column: add --tree to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 11:47:46 +02:00
Karel Zak b0f00a9471 column: fix --tree id-parent loop crash
The loop is silently ignored.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 11:31:47 +02:00
Karel Zak f3626e039f tests: add new build-sys tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-03 14:33:04 +02:00
Karel Zak c4b6c832b4 testsL update build-sys tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-03 13:36:20 +02:00
Karel Zak 8b7f00a8bb build-sys: fix lsmem dependence
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-03 12:00:20 +02:00
Karel Zak 960ee8e3f1 build-sys: remove column-old.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-03 10:40:46 +02:00
Sami Kerola e41ae45093
chfn, chsh: use readline(3) to receive user input
The readline offers editing capabilities while the user is entering the
line, unlike fgets(3) and getline(3) that were used earlier.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:05 +01:00
Sami Kerola 0e1fa6b63a
findfs: use getopt_long() to parse options
This change makes the findfs(8) more coherent with other commands in the
project source tree.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +01:00
Sami Kerola c8598d8a51
logger: make month names, login name, and tag read-only objects
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +01:00
Sami Kerola 71f207a5f5
sulogin: reduce vulnerability surface
Hopefully these changes are unreachable code, but better safe than sorry
when dealing with setuid root code that is installed everywhere.  Quite
obviously the introduced abort() calls protect from impossible inputs.

Secondly set all possible data to be read-only in attempt to make it more
difficult to alter anything at all.

Reference: https://www.securecoding.cert.org/confluence/display/c/DCL00-C.+Const-qualify+immutable+objects
Reviewed-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +01: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 635d9aa5db
libblkid: add blkid_partitions_get_name()
This new function can be use to enquiry what partition names libblkid is
aware of.  First use of this information will be in partx(8) to make bash
completion to work without a magic list.

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 15a74f755a
blkid: add long options
This change attempts to make tab completion more reasonable by alloging
memorizable option names.  That also has positive impact to manual page, in
which referrals to other options are now easier to understand.

All short options are kept exactly as they were to avoid ABI breakage.  The
only exception is -f option that getopt(3) recognized, but was not found
from anywhere else.  The -f has been part of blkid since the initial commit.

Commit: 51410fc6de
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +01:00
Sami Kerola 1b71d08c63
lsipc: fix options parsing and sync with man page
Option --pid was never implemented so remove it from struct options and
manual page.  Interestingly this option was not in usage().  Short option
string had 'u' that has never appear anywhere else, so it is also removed.
Finally add options --bytes and --numeric-perms to manual page.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +01:00
Karel Zak 74cc7c2515 column: parent and child has to be independent
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 1c9de9dbc8 tests: add tests for new column features
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 7e2a4ef700 libsmartcols: add debug mesg to see width change
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak bd6b5a6498 column: force to follow specified width
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 838ca70ce7 columns: add note about width
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak c728e00012 column: use NOEXTREMES for the last column
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 90852c3e12 column: add support for trees
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 236092172a column: clean up man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 7e947f48e7 column: clean up usage() and options order
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 166271a90b column: add --table-order
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 2483c4c9da column: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 9624f6157c column: add --table-hide
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 68916af3b9 column: add --table-wrap
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 1ae24ec239 column: add --table-noextreme
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 3ba01db0ab column: add --table-truncate
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 01e335c9e4 column: rename options
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak f05593e100 column: fix greedy initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak dbed2f8c63 column: add --table-colright
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak be03f65232 column: use err_exclusive_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00