Commit Graph

13559 Commits

Author SHA1 Message Date
Karel Zak c60231a744 tests: update fdisk output
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-08 14:20:05 +02:00
Karel Zak 08474fde66 libfdisk: (script) support shortcuts in the type= field
The unnamed-field format supports partition type shortcuts:

	",1MiB,L'

but for named-field format it requires full type:

 (mbr)	"size=1MiB,type=83"
 (gpt)  "size=1MiB,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4"

This patch implements type shortcuts also for named-field format:

	"size=1MiB,type=L"

to make it more user-friendly and unified.

Addresses: https://github.com/karelzak/util-linux/issues/837
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-08 10:34:27 +02:00
Karel Zak 11aaedf574 tests: use subtests for mountpoint(1)
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-07 11:45:57 +02:00
Karel Zak cd38987bf4 Merge branch 'issue832' of https://github.com/kerolasa/util-linux
* 'issue832' of https://github.com/kerolasa/util-linux:
  mountpoint: add --nofollow option
2019-08-07 11:20:21 +02:00
Karel Zak 2adf30dceb Merge branch 'master' of https://github.com/chstarkd/util-linux
* 'master' of https://github.com/chstarkd/util-linux:
  removed double space
  fixed mount man page typo, "bythe" -> "by the"
2019-08-07 11:16:14 +02:00
Karel Zak cb74ebad25 libfdisk: refer to partx(8) rather than to kpartx(8)
Reported-by: Petr Pisar <petr.pisar@atlas.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-06 12:24:33 +02:00
Chistyj Arkadij 0797511930 removed double space 2019-08-04 21:21:55 +03:00
Chistyj Arkadij e9d2e0c819 fixed mount man page typo, "bythe" -> "by the" 2019-08-04 17:06:38 +03:00
Sami Kerola 6d56251220
mountpoint: add --nofollow option
The no follow option will allow user to distinct mount points from symbolic
links pointing to them.  Arguably this is pretty pedantic option, mounting a
device or bind mount to a directory via symlink does not have or cause any
issues.

Addresses: https://github.com/karelzak/util-linux/issues/832
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-02 19:39:05 +01:00
Karel Zak 3661aab4cf dmesg: fix output hex encoding
The current code ignores single-byte non-printable characters.

Reported-by: Marc Deslauriers <marc.deslauriers@canonical.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-01 11:43:58 +02:00
Karel Zak 0c493067dd choom: improve docs
It's not obvious from the current docs that you have to explicitly
split command line options and wanted commands.

Addresses: https://github.com/karelzak/util-linux/issues/833
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-01 11:06:06 +02:00
Karel Zak c4d6d1c54d libblkid: fix file descriptor leak in blkid_verify()
The function blkid_verify() uses private device file descriptor and
uses blkid_probe_set_device() to assign the descriptor to low-level
probing code. Unfortunately, close() in this case is not enough as the
prober can internally open whole-disk device too.

The library API has been extended so blkid_probe_set_device()
deallocates and close previously used prober for whole-disk. This new
functionality is used in blkid_verify() now.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1734545
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-31 16:31:10 +02:00
Karel Zak efee3e01bf Merge branch '2019wk29' of https://github.com/kerolasa/util-linux
* '2019wk29' of https://github.com/kerolasa/util-linux:
  lscpu: prefer memcpy() to manual pointer arithmetic
2019-07-29 11:13:51 +02:00
Yousong Zhou 325bfd53e8 column: fix outputing empty column at the end of line
The following commands manifests the problem.  In old versions before
commit 4762ae9d60 ("column: use libsmartcols for --table"), both of them
should output with 2 "|"

	echo '||'  | column -o '|' -s '|' -t
	echo '|| ' | column -o '|' -s '|' -t

Fixes: 4762ae9d60 ("column: use libsmartcols for --table")
Signed-off-by: Yousong Zhou <zhouyousong@yunionyun.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
2019-07-29 10:33:58 +02:00
Sami Kerola b5f376d11d
lscpu: prefer memcpy() to manual pointer arithmetic
With pointer arithmetic clang address sanitizer gives following error this
change addresses.  Notice the following happens only when running as root.

sys-utils/lscpu-dmi.c:83:14: runtime error: load of misaligned address
0x55a1d62f3d1d for type 'const uint16_t' (aka 'const unsigned short'), which
requires 2 byte alignment

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-27 19:00:34 +01:00
Karel Zak 8bad603ae0 lscpu: (man) add note about cache sizes
Addresses: https://github.com/karelzak/util-linux/issues/827
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-25 12:23:59 +02:00
Sami Kerola 2a952555d2 agetty: simplify code in dolog() preprocessor blocks
Aim is to make dolog() a lot more readable and understandable, with downside
of when (rarely?) USE_SYSLOG it not defined the function will use a bit more
space from stack.  I think that is price well worth paying.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-24 11:11:46 +02:00
Sami Kerola 1aaee548e3 login: simplify string handling
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-24 11:11:29 +02:00
Sami Kerola 0675f52ab5 last: replace strncat() with more robust mem2strcpy()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-24 11:11:10 +02:00
Karel Zak 7ea0907364 tests: (fdisk) update padding in output
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-23 16:35:20 +02:00
Karel Zak fc970a0947 tests: (libsmartcols) add padding tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-23 16:26:48 +02:00
Karel Zak 94dbb32273 libsmartcols: cleanup and extend padding functionality
LIBSMARTCOLS_DEBUG_PADDING=on in the next examples forces libsmartcols
print '.' as a padding char. See line "ffff" in the exmaples.

* default output is to fill all except last cell

	$ LIBSMARTCOLS_DEBUG_PADDING=on ./sample-scols-fromfile --nlines 10  --width 80 --column tests/ts/libsmartcols/files/col-name --column tests/ts/libsmartcols/files/col-number --column tests/ts/libsmartcols/files/col-string --column tests/ts/libsmartcols/files/col-string tests/ts/libsmartcols/files/data-string tests/ts/libsmartcols/files/data-number tests/ts/libsmartcols/files/data-string-empty tests/ts/libsmartcols/files/data-string-empty 2> /dev/null
	NAME.. ......NUM STRINGS STRINGS
	aaaa.. ........0 aaaa... aaaa
	bbb... ......100 bbb.... bbb
	ccccc. .......21 ccccc.. ccccc
	dddddd ........3 dddddd. dddddd
	ee.... ......411 ee..... ee
	ffff.. .....5111 .......
	gggggg 678993321 gggggg. gggggg
	hhh... ..7666666 hhh.... hhh

* scols_table_enable_minout() minimizes output for tailing empty cells, example:

	$ LIBSMARTCOLS_DEBUG_PADDING=on ./sample-scols-fromfile --nlines 10 --minout  --width 80 --column tests/ts/libsmartcols/files/col-name --column tests/ts/libsmartcols/files/col-number --column tests/ts/libsmartcols/files/col-string --column tests/ts/libsmartcols/files/col-string tests/ts/libsmartcols/files/data-string tests/ts/libsmartcols/files/data-number tests/ts/libsmartcols/files/data-string-empty tests/ts/libsmartcols/files/data-string-empty 2> /dev/null
	NAME.. ......NUM STRINGS STRINGS
	aaaa.. ........0 aaaa... aaaa
	bbb... ......100 bbb.... bbb
	ccccc. .......21 ccccc.. ccccc
	dddddd ........3 dddddd. dddddd
	ee.... ......411 ee..... ee
	ffff.. .....5111
	gggggg 678993321 gggggg. gggggg
	hhh... ..7666666 hhh.... hhh

* cleanup up scols_table_enable_maxout() use, example:

	$ LIBSMARTCOLS_DEBUG_PADDING=on ./sample-scols-fromfile --nlines 10 --maxout  --width 80 --column tests/ts/libsmartcols/files/col-name --column tests/ts/libsmartcols/files/col-number --column tests/ts/libsmartcols/files/col-string --column tests/ts/libsmartcols/files/col-string tests/ts/libsmartcols/files/data-string tests/ts/libsmartcols/files/data-number tests/ts/libsmartcols/files/data-string-empty tests/ts/libsmartcols/files/data-string-empty 2> /dev/null
	NAME.............. ..................NUM STRINGS............ STRINGS............
	aaaa.............. ....................0 aaaa............... aaaa...............
	bbb............... ..................100 bbb................ bbb................
	ccccc............. ...................21 ccccc.............. ccccc..............
	dddddd............ ....................3 dddddd............. dddddd.............
	ee................ ..................411 ee................. ee.................
	ffff.............. .................5111 ................... ...................
	gggggg............ ............678993321 gggggg............. gggggg.............
	hhh............... ..............7666666 hhh................ hhh................

Note that we cannot make scols_table_enable_minout() default because
for example "column --table" is pretty commonly used with non-blank
columns separator and in this case all cells has to be filled.

	$ echo -e "aa,b,ccc\na,,\naaa,bbb,ccc" |  column --table --separator ',' --output-separator '|'
	aa |b  |ccc
	a  |   |
	aaa|bbb|ccc

Addresses: https://github.com/karelzak/util-linux/issues/826
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-23 16:24:42 +02:00
Karel Zak 10c39f03a1 libfdisk: improve partition copy on resize
It seems pretty fragile to copy also reference counting and reference
to table list.

Addresses: https://github.com/karelzak/util-linux/pull/822
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-22 12:09:38 +02:00
Karel Zak 1768d77c18 libblkid: (drbd) fix comment formatting
... to avoid misinterpretation by gtk-docs.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-22 11:49:45 +02:00
Karel Zak 68cf159b07 Merge branch 'master_fix-partition-copy' of https://github.com/vojtechtrefny/util-linux 2019-07-22 11:35:12 +02:00
Karel Zak c64d452b3e fstrim: fix systemd service protection
ProtectHome=yes makes /home inaccessible, but we need to open the
directories (mountpoints) read-only.

Addresses: https://github.com/karelzak/util-linux/issues/824
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-22 11:10:30 +02:00
Vojtech Trefny 79f37ec4e1 libfdisk: Fix double free of *_chs strings in fdisk_partition
__copy_partition doesn't duplicate these strings which leads to
occasional double free.

Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
2019-07-19 13:42:49 +02:00
Karel Zak 1ace839781 libfdisk: don't use NTFS as MBR
Same as 7c643ed285.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-17 12:42:39 +02:00
Karel Zak cdb9140967 libblkid: do not interpret NTFS as MBR
# mkntfs -Q -F /dev/sdc

old version:
 # ./blkid -p /dev/sdc
 /dev/sdc: UUID="0E9E8C5F2F718479" TYPE="ntfs" USAGE="filesystem" PTTYPE="dos"

new version:
 # ./blkid -p /dev/sdc
 /dev/sdc: UUID="0E9E8C5F2F718479" TYPE="ntfs" USAGE="filesystem"

Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-17 12:35:45 +02:00
Karel Zak 7c643ed285 libfdisk: don't use FAT as MBR
The current libfdisk MBR detection is too weak, the result is that it
reuses MBR from FAT. The correct behavior is to create a new MBR, wipe
first sector (on write) and warn about obsolete FAT superblock.

Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-17 12:11:38 +02:00
Karel Zak b106229206 build-sys: improve hwclock CMOS dependences
Let's use standard UL_* macros to check for dependencies
(architectures and hwclock).

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-15 15:32:49 +02:00
Karel Zak c7eca69d6d build-sys: add UL_REQUIRES_ARCH()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-15 15:31:40 +02:00
Carlos Santos 88bc304ba8 hwclock: use CMOS clock only if available
- Add --disable-hwclock-cmos configuration argument
- Add USE_HWCLOCK_CMOS (enabled by default for i386/x86_64)
- Add define(USE_HWCLOCK_CMOS)
- Compile hwclock-cmos.c only if USE_HWCLOCK_CMOS is true
- Remove all unnecessary #ifdefs from hwclock-cmos.c
- Add #ifdef USE_HWCLOCK_CMOS around the determine_clock_access_method()
  call in hwclock.c

Signed-off-by: Carlos Santos <unixmania@gmail.com>
2019-07-15 13:56:13 +02:00
Karel Zak 8ebecc18e8 tests: (libmount) make X-* and x-* more robust
Addresses: https://github.com/karelzak/util-linux/issues/818
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-15 12:46:11 +02: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
Karel Zak 5c8a88356d libblkid: (drbd) simplify padding
We do not need all the metadata and it seems the extra padding is
problematic in some cases. Let's keep is simple and use fixed offset
for the metadata rather than sizeof().

References: https://github.com/karelzak/util-linux/pull/820
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-15 12:07:42 +02:00
Karel Zak 6744302ce5 Merge branch '2019wk27' of https://github.com/kerolasa/util-linux
* '2019wk27' of https://github.com/kerolasa/util-linux:
  libblkid: fix address sanitizer issues
  libblkid: check number of test_blkid_save arguments correctly
  include/xalloc: ensure xstrdup() and xstrndup() returns nonnull attribute
  libmount: fix potential null pointer dereference
  libfdisk: fix variable shadowing
  lib/ttyutils: avoid checking same thing twice
2019-07-15 11:37:17 +02:00
Florian Weimer 1632856ef1 build-sys: Include <stdlib.h> in ./configure wchar_t test
Without #include <stdlib.h>, this configure check fails for strict
C99/C11 compilers which do not support implicit function declarations
(which are a C90 feature removed from C99).

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-15 11:06:21 +02:00
Sami Kerola f55dd4cc2d
libblkid: fix address sanitizer issues
With aligned attribute many blkid tests fail with following error.  So
instead of aligning to 4K add padding that makes the struct same size
without causing asan trip over.

    libblkid/src/superblocks/drbd.c:179:6: runtime error: member access
    within misaligned address 0x55913d7e6958 for type 'struct
    meta_data_on_disk_9', which requires 4096 byte alignment

In zfs structure it seems compiler is adding padding, that does not mix well
with be32_to_cpu() and other bit operations.

    libblkid/src/superblocks/zfs.c:109:23: runtime error: load of misaligned
    address 0x7ff6406540e4 for type 'uint32_t' (aka 'unsigned int'), which
    requires 8 byte alignment

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-14 11:53:59 +01:00
Sami Kerola 9175f39075
libblkid: check number of test_blkid_save arguments correctly
Without this running test_blkid_save without arguments will cause a crash
when strdup() refers to none-exiting file name.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-14 11:53:59 +01: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
Sami Kerola 371be858d7
libmount: fix potential null pointer dereference
This is false positive warning, but lets silence it so that if and when
warnings crop up they are easy to notice and take seriously.

libmount/src/optstr.c:354:29: warning: potential null pointer dereference
[-Wnull-dereference]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-12 22:09:31 +01:00
Sami Kerola 34813bdd29
libfdisk: fix variable shadowing
libfdisk/src/context.c:678:7: warning: declaration of ‘rc’ shadows a
previous local [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-12 21:45:50 +01:00
Sami Kerola 5119ef0a83
lib/ttyutils: avoid checking same thing twice
Check cols and lines are not NULL only once.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-01 22:02:06 +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
Sanchit Saini cfb9934d5f
TODO: fix typo 2019-06-21 23:21:46 +05:30
Stanislav Brabec d670a3f30b Fix translations for losetup typo fix
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2019-06-21 14:38:33 +02:00
Stanislav Brabec ec06412c90 losetup: Typo fix
Fix a typo in usage introduced in a1a41597bf.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2019-06-21 14:38:32 +02:00
Stanislav Brabec b0853a08db agetty: Remove superfluous fflush()
eval_issue_file() contains fflush(stdout). It comes from an old code that
used fputs() to write to the console.

In the new code, we write to a temporary memstream, and
fclose(ie->output) fully replaces possible fflush(ie->output) in this
implementation.

The new print_issue_file() does not need it as well, as it uses
unbuffered write_all().

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2019-06-21 14:38:32 +02:00
Marcos Mello f1424a9423 libfdisk: fix typos 2019-06-20 08:22:25 -03:00