Commit Graph

1773 Commits

Author SHA1 Message Date
Karel Zak bce4a17b01 blkid: (man) add note about udev to --list-one
Addresses: https://github.com/karelzak/util-linux/issues/866
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-12 13:24:42 +02:00
Sami Kerola dbeb1d733e
docs: try to find broken man references and fix them
Unfortunately methods I used to find and fix were based on quite manual
process that cannot be easily repeated so I do not see how this fix could be
turned into a tools/checkmans.sh addition.  Well, lets hope doing this
manually twice every decade is good enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-26 19:43:40 +01:00
Sami Kerola a7466bdcbe
po: remove possibility to translate static option arguments
These strings are expected to be wrote exactly as they are parsed, so make
translating them impossible.  Since mkfs.cramfs -N option arguments need
this treatment use opportunity to slice usage() output to multiple lines.

Addresses: https://bugs.debian.org/907568
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-24 09:29:52 +01:00
Karel Zak 9e677de1ec lsblk: fix -E segfault
We need to check if referenced wholedisk defines the de-duplication
key...

Addresses: https://github.com/karelzak/util-linux/issues/819
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-15 12:28:26 +02:00
Sami Kerola f3aded3fdb
include/xalloc: ensure xstrdup() and xstrndup() returns nonnull attribute
Turned out lsblk is passing null as argument to xstrdup(), so fix that and
add assert() to make sure promise of not returning null is kept in future.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-14 11:52:13 +01:00
Karel Zak e3bb9bfb76 lsblk: force to print PKNAME for partition
PKNAME (parent kernel device name) is based on printed tree according
to parent -> child relationship. The tree is optional and not printed
if partition specified (.e.g "lsblk -o+PKNAME /dev/sda1"), but old
versions print the PKNAME also in this case.

Addresses: https://github.com/karelzak/util-linux/issues/813
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-27 09:22:18 +02:00
Karel Zak f5b7bf155b findmnt: (verify) ignore passno for XFS
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1719069
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-12 11:03:23 +02:00
Karel Zak f7c5507db6 hardlink: fix bad formatting in hardlink.1
* fix regex\f to regex\fR (issue #805)
* replace \fP with \fR to be consistent with our another man pages

Addresses: https://github.com/karelzak/util-linux/issues/805
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-31 11:57:29 +02:00
Karel Zak 21d93094d4 findmnt: fix filters use on --list
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1714826
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-29 17:59:33 +02:00
Karel Zak a2761af42b whereis: make subdirs scan more robust
* call strchr() only once
* avoid things like strcat(buf, strchr(dir, '*') + 1)
* make it more readable
* improve debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 13:53:00 +02:00
Karel Zak 106e696064 lsblk: make sure __process_one_device() has proper arguments [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:36:53 +02:00
Karel Zak 74152bf944 lsblk: check ul_path_scanf() return value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:31:49 +02:00
Karel Zak 404eef654a lsblk: check stat() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:28:13 +02:00
Karel Zak 7241dda191 logger: make code more robust for static analyzer [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:14:10 +02:00
Karel Zak ac255c2b14 hardlink: avoid uninitialized variables [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:12:07 +02:00
Karel Zak aa75c5eb74 whereis: use xstrncpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:59:02 +02:00
Karel Zak 002931c485 Merge branch '2019wk19' of https://github.com/kerolasa/util-linux
* '2019wk19' of https://github.com/kerolasa/util-linux:
  lib/colors: remove redundant if statement
  wipefs: fix variable / function shadowing [cppcheck]
  sulogin: fix variable / function shadowing [cppcheck]
  lscpu: remove redundant condition check [cppcheck]
  libmount: avoid possible null pointer dereference [cppcheck]
  lib/mangle: fix possible null pointer dereference [cppcheck]
  sfdisk: remove unnecessary size check [cppcheck]
2019-05-20 12:35:38 +02:00
Sami Kerola 9abc8a42aa
wipefs: fix variable / function shadowing [cppcheck]
[misc-utils/wipefs.c:636] -> [misc-utils/wipefs.c:310]: (style) Local
variable usage shadows outer function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:42:13 +01:00
Karel Zak 778e2b2b7f findmnt: keep it easy for static analyzers 2019-05-16 14:38:12 +02:00
Karel Zak 097c067f5c findmnt: (verify) check mnt_table_next_fs() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 14:33:47 +02:00
Karel Zak 374cb54381 fincore: remove unused variable [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 14:27:15 +02:00
Karel Zak f06d8b69a9 cal: make sure months_in_row makes sense [coverity scan]
* avoid divide by zero in mountly() dues to wrong months_in_row
* make sure months_in_row is at least 1

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 14:22:43 +02:00
Karel Zak fa1b64da96 blkid: improve strcpy() usage [coverity scan]
The old deprecated list output format ("-o list") copies gettex string
into fixed buffer, that's really bad idea.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 13:56:34 +02:00
Austin English fd5f21ca45 lsblk: fix "maybe be" duplication
Signed-off-by: Austin English <austinenglish@gmail.com>
2019-05-15 13:48:54 +02:00
Karel Zak f6f8a671a9 lsblk: fix heap-use-after-free
Addresses: https://github.com/karelzak/util-linux/issues/787
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-06 12:39:07 +02:00
Karel Zak fe22543d6b lsblk: add more debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-02 15:51:48 +02:00
Karel Zak 74a4d22078 hardlink: fix compiler warnings [-Wsign-compare -Wmaybe-uninitialized]]
misc-utils/hardlink.c: In function ‘process_path’:
misc-utils/hardlink.c:287:30: warning: operand of ?: changes signedness from ‘off_t’ {aka ‘long int’} to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]

misc-utils/hardlink.c: In function ‘main’:
misc-utils/hardlink.c:455:5: warning: ‘exclude_pattern’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-02 12:48:05 +02:00
Sami Kerola e2aa5d82b9
hardlink: retire NIOBUF in favour of more common BUFSIZ
Reason to retire NIOBUF is that it is obscure local definition, while BUFSIZ
is well understood and commonly used constant.  Besized sizes of these are
not far off, the NIOBUF was 4096 bytes and BUFSIZ tends to be 8192 bytes.

Proposed-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/783
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-01 20:19:19 +01:00
Sami Kerola 007b9874d8
hardlink: move global variables to a control structure
Well, sort of.  Due to use of ctl values in atexit() print_summary() there
is need for global control structure.

Secondly couple variables can be moved to more restricted scope, namely the
PCRE variables are now in main().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-01 19:49:07 +01:00
Sami Kerola e87263aa13
hardlink: use flexible array member rather than zero-size array
This fixes two standards compliancy warnings.

hardlink.c:65:7: warning: ISO C forbids zero-size array ‘name’ [-Wpedantic]

Reference: https://en.wikipedia.org/wiki/Flexible_array_member
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-01 19:37:54 +01:00
Karel Zak 08a2cf7292 hardlink: remove \r from output
* remove \r from internationalized messages
* remove \r from all output to make it easy to use (see for example
  output file from "hardlink -vv --dry-run . &> log")

* remove unnecessary formatting stuff from output, just keep is simple
  and stupid...

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-24 18:31:08 +02:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Karel Zak 68224d108d include/c: add print_version() macro
Let's consolidate the version printing code. It also seems better to
use exit() after --version, because it's handled in different way by
ASAN.

It's strange, but ASAN reports leaks after return in main(). Note that
we do not use free-before-exit.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 13:47:17 +02:00
Karel Zak 7761bd3bb6 lib/fileutils: add xreaddir()
Remove duplicate code and keep only one implementation in
include/fileutils.h.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-11 13:11:53 +02:00
Karel Zak a44cd89128 lscpu: fix excl[] array order
It (rows and columns) must be in ASCII order.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-19 16:56:28 +01:00
Karel Zak fb3761809f lsblk: force tree on --json --tree independently on used columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-18 16:58:41 +01:00
Karel Zak 5bf5752e28 blkid: (man) cleanup return code section
Addresses: https://github.com/karelzak/util-linux/issues/764
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-11 12:02:31 +01:00
Karel Zak b9c088f2f3 lsblk: allow to specify tree column
* document --tree (was missing in the man page)
* add optional argument to --tree to specify tree

For example:

$ lsblk -o KNAME,SIZE,MOUNTPOINT --tree=KNAME /dev/dm-0
KNAME      SIZE MOUNTPOINT
dm-0     232.9G
└─dm-1   232.9G
  └─dm-2 232.9G

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-20 12:49:24 +01:00
Sami Kerola 110260830d docs: fix typos [codespell]
Reference: https://github.com/codespell-project/codespell
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:22:43 +01:00
Sami Kerola 123eb9ef8c hardlink, wall: fix variable shadowing
misc-utils/hardlink.c:91:65: warning: declaration shadows a variable in the global scope [-Wshadow]
misc-utils/hardlink.c:73:5: note: previous declaration is here
int content_only = 0;

term-utils/wall.c:114:40: warning: declaration shadows a variable in the global scope [-Wshadow]
term-utils/wall.c:129:65: warning: declaration shadows a variable in the global scope [-Wshadow]
/usr/include/bits/getopt_core.h:36:14: note: previous declaration is here
extern char *optarg;

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:20:34 +01:00
Sami Kerola 4813a5210f various: fix 'uninitialized when used' warnings [clang]
This change fixes "warning: variable 'var' may be uninitialized when used
here [-Wconditional-uninitialized]" warnings reported in various files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:19:24 +01:00
Karel Zak d135e1a1e3 cal: fix Sexit and Senter
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-18 13:10:58 +01:00
Karel Zak 985421192d hardlink: add long options
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 14:01:55 +01:00
Karel Zak c8ca29beb2 hardlink: rename function
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:30:46 +01:00
Karel Zak bd7722af02 hardlink: make code more readable
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:25:04 +01:00
Karel Zak 0b05aab402 hardlink: cleanup global variables
* remove NAMELEN, use PATH_MAX
* mark global variables as static
* move all global variables to the begin of the code

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:18:35 +01:00
Karel Zak 3807e71af4 hardlink: remove typedefs
- remove typedefs
- use long names for structs

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:00:18 +01:00
Sven Wiltink c2f6513c10 lsblk: use ID_SCSI_SERIAL when available
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 10:37:27 +01:00
Karel Zak d55db6724c hardlink: cleanup error messages, use xalloc.h
- do not use magical doexit(), just use err()
- print summary on exit

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-06 17:23:54 +01:00
Karel Zak c545e62c68 hardlink: cleanup verbose and warning messages
- use warn()
- use stdout rather than stderr

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-06 17:14:01 +01:00
Karel Zak bd9a35c6ce hardlink: (man) add AVAILABILITY
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-06 14:37:34 +01:00
Karel Zak 117f4d8bf4 Merge branch 'hardlink' of https://github.com/rudimeier/util-linux into hardlink
* 'hardlink' of https://github.com/rudimeier/util-linux: (25 commits)
  hardlink: add first simple tests
  hardlink: util-linux usage
  hardlink: fix compiler warnings
  hardlink: style indentations and license header
  hardlink: enable build with and without pcre2
  fixes for the fixes
  temporal fix before re-patch (updates from Fedora repo)
  Update hardlink.1
  Fixed version number, added changelog about Todd Lewis' patch
  exclude files via pcre
  Fixed 32 bit build with gcc7 (RH Bugzilla ID 1422989)
  spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); update FSF address at .c source file
  Revert "spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file"
  spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file
  Mention -f option in the man page
  do not allow to hardlink files across filesystems by default (#786719) (use -f option to override)
  fix possible buffer overflows, integer overflows, update man page
  fix URL and remove mmap() (#676962, #672917)
  - update docs to describe highest verbosity -vv option (#210816) - use dist Resolves: 210816
  mostly spec cleanup
  ...
2019-02-06 13:55:20 +01:00
Karel Zak f90d8b8bcc cal: use standout mode on monochrome terminals
The function colors_init() checks for colors, it means it fails
on monochrome terminals, but cal(1) in this case still need to
highlight the current day.

Reported-by: Nuno Silva <nunojsilva@ist.utl.pt>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-04 14:20:03 +01:00
Karel Zak 8fd512e932 logger: (man) add info about rewrite and authors
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-29 15:59:41 +01:00
Karel Zak bd0029f6be logger: (man) make more obvious that --server/socket is required
The options --tcp/udp specify only how, but no where.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-29 15:44:13 +01:00
Karel Zak 1c4a2600cc logger: concatenate multiple lines of MESSAGE into a single field.
this is deemed a useful special case since journalctl will only show
either the first or last element of the message array if the field
appears multiple times.

Based on patch from: Kjetil Torgrim Homme <kjetil.homme@redpill-linpro.com>
https://github.com/karelzak/util-linux/pull/743

Addresses: https://github.com/karelzak/util-linux/issues/742
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-23 11:41:43 +01:00
Karel Zak 9ed2117897 whereis: search in /(s)bin before /usr/lib
Addresses: https://github.com/karelzak/util-linux/issues/741
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-17 11:19:27 +01:00
Karel Zak 969e8cbeb1 libblkid: improve whole-disk detection when read /proc/partitions
blkid(8) in high-level mode checks partitions and unpartitioned
whole-disk devices from the file /proc/partitions.

The current heuristic assumes that partition name ends with a digit.
Unfortunately, this is not correct -- for example md0 or nvme0n1 are
whole-disk devices.

This commit uses sysfs_devno_is_wholedisk() to make sure the device is
a partition (according to kernel or DM). It's probably more expensive,
because this way requires more syscalls (to read stuff from /sys etc.).

The patch also adds more information to the blkid(8) man page.

Addresses: https://github.com/karelzak/util-linux/issues/728
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-08 12:07:18 +01:00
Sami Kerola e361253e88
lsblk: fix null pointer dereferences
Both catched with -Wnull-dereference compiler option:

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-12-10 20:25:58 +00:00
Karel Zak 0bd05f5ee4 lsblk: add --merge
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:57:49 +01:00
Karel Zak 0986f29a3f lsblk: make devtree dependences more generic
We also need reference from child to parent to implement multi-parent
view. This change allows to walk on tree in both directions.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:33:34 +01:00
Karel Zak dc4662f0e7 lsblk: add --dedup <column>
The target use-case are systems with large number of multi-path
devices or systems with duplicate (copied) filesystems.

The feature is flexible enough to use arbitrary column (for example
WWM or UUID, ...) as de-duplication key.

For example tree with multi-path devices sd{c,d,e,f}

./lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0 223.6G  0 disk
├─sda1        8:1    0   200M  0 part  /boot/efi
├─sda2        8:2    0   200M  0 part  /boot
├─sda3        8:3    0 130.3G  0 part
├─sda4        8:4    0    50G  0 part  /
└─sda5        8:5    0  42.9G  0 part
sdb           8:16   0  74.5G  0 disk
└─sdb1        8:17   0  74.5G  0 part  /home/archive
sdc           8:32   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sdd           8:48   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sde           8:64   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sdf           8:80   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part

De-duplicate by WWN:

./lsblk -M WWN
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0 223.6G  0 disk
├─sda1        8:1    0   200M  0 part  /boot/efi
├─sda2        8:2    0   200M  0 part  /boot
├─sda3        8:3    0 130.3G  0 part
├─sda4        8:4    0    50G  0 part  /
└─sda5        8:5    0  42.9G  0 part
sdb           8:16   0  74.5G  0 disk
└─sdb1        8:17   0  74.5G  0 part  /home/archive
sdc           8:32   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part

Addresses: https://github.com/karelzak/util-linux/issues/616
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:33:34 +01:00
Karel Zak 10501add02 lsblk: remember whole-disk, remove unused struct member
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:33:34 +01:00
Karel Zak d81e32bde9 lsblk: make device_get_data() more generic
* independent on smartcols line
* keep sort data optional

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak 57a061339b lsblk: apply --nodeps to partitions too
The new implementation differentiates between partitions and another
dependences -- this is regression, we need root devices only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak 8a2f175cbb lsblk: read queue/discard_granularity only when necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak 81a8936c56 lsblk: reuse 'removable' flag from parent
It's used in the default output, let's make it a little bit more
effective.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak ff7992d631 lsblk: don't keep sysfs dirs open
Don't keep open sysfs file descriptors for all time to avoid problems
on systems with huge number of block devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak b158bd29de lsblk: rename set_device()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak b93585e8fc lsblk: add comments
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak e7b5353e8b lsblk: add process_all_devices_inverse()
This is necessary to implement --inverse. Note that this new
implementation scans /sys/dev/block/ to get top-level devices
and than it calls process_one_device().

Note that standard non-inverse tree does not use process_one_device()
as it's more effective to scan /sys/block where are no partitions.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak e15c9e3dc5 lsblk: reorder functions
The goal is to call process_one_device() from process_all_devices(),
so let's it keep in code in the right order.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak cf3c1bc77a lsblk: make process_partitions() more readable
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 0e086f8230 lsblk: remove unncessary parent pointer
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak ae4c2c375b lsblk: use real rather than hardcoded parent
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 4ca3c472f3 lsblk: use devtree functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak e2d7870b00 lsblk: add lsblk_device_has_dependence()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 291606faf9 lsblk: process_one_device() refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 583b6489f6 lsblk: add devtree_get_device_or_new()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 97c89dff13 lsblk: keep functions names consistent
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 9b4c648612 lsblk: remove unused reset_device()
Now all is maintained by reference counting ion the devtree.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 57502dd34c lsblk: fix devtree deallocation
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak f43b829759 lsblk: split sysfs reading and scols table filling
This change allows read devices from sysfs only once and reuse device
properties if the device is references more than once in the tree
(RAIDs, etc.).

* every device is in the tree only once (tree->devices list)

* iterate_block_devices() reuse already read devices (for example if
  already read for any dependence)

* the smartscols table is build from the final tree

The patch temporary disables dependencies evaluation (in
process_blkdev() to keep the patch small and simple.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 21d4a48c9c lsblk: cleanup device reference in the tree
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 3bf2a36cc5 lsblk: remove badly named debug interface name
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 5bb395f4f6 lsblk: add basic function to build devices tree
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak a0a76f4265 lsblk: properly initialize structs
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 7cd9de40fa lsblk: rename reset_lsblk_device() to reset_device()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak fed34a1e63 lsblk: rename blkdev_cxt to lsblk_device
The patch does not change code logic and semantic -- just rename.

* set_cxt() to set_device()
* struct blkdev_cxt to lsblk_device

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 6df5acf970 lib/timer: add fallback if timer_create() not available
* add struct ul_timer as API abstraction to hide differences between
timer_create() and setitimer()

* add setitimer() detection to ./configure.ac

* add fallback code to use setitimer() if timer_create() not available
  (for example on OSX)

Addresses: https://github.com/karelzak/util-linux/issues/584
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-03 11:23:33 +01:00
Karel Zak 0ab0817917 blkid: fix usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-29 13:30:11 +01:00
Karel Zak 5e91d5dd71 blkid: make PART_ENTRY_* tags optional (add --no-part-details)
blkid(8) returns information from partition table also for empty
partitions. This is necessary for example for udev, but it could be
confusing if you care about on-device content only.

Default:
 # blkid -p /dev/md0p1; echo $?
 /dev/md0p1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="6d8796b1-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="204800" PART_ENTRY_DISK="9:0"
 0

With --no-part-details:
 # blkid -p /dev/md0p1 --no-part-details; echo $?
 2

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653413
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-29 13:21:36 +01:00
Andreas Henriksson df8d991b24 uuidd: Add hardening settings to uuidd.service
This limits what the uuid daemon has access to when it runs.

Further improving this with additional option or making
things even tighter is most likely possible.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2018-11-29 10:37:08 +01:00
Andreas Henriksson c8d61f361c uuidd: Add Documentation key to uuidd.service 2018-11-21 10:47:31 +01:00
Ruediger Meier 7d50d36121 hardlink: util-linux usage
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-14 00:37:14 +01:00
Ruediger Meier 53071734aa hardlink: fix compiler warnings
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-14 00:37:04 +01:00
Ruediger Meier 55c000e1eb hardlink: style indentations and license header
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-12 19:44:39 +01:00
Ruediger Meier 04ae85a7e5 hardlink: enable build with and without pcre2
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-12 19:40:33 +01:00
Patrick Steinhardt d2523d3dd2 rename: avoid undefined function prototype for `fpurge`
In case where the non-standard `fpurge` function is available, we
redefine `__fpurge` to `fpurge`. We can do so because the only
difference between both functions is that one returns an error code
while the other does not. But as we do not check the error code either
way, we do not care about which one of them we use.

The above redefinition happens unconditionally if we know that `fpurge`
exists. Most notably, we also redefine it if we already do have an
`__fpurge` function available that could be used. This causes problems
on musl-based platforms, where we detect availability of `fpurge` in
libc, but where no function declaration for it exists in "stdio_ext.h".
The compiler thus prints a warning due to an unknown function, even
though it will link just fine.

Avoid this warning by only redefining `__fpurge` to `fpurge` when
HAVE___FPURGE is not defined.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2018-10-04 11:56:37 +02:00
Patrick Steinhardt 6529212d5b lsblk: fix unknown type `stat` caused by missing header
The structure `blkdev_cxt` has a `struct stat` member embedded, whose
size may not be known on some systems because of a missing include for
"sys/stat.h". On glibc-based systems, this header is included
transitively via "sys/statvfs.h", but on musl-based systems it is not.

Fix the resulting compile error due to unknown size of the struct by
including "sys/stat.h".

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2018-10-04 11:56:35 +02:00
Karel Zak ef2ce68b1f lsblk: always use "part" as TYPE for partitions
The current code uses "part" or "disk" only if nothing else is
possible to recognize. It means for example partitions on loops (or
RAIDs, etc) are marked as "loop" rather than "part".

Addresses: https://github.com/karelzak/util-linux/issues/700
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-10-03 14:39:57 +02:00
Karel Zak ccafadb7c5 lsblk: move udev and blkid stuff to lsblk-properties.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-19 11:40:17 +02:00
Karel Zak baad6dcc6e lsblk: cleanup udev/blkid properties code
* split properties to separate struct which is allocated only when
  udev or blkid provides some information

* use separate function for udev and blkid and hide details in generic
  get_device_properties()

* make sure we do not overwrite stuff udev and blkid (but this is only
  theoretic issue as we do not call get_properties_by_blkid() directly
  from code)

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-19 11:40:17 +02:00
Karel Zak 652cb1cd26 lsblk: encapsulate stat() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 16:27:26 +02:00
Karel Zak 82dae67d1a lsblk: differentiate between swap and mount
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:57:45 +02:00
Karel Zak 04be258d65 lsblk: use lsblk_ prefix mountpoint getter
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:49:00 +02:00
Karel Zak e0c016f11b lsblk: init/deinit libmount stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:45:53 +02:00
Karel Zak cfb715ed1d lsblk: move mount stuff to lsblk-mnt.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:41:39 +02:00
Karel Zak 14560b7f54 lsblk: add lsblk.h
* move core struct to the header file
* move debug stuff to the header file

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:36:59 +02:00
Karel Zak bc405d641e lsblk: add columns FSAVAIL,FSSIZE,FSUSED,FSUSE%
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-13 12:11:06 +02:00
Karel Zak 137599ebe1 lsblk: don't ask udev when --sysroot specified
We use --sysroot to get information about block devices from /proc and
/sys dumps. In this case does not make sense to read anything from
udev as udevd is about the current system devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-11 09:53:18 +02:00
Karel Zak 13cbc6f21c lsblk: prefer MODEL from udev DB
sysfs device model is truncated to 16 characters:

> cat /sys/block/sda/device/model
Crucial_CT128MX1
> udevadm info --query=property /dev/sda | grep MODEL=
ID_MODEL=Crucial_CT128MX100SSD1

sysfs uses INQUARY response which has the 16 characters limitation and
udev uses something else.

Addresses: https://github.com/karelzak/util-linux/issues/690
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-10 10:31:17 +02:00
Karel Zak 1b0a420281 Merge branch 'spelling' of https://github.com/jwilk-forks/util-linux
* 'spelling' of https://github.com/jwilk-forks/util-linux:
  Fix man page typos
2018-08-16 13:47:51 +02:00
Jakub Wilk b9c3b903fe Fix man page typos
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-08-16 11:09:15 +02:00
Jakub Wilk 456bda924f fincore.1: add missing space
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-08-16 10:37:10 +02:00
Karel Zak 1f6583930b logger: add -S to the man page
Reported-by: Radka Skvarilova <rskvaril@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-10 16:55:14 +02:00
Karel Zak 2395f93c8c cal: fix --span for large numbers of months
The need to calculate with whole years when go back for --span.

Addresses: https://github.com/karelzak/util-linux/issues/677
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-07 10:52:33 +02:00
Karel Zak 100a140688 cal: use snprintf everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-07 10:15:42 +02:00
Bjarni Ingi Gislason 62aa3f0eaf man pages: fix formatting of long lines in tables
Define the allowed length of the last (second) column to use the
whole line for text.

  Use text blocks for long lines.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-08-06 08:58:57 +02:00
Bjarni Ingi Gislason 934a6fa80b man pages: Remove "left" (or change to "l") in the column formats of tables
A developmental version of "groff" issued a warning, for example with
"test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z":

troff: <logger.1>:299: warning: can't find font 't'

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-08-06 08:58:57 +02:00
Karel Zak e736434bc8 blkid: fix compiler warnings [-Wcast-qual]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23 12:30:37 +02:00
Karel Zak 881953d735 lsblk: add note about --list -I <maj,...>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-18 16:21:01 +02:00
Karel Zak 66638b0b70 lsblk: add PATH column
$ lsblk -o+PATH
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT    PATH
sda           8:0    0 223.6G  0 disk               /dev/sda
├─sda1        8:1    0   200M  0 part /boot/efi     /dev/sda1
├─sda2        8:2    0   200M  0 part /boot         /dev/sda2
├─sda3        8:3    0 130.3G  0 part               /dev/sda3
├─sda4        8:4    0    50G  0 part /             /dev/sda4
├─sda5        8:5    0  35.1G  0 part               /dev/sda5
└─sda6        8:6    0   7.8G  0 part               /dev/sda6

Requested-by: Marcel Partap <mpartap@gmx.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-10 10:33:18 +02:00
YmrDtnJu 03190b73f0
logger: Define SD_JOURNAL_SUPPRESS_LOCATION.
The normal journald functions add the location in the C source code files to
the log messages. This is nice for a big C based project, but logger is used in
scripts so it would be more useful to let users specify the location in the
script by adding the CODE_FUNC, CODE_FILE and CODE_FILE fields to the log
message.

It is already possible to do this, but it will result in two versions of these
fields: one for the location in logger.c and one for the location in the
script.
2018-07-07 20:11:46 +02:00
Ruediger Meier 3097f788f9 wipefs: add missing ifdef
Seen on OSX:
misc-utils/wipefs.c:822:5: warning: implicit declaration of function 'rereadpt' is invalid in C99 [-Wimplicit-function-declaration]
                                rereadpt(fd, devname);

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-06-25 16:49:54 +02:00
Karel Zak 905bc7817e lsblk: fix ul_path_read_string() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak bd45b74fc9 lsblk: fix COL_SCHED
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 498d148661 lsblk: document --sysroot
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 3273ce07e3 lsblk: fix sysfs_devno_to_devname() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak caf1b443c0 lsblk: follow --sysroot when read mountpoints
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 5a89aa99a7 lsblk: use prefix for DM name
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak ffc2762393 lsblk: add --sysroot
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak f153614c57 lsblk: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Milan Broz 1b06b33dd0 lsblk: add partition table UUID and type fields.
This patch adds PTUUID and PTTYPE fields to lsblk, that are corresponding
fields to ID_PART_TABLE_UUID and ID_PART_TABLE_TYPE in udev database.

[kzak@redhat.com: - small change in PTUUID description]

Signed-off-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-19 17:05:42 +02:00
Ruediger Meier f385180ab3 Merge branch 'hardlink-import' into hardlink
Import hardlink source and manpage version 1.3 from
https://pagure.io/hardlink.git
revision 24da8615f7a9c67648bfe9b6709ba7786d61b89a
2018-06-12 14:26:25 +02:00
Kevin Fenzi 5aad3c12f3 fixes for the fixes
Signed-off-by: Francisco Javier Tsao Santín <tsao@gpul.org>
2018-06-12 14:24:15 +02:00
Francisco Javier Tsao Santín 3b94989389 temporal fix before re-patch (updates from Fedora repo) 2018-06-12 14:24:11 +02:00
utoddl 88824694f6 Update hardlink.1
The example regex in the BUGS section needs its backslashes backslashed.
2018-06-12 14:24:07 +02:00
Francisco Javier Tsao Santín c64d7e60b1 Fixed version number, added changelog about Todd Lewis' patch 2018-06-12 14:24:04 +02:00
Todd Lewis 551e8963f4 exclude files via pcre 2018-06-12 14:24:02 +02:00
Francisco Javier Tsao Santín 92c79dc79e Fixed 32 bit build with gcc7 (RH Bugzilla ID 1422989) 2018-06-12 14:23:57 +02:00
Francisco Javier Tsao Santín 4d072ba715 spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); update FSF address at .c source file 2018-06-12 14:23:55 +02:00
Francisco Javier Tsao Santín cbb0524c7c Revert "spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file"
This reverts commit bb9e76ae339794c2243ae294207942b7ea278364.
2018-06-12 14:23:52 +02:00
Francisco Javier Tsao Santín c11af66f0f spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file 2018-06-12 14:23:49 +02:00
Jan Zeleny 348af99a62 Mention -f option in the man page 2018-06-12 14:23:47 +02:00
Jindrich Novy c23b4a2305 do not allow to hardlink files across filesystems by default (#786719)
(use -f option to override)
2018-06-12 14:23:44 +02:00
Jindrich Novy 94b040b06b fix possible buffer overflows, integer overflows, update man page 2018-06-12 14:23:41 +02:00
Jindrich Novy 0cd6b1d353 fix URL and remove mmap() (#676962, #672917) 2018-06-12 14:23:38 +02:00
Jindrich Novy a272f143e7 - update docs to describe highest verbosity -vv option (#210816)
- use dist Resolves: 210816
2018-06-12 14:23:35 +02:00
Jindrich Novy b4ece7768f mostly spec cleanup 2018-06-12 14:23:31 +02:00
Jindrich Novy cabf1c1cb7 add -h option 2018-06-12 14:23:25 +02:00
Dave Jones a810992a72 Document hardlink command line options. (Ville Skytta) (#161738) 2018-06-12 14:23:03 +02:00
Jeremy Katz a16d7294a8 - don't try to hardlink 0 byte files (#154404) 2018-06-12 14:22:59 +02:00
Dave Jones 5edefc9242 kill warning 2018-06-12 14:22:54 +02:00
Dave Jones 0ec20db824 auto-import hardlink-1.0-1.1 on branch devel from hardlink-1.0-1.1.src.rpm 2018-06-12 14:22:47 +02:00
Karel Zak 921f63433e wipefs: postpone BLKRRPART until all is done
It's possible we erase from the whole device before we erase from the
partition on the same disk:

 # wipefs -a /dev/sdc /dev/sdc1

the current code calls re-read PT ioctl immediately after erase (so,
before sdc1 is processed). The result is that sdc1 node is no more
accessible:

  # wipefs -a /dev/sdc /dev/sdc1
  /dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
  /dev/sdc: calling ioctl to re-read partition table: Success
  wipefs: error: /dev/sdc1: probing initialization failed: No such file or directory

It seems the most simple solution is to postpone the re-read ioctl and
do it as the last thing.

  # wipefs -a  /dev/sdc /dev/sdc1
  /dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
  /dev/sdc1: 2 bytes were erased at offset 0x00000438 (ext4): 53 ef
  /dev/sdc: calling ioctl to re-read partition table: Success

The patch also adds a small delay before the re-read ioctl call. It's
not elegant, but without the usleep(25000) the first attempt returns
EBUSY.

Addresses: https://github.com/karelzak/util-linux/issues/598
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 12:36:32 +02:00
Sami Kerola 1405658822 nls: remove translation strings
While looking earlier commit I noticed everything but formatting was removed
from a message in namei.c file.  That inspired me to look if there are more
strings that does not need translation project attention.  This change
removes at least some of them, if not all.

Reference: e19cc7b65b
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:36:38 +02:00
Bjarni Ingi Gislason 3fe5e8ec09 man: Change the only argument to two for the two-fonts macros
Punctuation marks have been left in the only argument of two-fonts
macros, instead of being separated from it to make the second one.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-05-23 10:43:27 +02:00
Bjarni Ingi Gislason 0bb7e904d7 man: Use the correct macro for a font change of one argument
Use the correct macro (I, B) for the font change of one argument, not
those that are used for alternating two fonts, like "BR", "IR", "RB",
or "RI".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-05-23 10:43:27 +02:00
Karel Zak 3d15a5e852 lsblk: fix notes about RAM disks
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-15 10:51:15 +02:00
Karel Zak b9dd5721fc lsblk: don't exclude RAM disks on --all
Reported-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-15 10:29:22 +02:00
sluidfoe 0bff4e134e misc-utils/findmnt.8: add --pseudo and --real options 2018-05-10 11:58:31 -05:00
sluidfoe f920bfd5a8 misc-tools/findmnt: a few whitespace fixes 2018-05-10 11:58:31 -05:00
sluidfoe 4c856a471e misc-tools/findmnt: add --pseudo, --real filters 2018-05-10 11:58:30 -05:00
Sami Kerola 25d3c40534
lslocks: add --output-all option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-03 19:56:20 +01:00
Sami Kerola 00147883de
findmnt: add --output-all option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-03 19:56:20 +01:00
Karel Zak fc402b8b71 blkid: (man) add note about udev encoding
Addresses: https://github.com/karelzak/util-linux/issues/632
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-30 10:53:04 +02:00
Karel Zak a3571e1b97 wipefs: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 15:12:46 +02:00
Karel Zak fffdff1e61 lslocks: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 15:07:31 +02:00
Karel Zak 51b0bcf01d lslocks: add --bytes cleanup SIZE usage
The new command line option --bytes disables human readable output for
the SIZE and keep size in bytes. We use the same concept for all our
utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 15:01:31 +02:00
Karel Zak 3a645e3658 findmnt: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 14:45:21 +02:00
Karel Zak 8945d9dc63 fincore: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 14:32:39 +02:00
Karel Zak d14c1c39dd Merge branch 'rename-interactive' of https://github.com/g-raud/util-linux
* 'rename-interactive' of https://github.com/g-raud/util-linux:
  rename: fixup & style (no functional changes)
  rename: test availability of __fpurge() and fpurge()
  rename: ask(): call __fpurge() to cater for multi-byte characters
  rename.1: describe interactive mode
  rename: ask(): print n when EOF on input
  rename: detect tty in cbreak mode to make ask() read a single byte
  rename.1: fix warning section
  rename: add option --interactive to ask before overwriting
  rename: skip faccessat() failure if AT_SYMLINK_NOFOLLOW is not a valid flag
  rename: check source file access early
2018-04-16 10:37:31 +02:00
Karel Zak 6ceb17c8a7 lslocks: fix memory leak
Addresses: https://github.com/karelzak/util-linux/pull/618
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-16 10:27:29 +02:00
Karel Zak 2aaf56c45f lslocks: add info about OFD
It seems users are confused by PID -1 and missing path. This patch add
more information about OFD locks to the man page and "undefined" to
the COMMAND column.

References: http://austingroupbugs.net/view.php?id=768
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1527102
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-13 11:22:21 +02:00
G.raud Meyer 7ac394f84b rename: fixup & style (no functional changes) 2018-04-09 17:21:17 +02:00
G.raud Meyer 0dba6b6f19 rename: test availability of __fpurge() and fpurge() 2018-04-09 17:21:17 +02:00
G.raud Meyer 33785dd33c rename: ask(): call __fpurge() to cater for multi-byte characters
Making a purge in cbreak mode also makes the code compatible with
canonical mode.  This can be useful in the case a shell, like bash, does
not restore the tty state of stopped jobs before restarting them.  An
alternative fix to this minor shortcoming would be to retest the tty
state each time inside ask().
2018-04-09 17:21:17 +02:00
G.raud Meyer 16740b0c7a rename.1: describe interactive mode 2018-04-09 17:21:16 +02:00
G.raud Meyer 0cb2c653c3 rename: ask(): print n when EOF on input 2018-04-09 17:21:16 +02:00
G.raud Meyer f43bdedaa7 rename: detect tty in cbreak mode to make ask() read a single byte
Set tty_cbreak only when tty has a VMIN of 1 to avoid having to purge at
all in cbreak mode.

The prompt is still compatible with a non interactive input from a pipe.
2018-04-09 17:21:16 +02:00
G.raud Meyer 961b094629 rename.1: fix warning section 2018-04-09 17:21:16 +02:00
G.raud Meyer eb4aea8a47 rename: add option --interactive to ask before overwriting
The option name -i/--interactive is picked from mv(1) and cp(1) from GNU
and BSD.

Also update the manpage.
2018-04-09 16:05:44 +02:00
G.raud Meyer 826538bf64 rename: skip faccessat() failure if AT_SYMLINK_NOFOLLOW is not a valid flag
AT_SYMLINK_NOFOLLOW is not required by POSIX and it is not a valid flag
on Mac OSX.
2018-04-09 15:41:30 +02:00
G.raud Meyer 5454df9c31 rename: check source file access early
This change makes rename detect inexisting files given on the command
line and consider them faliures.  This is particularly useful with
--no-act (to detect extraneous arguments).

It also prevents skipping non existing files (when the modified name
happens to exist).  This makes --verbose not print skipping messages of
false positives (the access error is printed instead).
2018-04-09 14:37:56 +02:00
Karel Zak e4c58e00a0 Merge branch 'rename-fix-noact-without-nooverwrite' of https://github.com/g-raud/util-linux
* 'rename-fix-noact-without-nooverwrite' of https://github.com/g-raud/util-linux:
  rename: prevent --no-act from setting --no-overwrite
  rename: when --no-overwrite skip verbosily only when --verbose
  rename: consolidate printing the symlink in addition to its target
  rename: fix/reverse the semantics of --no-overwrite in --symlink mode
2018-04-09 11:46:22 +02:00
Bjarni Ingi Gislason ac5ebb8cb8 misc-utils/getopt.1: minor corrections to the manual
Input file is getopt.1

Test nr. 2:

Enable and fix warnings from 'test-groff'.

Input file is /tmp/getopt.1

<getopt.1>:5 (macro BI): only 1 argument, but more are expected
<getopt.1>:419 (macro IR): only 1 argument, but more are expected
<getopt.1>:421 (macro IR): only 1 argument, but more are expected

chk_manuals: Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z

  and

Test nr. 15:

Change the name of a macro for two fonts (e.g., BR and IR) to one letter,
if there is only one argument.
Add the second argument if needed.  It is sometimes part of the first one.

5:.BI getopt
419:.IR /usr/share/getopt/
421:.IR /usr/share/doc/

#####

Test nr. 8:

Protect a full stop (.) with "\&", if it has a blank (white-space) in front
of or (ignoring transparent characters to the full stop) after it, and it does
not mean an end of a sentence.

204:the next parameter (i.e. separated by whitespace on the command
219:or as the next argument (i.e. separated by whitespace on the command
352:(i.e. a parameter that does not start with a
379:will be parsed.  It will still do parameter shuffling (i.e. all

#####

Test nr. 20:

Use a macro to change to the italic font, instead of \fI [1], if
possible.
The macros have the italic corrections, but "\c" removes them.
[1] man-pages(7)

57:is set, or if the first \fIparameter\fR is not an option (does not start
144:Set quoting conventions to those of \fIshell\fR.

#####

Test nr. 21:

Use the word (in)valid instead of (il)legal if not related to legal matters.
See "www.gnu.org/prep/standards".

25:check for legal options.  It uses the

#####

Test nr. 28:

Wrong distance between sentences or protect the indicator.

1) Separate the sentences and subordinate clauses; each begins on a new
line.  See man-pages(7) and "info groff".

Or

2) Adjust space between sentences (two spaces),

3) or protect the indicator by adding "\&" after it.

The "indicator" is an "end-of-sentence character" (.!?).

204:the next parameter (i.e. separated by whitespace on the command
219:or as the next argument (i.e. separated by whitespace on the command
352:(i.e. a parameter that does not start with a
379:will be parsed.  It will still do parameter shuffling (i.e. all
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>

#####
2018-04-06 13:10:23 +02:00
Karel Zak 407e0ea619 lsblk: consolidate column types for JSON and qsort()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-03 15:10:21 +02:00
G.raud Meyer 0849ff3660 rename: prevent --no-act from setting --no-overwrite
This fixes a bug introduced by commit fabb90676 ("Added --no-override
option to rename.", 2017-05-27) where the fallthrough meant to let
--no-act set --verbose was changed to set --no-override (the previous
code was too smart).

Do not let --no-act set --verbose anymore but update the manual to
recommend adding option --verbose.  This is to be able to make --no-act
detect only non existing file arguments (in a future commit).
2018-03-29 20:35:30 +02:00
G.raud Meyer 6277e2310e rename: when --no-overwrite skip verbosily only when --verbose 2018-03-27 15:22:58 +02:00
G.raud Meyer b98ab3032d rename: consolidate printing the symlink in addition to its target 2018-03-27 14:49:52 +02:00
G.raud Meyer 5bb927006f rename: fix/reverse the semantics of --no-overwrite in --symlink mode
The previous behaviour was to overwrite a symlink only when the new
destination did not exist, i.e. to avoid creating a symlink to an
existing file!  It had not been documented and it seems
counter-intuitive to me.  So the new behavior protects symlinks pointing
to existing targets from being changed.

Also update manpage to document this mode.
2018-03-27 14:48:00 +02:00
Karel Zak e19cc7b65b namei: provide more usable error message on lstat() error
Addresses: https://github.com/karelzak/util-linux/issues/608
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-27 13:30:16 +02:00
Karel Zak 04060bc3f1 Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  tests: Add tests for FAT32 labels
  blkid: Encode any field which starts with LABEL in same way as LABEL field
  libblkid: vfat: Change parsing label in special cases
2018-03-27 12:54:53 +02:00
Karel Zak 655776a2c1 mcookie: (man) add note about getrandom()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-19 14:03:33 +01:00
Karel Zak 2446d0487f uuidd: cosmetic coding style change
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-07 11:53:15 +01:00
Ruediger Meier eb10dbc159 uuidd: don't truncate long socket paths
This was the error
  uuidd: couldn't bind unix socket /var/tmp/portage/sys-apps/util-linux-2.31.1/work/util-linux-2.31.1-abi_x86_64.amd64/tests/output/uuid/uuiddkOcTUuoZ7kaP3: Address already in use

because the socket path was truncated to 108 chars which was luckily
an existing directory.

Now we abort early with "uuidd: socket name too long: ... "

Reported-by: Thomas Deutschmann <whissi@gentoo.org>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-03-07 11:50:05 +01:00
Tobias Stoeckmann fcfe1a5cde fincore: Handle large files on 32 bit without LFS
If util-linux is installed on a system without large file support,
an out of memory issue can occur while processing a file which is
2 GB in size:

$ ./configure --disable-largefile && make

$ dd if=/dev/zero of=2gb-file seek=2147483646 count=1 bs=1
$ fincore 2gb-file
(endless loop)
fincore: failed to do mmap: 2gb-file: Cannot allocate memory

Even though iterating with "len" seems counter-intuitive, it fixes
this issue. The variable len is only in the last iteration not a
multiplication of pagesize -- which is the requirement for mmap.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2018-02-26 11:54:12 +01:00
Tobias Stoeckmann ea62c15276 fincore: Handle large files correctly on 32 bit
If a file is larger than 4 GB on a 32 bit system with large file
support (default), it can happen that not all pages are properly
processed. This happens due to an int truncation (off_t vs size_t).

You can reproduce this on 32 bit with these commands:

$ dd if=/dev/zero of=4gb-file seek=4294967295 count=1 bs=1
$ fincore 4gb-file
fincore: failed to do mmap: 4gb-file: Invalid argument

If a file is larger than 4 GB, the first few pages of a file won't
be properly processed. "len" will be smaller than window_size,
but the for-loop iterates "window_size" bytes, skipping some pages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2018-02-26 11:54:12 +01:00
Karel Zak 3476084d14 lsblk: document LSBLK_DEBUG=
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-16 19:10:35 +01:00