summaryrefslogtreecommitdiff
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'nsenter-keep-caps' of https://github.com/dgibson/util-linuxKarel Zak2023-05-171-0/+2
|\ | | | | | | | | | | * 'nsenter-keep-caps' of https://github.com/dgibson/util-linux: Add --keep-caps option to nsenter, similar to the one in unshare unshare: Move implementation of --keep-caps option to library function
| * unshare: Move implementation of --keep-caps option to library functionDavid Gibson2023-03-291-0/+2
| | | | | | | | | | | | | | | | unshare.c open codes some logic to copy the permitted capability set to the ambient set in order to implement the --keep-caps option. Move this logic to lib/caputils.c so that we can reuse it in nsenter. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* | c.h: make err_nonsys availableThomas Weißschuh2023-05-161-0/+3
| | | | | | | | Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
* | include/mount-api-utils: make fallback more portableKarel Zak2023-04-241-0/+4
| | | | | | | | | | Addresses: https://github.com/util-linux/util-linux/issues/2186 Signed-off-by: Karel Zak <kzak@redhat.com>
* | lib: Add crc32c function that can deal with holesJeremy Linton2023-04-141-0/+4
|/ | | | | | | | | | XFS, and possibly other filesystems expect that the CRC field is excluded (or rather RAZ) during the CRC operation. Lets create a generic helper that is similar to the CRC32 version ul_crc32_exclude_offset() which computes the CRC while replacing exclude_len bytes of exclude_off with zeros. Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
* libmount: add missing MOUNT_ATTR_NODEVKarel Zak2023-03-231-0/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* wall: use fputs_careful()наб2023-03-171-9/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | LINE_MAX only applies to teletypes in canonical mode: when stdin is a file, it could still very much tear; start off at 512 for the sprintf(), then use getline() like in write. The line wrapping has one suboptimal edge-case: $ wall < all Broadcast message from nabijaczleweli@tarta (pts/4) (Tue Mar 14 22:31:25 2023): ^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ KLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?\200\201\202\203\204\205\206 \207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232 \233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256 \257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302 \303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326 \327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352 \353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376 \377 but that's a pathological input, and the result is still infinitely better than it was before, so fixing that is more trouble than it's worth. Bug-Debian: https://bugs.debian.org/826596
* write: correctly handle wide charactersнаб2023-03-171-16/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do this by replacing fputc_careful() (notice that the description said it's locale-aware ‒ it very much is /not/), with a fputs_careful() which does the same thing, but if it were to output a byte in the \123 format, first it checks whether this byte starts a valid multibyte character. If it does, and that character is printable, write it verbatim. This means that echo 'foo åäö ąęćźżń bar' | write nabijaczleweli pts/4 instead of foo \303\245\303\244\303\266 \304\205\304\231\304\207\305\272\305\274\305\204 bar yields foo åäö ąęćźżń bar or, more realistically, from a message I got earlier today, Filip powiedzia\305\202 \305\274e zap\305\202aci jutro becomes Filip powiedział że zapłaci jutro Invalid/non-printable sequences get processed as before. Line reading in write must become getline() to avoid dealing with partial characters: for example on input consisting solely of ąęćźżń, where every {1} is an instance, the output would be {42}ąęć\305\272żń{84}ąęćź\305\274ń{84}ąęćźż\305\204{39} with just fixed-512 fgets() Bug-Debian: https://bugs.debian.org/826596
* nsenter: add --env for allowing environment variables inheritanceu23862023-03-022-1/+31
| | | | | | | | | | | | | | | | | | | | | | | | This commit adds support for the -e or --env option in nsenter, allowing a new process to inherit the environment va If the option is not given, the environment variables will stay the same as in the current namespace. Example: Setup the namespace: $ docker run -d -e PROJECT='util linux' --rm alpine sleep 10000 cb0b69aa7aec $ docker inspect --format '{{ .State.Pid }}' cb0b69aa7aec 470012 Enter the namespace: $ nsenter --all -t 470012 --env env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=cb0b69aa7aec PROJECT=util linux HOME=/root Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de> Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: u2386 <hugo.cavan2386@gmail.com>
* include/c: make err_oom() usable everywhereKarel Zak2023-03-022-10/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/fileutils: remove duplicated includeKarel Zak2023-03-021-1/+0
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: remove duplicate include, improve readablityKarel Zak2023-03-021-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: move colors canonicalization to lib/color-names.cKarel Zak2023-02-271-0/+3
| | | | | | | | | | | | | | * let's make simplified sequences (e.g. "35;4") used without lib/colors.c (without color schemes) * add function to detect already usable esc sequence * support this new feature in "test_colors --color <name|seq|...>" ./test_colors --color "red" ./test_colors --color "35;5" Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: introduce color_get_disable_sequence()Thomas Weißschuh2023-02-151-0/+2
| | | | Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
* include: improve statx fallbackKarel Zak2023-02-141-2/+2
| | | | | Addresses: https://github.com/util-linux/util-linux/pull/2065 Signed-off-by: Karel Zak <kzak@redhat.com>
* include: cleanup close_range fallbackKarel Zak2023-02-131-3/+1
| | | | | | | * let's use && operator rather than if-if * define HAVE_CLOSE_RANGE only if callback is really avalable Signed-off-by: Karel Zak <kzak@redhat.com>
* include: add fallback for statxKarel Zak2023-02-131-0/+14
| | | | | Fixes: https://github.com/util-linux/util-linux/pull/2065 Signed-off-by: Karel Zak <kzak@redhat.com>
* include/cctype: fix License headerKarel Zak2023-02-021-26/+21
| | | | | | | | This file has been originally imported from gnulib with GPL header, but it's now available with LGPLv2+ now (since gnulib commit https://git.savannah.gnu.org/cgit/gnulib.git/commit/lib/c-ctype.h?id=5ffa144085078c72e7d60759ab2d6100b04cd2c2). Fixes: https://github.com/util-linux/util-linux/issues/2050 Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'dmesg-subsecond' of https://github.com/t-8ch/util-linuxKarel Zak2023-01-252-1/+22
|\ | | | | | | | | | | | | | | | | * 'dmesg-subsecond' of https://github.com/t-8ch/util-linux: dmesg: use subsecond granularity in iso format dmesg: add subsecond granularity for --since and --until lib/monotonic: get_suspended_time: use usec_t timeutils: add utilities for usec_t conversions dmesg: add test for --since and --until
| * lib/monotonic: get_suspended_time: use usec_tThomas Weißschuh2023-01-241-1/+3
| | | | | | | | Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
| * timeutils: add utilities for usec_t conversionsThomas Weißschuh2023-01-241-0/+19
| | | | | | | | Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
* | lib/sysfs: add function blkdev_is_removableThomas Weißschuh2023-01-241-0/+1
| | | | | | | | | | | | | | This exactly represents the kernels notion of a "removable" blockdevice. That is, the device itself is persistent but can contain some sort of medium that can be changed at runtime. Specifically it is *not* hotpluggable.
* | include/c: add functions to print from signal handlersKarel Zak2023-01-241-0/+23
|/ | | | | Addresses: https://github.com/util-linux/util-linux/pull/2019 Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: add sizeof_member()Karel Zak2023-01-201-0/+4
| | | | | | This macro returns size of struct member. Signed-off-by: Karel Zak <kzak@redhat.com>
* c.h: fix compiler warning [-Werror=shift-count-overflow]Karel Zak2023-01-171-1/+1
| | | | | | | | | It's probably typo in the original path (too many brackets:-)). Let's be explicit about the types used in the calculation. '1 << n' means the left shift is on 'int', but we need '(t)1 << n'. Addresses: e53463ea40c58a6f84a597966ac69be9be72cd7d Signed-off-by: Karel Zak <kzak@redhat.com>
* c.h: really avoid undefined behavior in SINT_MAXThomas Weißschuh2023-01-141-1/+1
| | | | | | | | | | | | | | | The previous fix in #2013 still invoked undefined behavior by shifting into the sign-bit. Now we have a correct, albeit unwieldy solution that avoids undefined behavior. Instead of bit fiddling it uses plain addition and substraction. We are looking for (in LaTeX notation): 2^(n - 1) - 1 = 2 * 2^(n - 2) - 1 = 2^(n - 2) + 2^(n - 2) - 1 = 2^(n - 2) - 1 + 2^(n - 2)
* include: add missing license linesKarel Zak2023-01-1254-1/+234
| | | | | | | | | | The header files are usually based on code from lib/. This commit copies relevant license headers from lib/ to include/ to keep things consistent. The very generic things (e.g. MBR definitions) are always public domain. Fixes: https://github.com/util-linux/util-linux/issues/2010 Signed-off-by: Karel Zak <kzak@redhat.com>
* c.h: avoid undefined behavior in SINT_MAX macroThomas Weißschuh2023-01-121-1/+1
| | | | | | | | | The previous implementation relied on signed-integer overflow. This is undefined behavior. Instead use an implementation that only requires twos-complement representation. This is what everybody uses anyways and it will be required by C23.
* include: add MOVE_MOUNT_SET_GROUP fallbackKarel Zak2023-01-101-0/+4
| | | | | Addresses: https://github.com/torvalds/linux/commit/9ffb14ef61bab83fa818736bf3e7e6b6e182e8e2 Signed-off-by: Karel Zak <kzak@redhat.com>
* strutils: add function strtotimespec_or_errThomas Weißschuh2023-01-061-0/+2
|
* Merge branch 'waitpid' of https://github.com/t-8ch/util-linuxKarel Zak2023-01-044-0/+6
|\ | | | | | | | | | | | | | | * 'waitpid' of https://github.com/t-8ch/util-linux: waitpid: add new command tests: add ts_skip_exitcode_not_supported exitcodes: add EXIT_NOTSUPP pidfd-utils: include wait.h for siginfo_t
| * waitpid: add new commandThomas Weißschuh2023-01-042-0/+3
| | | | | | | | | | | | | | | | | | This command implements waiting for the exit of multiple processes. Especially it allows to wait for process that are not children of the current process. In contrast to wait(1P) it does not allow to retrieve the processes exit codes.
| * exitcodes: add EXIT_NOTSUPPThomas Weißschuh2023-01-031-0/+2
| |
| * pidfd-utils: include wait.h for siginfo_tThomas Weißschuh2023-01-031-0/+1
| |
* | include/cctype: add c_strcasecmp() and c_strncasecmp()Karel Zak2023-01-041-0/+34
|/ | | | | | | | Sometimes, we need to compare ASCII-only strings independently on the current locales. Let's follow our cctype.h to implement such functions. Addresses: https://github.com/util-linux/util-linux/issues/1991 Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: add --disable-libmount-mountfd-supportKarel Zak2023-01-031-18/+3
| | | | | | | | | | We need to disable support for new kernel API in libmount to test the old code on new kernels (or maybe also for conservative users). The new configure option disable only mount(2)-like operations, the another stuff (like IDs mapping) is not affected. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add MOUNT_ATTR_NOSYMFOLLOWKarel Zak2023-01-031-4/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/mount-api-utils: use standard uint64_tKarel Zak2023-01-031-5/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add optlist testsKarel Zak2023-01-031-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/mount-api-utils: add new syscallsKarel Zak2023-01-031-1/+71
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/mount-api-utils: cleanupKarel Zak2023-01-031-16/+16
| | | | | | | | | | | | * use SYS_* macros * check for the syscalls in configure.ac * use SYS_* macros for #ifdefs * add "idmapping" to the list if libmount features Signed-off-by: Karel Zak <kzak@redhat.com>
* include/mount-api-utils: fix indentionKarel Zak2023-01-031-29/+29
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: check for mount_attr in linux/mount.hKarel Zak2023-01-031-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include: add mount-api-utils.hChristian Brauner2023-01-032-0/+133
| | | | Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
* Merge branch 'blockdev' of https://github.com/t-8ch/util-linuxKarel Zak2023-01-021-0/+5
|\ | | | | | | | | * 'blockdev' of https://github.com/t-8ch/util-linux: blockdev: add support for ioctl BLKGETDISKSEQ
| * blockdev: add support for ioctl BLKGETDISKSEQThomas Weißschuh2022-12-281-0/+5
| |
* | sysfs: add helper for /sys/kernel/address_bitsThomas Weißschuh2022-12-212-0/+2
|/
* Merge branch 'fssize' of https://github.com/t-8ch/util-linuxKarel Zak2022-12-211-12/+13
|\ | | | | | | | | | | | | | | | | | | | | | | * 'fssize' of https://github.com/t-8ch/util-linux: libblkid: iso9660: read block size from superblock iso9660.h: avoid undefined signed integer shift iso9660.h: use more correct function types libblkid: ntfs: report fssize libblkid: ubifs: report fssize libblkid: f2fs: report fssize libblkid: erofs: report fssize libblkid: vfat: report fssize
| * iso9660.h: avoid undefined signed integer shiftThomas Weißschuh2022-12-151-2/+2
| | | | | | | | | | | | When the high bit in p[3] is set we would overflow our signed 4-byte integer result value. Force an unsigned type instead.
| * iso9660.h: use more correct function typesThomas Weißschuh2022-12-151-10/+11
| |