]> git.ipfire.org Git - thirdparty/util-linux.git/commit
text-utils: add bits command
authorRobin Jarry <robin@jarry.cc>
Mon, 6 May 2024 21:45:21 +0000 (23:45 +0200)
committerRobin Jarry <robin@jarry.cc>
Thu, 24 Oct 2024 21:55:40 +0000 (23:55 +0200)
commit6e1301d59350338303b22b0f12098a176d9f0a86
tree22204f476b141792d5dd9fa011ed633509fac9a9
parentbc325a65d10ed6b136272fe64a67a042b81ae838
text-utils: add bits command

Add a new text utility to convert bit masks in various formats.

This can be handy to avoid parsing affinity masks in one's head and/or
to interact with the kernel in a more human friendly way. It is
a rewrite in C of the bits command from my linux-tools python package so
that it can be more widely available.

Here is an example:

 ~# cat /sys/kernel/debug/tracing/tracing_cpumask
 ffffffff,ffffffff,ffffffff,ffffffff
 ~# bits -l ,$(cat /sys/kernel/debug/tracing/tracing_cpumask)
 0-128
 ~# bits -g 58,59,120,123
 9000000,00000000,0c000000,00000000
 ~# bits -g 58,59,120,123 > /sys/kernel/debug/tracing/tracing_cpumask
 ~# echo 1 > /sys/kernel/debug/tracing/tracing_on

Add man page and basic tests.

Link: https://git.sr.ht/~rjarry/linux-tools#bits
Signed-off-by: Robin Jarry <robin@jarry.cc>
28 files changed:
.gitignore
bash-completion/bits [new file with mode: 0644]
configure.ac
meson.build
meson_options.txt
tests/commands.sh
tests/expected/misc/bits [new file with mode: 0644]
tests/expected/misc/bits-and [new file with mode: 0644]
tests/expected/misc/bits-binary [new file with mode: 0644]
tests/expected/misc/bits-default [new file with mode: 0644]
tests/expected/misc/bits-grouped-mask [new file with mode: 0644]
tests/expected/misc/bits-list [new file with mode: 0644]
tests/expected/misc/bits-mask [new file with mode: 0644]
tests/expected/misc/bits-not [new file with mode: 0644]
tests/expected/misc/bits-or [new file with mode: 0644]
tests/expected/misc/bits-parse-grouped-mask [new file with mode: 0644]
tests/expected/misc/bits-parse-mask [new file with mode: 0644]
tests/expected/misc/bits-parse-range [new file with mode: 0644]
tests/expected/misc/bits-stdin [new file with mode: 0644]
tests/expected/misc/bits-truncate [new file with mode: 0644]
tests/expected/misc/bits-width [new file with mode: 0644]
tests/expected/misc/bits-width-truncate [new file with mode: 0644]
tests/expected/misc/bits-xor [new file with mode: 0644]
tests/ts/misc/bits [new file with mode: 0755]
text-utils/Makemodule.am
text-utils/bits.1.adoc [new file with mode: 0644]
text-utils/bits.c [new file with mode: 0644]
text-utils/meson.build