summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* lib/path: fix read string to be backwardly compatibleKarel Zak2018-06-211-0/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path lib/sysfs: add debugKarel Zak2018-06-215-2/+81
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: remove obsolete macroKarel Zak2018-06-211-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: use new ul_path_* APIKarel Zak2018-06-212-27/+27
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: add ul_new_sysfs_path() shortcutKarel Zak2018-06-212-20/+34
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: new implementationKarel Zak2018-06-213-606/+498Star
| | | | | | | | | * reuse ul_path_* API * allow to use prefix for sysfs paths, so we can use snapshots from sysfs for regression tests Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: new implementationKarel Zak2018-06-213-167/+1024
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to avoid duplicate code in path.c and sysfs.c and make it possible to define prefix for paths for all sysfs and procfs based utils. Now we have /proc snapshots (for tests) for lscpu only. It would be nice to have the same (for sysfs) for lsblk and another tools. * very simple API to read numbers, strings and symlinks * based on openat() pc = ul_new_path("/sys/block/sda"); ul_path_read_u64(pc, &size, "size"); ul_path_read_u64(pc, &lsz, "queue/logical_block_size"); * printf-like API to generate paths, for example: ul_path_readf_u64(pc, &num, "sda%d/size", partno) * allow to define prefix to redirect hardcoded paths to another location, for example: pc = ul_new_path("/sys/block/sda"); ul_path_set_prefix(pc, "/my/regression/dump"); ul_path_read_u64(pc, &num, "size"); to read /my/regression/dump/sys/block/sda/size * allow to extend the API by "dialects", for example for sysfs: pc = ul_new_path(NULL); sysfs_blkdev_init_path(pc, devno, NULL); and use ul_path_* functions to read from @pc initialized by sysfs_blkdev_init_path() * add test_path binary Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add partition table UUID and type fields.Milan Broz2018-06-191-0/+27
| | | | | | | | | | This patch adds PTUUID and PTTYPE fields to lsblk, that are corresponding fields to ID_PART_TABLE_UUID and ID_PART_TABLE_TYPE in udev database. [kzak@redhat.com: - small change in PTUUID description] Signed-off-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: exit with error code when partition read failedAndreas Henriksson2018-06-181-1/+3
| | | | | | | | | | | | | | | | | | | Make sure partx exits with a non-0 return code when it runs into either code-path where getting the partition table failed (or wasn't even attempted because of previous error condition). Change was tested using: touch /tmp/foobar partx -s - /tmp/foobar Previously that was only printing an error/warning message and then exiting with 0, but after this change it exits with 1. Signed-off-by: Andreas Henriksson <andreas@fatal.se> Reported-by: Juan Céspedes <cespedes@debian.org> Addresses: https://bugs.debian.org/898426
* setarch: add another PER_LINUX32 aliases for ppcleKarel Zak2018-06-141-0/+2
| | | | | | | | | The big-endian version maps generic "ppc" and "ppc32" aliases to PER_LINUX32. It seems that we can do the same for little-endian. Note that SYS_personality does not care about LE/BE, it's 32 or 64 bit. Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: update TODOKarel Zak2018-06-111-13/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: add -N to man page helpers sectionKarel Zak2018-06-112-1/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* umount: fix behaviour of -A and -R with --namespaceVaclav Dolezal2018-06-111-1/+10
| | | | | | | Load /proc/self/mountinfo from correct namespace. Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* umount: allow PID as --namespace argumentVaclav Dolezal2018-06-112-3/+25
| | | | | | | [kzak@redhat.com: - update code] Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* mount: allow PID as --namespace argumentVaclav Dolezal2018-06-112-3/+26
| | | | | | | [[kzak@redhat.com: - update code] Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* mount: document --namespace in man/helpVaclav Dolezal2018-06-114-0/+11
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: switch namespace when appropriateVaclav Dolezal2018-06-114-19/+241
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: support for namespaces for helpersVaclav Dolezal2018-06-112-5/+37
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: make errno usable after mnt_context_set_target_ns()Karel Zak2018-06-113-16/+10Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* umount: add support for namespacesVaclav Dolezal2018-06-111-1/+11
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* mount: add support for namespacesVaclav Dolezal2018-06-111-1/+11
| | | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: added error MNT_ERR_NAMESPACEVaclav Dolezal2018-06-113-0/+22
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: note namespaces in mnt_reset_context() docsVaclav Dolezal2018-06-111-2/+3
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libmount: add support for switching namespacesVaclav Dolezal2018-06-115-0/+242
| | | | | | | [kzak@redhat.com: - cosmetic changes, add some comments] Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* wipefs: postpone BLKRRPART until all is doneKarel Zak2018-06-112-7/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* zramctl: (man) explain that --find is necessaryKarel Zak2018-06-111-1/+6
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1589148 Signed-off-by: Karel Zak <kzak@redhat.com>
* blkzone: fix whole device detectionKarel Zak2018-06-081-4/+5
| | | | | | | | | | | | | | Matias Bjørling wrote: The current detection code for chunk size assumes that the underlying device is a device that uses the minor device id as the partition id, and that the whole device has minor id 0. This is not true for example null_blk and nvme device drivers. Let's use sysfs_devno_to_wholedisk() to get whole-disk devno. Addresses: https://github.com/karelzak/util-linux/pull/646 Reported-by: Matias Bjørling matias.bjorling@wdc.com Signed-off-by: Karel Zak <kzak@redhat.com>
* losetup: keep -f and <devname> mutually exclusiveKarel Zak2018-06-071-0/+3
| | | | | | | | | | | | | | | | losetup tries to blindly use specified device as well as search for the first free device, the result is: # losetup /dev/loop1 -f /tmp/tfile_loop1 losetup: /dev/loop1: failed to set up loop device: Invalid argument fixed version: # losetup /dev/loop10 -f img losetup: unexpected arguments Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1566432 Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: keep c_iflags unmodified on --autologinKarel Zak2018-06-062-4/+17
| | | | | | | | | | | | | | | agetty sets c_iflags according to interaction with serial line in get_logname(). For --autologin it does not read from the line, so we have no clue how to set the flags. The current behavior is to zeroize the flags. Unfortunately, it seems like bad idea, because the line may be already properly initialized by kernel (or systemd, etc.). The new behavior is not touch the flags on --autologin. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1252764 Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: add empty column testKarel Zak2018-06-042-0/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: don't print empty columnKarel Zak2018-06-041-2/+9
| | | | | | | | | | | | | | | | The commit 0f9f927b6f62cb7f488fadfad76c4a5defdefe36 forces libsmartcols to use one byte as a minimal column width. This seems like a bug if the column is empty and without header. $ printf ':a:b\n' | column -t -s ':' -o ':' :a:b Fixed version: $ printf ':a:b\n' | column -t -s ':' -o ':' :a:b Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: keep MS_MOVE as flagKarel Zak2018-06-012-3/+10
| | | | | | | | The previous commit 4ebea84bb1ca6b0fa817588aba13de26c8d5e5a0 replaced all operations by strings, but it does not work for MS_MOVE as this operation is not supported in fstab by libmount. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: don't use MS_MGC_VAL magic in mount(2) syscallKarel Zak2018-06-013-4/+3Star
| | | | | | | | | Specifying MS_MGC_VAL was required in kernel versions prior to 2.4, but since Linux 2.4 is no longer required and is ignored if specified The minimal kernel requirement for util-linux is Linux v2.6. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: improve MS_REC usageKarel Zak2018-06-013-6/+33
| | | | | | | | | | | | | | | | | | | | | | | | | libmount allows to split one library (mount(8)) call to multiple mount(2) syscalls, for example --rbind --make-rslave in this case we have to be careful with MS_REC because the flag is applied to multiple operations. # strace -e mount mount --rbind --make-rslave /mnt/A /mnt/B Old version: mount("/mnt/A", "/mnt/B", 0x13ecac0, MS_MGC_VAL|MS_BIND, NULL) = 0 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0 Fixed version: mount("/mnt/A", "/mnt/B", 0x1f22ac0, MS_MGC_VAL|MS_BIND|MS_REC, NULL) = 0 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1584443 Signed-off-by: Karel Zak <kzak@redhat.com>
* mount: use internally string to set move/bind operationsKarel Zak2018-06-011-8/+7Star
| | | | | | | | | It's better to inform libmount about operations by string than by flags, because for example "rbind,slave" cannot be specified by MS_REC|MS_BIND|MS_SLAVE. https://bugzilla.redhat.com/show_bug.cgi?id=1584443 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: include sys/mount.h on Linux onlyKarel Zak2018-05-291-1/+1
| | | | | Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=891812 Signed-off-by: Karel Zak <kzak@redhat.com>
* po: fix lsblk translationKarel Zak2018-05-291-1/+1
| | | | | Reported-by: Rosberg Nascimento Freitas Rodrigues <rosberg.berg@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: accept another flags on MS_REMOUNT|MS_BINDKarel Zak2018-05-283-16/+14Star
| | | | | | | | | | | | | | | | | | | | | | The current libmount MS_REMOUNT|MS_BIND support is restricted to MS_RDONLY (read-only bind mount). This is too restrictive as Linux kernel supports bind-remount for arbitrary VFS flags. After this update you can use # mount /dev/sdc1 /mnt/A # mount --bind -onosuid,noexec /mnt/A /mnt/B # findmnt /dev/sdc1 -oTARGET,SOURCE,FS-OPTIONS,VFS-OPTIONS TARGET SOURCE FS-OPTIONS VFS-OPTIONS /mnt/A /dev/sdc1 rw,stripe=512,data=ordered rw,relatime /mnt/B /dev/sdc1 rw,stripe=512,data=ordered rw,nosuid,noexec,relatime The "mount --bind" is composed from two syscalls of course (1st is bind, 2nd is bind,remount,nosuid,noexec). Addresses: https://github.com/karelzak/util-linux/issues/637 Signed-off-by: Karel Zak <kzak@redhat.com>
* mountpoint: simplify test condition [cppcheck]Sami Kerola2018-05-281-2/+1Star
| | | | | | | [sys-utils/mountpoint.c:79]: (style) Redundant condition: ctl->st.st_dev==pst.st_dev. 'A || (!A && B)' is equivalent to 'A || B' Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include/pt-mbr.h: fix integer overflowSami Kerola2018-05-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gcc -fsanitize=undefined gives following warning. include/pt-mbr.h:27:51: runtime error: left shift of 248 by 24 places cannot be represented in type 'int' It looks like char is converted internally to int before bit-shift, and that type overflows when char value is greater than 127. Following code snippet will show the effect what is stored when undefined behaviour happens. #include <stdio.h> #include <inttypes.h> int main(int argc, unsigned char **argv) { char p[] = { 170, 170, 170, 170 }; unsigned int uint = p[3]; uint64_t res = 0; /* overflow */ res = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); printf("%" PRIu64 "\n", res); /* this is fine */ res = 0; res = p[0] | (p[1] << 8) | (p[2] << 16) | (uint << 24); printf("%" PRIu64 "\n", res); return 0; } I tested gcc 8.1.0, clang 6.0.0, and tcc 0.9.27 and they all printed the same values. $ ./a.out 18446744073709551530 4294967210 Because output is result of undefined behavior what is stored may change in future, and other compilers / version might do something different. In the case of what pt-mbr.h the destination data type size was commonly 32 bits in size, that truncated excess rubbish from bitshift. Needless to say that was not very robust code. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* nls: remove translation stringsSami Kerola2018-05-285-7/+7
| | | | | | | | | | 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: e19cc7b65b31c57f0fe9cb73c9afad5197796f82 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* bash-completion: add swapon specifiers to completionSami Kerola2018-05-281-3/+18
| | | | | | | No space after device name is not entirely right, but that's better than missing argument completions. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rev: move a global variable to local scopeSami Kerola2018-05-281-3/+2Star
| | | | | | Mark also file names read-only. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* tests: move stderr redirection out from test expressionSami Kerola2018-05-281-1/+1
| | | | | | | | | | | | | Fix shellcheck error. if ! [ "$paraller_jobs" -ge 0 2>/dev/null ]; then ^-- SC1009: The mentioned parser error was in this if expression. ^-- SC1073: Couldn't parse this test expression. ^-- SC1072: Expected test to end here (don't wrap commands in []/[[]]). Fix any mentioned problems and try again. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/strutils: fix strnlen() fallbackKarel Zak2018-05-281-2/+2
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/643 Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'master' of https://github.com/pali/util-linuxKarel Zak2018-05-283-0/+20
|\ | | | | | | | | * 'master' of https://github.com/pali/util-linux: libblkid: udf: Fix reporting UDF 2.60 revision
| * libblkid: udf: Fix reporting UDF 2.60 revisionPali Rohár2018-05-253-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | According to the UDF 2.60 specification, the Minimum UDF Read Revision value shall be at most #0250 for all media with a UDF 2.60 file system. So in this case use Minimum UDF Write Revision as ID_FS_VERSION to distinguish between UDF 2.50 and UDF 2.60 discs. This commit also adds a testing Blu-Ray Recordable image with UDF revision 2.60 created by Nero which really sets Minimum UDF Read Revision to 2.50. Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
* | libblkid: (ntfs) fix cluster size checkKarel Zak2018-05-251-1/+1
|/ | | | | Addresses: https://github.com/karelzak/util-linux/issues/641 Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: (ntfs) enlarge cluster limit to 2MBKarel Zak2018-05-251-4/+8
| | | | | | | | | | Windows 10 Creators edition has extended the ntfs cluster limit to 2MB. As a consequence blkid does not identify recent partitions with clusters beyond 65K as ntfs ones. Addresses: https://github.com/karelzak/util-linux/issues/641 Signed-off-by: Karel Zak <kzak@redhat.com> Co-Author: Jean-Pierre André <jean-pierre.andre@wanadoo.fr>
* cfdisk: fix compiler warnings, follow-up 7085f1e4 (#636)Ruediger Meier2018-05-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Seen on OSX 10.13, xcode 9.3. disk-utils/cfdisk.c:1860:45: error: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat] DBG(UI, ul_debug("get_size (default=%ju)", *res)); ~~~ ^~~~ %llu disk-utils/cfdisk.c:267:60: note: expanded from macro 'DBG' #define DBG(m, x) __UL_DBG(cfdisk, CFDISK_DEBUG_, m, x) ^ ./include/debug.h:67:4: note: expanded from macro '__UL_DBG' x; \ ^ disk-utils/cfdisk.c:1889:25: error: incompatible pointer types passing 'uint64_t *' (aka 'unsigned long long *') to parameter of type 'uintmax_t *' (aka 'unsigned long *') [-Werror,-Wincompatible-pointer-types] rc = parse_size(buf, &user, &pwr); /* parse */ ^~~~~ ./include/strutils.h:15:51: note: passing argument to parameter 'res' here extern int parse_size(const char *str, uintmax_t *res, int *power); ^ 2 errors generated. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>