summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* partx: document -d vs. --nr and fix testHEADmasterKarel Zak2019-08-212-3/+11
| | | | | | | | | | The commit ab025087f91b66ee8e23a16bc49eb0d9bd421d65 has disabled error message, but unfortunately it keeps wrong return code. This has been fixed by commit 53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555. This commit add hit about it to docs and fix regression test too. Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: don't report ENXIO as error on -dKarel Zak2019-08-211-2/+1Star
| | | | | | | | | | | | | | | | | The errno ENXIO should be ignored, unfortunately the current code uses variable 'rc' for ioctl return code as well as for final del_parts() return value. So, failed ioctl (which should be ignored) affects all del_parts() status. # modprobe scsi_debug dev_size_mb=100 # partx -d --nr 1-1024 /dev/sdc; echo $? 1 The device dos not contains any partitions, so 0 return code is expected in this case. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix comment referring to passno fieldPatrick Steinhardt2019-08-201-1/+1
| | | | | | | | | | | There's an obvious copy-paste error in `mnt_parse_table_line` when referring to the 6th field of the fstab format, where it says "freq" instead of "passno". This has probably been copied from the 5th field, which is in fact correctly labelled as "freq". Fix the mistake by changing the comment to say "passno" instead. Signed-off-by: Patrick Steinhardt <ps@pks.im>
* wdctl: remove duplicate include of <unistd.h>Patrick Steinhardt2019-08-191-1/+0Star
| | | | | | | The <unistd.h> header is included twice in "wdctl.c". Remove one of these includes to keep "make checkincludes" happy. Signed-off-by: Patrick Steinhardt <ps@pks.im>
* libmount: Keep the mnt_tab info for the existent dest in mnt_copy_fs()Kevin Hao2019-08-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | The "umount -f -a -r" get stuck in a endless loop when run with a mountinfo like below: 15 0 179:2 / / ro,relatime - ext4 /dev/root ro 16 15 0:6 / /dev rw,relatime - devtmpfs devtmpfs rw,size=242896k,nr_inodes=60724,mode=755 17 15 0:4 / /proc rw,relatime - proc proc rw 18 15 0:15 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k 19 15 0:16 / /sys rw,relatime - sysfs sysfs rw 20 19 0:7 / /sys/kernel/debug rw,relatime - debugfs debugfs rw 21 15 0:17 / /run rw,nosuid,nodev - tmpfs tmpfs rw,mode=755 22 15 0:18 / /var/volatile rw,relatime - tmpfs tmpfs rw 23 15 179:1 / /boot rw,relatime - vfat /dev/mmcblk0p1 rw,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 24 16 0:19 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 25 18 0:20 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k The reason is that the two same mnt entry "/mnt/.psplash" will cause the dst->tab set to NULL when umount this mnt entry the second time. This will trigger an endless loop in mnt_reset_table() because that mnt entry is linked on the libmnt_table but its .tab is set to NULL. Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
* tests: Skip fdisk/mbr-nondos-mode on Sparc as unsupportedKarel Zak2019-08-192-194/+2Star
| | | | | | | | | The test has been originally designed as usable on sparc, but now we use it for many features which are MBR specific. Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Co-Author: Anatoly Pugachev <matorola@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* chfn: don't append extra tailing commasKarel Zak2019-08-191-1/+1
| | | | | | | | | | | | | | | | | | | # grep kzak /etc/passwd kzak:x:1000:1000::/home/kzak:/bin/bash # chfn kzak ... grep kzak /etc/passwd old version: kzak:x:1000:1000:Karel Zak,,,,:/home/kzak:/bin/bash fixed version: kzak:x:1000:1000:Karel Zak:/home/kzak:/bin/bash Reported-by: Filip Dvorak <fdvorak@redhat.com> References: f723cbf544a7eac2927634f2cb6d802437a2d519 Signed-off-by: Karel Zak <kzak@redhat.com>
* Remove unused utime.h headerRosen Penev2019-08-081-1/+0Star
| | | | | It is sometimes unavailable and errors on inclusion. For example, when disabled in uClibc-ng.
* Remove isascii usageRosen Penev2019-08-083-3/+7
| | | | | | | There is a c_isascii function that can be used. isascii is deprecated and not available with some libcs like uClibc-ng where it can be compile time disabled.
* tests: update fdisk outputKarel Zak2019-08-081-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (script) support shortcuts in the type= fieldKarel Zak2019-08-082-3/+9
| | | | | | | | | | | | | | | | | | | | 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>
* tests: use subtests for mountpoint(1)Karel Zak2019-08-075-13/+12Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'issue832' of https://github.com/kerolasa/util-linuxKarel Zak2019-08-075-5/+59
|\ | | | | | | | | * 'issue832' of https://github.com/kerolasa/util-linux: mountpoint: add --nofollow option
| * mountpoint: add --nofollow optionSami Kerola2019-08-025-5/+59
| | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'master' of https://github.com/chstarkd/util-linuxKarel Zak2019-08-071-1/+1
|\ \ | | | | | | | | | | | | | | | * 'master' of https://github.com/chstarkd/util-linux: removed double space fixed mount man page typo, "bythe" -> "by the"
| * | removed double spaceChistyj Arkadij2019-08-041-1/+1
| | |
| * | fixed mount man page typo, "bythe" -> "by the"Chistyj Arkadij2019-08-041-1/+1
| |/
* / libfdisk: refer to partx(8) rather than to kpartx(8)Karel Zak2019-08-061-1/+1
|/ | | | | Reported-by: Petr Pisar <petr.pisar@atlas.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: fix output hex encodingKarel Zak2019-08-011-11/+15
| | | | | | | 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>
* choom: improve docsKarel Zak2019-08-012-1/+2
| | | | | | | | 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>
* libblkid: fix file descriptor leak in blkid_verify()Karel Zak2019-07-312-4/+19
| | | | | | | | | | | | | | 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>
* Merge branch '2019wk29' of https://github.com/kerolasa/util-linuxKarel Zak2019-07-291-1/+1
|\ | | | | | | | | * '2019wk29' of https://github.com/kerolasa/util-linux: lscpu: prefer memcpy() to manual pointer arithmetic
| * lscpu: prefer memcpy() to manual pointer arithmeticSami Kerola2019-07-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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>
* | column: fix outputing empty column at the end of lineYousong Zhou2019-07-294-1/+11
|/ | | | | | | | | | | | | 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>
* lscpu: (man) add note about cache sizesKarel Zak2019-07-251-0/+5
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/827 Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: simplify code in dolog() preprocessor blocksSami Kerola2019-07-241-26/+20Star
| | | | | | | | 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>
* login: simplify string handlingSami Kerola2019-07-241-4/+1Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: replace strncat() with more robust mem2strcpy()Sami Kerola2019-07-241-2/+1Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* tests: (fdisk) update padding in outputKarel Zak2019-07-231-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: (libsmartcols) add padding testsKarel Zak2019-07-235-0/+89
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: cleanup and extend padding functionalityKarel Zak2019-07-239-45/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libfdisk: improve partition copy on resizeKarel Zak2019-07-221-0/+6
| | | | | | | | 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>
* libblkid: (drbd) fix comment formattingKarel Zak2019-07-221-3/+4
| | | | | | ... to avoid misinterpretation by gtk-docs. Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'master_fix-partition-copy' of ↵Karel Zak2019-07-221-0/+4
|\ | | | | | | https://github.com/vojtechtrefny/util-linux
| * libfdisk: Fix double free of *_chs strings in fdisk_partitionVojtech Trefny2019-07-191-0/+4
| | | | | | | | | | | | | | __copy_partition doesn't duplicate these strings which leads to occasional double free. Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
* | fstrim: fix systemd service protectionKarel Zak2019-07-221-1/+1
|/ | | | | | | | 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>
* libfdisk: don't use NTFS as MBRKarel Zak2019-07-171-1/+3
| | | | | | Same as 7c643ed2855058657798d9e8e80701023de14a08. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: do not interpret NTFS as MBRKarel Zak2019-07-173-1/+31
| | | | | | | | | | | | | | | # 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>
* libfdisk: don't use FAT as MBRKarel Zak2019-07-172-5/+15
| | | | | | | | | 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>
* build-sys: improve hwclock CMOS dependencesKarel Zak2019-07-151-10/+9Star
| | | | | | | Let's use standard UL_* macros to check for dependencies (architectures and hwclock). Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: add UL_REQUIRES_ARCH()Karel Zak2019-07-151-1/+41
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* hwclock: use CMOS clock only if availableCarlos Santos2019-07-154-43/+26Star
| | | | | | | | | | | | - 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>
* tests: (libmount) make X-* and x-* more robustKarel Zak2019-07-153-3/+4
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/818 Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: fix -E segfaultKarel Zak2019-07-151-0/+2
| | | | | | | | 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>
* libblkid: (drbd) simplify paddingKarel Zak2019-07-151-4/+14
| | | | | | | | | 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>
* Merge branch '2019wk27' of https://github.com/kerolasa/util-linuxKarel Zak2019-07-158-18/+24
|\ | | | | | | | | | | | | | | | | | | * '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
| * libblkid: fix address sanitizer issuesSami Kerola2019-07-142-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * libblkid: check number of test_blkid_save arguments correctlySami Kerola2019-07-141-1/+1
| | | | | | | | | | | | | | 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>
| * include/xalloc: ensure xstrdup() and xstrndup() returns nonnull attributeSami Kerola2019-07-142-5/+9
| | | | | | | | | | | | | | 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>
| * libmount: fix potential null pointer dereferenceSami Kerola2019-07-121-1/+3
| | | | | | | | | | | | | | | | | | | | 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>