Commit Graph

11684 Commits

Author SHA1 Message Date
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
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
Karel Zak c525260293 Merge branch 'usage-part1' of https://github.com/rudimeier/util-linux
* 'usage-part1' of https://github.com/rudimeier/util-linux:
  misc: no more errtryh()
  mkfs.cramfs: add --help and --version
  more: add --help and --version
  whereis: add --help and --version
  login: add --help and --version
  fsck: add --help and --version
  setarch: use errtryhelp()
  dmesg: do not accept any non-option arguments
  blkid: use errtryhelp instead of errtryh
  misc: remove superfluous null pointer checks for optarg
  uuidd: remove unused define
2017-06-26 13:42:25 +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
Ruediger Meier 300d702540 mkfs.cramfs: add --help and --version
Note, we were already using errtryhelp() without providing
a --help option.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-25 02:22:27 +02:00
J William Piggott 7948117da5 Docs: move option naming to howto-contribute.txt
Creating and naming options is not done when writing usage().
A contributor may not even read howto-usage-function.txt, but
they should read howto-contribute.txt. So move option naming
and change information there.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-24 15:22:49 -04:00
J William Piggott 72727e28a1 Docs: update howto-usage-function.txt
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-24 13:57:12 -04:00
J William Piggott 610d0fbc77 Docs: add a comment for constants to boilerplate.c
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-24 13:57:12 -04: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
Karel Zak 2a14beb4e9 agetty: fix login name DEL/CTRL^U issue
agetty refresh prompt (/etc/issue file etc.) when requested by inotify
or netlink. For this purpose we monitor some file descriptors by
select().

The terminal input file descriptor is switched to non-canonical mode before
select(). The goal is to be informed about user activity before
new-line. The FD is immediately switched back to canonical mode when
activity is detected. The side effect is that all not-read-yet chars in
the input buffer are lost ... so we need to call read() before switch
to canonical mode to save the chars.

The original implementation has been based on TIOCSTI ioctl. It
returns already read chars back to the terminal input buffer to make
them useful for canonical mode. The problem was race (agetty writes to
input buffer in the same time as user) and result was reordered chars
in login name... so useless.

This issue has been later fixed by extra buffer (commit
790119b885) for already read data.  And
TIOCSTI ioctl has been removed. Unfortunately this solution is also
wrong, because the buffer is maintained only by agetty and
inaccessible for terminal when user edit (by DEL/CTRL^U) login name in
canonical mode.

The solution is simple -- just don't try to be smart and keep terminal
in canonical mode all time (so terminal controls DEL, CTRL^U, etc) and
flush input buffer (=discard unread data) and ask user for login name
again after prompt reload.

The agetty reload is very rarely situation and for user it's pretty
obvious that he has to type login name again (as all terminal has been
clear+redraw).

Addresses: https://github.com/karelzak/util-linux/issues/454
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1464148
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-23 14:26:47 +02:00
Ruediger Meier 39aa4e3978 misc: fix optutils.h related exit codes
Found by:

  grep -L "OPTUTILS_EXIT_CODE" $(grep -l "err_exclusive_options" \
      $(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:31 +02: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 0b2b32e8a7 misc: fix more strutils related exit codes
Found by grep:

grep -l "\bEXIT_\|exit *( *[0-9][0-9] *)\|strutils\.h" $(grep -L \
    strutils_set_exitcode  $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))

The Command shows also some false positives (fstrim.c,
context_mount.c, ...)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 22:40:21 +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 c1da6d1eec more: add --help and --version
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:35:01 +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 7491906df6 login: add --help and --version
Also we don't print the usage text on stderr anymore.

Note, the usage text could be improved, currently it
does not describe any options. I have only added a
pointer to the man page.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:34:54 +02:00
Ruediger Meier 58745f3599 fsck: add --help and --version
Also cleanup usage() function, never write usage to stderr.

FIXME:
 - currently strtou32_or_err() exits with wrong exit code.
 - option -C does not use a safe strto*_err function

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:34:51 +02:00
Ruediger Meier 7a87a774af setarch: use errtryhelp()
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:34:47 +02:00
Ruediger Meier 488a21686f dmesg: do not accept any non-option arguments
'dmesg foo' is no valid syntax and gives an error now.
BTW we avoid the "dead increment of argc and argv.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:34:43 +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
Karel Zak ee8bc16e56 Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  tests: Add UDF hdd image which label has length 30 characters
  libblkid: udf: Fix parsing of UDF dstring structures
2017-06-22 10:51:58 +02:00
Karel Zak a00af97c0d Merge branch '170618' of github.com:jwpi/util-linux
* '170618' of github.com:jwpi/util-linux:
  hwclock: add audit for --systz
  hwclock: remove unused optstring characters
2017-06-22 10:45:22 +02:00
Ivan Delalande 2e45524d96 dmesg: print only 2 hex digits for each hex-escaped byte
As buf is passed as a signed char buffer in fwrite_hex, fprintf will
print every byte from 0x80 as a signed-extended int causing each of
these bytes to be printed as "\xffffff80" and such, which can be pretty
confusing. Force fprintf to use the argument as a char to make it print
only 2 digits, e.g. "\x80".

Signed-off-by: Ivan Delalande <colona@arista.com>
2017-06-22 10:44:35 +02:00
Pali Rohár 56dce6b7fc tests: Add UDF hdd image which label has length 30 characters
Structure dstring for label has 32 bytes, first byte is 8 (Compression ID),
last byte is 30 (count of 8bit characters in label). Therefore label is not
nul terminated and dstring parser needs to handle it (fixed in previous
commit).

$ dd if=/dev/zero of=udf-hdd-mkudffs-1.3-6.img bs=1M count=10
$ mkudffs -l AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -b 512 udf-hdd-mkudffs-1.3-6.img
2017-06-22 10:38:24 +02:00
Pali Rohár f0fcfdc30f libblkid: udf: Fix parsing of UDF dstring structures
First byte of dstring is OSTA Compression ID and the last byte is length of
recorded bytes (including first byte). Last byte is not a part of recorded
characters, therefore it should not be treated as data to decode.
2017-06-22 10:38:08 +02:00
Ruediger Meier 0caad87fdb misc: remove superfluous null pointer checks for optarg
This is only needed for optional arguments.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 02:56:57 +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
J William Piggott 2cb89055c5 hwclock: add audit for --systz
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-21 20:37:41 -04:00
J William Piggott 32adac4c9e hwclock: remove unused optstring characters
getopt_long() opstring contained obsolete entries.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-21 20:37:41 -04:00
Karel Zak fad561b0e4 build-sys: update DISTCHECK_CONFIGURE_FLAGS
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-21 15:41:21 +02:00
Karel Zak 4ccea66996 travis: fix another chown issue
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-21 13:41:08 +02:00
Karel Zak 258e74626d Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  tests: Add UDF hdd images with blocksize 1024 and 4096 created by Linux mkudffs 1.3
  libblkid: udf: Fix detection of UDF images with block size 1024 and 4096
2017-06-21 11:54:51 +02:00
Karel Zak 4a679468ca travis: use --disable-makeinstall-chown everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-21 11:51:39 +02:00
Karel Zak 9e258f388a docs: add program-desc to howto-usage-function.txt and boilerplate.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-21 11:25:55 +02:00
Karel Zak 3d27fdba59 hwclock: remove unwanted space before description
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-21 11:25:16 +02:00
Karel Zak 8ad750bc3c Merge branch '170427' of github.com:jwpi/util-linux
* '170427' of github.com:jwpi/util-linux:
  hwclock: remove unused stdarg.h
  Docs: update howto-usage-function.txt
  hwclock: add --update-drift check
  hwclock: slice up the usage text
  hwclock: update --help content and grammar
  hwclock: use RTC in help output
  include: update pathnames.h
  hwclock: add usage() functions heading
  hwclock: update usage() FILE name
  hwclock: update usage() to util-linux style
  hwclock: remove dead code in usage()
2017-06-21 11:16:23 +02:00
Karel Zak a65041b5ae build-sys: make chown usage more robust
* add --disable-makeinstall-chown to travis non-root mode

* use "if MAKEINSTALL_DO_SETUID" for chown root:root

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-21 11:12:04 +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
J William Piggott ba2cdc0c66 hwclock: remove unused stdarg.h
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-20 19:56:39 -04:00
J William Piggott 2671bcd654 Docs: update howto-usage-function.txt
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-20 19:56:39 -04:00
J William Piggott 891b43432f hwclock: add --update-drift check
Only allow --update-drift for --set or --systohc

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-20 19:56:39 -04:00
J William Piggott d4affe81bb hwclock: slice up the usage text
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-20 19:56:39 -04:00
J William Piggott cc7cb070d9 hwclock: update --help content and grammar
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-20 19:55:08 -04:00
J William Piggott 36b2645405 hwclock: use RTC in help output
Switching between 'hardware clock' and 'RTC' is ambiguous.
RTC is used due to space constraints, so use it consistently.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-20 19:51:27 -04:00
J William Piggott 8493eedd15 include: update pathnames.h
* use /dev/rtc0 (/dev/rtc was for the 'old' driver)
* remove hwclock Award workaround and alpha cmos paths
* relocate _PATH_BTMP from hwclock to login-utils
* add a comment for _PATH_BTMP and fix other login-utils comments
* add a comment for proc/cpuinfo
* remove empty shutdown.c comment from 4d43977f

Review changes
* remove 'used in' comments
* white space fixes

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-20 19:51:26 -04:00
J William Piggott 513bfbefa2 hwclock: add usage() functions heading
Make a functions heading, similar to the existing options heading.

* include/c.h: define USAGE_FUNCTIONS
* Documentation/boilerplate.c: add USAGE_FUNCTIONS
* sys-utils/hwclock.c add functions header to usage()

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-20 19:50:38 -04:00