Commit Graph

1623 Commits

Author SHA1 Message Date
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
Ruediger Meier 73afd3f8e8 misc: fix typos using codespell
Some more funny typos, please review carefully.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-02-16 11:12:52 +01:00
Karel Zak a31bb9b6a1 cal: clean up man page synopsis syntax
Let's use '[ ]' rather than '< >' to be compatible with our another
man pages. Note that all time addressing on cal(1) command line is
optional.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1542883
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-07 11:19:44 +01:00
Jakub Wilk f04c77f0a3 findmnt.8: remove spurious spaces before "--tree" and "--verbose"
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-02-04 19:31:17 +01:00
Karel Zak b9d9ab7dae cal: add ifdef TEST_CAL
The test program follows CAL_TEST_TIME=<sec> rather than libc time().
It allows to use cal(1) in regression tests in cases where output
depends on the current time.

(We already use the same for example for logger.)

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-02 10:05:15 +01:00
Karel Zak 79d6aa3811 findfs: don't include exitcodes.h
The code uses findfs return codes only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 14:51:55 +01:00
Karel Zak f066c107ce cal: remove extra space after year output
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 16:17:10 +01:00
Karel Zak 37bd991f77 cal: don't use year header for -1, -3 or -n
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 16:14:15 +01:00
Karel Zak 8315a2ff15 cal: follow terminal width
* modify number of months in row according to the terminal width
* don't print blank space behind last char on row

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 16:10:06 +01:00
J William Piggott d7db28c6d6 cal: do not set months_in_row with -3 option
Having the -3 option set months_in_row causes ordinal days
to wrap; it overrides the automatic handling of months_in_row
that falls back to 2 month columns for ordinal days.

Before:
cal -3j 2020
                           2020

            July                         August                      September
Sun Mon Tue Wed Thu Fri Sat   Sun Mon Tue Wed Thu Fri Sat   Sun Mon Tue Wed Thu Fri Sat
    182 183 184 185 186 187                   213 214 215   244 245 246 247 248 249 250
188 189 190 191 192 193 194   216 217 218 219 220 221 222   251 252 253 254 255 256 257
195 196 197 198 199 200 201   223 224 225 226 227 228 229   258 259 260 261 262 263 264
202 203 204 205 206 207 208   230 231 232 233 234 235 236   265 266 267 268 269 270 271
209 210 211 212               237 238 239 240 241 242 243   272 273

Patched:
cal -3j 2020
                           2020

          December                      January
Sun Mon Tue Wed Thu Fri Sat   Sun Mon Tue Wed Thu Fri Sat
335 336 337 338 339 340 341                 1   2   3   4
342 343 344 345 346 347 348     5   6   7   8   9  10  11
349 350 351 352 353 354 355    12  13  14  15  16  17  18
356 357 358 359 360 361 362    19  20  21  22  23  24  25
363 364 365                    26  27  28  29  30  31

          February
Sun Mon Tue Wed Thu Fri Sat
                         32
 33  34  35  36  37  38  39
 40  41  42  43  44  45  46
 47  48  49  50  51  52  53
 54  55  56  57  58  59  60

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-24 13:24:33 +01:00
J William Piggott 2bcf8f7934 cal: honor num_months when only a year argument
I don't know if this was an oversight or an overzealous
interpretation of POSIX. Just in case, I'll address the
POSIX possibility. POSIX description for cal(1) says:

  If only the year operand is given, cal shall produce a
  calendar for all twelve months in the given calendar year.

It also says that cal(1) has no options, so in that context
if an option is given then it should be expected to override
POSIX behavior.

Before patched all of these command displayed a full year:
cal -1 2020
cal -3 2020
cal -n6 2020

Patched the number of months options are honored.

This patch also fixes the -1 option which was a no-op.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-24 13:24:33 +01:00
J William Piggott 6304358cb7 cal: fix first week calculation
Commit efafeaf set 1 Jan as week 1, but the change
was missed in week_to_day() and in the man page.

Before
cal --week=40 --iso 1752
      October 1752
   Su Mo Tu We Th Fr Sa
41  1  2  3  4  5  6  7
42  8  9 10 11 12 13 14
43 15 16 17 18 19 20 21
44 22 23 24 25 26 27 28
45 29 30 31

Patched
cal --week=40 --iso 1752
     September 1752
   Su Mo Tu We Th Fr Sa
36                 1  2
37  3  4  5  6  7  8  9
38 10 11 12 13 14 15 16
39 17 18 19 20 21 22 23
40 24 25 26 27 28 29 30

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-22 14:16:57 +01:00
J William Piggott e572a765f9 cal: fix week calculations for 1752
Before:
cal --week=39 1752
     September 1752
   Su Mo Tu We Th Fr Sa
36        1  2 14 15 16
37 17 18 19 20 21 22 23
38 24 25 26 27 28 29 30

Patched:
cal --week=39 1752
      October 1752
   Su Mo Tu We Th Fr Sa
39  1  2  3  4  5  6  7
40  8  9 10 11 12 13 14
41 15 16 17 18 19 20 21
42 22 23 24 25 26 27 28
43 29 30 31

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-22 14:16:57 +01:00
Rafal Luzynski 4e12a62e88 cal: Use ALTMON_* correctly
cal: use ALTMON_* and _NL_ABALTMON_* constants to display
months in a standalone form correctly.  These constants have just
been newly added to glibc.  ALTMON_x has been used in BSD family
since 1990s and has been accepted as the future POSIX extension.
_NL_ABALTMON_* is exclusively a GNU extension but it is expected
to be added to POSIX in future.

More info: https://sourceware.org/bugzilla/show_bug.cgi?id=10871
2018-01-22 11:50:50 +01:00
J William Piggott 1dca3edc36 cal: fix julian calendars for large years
Before:
cal --r julian 31 12 2147483646
 December 2147483646
Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

Patched:
cal --r julian 31 12 2147483646
 December 2147483646
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-22 11:33:20 +01:00
Karel Zak a15dca2f6d include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()
Let's make it possible to use debug.h without environment variables.

Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-17 13:58:29 +01:00
J William Piggott a4b55ad008 cal: update man page
Update cal.1 with the new options --reform and --iso.

Also add information about the calendar systems used and
the difference between the --julian option and the Julian
calendar system.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-16 13:51:43 -05:00
J William Piggott ae51e7b429 cal: add option to set Gregorian reform date
Create the new option: --reform <1752|gregorian|iso|julian>

This adds the capability to display either the proleptic Gregorian or
the Julian calendar systems exclusively.

Also create the option --iso as alias of --reform=gregorian.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-16 13:51:24 -05:00
J William Piggott db9baa8ab7 cal: move REFORMATION_YEAR to control struct
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-15 11:06:36 -05:00
Karel Zak 6d00cfb233 include/debug: don't print pointer address for SUID programs
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing

* use __UL_DEBUG_FL_NOADDR when SUID

* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
  to provide access to the current mask from ul_debugobj(). It's better
  than modify all ul_debugobj() calls and use the global mask as
  argument.

* remove never used UL_DEBUG_DEFINE_FLAG

Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-12 11:01:26 +01:00
Kenyon Ralph deff4975a1
rename.1: fix typo, where -> were 2017-12-23 13:44:34 -08:00
Karel Zak 6ce7eca36c cal: fix multi-byte comment, explain in better way
On Sun, Dec 17, 2017 at 07:47:49PM -0500, J William Piggott wrote
> * it contains multi-byte characters (which is what drew me to reading it).
> * it truncates one very important piece of the formula: ". . . (mod 7)."
> * it explains the values for 'e', but there is no 'e' in the code.
> * it doesn't include a row resolving 'e' in the table, so it is not
>    obvious what it relates to in the code.
> * without citing it as an external reference, the comment language is confusing.

Co-Author: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-18 12:44:03 +01:00
Karel Zak 7468a8d106 whereis: fix typo in debug message
Reported-by: Matthew White <mehw.is.me@inventati.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:52:57 +01:00
Karel Zak b9c650106b Revert "cal: simplify leap year rule"
It was mistake, we use extra rule for date < 1752 from the beginning
and another calculations depends on this.

This reverts commit b9bd8dc267.
2017-12-14 13:19:08 +01:00
Karel Zak 3c49b23ad6 cal: explain magic values for day of week calculation
Based on BERNDT E.SCHWERDTFEGER papers.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-13 19:09:56 +01:00
Masatake YAMATO 616e75c02c fincore: fix a typo in fincore.1
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-13 13:06:54 +01:00
Karel Zak 856d856a98 mcookie: properly initialize hash
This stupid mistake has been introduced by commit 46ae163a8e.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 12:09:13 +01:00
Karel Zak 42dea85c5a lib/md5: use ul_/UL_ prefix
The symbols names are too generic.

Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 12:06:15 +01:00
Sami Kerola 378d58abb1 rename: use access(3) to check if a file exists
This is more lightweight than calling stat(3).  In same go add a regression
test to ensure changes like this will not break --no-overwrite option.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-12-04 13:04:12 +01:00
Sami Kerola bfcd327541 man: use long options in text and add example to uuidgen
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:15 +01:00
Sami Kerola fcf841f8d3 misc: fix typos
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:13 +01:00
Pali Rohár 0d2e8ff94d blkid: Encode any field which starts with LABEL in same way as LABEL field
This applies also for LABEL_FATBOOT which contains bytes according to DOS
code page and therefore does not contain valid UTF-8 sequence.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2017-11-25 12:48:32 +01:00
Karel Zak 06a27566e1 lsblk: add hint about perms to man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-22 12:31:58 +01:00
Karel Zak b9bd8dc267 cal: simplify leap year rule
Gregorian rule for leap years has been adopted by reformation in year
1782 (Calendar Act 1750), but all tools (date, SQL servers, etc. etc.)
don't care about it and apply the new rule for all year -- including
years before the reformation.

It's better to be compatible with another tools than try to be perfect :-)

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1507271
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-13 17:34:19 +01:00
J William Piggott 4111bb3ab5 lib/timeutils: add common ISO timestamp masks
* Start the ISO format flags at bit 0 instead of bit 1.

* Remove unnecessary _8601 from ISO format flag names to
  avoid line wrapping and to ease readability.

* ISO timestamps have date-time-timzone in common, so move
  the TIMEZONE flag to bit 2 causing all timestamp masks
  to have the first three bits set and the last four bits
  as timestamp 'options'.

* Change the 'SPACE' flag to a 'T' flag, because it makes
  the code and comments more concise.

* Add common ISO timestamp masks.

* Implement the ISO timestamp masks in all applicable code
  using the strxxx_iso() functions.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-11-10 16:34:55 -05:00
Karel Zak 4707bc83e1 lslocks: add note about OFDLCK
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-03 11:20:41 +01:00
Karel Zak c61e986fd0 lib/signames: remove signame array from header file
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-23 13:18:57 +02:00
Karel Zak c5910c7f27 Merge branch 'kill-child-feature' of https://github.com/nh2/util-linux
* 'kill-child-feature' of https://github.com/nh2/util-linux:
  unshare: Allow passing <signame> to --kill-child
  unshare: Add --kill-child option.
  signames: Make input char buffers const
  kill: Extract signal names into signames.h/signames.c
2017-10-23 12:58:21 +02:00
Karel Zak beaca64a6c blkid: improve man page wording
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-16 23:26:45 +02:00
Karel Zak 27fbfef33c blkid: more info about ambivalent results to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-16 12:01:41 +02:00
Karel Zak 12786a9015 blkid: cleanup man page info about lsblk
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-16 11:45:41 +02:00
Niklas Hambüchen 6855f6e80b kill: Extract signal names into signames.h/signames.c 2017-10-14 04:46:13 +02:00
Karel Zak 2d4c226dfb logger: keep header generators independent on connection
* avoid memory leaks
* don't use incomplete or header after free()

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-12 14:21:27 +02:00
Karel Zak 5794087292 fincore: make sure mmap(NULL, ...) [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-12 12:44:55 +02:00
Karel Zak e92d55e6cb logger: allow to reconnect on initial failed connect too
The current code sets noact flag if unix socked connection failed. This is ugly.
We want to reconnect always in all cases (well, except --socket-error=on).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-11 12:35:24 +02:00
Karel Zak 87ac63c9fa logger: add dummy fallback for OSX
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-10 14:45:55 +02:00
Karel Zak caf6ac6e59 logger: reconnect on failed send()
The libc syslog() reconnects on failed send(). We need the same thing
as logger(1) is expected as long time running tool. For example
recommended Apache configuration is:

	ErrorLog "| /usr/bin/logger -t apache_error -p local6.debug"

The issue is that connection endpoint (e.g. syslogd) maybe restarted.
The simple way how to test is:

	for i in $(seq 0 3600); do echo "This is message number $i"; sleep 1; done | logger --tcp --server 127.0.0.1 --port 514

and restart your syslog. The current implementation gets SIGPIPE or
write warning message, but it never reconnect.

Addresses: https://github.com/karelzak/util-linux/issues/363
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-10 13:56:30 +02:00
Karel Zak 774178f727 Merge branch 'patch-1' of https://github.com/aner-perez/util-linux 2017-09-15 14:45:36 +02:00
Karel Zak ae1c9d6008 uuidparse:fix stack-buffer-overflow [asan]
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:30:45 +02:00
Karel Zak 9f20d80079 misc: cleanup UUID_STR_LEN definitions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:25:32 +02:00
Karel Zak 8b318eb25e logger: make stdin parsing more friendly to static analyzers
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 12:54:54 +02:00
Aner Perez ed21c47aa1 Example for renaming foo? does not work as described
Command for renaming foo? should add 2 zeros to make all the file names have 3 digits as described in the example results.
2017-09-14 11:30:53 -04:00
Karel Zak e12364cdfb lsblk: small man page change in return codes description
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-07 10:03:18 +02:00
Karel Zak 3184afa529 uuidgen: add more details to man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-05 12:17:26 +02:00
Philip Prindeville c6f1ec68a8 uuidgen: add support for hash-based UUIDs
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:56:24 +02:00
Philip Prindeville b443c1779e misc: replace magic number 37 with UUID_STR_LEN
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:49:21 +02:00
Karel Zak 0e45b256ac wipefs: cleanup offsets list usage, fix -t filter
* move list with offsets specified by -o to the wipe_control struct
* don't clone the list of offsets, just keep it simple and stupid
* apply all filters (-o and -t) in get_desc_for_probe()
* always return offset and len by get_desc_for_probe() and apply
  always use libblkid hide & step-back

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1486777
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-31 14:47:14 +02:00
Sami Kerola a653878c45 look: use WORDLIST environment variable to find word list
The WORDLIST is the same hunspell(1) and ispell(1) uses to achieve the same.
Apparently aspell(1) does not work with files like traditional dict lists.

Reference: https://github.com/hunspell/hunspell/blob/master/man/hunspell.1#L388
Reference: http://www.skrenta.com/rt/man/ispell.1.html
Reference: http://aspell.net/man-html/Creating-an-Individual-Word-List.html#Creating-an-Individual-Word-List
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-08-21 10:48:20 +02:00
Sami Kerola 8cfbd35048
uuidparse: nil uuid have all bits set to zero
The nil UUID is special form of UUID that is specified to have all 128 bits
set to zero.

Reference: https://tools.ietf.org/html/rfc4122#section-4.1.7
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-08-05 09:58:25 +01:00
Andreas Henriksson 8df545592d build: use --runstatedir instead of --localstatedir
The util-linux code was previously aligned to use @localstatedir@ and
the util-linux build system was set to override the default to use /run.

Current GNU Coding Standards introduced the @runstatedir@ variable
for this purpose. Lets use that instead.

The GNU default for @runstatedir@ is ${localstatedir}/run so util-linux
still override the default to be /run to preserve the status quo from
before. The only difference is that you'll now pass --runstatedir to
override the location on the command line instead of --localstatedir.

(FWIW, Debhelper in compat 11 will automatically start passing
--runstatedir=/run to all autotools configured builds. It already
passes --localstatedir=/var (to avoid it ending up with the GNU default
/usr/local/var) which breaks the util-linux build system code that
tries to default it to /run. This change will thus allow util-linux
and debhelper to work better together and avoid the need for a
package-specific override.)

Relevant historic commits:
 * commit 07a16b9d1e
   "build-sys: change --localstatedir to /run"
 * commit 80c51185d5
   "uuidd: use run configured state directory"
 * commit 01c5b78794
   "agetty: use configured run state directory"

[kzak@redhat.com: - add $runstatedir fallback for autoconf < 2.70
                  - check for unmodified $localstatedir]

CC: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-31 15:24:46 +02:00
Andreas Henriksson c9ab738706 whereis: include native multiarch path in lib search paths
This includes atleast the native multiarch path in the paths to search.
(Maybe also other multiarch paths should also be searched? But atleast
this is a first step.)

Before this change (on Debian):
$ whereis libc
libc: /usr/share/man/man7/libc.7.gz

After this change:
$ whereis libc
libc: /usr/lib/x86_64-linux-gnu/libc.so /usr/lib/x86_64-linux-gnu/libc.a /usr/share/man/man7/libc.7.gz

Addresses: https://bugs.debian.org/856968
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2017-07-31 13:48:04 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
changed in include/c.h and applied via sed:

  sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
  sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 16:54:33 +02:00
Karel Zak 07fd6640c8 Merge branch 'path-fixes' of https://github.com/rudimeier/util-linux
* 'path-fixes' of https://github.com/rudimeier/util-linux:
  hwclock: don't ifdef printf arguments
  setpriv: align --help
  tools: add segfault detection for checkusage.sh
  misc: avoid some dead initialization warnings
  lscpu: make clang analyzer happy
  lsmem: fix, using freed memory
  lib/path: add error handling to path_vcreate()
  lib/path: fix crash, pathbuf overflow
2017-06-29 15:29:33 +02:00
Ruediger Meier c3ae785433 misc: avoid some dead initialization warnings
Clang analyzer warnings:

Dead store, Dead initialization:

    lib/mbsedit.c:154:8: warning: Value stored to 'in' during its initialization is never read
            char *in = (char *) &c;
                  ^~   ~~~~~~~~~~~

    misc-utils/findmnt-verify.c:129:14: warning: Value stored to 'cn' during its initialization is never read
            const char *cn = tgt;
                        ^~   ~~~
Dead store, Dead increment:

    sys-utils/hwclock.c:1461:2: warning: Value stored to 'argv' is never read
            argv += optind;
            ^       ~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 14:04:25 +02:00
Karel Zak 4c2af16845 uuidgen: improve --help
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-29 12:40:22 +02:00
Karel Zak 42d2a8b30d wipefs: improve --help
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-29 12:38:40 +02:00
Karel Zak d9921b2a12 wipefs: use libsmartcols
The old output is horrible and useless when more devices specified.
The old format is also too tricky if more signatures detected. The new
output uses one line for each signature, prefixed by device name.

For example my workstation:

	# wipefs /dev/sda* /dev/sdb*
	DEVICE OFFSET       TYPE UUID                                 LABEL
	sda    0x1fe        PMBR
	sda    0x37e4895e00 gpt
	sda    0x200        gpt
	sda1   0x1fe        vfat F2BC-BFEC                            EFI
	sda1   0x0          vfat F2BC-BFEC                            EFI
	sda1   0x36         vfat F2BC-BFEC                            EFI
	sda2   0x438        ext4 c5490147-2a6c-4c8a-aa1b-33492034f927 BOOT
	sda3   0x438        ext4 196972ad-3b13-4bba-ac54-4cb3f7b409a4 HOME
	sda4   0x438        ext4 d834bc84-0089-4be1-9013-cd8bf35d5ffa ROOT
	sda5   0x438        ext4 e8ce5375-29d4-4e2f-a688-d3bae4b8d162 WINE
	sda6   0xff6        swap 210337c6-f8b5-4d65-aab5-a0f343fa9ad4 SWAP
	sdb    0x200        gpt
	sdb    0x1fe        dos
	sdb1   0x438        ext4 6467a684-0d10-4f61-a301-67bb26934d90

This patch add --noheadings, --json and --output.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-29 11:59:38 +02:00
Karel Zak e8fd8c6b9b uuidparse: se JSON table name on -J
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-29 11:07:54 +02:00
Karel Zak 2cd417ea71 wipefs: try another magic strings on -o and -t
The commit 92296e9ba2 introduces "try
all permutations for the same superblock". This feature has to be also
available if -o and -t is specified.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-28 12:08:25 +02:00
Karel Zak 4e60928139 wipefs: add control struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-28 11:51:12 +02:00
Karel Zak 193d6f27fb wipefs: don't do step-back if <type> does not match
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-28 10:28:41 +02:00
Karel Zak 92296e9ba2 wipefs: print all signature permutations
The same FS/RAID/PT signature may be detected by more ways and on more
places on the device. The libblkid returns only the first detected
signature by default. This patch use blkid_probe_hide_range() to
re-scan device for all possible permutations of the same signature.

For example the default wipefs(8) output as well as --no-act output will
contains primary as well as backup GPT signature now.

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-28 10:28:41 +02:00
Karel Zak b899fd87bd Merge branch 'help-description' of https://github.com/rudimeier/util-linux
* 'help-description' of https://github.com/rudimeier/util-linux:
  misc: update --help content again
  login: add --help text
  blockdev: improve --help and man page
  misc: consolidate all --help option descriptions
  misc: introduce print_usage_help_options()
  misc: revert to the old USAGE_HELP strings
2017-06-27 14:14:14 +02:00
Ruediger Meier b305445495 misc: consolidate all --help option descriptions
Now we are always using the same text also for commands
which had still hardcoded descriptions or where we can't
use the standard print_usage_help_options macro.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:28:36 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
Consolidate --help and --version descriptions. We are
now able to align them to the other options.

We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:26:19 +02:00
Ruediger Meier f2bd688157 uuidparse: fix getopt crash
$ ./uuidparse --unknownopt
Segmentation fault (core dumped)

Hehe, this is the first real bug found by 'make checkusage'.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 22:38:43 +02:00
Karel Zak 47ccf06b47 Merge branch 'usage-part2' of https://github.com/rudimeier/util-linux
* 'usage-part2' of https://github.com/rudimeier/util-linux:
  misc: cosmetics, remove argument from usage(FILE*)
  misc: cosmetics, remove argument from usage(int)
  misc: never use usage(stderr)
  misc: never use usage(ERROR)
  misc: cleanup and fix --unknownopt issues
  flock, getopt: write --help to stdout and return 0
  tools: add checkusage.sh
2017-06-26 15:58:37 +02:00
Sami Kerola 83893f2678 uuidparse: add new command
This command will analyze and print information about UUID's.  The command
is based on libuuid/src/uuid_time.c but modified to use libsmartcol.

[kzak@redhat.com: - minor coding style changes]

Reference: http://marc.info/?l=util-linux-ng&m=149735980715600&w=2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-26 14:46:35 +02:00
Ruediger Meier 86be6a32d3 misc: cosmetics, remove argument from usage(FILE*)
This patch is trivial and changes nothing, because
we were always using usage(stdout)

Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier fa2cd89aca misc: cosmetics, remove argument from usage(int)
This patch is trivial and changes nothing, because
we were always using usage(0).

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 5118d1be2a misc: never use usage(ERROR)
We are using better/shorter error messages and somtimes
also errtryhelp().

Here we fix all cases where the usage function took
an int argument for exit_code.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 6d7bee26bc flock, getopt: write --help to stdout and return 0
... and use errtryhelp() instead of usage().

Note in past "getopt --help" returned 2. But it is otherwise
documented and was just a mistake IMO. See the unreachable exit(0)
which was removed here: d1d03b54

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Karel Zak c3a4cfc579 misc: consolidate usage() "Available columns"
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-26 14:09:53 +02:00
Karel Zak d6ec64e824 Merge branch '170622' of github.com:jwpi/util-linux
* '170622' of github.com:jwpi/util-linux:
  Docs: move option naming to howto-contribute.txt
  Docs: update howto-usage-function.txt
  Docs: add a comment for constants to boilerplate.c
  include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
2017-06-26 13:56:45 +02:00
Karel Zak dfdb1ca818 Merge branch 'fix-exit-codes' of https://github.com/rudimeier/util-linux
* 'fix-exit-codes' of https://github.com/rudimeier/util-linux:
  misc: fix optutils.h related exit codes
  misc: fix xalloc.h related exit codes
  misc: fix more strutils related exit codes
  lib: fix strutils.h, remove STRTOXX_EXIT_CODE
  misc: fix some broken exit codes
2017-06-26 13:47:04 +02:00
Ruediger Meier a2248466e4 misc: no more errtryh()
Nowadays all our regular commands have --help options.
test_uuidd does not use translations anyways.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-25 02:22:53 +02:00
J William Piggott 6e2d5a4460 include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
* login-utils/lslogins.c: all uses changed
* misc-utils/findmnt.c: likewise
* sys-utils/blkzone.c: likewise
* disk-utils/sfdisk.c: likewise
* sys-utils/lscpu.c: likewise
* sys-utils/lsmem.c: likewise
* sys-utils/wdctl.c: likewise

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-24 13:57:12 -04:00
Ruediger Meier 778ca2a0d4 misc: fix xalloc.h related exit codes
Found by:

grep -L "XALLOC_EXIT_CODE" $(grep -l "xalloc\.h" \
    $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 22:40:27 +02:00
Ruediger Meier 9c8b9fbacc lib: fix strutils.h, remove STRTOXX_EXIT_CODE
As discussed on the mailing list. We fix all places
where the non-working define STRTOXX_EXIT_CODE was used.

Regarding tunelp, also see 7e3c80a7.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 22:40:12 +02:00
Ruediger Meier 05691d9e88 misc: fix some broken exit codes
These tools have special exit codes. They got changed mistakenly.

See:
  findfs       0e1fa6b6
  fsck         658c0891
  fsck.cramfs  922ec175
  mkfs.cramfs  16154b1f
  tunelp       2ab428f6

FIXME: STRTOXX_EXIT_CODE doesn't work as it should.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:51:40 +02:00
Ruediger Meier 5aaa966dcd whereis: add --help and --version
We can use errtryhelp() now and never print usage to stderr.
One may improve all these "bad usage" messages.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:34:58 +02:00
Ruediger Meier 3b7693cada blkid: use errtryhelp instead of errtryh
We have a --help option and this is preferred.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:34:40 +02:00
Ruediger Meier 619081cdab uuidd: remove unused define
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 02:56:57 +02:00
Karel Zak 6f1507f135 wipefs: exit on failed erase
The current behavior is to report error and continue, it seems strange:

	# blockdev --setro /dev/sdc

	# wipefs -a /dev/sdc
	wipefs: /dev/sdc: failed to erase xfs magic string at offset 0x00000000: Operation not permitted
	/dev/sdc: 4 bytes were erased at offset 0x00000000 (xfs): 58 46 53 42
                          ^^^^^^^^^^^
                           not true

The patch calls err() to exit.

Reported-by: Vratislav Podzimek <vpodzime@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-21 10:53:28 +02:00
Sami Kerola f4d3783867 misc: remove stray semicolons
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:21:29 +02:00
Sami Kerola 1b5042636f misc: fix reassigned values before old ones has been used [cppcheck]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:19:20 +02:00
Sami Kerola 504c03ecf8 uuidgen: slice up the usage text
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:17:53 +02:00
Sami Kerola 9f430c8a5b rename: notice when expression and replacement are the same string
The rename(1) can exit early when replace expression and replacement are
identical string.  It is also appropriate to change return value in this
case to 'nothing was renamed'.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:17:27 +02:00
Sami Kerola b1557fe981 misc: fix ggc-7 fallthrough warnings
(Original patch and commit message edited by Rudi.)

gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra.
This warning can be silenced by using comment /* fallthrough */
which is also recognized by other tools like coverity. There are
also other valid comments (see man gcc-7) but we consolidate this
style now.

We could have also used __attribute__((fallthrough)) but the comment
looks nice and does not need to be ifdef'ed for compatibility.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Suggested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 11:48:22 +02:00
Karel Zak 1d9e35cc1e lsblk: add option --tree
Now lsblk uses --list when --sort <column> is specified. This patch
allows to specify --tree to overwrite this default behavior add to
force tree-like output. In this case tree branches are sorted by the
<column>.

$ lsblk --sort SIZE
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda2   8:2    0   200M  0 part /boot
sda1   8:1    0   200M  0 part /boot/efi
sda6   8:6    0   7.8G  0 part [SWAP]
sda5   8:5    0  35.1G  0 part /home/misc
sda4   8:4    0    50G  0 part /
sdb1   8:17   0  74.5G  0 part /home/archive
sdb    8:16   0  74.5G  0 disk
sda3   8:3    0 130.3G  0 part /home
sda    8:0    0 223.6G  0 disk

$ lsblk --sort SIZE --tree
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   0  74.5G  0 disk
└─sdb1   8:17   0  74.5G  0 part /home/archive
sda      8:0    0 223.6G  0 disk
├─sda2   8:2    0   200M  0 part /boot
├─sda1   8:1    0   200M  0 part /boot/efi
├─sda6   8:6    0   7.8G  0 part [SWAP]
├─sda5   8:5    0  35.1G  0 part /home/misc
├─sda4   8:4    0    50G  0 part /
└─sda3   8:3    0 130.3G  0 part /home

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-09 11:33:18 +02:00
Karel Zak f60d62afa1 rename: add -o to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-06 12:09:34 +02:00
Karel Zak 5fba8b758c Merge branch 'rename-nooverride' of https://github.com/dov/util-linux
* 'rename-nooverride' of https://github.com/dov/util-linux:
  Changed "override" to "overwrite" rename option.
  Added --no-override option to rename.
2017-06-06 12:07:26 +02:00
Dov Grobgeld 9a838c3c55 Changed "override" to "overwrite" rename option. 2017-06-03 23:40:47 +03:00
Karel Zak 7dec8dfeca Merge branch 'master' of https://github.com/yurchor/util-linux
* 'master' of https://github.com/yurchor/util-linux:
  Fix minor typos
2017-06-02 11:13:39 +02:00
Ruediger Meier f2ff0adf5d misc: fix some warnings
sys-utils/prlimit.c: In function 'do_prlimit':
sys-utils/prlimit.c:367:16: warning: format '%ju' expects argument of type 'uintmax_t', but argument 2 has type 'rlim_t {aka long long unsigned int}' [-Wformat=]
     printf("<%ju", new->rlim_cur);

lib/plymouth-ctrl.c: In function 'open_un_socket_and_connect':
lib/plymouth-ctrl.c:88:20: warning: passing argument 2 of 'connect' from incompatible pointer type [-Wincompatible-pointer-types]
  ret = connect(fd, &su, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(su.sun_path+1));
                    ^
In file included from lib/plymouth-ctrl.c:35:0:
/usr/include/sys/socket.h:314:5: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_un *'
 int connect (int, const struct sockaddr *, socklen_t);

login-utils/last.c: In function 'list':
login-utils/last.c:506:54: warning: pointer targets in passing argument 4 of 'dns_lookup' differ in signedness [-Wpointer-sign]
   r = dns_lookup(domain, sizeof(domain), ctl->useip, p->ut_addr_v6);
                                                      ^
login-utils/last.c:291:12: note: expected 'int32_t * {aka int *}' but argument is of type 'unsigned int *'
 static int dns_lookup(char *result, int size, int useip, int32_t *a)
            ^~~~~~~~~~

In file included from sys-utils/hwclock-cmos.c:92:0:
sys-utils/hwclock.h:67:32: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
 extern double time_diff(struct timeval subtrahend, struct timeval subtractor);

misc-utils/test_uuidd.c: In function 'create_nthreads':
misc-utils/test_uuidd.c:187:19: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
        proc->pid, (int) th->tid, th->index));

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-01 10:28:18 +02:00
Karel Zak 3947ca4ca9 build-sys: ncurses headers cleanup
* assume ncursesw headers in ncursesw/ directory only
* prefer long paths, <term.h> and <ncurses.h> should be last
  possibility
* fix typos

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-31 11:01:46 +02:00
Karel Zak 18451b2cf4 cal: ncurses cleanup
* use proper paths to term.h
* keep ncurses support optional
* link with TINFO_LIBS (-ltinfo), or fallback to NCURSES_LIBS (-ltinfo -lncurses)
* don't include unnecessary ncurses.h (term.h is enough)

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-30 17:14:46 +02:00
Karel Zak b770b48700 test_uuidd: don't use error.h
The header file is not provided by musl-libc.

Reported-by: Assaf Gordon <assafgordon@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-30 10:26:17 +02:00
Dov Grobgeld fabb90676a Added --no-override option to rename. 2017-05-27 23:26:32 +03:00
Yuri Chornoivan 0508f347c8 Fix minor typos 2017-05-24 00:22:20 +03:00
Sami Kerola 8c1ce08da9 rename: make --no-act to imply --verbose
It is reasonable to assume use of --no-act means one wants to always see
what would have happen if rename is done.  To say same slightly differently,
if there is sn use case for silent rename --no-act run I cannot think one.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-19 11:43:34 +02:00
Karel Zak 55548b14c1 lslocks: remove dead code
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-18 15:10:51 +02:00
Karel Zak 780ce22cda misc: consolidate smartcols error messages
... just to keep translators happy

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-18 11:39:34 +02:00
Karel Zak b7ebf49c9b fincore: check rc from smartcols stuff [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 13:08:33 +02:00
Sami Kerola 9ac755f6c3 getops: make --a-long option work again
Add back a character lost in earlier change.

Regression-from: d27f5fe770
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-16 14:54:41 +02:00
Karel Zak 5d217e6f15 wipefs: add note about no-act to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-11 15:54:30 +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
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
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 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
Karel Zak be685b98c0 lsblk: don't duplicate columns
$ lsblk --discard --perms
NAME   DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO NAME     SIZE OWNER GROUP MODE
sdb           0        0B       0B         0 sdb     74.5G root  disk  brw-rw----
└─sdb1        0        0B       0B         0 └─sdb1  74.5G root  disk  brw-rw----
sda           0      512B       2G         0 sda    223.6G root  disk  brw-rw----
├─sda4        0      512B       2G         0 ├─sda4    50G root  disk  brw-rw----
├─sda2        0      512B       2G         0 ├─sda2   200M root  disk  brw-rw----
├─sda5        0      512B       2G         0 ├─sda5  35.1G root  disk  brw-rw----
├─sda3        0      512B       2G         0 ├─sda3 130.3G root  disk  brw-rw----
├─sda1        0      512B       2G         0 ├─sda1   200M root  disk  brw-rw----
└─sda6        0      512B       2G         0 └─sda6   7.8G root  disk  brw-rw----

... see NAME column.

It's fine to support duplicated columns when requested by user (e.g.
-o NAME,NAME,SIZE), but it does not make sense for the default output
when multiple command options specified.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-19 14:28:16 +02:00
Damien Le Moal f2df436564 lsblk: add ZONED column
Add the column "ZONED" to the output to display block devices zone
model information.

Example output:

> lsblk -o+ZONED
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT ZONED
sda      8:0    0 111.8G  0 disk            none
├─sda1   8:1    0   500M  0 part /boot      none
├─sda2   8:2    0  87.3G  0 part /          none
└─sda3   8:3    0    24G  0 part [SWAP]     none
sdb      8:16   0  12.8T  0 disk            host-managed
sdc      8:32   0   5.5T  0 disk            host-managed

or:

> lsblk --zoned
NAME   ZONED
sda    none
├─sda1 none
├─sda2 none
└─sda3 none
sdb    host-managed
sdc    host-managed

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2017-04-19 14:07:03 +02:00
Karel Zak 091683a82f lsblk: fix --inverse --list
Let's follow --inverse dependencies although --list output requested.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1441175
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 11:39:22 +02:00
Karel Zak 341c4ae26e lsblk: move scols_flags to lsblk control struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 10:17:36 +02:00
Sami Kerola b9dc8d071d fincore: fix file descriptor leak
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-10 15:40:39 +02:00
Karel Zak 452089fa2f fincore: use size_t everywhere
It seems better to avoid "int" at all from sizes calculations to make
the code more robust for future changes.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-06 12:40:01 +02:00
Ruediger Meier 379c1a52a2 fincore: fix multiplication overflow
This failed on ppc64 with page size 64k.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-04-06 12:30:09 +02:00
Karel Zak e4e8b57be2 fincore: add column RES
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-27 13:08:40 +02:00
Karel Zak 071147ab89 blkid: fix compiler warning [-Wdiscarded-qualifiers]
Let's also hide the show[] array in has_item().

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-24 12:07:17 +01:00
Karel Zak 3006dd7352 Merge branch '2017wk11' of git://github.com/kerolasa/lelux-utiliteetit
* '2017wk11' of git://github.com/kerolasa/lelux-utiliteetit:
  blkid: add control struct
  blkid: simplify version option handling
  tests: add static keyword where needed [smatch scan]
  tests: do not use plain 0 as NULL [smatch scan]
  libsmartcols: fix test variable shadowing
2017-03-24 11:59:57 +01:00
Karel Zak cff1c113fe fincore: fix error on open()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 15:28:05 +01:00
Karel Zak 9b48766fb3 fincore: add --raw and --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 14:34:12 +01:00
Karel Zak c5cb541299 fincore: add --output
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 14:27:42 +01:00
Karel Zak 3f91dd88ca fincore: add --bytes and --noheadings
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 14:17:46 +01:00
Karel Zak 3e37d7b773 fincore: use libsmartcols
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 14:09:20 +01:00
Karel Zak b57fe43cd4 fincore: cleanup return codes
Don't use EXIT_* macros as functions return code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-23 13:07:06 +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
Sami Kerola 59b94cc0c5
blkid: add control struct
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-17 21:22:26 +00:00
Sami Kerola 93bdbe1993
blkid: simplify version option handling
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-17 21:22:26 +00:00
Sami Kerola 41427f97d9
tests: add static keyword where needed [smatch scan]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-17 21:22:26 +00:00
Sami Kerola 71f08e9706
tests: do not use plain 0 as NULL [smatch scan]
Likewise commit 8791804065.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-17 21:22:26 +00: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
Sami Kerola 79b915e8df findmnt: fix couple memory leaks [cppcheck]
In both cases FILE *f was leaked.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 13:00:58 +01:00
Sami Kerola 2ba641e5f3 misc: add static keyword to where needed [smatch scan]
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer

Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.

Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Alexander F Rødseth 990bf1f048 rename: add --no-act option
[kzak@redhat.com: - rename --dry-run to --no-act]

Signed-off-by: Alexander F Rødseth <xyproto@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-15 13:41:46 +01:00
Yuri Chornoivan a7349ee315 docs: Fix word repetitions 2017-02-13 14:10:12 +01:00