]> git.ipfire.org Git - thirdparty/systemd.git/commit
cgroup: systemctl: Don't display NULL if protection was set to max
authorChris Down <chris@chrisdown.name>
Wed, 5 Feb 2020 12:12:52 +0000 (12:12 +0000)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 Feb 2020 17:32:33 +0000 (18:32 +0100)
commite0e2112f618450e8836836e71fe9b1b422a6d63e
tree30274f1e6b3da0f67934cb971b8e68af4843c2c9
parent8b51950f4cd2364b7b3edcca423fdfa130a33cda
cgroup: systemctl: Don't display NULL if protection was set to max

Inside format_bytes, we return NULL if the value is UINT64_MAX. This
makes some kind of sense where this has some other semantic meaning than
being a value, but in this case the value is both a.) not the default
(so we definitely want to display it), and b.) means "infinity" (or
"max" in cgroup terminology).

This patch adds a small wrapper around format_bytes that can be used for
these cases, to avoid the following situation:

    [root@tangsanjiao ~]# cat /sys/fs/cgroup/workload.slice/memory.low
    max
    [root@tangsanjiao ~]# systemctl show workload.slice -p MemoryLow
    MemoryLow=infinity
    [root@tangsanjiao ~]# systemctl status workload.slice | grep low:
Memory: 14.9G (low: (null))

After the patch:

    [root@tangsanjiao ~]# systemctl status workload.slice | grep low:
Memory: 15.1G (low: infinity)
src/basic/format-util.h
src/systemctl/systemctl.c