Commit Graph

10653 Commits

Author SHA1 Message Date
Sami Kerola b7a245e27a uuidd: remove unnecessary pidpile path variable
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-08 12:33:16 +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 ba7f6ba53a deprecated.txt: Add sfdisk --show-pt-geometry 2016-08-08 12:03:12 +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
Karel Zak 041d33734e tests: fix loop-overlay test
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-04 15:15:12 +02:00
Karel Zak 05b483010e tests: fix libmount loop-overlay test
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-04 12:30:09 +02:00
Karel Zak c8bbdff083 Merge branch 'lo'
* lo:
  mount: small change to mount.8 loopdev section
  libmount: one iteration to detect overlap and reuse loopdev
  lib/loopdev: cleanup sizelimit check
  mount.8: Update loop device documentation
  tests: Add loop-overlay test
  libmout: Reuse loop device safely
  Implement loopcxt_check_conflict()
  Add sizelimit to internal API
  mount: Handle MNT_ERR_LOOPOVERLAP
  libmount: Introduce new error: MNT_ERR_LOOPOVERLAP
  libmount: Fix possible crash in mnt_context_setup_loopdev()
2016-08-04 11:57:49 +02:00
Karel Zak 03b4519b35 mount: small change to mount.8 loopdev section
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-04 11:56:50 +02:00
Karel Zak dff7e16046 libmount: one iteration to detect overlap and reuse loopdev
The current code scans loopdevs to detect already used loop device and
another scan to detect overlap.

Let's use one scan only, for this purpose loopcxt_find_overlap() has
been modified to return info (rc==2) about full size and offset match.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-04 11:48:26 +02:00
Karel Zak c444a71b1b lib/loopdev: cleanup sizelimit check
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-04 10:49:46 +02:00
Heiko Carstens 2c497d3288 lscpu: print correct number of threads per core if possible
lscpu calculates the number of threads per core by dividing the number
of online cpus with the number of cores. This may or may not give the
correct number of threads per core depending on the number of online
CPUs (and which CPUs are online).

At least on s390 there is a new "max thread id" field within
/proc/cpuinfo present which reliably allows us to tell the number of
threads per core. Let's use this instead, like we already have also
special treatment to figure out the number core per socket etc. on
s390.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2016-08-03 13:35:05 +02:00
Heiko Carstens 6417dd7ffd lspcu: minor manpage improvement
Always use the word "can" instead of "may" to be consistent with the
descriptions of the other columns.

Also print "lspcu" always with bold characters like everywhere else in
the man page.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2016-08-03 13:35:05 +02:00
Heiko Carstens 0002704ebe lscpu: only try to read sysfs attributes of present CPUs
lscpu can skip all CPUs which are possible but not present. For
configurations where a lot of CPUs are possible but only few CPUs are
present this saves a lot of pointless glibc/system calls.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2016-08-03 13:35:05 +02:00
Heiko Carstens 0be8771a71 lscpu: add parsable testcase with the --physical option
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2016-08-03 13:35:05 +02:00
Heiko Carstens 0d2b5d2a72 lscpu: add --physical option
With the --physical option lscpu will use the IDs that are reported by
the kernel (e.g. core id for the CORE column) instead of calculating
them on it's own.

This has the advantage that it is possible to tell on which physical
hardware CPUs a Linux instance runs. The logical IDs that lscpu
generates on it own are based on comparing of CPU masks and may or may
not be identical with the physical IDs.

If the kernel was unable to retrieve an ID for a topology element then
the corresponding sysfs file will normally contain "-1". In the
extended and parsable output a dash "-" will be displayed for such
cases.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2016-08-03 13:35:05 +02:00
Stanislav Brabec 7aa390db98 mount.8: Update loop device documentation
New code checks both offset and sizelimit before re-using loop device.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-03 11:53:28 +02:00
Stanislav Brabec ab9795aca8 tests: Add loop-overlay test
The test will check proper loop device reuse and error in case of overlapping
loop device.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-03 11:53:28 +02:00
Stanislav Brabec 8efad715b9 libmout: Reuse loop device safely
Add a safety check to mnt_context_setup_loopdev(). Only a loop device with equal
offset and sizelimit will be reused. If any overlapping loop device exists,
MNT_ERR_LOOPOVERLAP is returned.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-03 11:53:28 +02:00
Stanislav Brabec 211e1d4609 Implement loopcxt_check_conflict()
Add a function that searches for a possible conflicting (i. e. overlaying loop
device).

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-03 11:53:28 +02:00
Stanislav Brabec 74a4705a99 Add sizelimit to internal API
Fully safe checks of loop device need to check sizelimit. To prevent need of two
nearly equal functions, introduce sizelimit parameter to several internal
functions:
loopdev_is_used()
loopdev_find_by_backing_file()
loopcxt_is_used()
loopcxt_find_by_backing_file()

If sizelimit is zero, fall back to the old behavior (ignoring of sizelimit).

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-03 11:53:28 +02:00
Stanislav Brabec 41c9e5d366 mount: Handle MNT_ERR_LOOPOVERLAP
Use warnx(), as there is no strerror() text associated with it.

There is currently no easy way to report name and type of conflict.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-03 11:53:28 +02:00
Stanislav Brabec 7e6b7035e7 libmount: Introduce new error: MNT_ERR_LOOPOVERLAP
This error code is intended for situations where overlapping loop device exists
and cannot be reused.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-03 11:53:28 +02:00
Stanislav Brabec 441cdba95b libmount: Fix possible crash in mnt_context_setup_loopdev()
If loopcxt_init() fails, Iloopcxt_deinit() should not be called.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2016-08-03 11:53:28 +02:00
Sami Kerola cc73d2d9fd tests: remove unnecessary file
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-08-02 16:14:33 +02:00
Karel Zak 2b1df916e1 Merge branch 'getopt' of git://github.com/kerolasa/lelux-utiliteetit
* 'getopt' of git://github.com/kerolasa/lelux-utiliteetit:
  getops: improve getopt-parse.bash example
2016-08-02 16:08:31 +02:00
Karel Zak 38f6945d63 liblkid: fix probe_nilfs2 I/O error backup
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-02 15:54:13 +02:00
Karel Zak e948ac218b Merge branch 'oclint' of git://github.com/kerolasa/lelux-utiliteetit
* 'oclint' of git://github.com/kerolasa/lelux-utiliteetit:
  libblkid: fix debugging macro [oclint]
  agetty: move unreachable code to pre-processor #else segment [oclint]
  setterm: fix declarations shadowing variables in the global scope [oclint]
  misc: fix declarations shadowing variables in the global scope [oclint]
  dmesg: drop core at impossible case in read_buffer() [oclint]
  libmount, look: remove dead code [oclint]
  syspriv: flip inverted logic [oclint]
  logger: simplify if clause [oclint]
  libblkid: simplify if clause [oclint]
  lslogins: simplify if clause and move definition and comments [oclint]
  switch_root: simplify code and reduce indentation [oclint]
  misc: simplify if clauses [oclint]
2016-08-02 15:26:49 +02:00
Karel Zak 1ca2661bb8 libsmartcols: Corrected JSON escaping
Based on patch set https://github.com/karelzak/util-linux/pull/331
from Fordi.

Addresses: https://github.com/karelzak/util-linux/issues/330
Co-Author: Bryan Elliott <fordiman@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-02 12:05:05 +02:00
Sami Kerola d27f5fe770
getops: improve getopt-parse.bash example
Use correct names of example scripts in the script.  Remove use of
backticks, they require quoting that makes the example harder to follow.
Split one-liners to one-command-at-a-time expressions.  Add continue keyword
to avoid additional case statement matching.  Be strict with quoting.

Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-27 16:08:43 +01:00
Sami Kerola 6b95f11c06
libblkid: fix debugging macro [oclint]
The oclint was complaining 'empty do/while statement' that turned out to be
true and I started to think it is best to use the same DBG() macro as in
other source files for this library.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola 58c756c92d
agetty: move unreachable code to pre-processor #else segment [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola ef4d11d57e
setterm: fix declarations shadowing variables in the global scope [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola eb2306e675
misc: fix declarations shadowing variables in the global scope [oclint]
Fixes multiple occurences of 'optarg' overwrites.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola f6f1356f1c
dmesg: drop core at impossible case in read_buffer() [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola 445e9ca2d4
libmount, look: remove dead code [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola 7d55b2df2e
syspriv: flip inverted logic [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola da0788fb97
logger: simplify if clause [oclint]
This has effect of collapsing rather long indentation block, so commit
separately.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola 92a4d098ce
libblkid: simplify if clause [oclint]
Move negative and positive testing of 'has' variable to top level, and test
flag bit mask on second level.  This way the 'has' needs to be checked only
once.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola 01e6b621e4
lslogins: simplify if clause and move definition and comments [oclint]
The if clause change is pretty trivial.  Moving the macro near to where it
is used makes sense to people who want to read the code.  And finally the
comment about user list was at wrong spot.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola 341154da28
switch_root: simplify code and reduce indentation [oclint]
The if statement in line 162 already ensures value of cfd to be 0 or
greater, so the later if is not needed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01: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 10e8d7a324 agetty: call uname() only when necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-20 13:20:14 +02:00
Karel Zak 1132e5aad1 agetty: fix \S usage
If \S without argument used then uninitialized 'varname' compared with
ANSI_COLOR.

Addresses: https://github.com/karelzak/util-linux/issues/329
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-20 13:16:13 +02: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
Sami Kerola f1f5f21ee6 logger: remove trailing spaces when outputing to journal
Issues:
1. Whitespace-ish \r is not stripped, while it should be.
2. In journal \r is considered unprintable.

Lennart: "it is the duty of the client side to drop the trailing whitespace,
which "logger" doesn't do".

Reported-by: Ivan Babrou <ibobrik@gmail.com>
Explained-by: Lennart Poettering <lennart@poettering.net>
Reference: https://github.com/systemd/systemd/issues/3416
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-19 11:02:48 +02:00
Tobias Stoeckmann 3f0e7f371a tailf: Fix previously adjusted segfault patch
Casting the value to be checked to size_t renders the check useless.
If st_size is SIZE_MAX+1, it will be truncated to 0 and the check
succeeds. In fact, this check can never be false because every value
stored in a size_t is smaller or equal to SIZE_MAX.

I think this adjustment was meant to fix a compiler warning for 64 bit
systems for which sizeof(off_t) is sizeof(size_t), but the signedness
differs.

Going unconditionally to the greatest possible unsigned int type if
st_size is positive (off_t is signed) will fix this issue.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2016-07-19 11:01:18 +02:00
Karel Zak b8fd5c0558 tests: fix ttyutils test
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-15 10:11:35 +02:00
Karel Zak aefd6a9d6a write: don't use strftime()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-14 13:20:58 +02:00
Karel Zak 85a37ca8d1 Merge branch 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit
* 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit:
  lib: try to find tty in get_terminal_name()
  write: stop removing and adding /dev/ in front of tty string
  write: tell when effective gid and tty path group mismatch
  write: improve coding style
  write: remove PUTC macro
  write: make timestamp to be obviously just a clock time
  write: remove unnecessary utmp variables
  write: improve function and variable names
  write: add control structure to clarify what is going on
  write: run atexit() checks at the end of execution
  write: use xstrncpy() from strutils.h
  write: set atime value in term_chk() only when needed
  write: remove pointless fileno(3) calls
  write: get rid of function prototypes
  write: remove unused variable
2016-07-14 13:07:25 +02:00
Sami Kerola b236e43ef0 sulogin: remove __nonnull__ function attribute
This change fixes compiler option -Werror=nonnull option warning:

login-utils/sulogin-consoles.c: In function 'append_console':
login-utils/sulogin-consoles.c:324:14: warning: nonnull argument 'consoles'
compared to NULL [-Wnonnull-compare]

The NULL check done with list_empty() looks valid, so  it is best to remove
the function attribute that allows compiler to optimize the check away.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-14 12:28:53 +02:00