cgget segfaulted on v2.0.2 branch, with:
cgget: cannot find controller 'incal' in group '016cgget'
Fatal error: glibc detected an invalid stdio handle
Aborted (core dumped)
It was caught by ftests/016-cgget-invalid_options.py on Ubuntu 22.04, a
simple reproducer on the v2.0.2 branch:
$ sudo ./src/tools/cgget -n -v -r invalid.setting 016cgget
assuming 016cgget cgroup exists.
It is due to the invalid controller name passed to the
cgroup_read_value_begin(), which returns failure and callee
get_cv_value() in the error clean up path, does a fclose(handle).
If (handle != NULL) succeeds because its uninitialized and has some
garbage value. Fix this by initializing the handle to NULL.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 15 Sep 2022 20:43:07 +0000 (20:43 +0000)]
github: Add more dependencies to the apt install command
Add a few more dependencies - cmake, bison, flex, byacc, g++, autoconf,
libtool, and automake - to the apt-get install list. Also add a '-y'
flag to automatically install them.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 15 Sep 2022 20:06:02 +0000 (20:06 +0000)]
tests: Merge libcgroup-tests repo back into libcgroup repo
Merge the libcgroup-tests repo back into the main libcgroup repo.
The submodules logic has been deleted and the tests are now directly
hosted within the libcgroup repo.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Sam James [Wed, 14 Sep 2022 14:11:58 +0000 (08:11 -0600)]
configure.ac: fix bashism
configure scripts need to be runnable with a POSIX-compliant /bin/sh.
On many (but not all!) systems, /bin/sh is provided by Bash, so errors
like this aren't spotted. Notably Debian defaults to /bin/sh provided
by dash which doesn't tolerate such bashisms as '=='.
This retains compatibility with bash.
Fixes configure warnings/errors like:
```
checking whether to build static libraries... no
./configure: 14089: test: xno: unexpected operator
checking for x86_64-pc-linux-gnu-g++... x86_64-pc-linux-gnu-g++
```
Signed-off-by: Sam James <sam@gentoo.org> Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tools/cgsnapshot: fix wrong array size in is_ctrl_on_list()
GCC throws -Wstringop-overflow warning:
CC cgsnapshot-cgsnapshot.o
cgsnapshot.c: In function 'parse_controllers':
cgsnapshot.c:540:53: warning: 'is_ctlr_on_list' accessing 16777216 bytes in a region of size 409600 [-Wstringop-overflow=]
540 | if ((!(flags & FL_LIST) || (is_ctlr_on_list(controllers, cont_names))) &&
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cgsnapshot.c:540:53: note: referencing argument 2 of type 'char (*)[4096]'
cgsnapshot.c:495:12: note: in a call to function 'is_ctlr_on_list'
495 | static int is_ctlr_on_list(char controllers[CG_CONTROLLER_MAX][FILENAME_MAX],
| ^~~~~~~~~~~~~~~
cgsnapshot.c:560:37: warning: 'is_ctlr_on_list' accessing 16777216 bytes in a region of size 409600 [-Wstringop-overflow=]
560 | if ((!(flags & FL_LIST) || (is_ctlr_on_list(controllers, cont_names))) &&
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cgsnapshot.c:560:37: note: referencing argument 2 of type 'char(*)[4096]'
cgsnapshot.c:495:12: note: in a call to function 'is_ctlr_on_list'
495 | static int is_ctlr_on_list(char controllers[CG_CONTROLLER_MAX][FILENAME_MAX],
| ^~~~~~~~~~~~~~~
the warning is seen due to the mismatch in the array size of the second
argument passed to is_ctlr_on_list() from parse_controllers(). Fix,
this long standing warning by chaging the size of the second function
argument in is_ctrl_on_list().
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 31 Aug 2022 21:03:56 +0000 (15:03 -0600)]
src/api.c: support /proc mounted with subset=pid
/proc filesystem can be mounted with subset=pid as one of its mount
options. This option hides all the top-level files and directories,
those are not related to processes. The cgroup v1 filesystem depends
on the /proc/cgroups to populate the cgroups controllers and will fail
during the cgroup_init() phase, when not available, whereas cgroup v2
considers this as a deprecated file and recommends reading the list of
controller from <unified mount point>/cgroup.controllers[1].
Support this valid /proc mount point only when the system is booted with
the unified mode and will fail to initialize in the case we find the
cgroup v1 mounted, i.e, the system booted with legacy or hybrid mode.
Kamalesh Babulal [Wed, 31 Aug 2022 21:03:34 +0000 (15:03 -0600)]
api.c: use /proc/self/mounts
Use /proc/self/mount instead of /proc/mounts, which is a symbolic link
to the former. The symbolic link creation can be traced back to Linux
Kernel commit 59c7572e82d6 ("proc: remove fs/proc/proc_misc.c"). Also,
the /proc/mounts are not available in the cases where the /proc is
mounted with subset=pid option.
As per kernel docs filesystems/procs.rst:
"subset=pid hides all top level files and directories in the procfs that
are not related to tasks."
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 31 Aug 2022 20:26:15 +0000 (14:26 -0600)]
configure: remove AM_COND for --disable-tests
With the usage of DIST_SUBDIRS, the makefiles for the tests/* will be
generated, and building the tests/* should be controlled using SUBDIRS.
Remove the AM_COND condition for --disable-tests in the AC_CONFIG_FILES
list.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 31 Aug 2022 20:25:48 +0000 (14:25 -0600)]
make: use DIST_SUBDIRS
As per automake manual[1], DIST_SUBDIRS should be used to recurse into
the subdirectories those we want to ship as part of make dist and use
SUBDIRS for conditionally building the directories. Adopt this rule
across the source.
Kamalesh Babulal [Wed, 31 Aug 2022 14:25:16 +0000 (08:25 -0600)]
github/workflows: add support for testing different cgroup setups
Add support to run the Github workflow on three parallel runners, each
of them have a unique cgroup setup:
cgroup v1 only (legacy), cgroup v1/v2 (hybrid), cgroup v2 only (unified).
With this change, we should be able to run every patch against all
combination of cgroup setups.
Suggested-by: Tom Hromatka <tom.hromatka@oracle.com> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Remove the clean logic and instead use the Github Actions
$ACTIONS_RUNNER_HOOK_JOB_STARTED environment variable
Kamalesh Babulal [Mon, 29 Aug 2022 21:01:47 +0000 (15:01 -0600)]
api.c: fix file open in cg_chmod_path()
In cg_chmod_path(), the commit 8b9665c29cb8 ("api.c: fix TOCTOU in
cg_chmod_path()), converted the file operations from stat -> fstat and
chmod -> fchmod to fix a Coverity warning. The newly replaced file
operations operate on file descriptors and hence introduced a side
effect of opening the file at the wrong code block, that would only work
as expected when the caller calls cg_chmod_path() with owner_is_umask
set.
Fix it by moving the file operation out of the conditional block, so it
works in both of the cases of owner_is_umask being set or unset.
Fixes: 8b9665c29cb8 ("api.c: fix TOCTOU in cg_chmod_path()) Suggested-by: Tom Hromatka <tom.hromatka@oracle.com> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 24 Aug 2022 18:44:47 +0000 (12:44 -0600)]
api.c: fix TOCTOU in cg_chmod_path()
Fix TOCTOU warning, reported by Coverity Tool:
CID 258267 (#1 of 1): Time of check time of use (TOCTOU).
fs_check_call: Calling function stat to perform check on path.
in cg_chmod_path(), the file name is stat() and not immediately followed
by the file operation. One way to fix it, open the file and use the file
descriptor to manipulate the file.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Tue, 23 Aug 2022 17:22:04 +0000 (11:22 -0600)]
tools/tools-common.h: introduce CGROUP_LOG_CONT level for logging
There are cases, where we might want to print a very long/multiline log
message to the user. We could call the cgroup_log(), multiple times
to fit the log message, but the downside is that every time the
cgroup_log() called, the log level is prefixed to the message, hence
introducing loglevel char string in the mid of the log message.
Introduce a new logging level, CGROUP_LOG_CONT and cgroup_cont() macro,
that will continue printing the log message, when loglevel is set to
other than default log level. The above code can be rewritten as:
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Fix typo in commit message
Kamalesh Babulal [Tue, 23 Aug 2022 17:21:47 +0000 (11:21 -0600)]
log: introduce CGROUP_LOG_CONT level for logging
There are cases, where we might want to print a very long/multiline log
message to the user. We could call the cgroup_log(), multiple times to
fit the log message, but the downside is that every time the
cgroup_log() called, the log level is prefixed to the message, hence
introducing loglevel char string in the mid of the log message.
For example, calling the cgroup_warn() twice to print a long warning:
cgroup_warn("cgroup v1 expects /proc/cgroup, check if ");
cgroup_warn("/proc mounted with subset=pid option\n");
Introduce a new logging level, CGROUP_LOG_CONT and cgroup_cont() macro,
that will continue printing the log message, when loglevel is set to other
than default log level. The above code can be rewritten as:
cgroup_warn("cgroup v1 expects/proc/cgroup, check if ");
cgroup_cont("/proc mounted with subset=pid option\n");
Kamalesh Babulal [Wed, 10 Aug 2022 17:08:26 +0000 (11:08 -0600)]
daemon/cgrulesengd: check the bytes read in cgre_receive_unix_domain_msg()
Fix ignoring the number of bytes read, warning reported by Coverity
tool:
CID 258286 (#1 of 1): Ignoring number of bytes read (CHECKED_RETURN).
check_return: read(int, void *, size_t) returns the number of bytes
read, but it is ignored.
In cgre_receive_unix_domain_msg(), the number of bytes read() is
ignored, while reading from the flag value of the pid. Coverity warns on
not checking the number of bytes read, fix it.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 10 Aug 2022 16:52:09 +0000 (10:52 -0600)]
api.c: add precision to fscanf(), in cgroup_get_current_controller_path()
Fix calling risky function warning, reported by Coverity tool:
CID 258301 (#1 of 1): Calling risky function
(DC.STREAM_BUFFER)dont_call: fscanf assumes an arbitrarily long string,
so callers must use correct precision specifiers or never use fscanf.
As per secure coding standard, using '%s' in the fscanf() is not
recommend, hence fix it by using the precision of macro
FILENAME_MAX borrowed from Linux Kernel for the maximum
allowed controller/subsys_name length.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Small fix in the commit comment.
api.c: add precision to fscanf(), in cgroup_populate_controllers()
Fix calling risky function warning, reported by Coverity tool:
CID 258305 (#1 of 1): Calling risky function
(DC.STREAM_BUFFER)dont_call: fscanf assumes an arbitrarily long string,
so callers must use correct precision specifiers or never use fscanf.
As per secure coding standard, using '%s' in the fscanf() is not
recommend, hence fix it by using the precision of macro
MAX_CGROUP_TYPE_NAMELEN borrowed from Linux Kernel for the maximum
allowed controller/subsys_name length.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
api.c: add precision to fscanf(), in cgroup_get_all_controller_next()
Fix calling risky function warning, reported by Coverity tool:
CID 258300 (#1 of 1): Calling risky function
(DC.STREAM_BUFFER)dont_call: fscanf assumes an arbitrarily long string,
so callers must use correct precision specifiers or never use fscanf.
As per secure coding standard, using '%s' in the fscanf() is not
recommend, hence fix it by using the precision of macro
MAX_CGROUP_TYPE_NAMELEN borrowed from Linux Kernel for the maximum
allowed controller/subsys_name length.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tools/cgxget: de-allocate cg_convert_list[] in convert_cgroup()
The commit 66799b867c7 (tools/cgxget: fix the resource leak in
convert_cgroup()), is a partial fix. It de-allocated the array members
of the dynamically allocated cg_converted_list[], but fails to free()
the cg_converted_list. Fix the resource leak by de-allocating it.
Fixes: 66799b867c7 (tools/cgxget: fix the resource leak in convert_group) Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
daemon/cgrulesengd: check the bytes read in cgre_receive_unix_domain_msg()
Fix ignoring the number of bytes read, warning reported by Coverity
tool:
CID 258286 (#2 of 2): Ignoring number of bytes read (CHECKED_RETURN).
check_return: read(int, void *, size_t) returns the number of bytes
read, but it is ignored.
In cgre_receive_unix_domain_msg(), the number of bytes read() is
ignored, while reading from the flag value from the socket. Coverity
warns on not checking the number of bytes read, fix it.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
api.c: check the bytes read in cgroup_register_unchanged_process()
Fix ignoring the number of bytes read, warning reported by Coverity
tool:
CID 258288 (#1 of 1): Ignoring number of bytes read (CHECKED_RETURN).
check_return: read(int, void *, size_t) returns the number of bytes
read, but it is ignored.
In cgroup_register_unchanged_process(), the number of byte read/written
using read()/write() are ignored but coverity it warns about the read()
only, let's fix it.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
api.c: fix null deference in is_cgrp_ctrl_shared_mnt()
Fix explicit null dereferenced warning, reported by Coverity tool:
CID 258306 (#1 of 1): Explicit null dereferenced (FORWARD_NULL).
var_deref_model: Passing null pointer controller_name to
cgroup_find_parent, which dereferences it.
the code path which leads to the null dereference:
cgroup_delete_cgroup_ext()
- cgroup_find_parent()
- is_cgrp_ctrl_shared_mnt()
is_cgrp_ctrl_shared_mnt(), assumes that the controller_name is non-NULL
but there are changes that, this static function might be called with
NULL controller_name, let's fix it with a check.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tools/cgsnapshot: fix out-of-bounds write in parse_controllers()
Fix Out-of-bounds write warning, reported by Coverity tool:
CID 258289 (#2 of 2): Out-of-bounds write (OVERRUN)16. overrun-local:
Overrunning array controllers of 100 4096-byte elements at element index
100 (byte offset 413695) using index max (which evaluates to 100).
there are chances, that the index variable max dereferences controller
array might be over the array size of 100. Add upper bound checks
to index variable max, so that it doesn't overrun the controller array.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
api.c: check for invalid error code in cgroup_strerror()
Fix array overflow warning, reported by the Coverity tool:
CID 258309 (#1 of 1): Out-of-bounds read (OVERRUN). overrun-local:
Overrunning array cgroup_strerror_codes of 32 8-byte elements at element
index 49999 (byte offset 399999) using index code % ECGROUPNOTCOMPILED
(which evaluates to 49999).
there are chances of users passing error codes, resulting in crossing
the upper bound of the cgroup_strerror_codes[], fix it by introducing
bound checks.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tools/cgxget: fix the resource leak in convert_cgroup()
Fix a resource leak warning reported by the Coverity tool:
CID 258272 (#1-2 of 2): Resource leak (RESOURCE_LEAK). leaked_storage:
Variable cg_converted_list going out of scope leaks the storage it
points to.
while free'ing() the cg_converted_list() via cgroup_free(), wrong array
index variable was passed, causing the resource leak. Fix it by passing
the right index variable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix a resource leak, reported by the Coverity tool:
CID 258291 (#1 of 1): Resource leak (RESOURCE_LEAK)8. leaked_storage:
Variable handle going out of scope leaks the storage it points to.
In get_cv_value(), currently, we goto end label, on the failure of
strdup() before closing the handle, leaking the resource. Fix it by
removing the goto, that allows the code flow to close the handle and
execute the code under the end label.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix a resource leak, reported by the Coverity tool:
CID 258291 (#1 of 1): Resource leak (RESOURCE_LEAK)8. leaked_storage:
Variable handle going out of scope leaks the storage it points to.
In get_cv_value(), currently, we goto end label, on the failure of
strdup() before closing the handle, leaking the resource. Fix it by
removing the goto, that allows the code flow to close the handle and
execute the code under the end label.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
api: null terminate readlink buffer in cgroup_get_procname_from_procfs()
Fix readlink buffer null termination warning, reported by Coverity tool:
CID 258273 (#2 of 2): String not null terminated (STRING_NULL).
string_null: Passing unterminated string buf to strdup, which expects a
null-terminated string.
As per the man pages (man 2 readlink):
"readlink() does not append a null byte to buf. It will (silently)
truncate the contents (to a length of bufsiz characters), in case the
buffer is too small to hold all of the contents."
Explicitly null terminate the buffer passed to readlink() in
cgroup_get_procname_from_procfs()
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
api: null terminate readlink buffer in cg_get_procname_from_proc_cmdline()
Fix readlink buffer null termination warning, reported by Coverity tool:
CID 258276 (#1 of 1): String not null terminated (STRING_NULL).
string_null: Passing unterminated string buf_cwd to strcat, which
expects a null-terminated string.
As per the man pages (man 2 readlink):
"readlink() does not append a null byte to buf. It will (silently)
truncate the contents (to a length of bufsiz characters), in case the
buffer is too small to hold all of the contents."
Explicitly null terminate the buffer passed to readlink() in
cg_get_procname_from_proc_cmdline().
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
api.c: fix string termination in cgroup_get_procname_from_procfs()
Fix non-terminated string warning, reported by Coverity tool:
CID 258273 (#2 of 2): String not null terminated (STRING_NULL)6.
string_null: Passing unterminated string buf to strdup, which expects a
null-terminated string.
use snprintf() instead of sprintf(), to string terminate
cgroup_get_procname_from_procfs().
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
wrapper.c: null terminate string in cgroup_new_cgroup()
Fix non-terminated string warning, reported by Coverity tool:
CID 258290 (#1 of 1): String not null terminated (STRING_NULL)46.
string_null: Passing unterminated string aux_cgroup->name to
cgroup_create_cgroup, which expects a null-terminated string.
The call patch leading to this warning:
config.c::cgroup_config_create_template_group()
- wrapper.c::cgroup_new_cgroup()
fix it by null terminating the string.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
abstraction-cpu: fix resource leak in read_setting()
Fix a resource leak, reported by Coverity tool:
CID 258274 (#1 of 1): Resource leak (RESOURCE_LEAK)6. leaked_storage:
Variable handle going out of scope leaks the storage it points to
In read_setting(), currently, we goto end label, on the failure of
strdup() before closing the handle, leaking the resource. Fix it by
removing the goto, that allows the code flow to close the handle and
execute the code under the end label.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tools/cgsnapshot: add ret value fix in parse_controllers()
Fix the unused ret value warning, reported by Coverity:
CID 258275 (#1 of 1): Unused value (UNUSED_VALUE)returned_value:
Assigning value from display_controller_data(controllers, program_name)
to ret here, but that stored value is overwritten before it can be used.
The parse_controllers(), doesn't check for errors in the value returned
by display_controller_data(). The return value might very well contain
an error, that might go unnoticed. Fix it by adding a check for the
return value.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
With Ubuntu 5.15.0-1014 kernel, there are a few changes to the output
of cgget -g cpu:<cgroup> provides for both cgroup V1 and V2:
cgroup V1:
----------
- new stat files cpu.cfs_burst_us. cpu.idle
cgroup V2:
----------
- new stat files cpu.idle, cpu.max.burst
adopt these changes while looking for expected out based on the cgroup
version. Also, convert the expected out templates into per cgroup
version list[], making it easier to match using a for loop, instead of
nested if else. Using a list also makes it easier to append any new
changes to the output template.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
With Ubuntu 5.15.0-1014 kernel, there are a few changes to the output
of cgget -g cpu:<cgroup> provides for both cgroup V1 and V2:
cgroup V1:
----------
- new stat files cpu.cfs_burst_us. cpu.idle
cgroup V2:
----------
- new stat files cpu.idle, cpu.max.burst
adopt these changes while looking for expected out based on the cgroup
version. Also, convert the expected out templates into per cgroup
version list[], making it easier to match using a for loop, instead of
nested if else. Using a list also makes it easier to append any new
changes to the output template.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
With Ubuntu 5.15.0-1014 kernel, there are a few changes to the output
of cgget -g cpu:<cgroup> provides for both cgroup V1 and V2:
cgroup V1:
----------
- new stat files cpu.cfs_burst_us, cpu.idle
cgroup V2:
----------
- new stat files cpu.idle, cpu.max.burst
adopt these changes while looking for expected out based on the cgroup
version. Also, convert the expected out templates into per cgroup
version list[], making it easier to match using a for loop, instead of
nested if else. Using a list also makes it easier to append any new
changes to the output template.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
test-020: fix issues on unsuccessful no-container runs
Running the test with --no-container, might cause an issue with useradd
or groupadd command if the home directory of the test user exists/test
user group exists.
The home directory of the user doesn't get removed by default on all
distros, so explicitly pass the '-r' flag to userdel to remove the
directory. Whereas user group might exist due to unsuccessful test
runs, address it by passing '-f' flags to groupadd command, that
returns success even if the group exists, that will be removed
by the groupdel command at the exit.
This is not an issue with containers test cases, because they are
created and destroyed for every test case execution.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
test-019: fix issues on unsuccessful no-container runs
Running the test with --no-container, might cause an issue with useradd
or groupadd command if the home directory of the test user exists/test
user group exists.
The home directory of the user doesn't get removed by default on all
distros, so explicitly pass the '-r' flag to userdel to remove the
directory. Whereas user group might exist due to unsuccessful test
runs, address it by passing '-f' flags to groupadd command, that
returns success even if the group exists, that will be removed
by the groupdel command at the exit.
This is not an issue with containers test cases, because they are
created and destroyed for every test case execution.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
api.c: add ret value fix in cgroup_change_cgroup_flags()
Fix the unused ret value warning, reported by Coverity:
CID 258304 (#1 of 1): Unused value (UNUSED_VALUE)returned_value:
Assigning value from cgroup_create_template_group(newdest, tmp, flags)
to ret here, but that stored value is overwritten before it can be used.
It turns out that cgroup_change_cgroup_flags(), calls the function
cgroup_create_template_group() to a cgroup based on a template, which
may fail and we don't check the return value for the error. Â This fix
adds the check and bails out on error.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix copy into fixed size buffer warning, reported by Coverity tool:
CID 258284 (#4 of 4): Copy into fixed size buffer (STRING_OVERFLOW)1.
fixed_size_dest: You might overrun the 4096-character fixed-size string
tmp_val by copying tok without checking the length.
In indent_multiline_value(), warned about the usage of strcat(), that
might overwrite the string. Fix it by replacing strcat() -> strncat()
in the function.
Signed-off-by: Kamalesh Babulal kamalesh.babulal@oracle.com Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix copy into fixed size buffer warning, reported by Coverity tool:
CID 258284 (#4 of 4): Copy into fixed size buffer (STRING_OVERFLOW)1.
fixed_size_dest: You might overrun the 4096-character fixed-size string
tmp_val by copying tok without checking the length.
In indent_multiline_value(), warned about the usage of strcat(), that
might overwrite the string. Fix it by replacing strcat() -> strncat()
in the function.
Signed-off-by: Kamalesh Babulal kamalesh.babulal@oracle.com Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:38:54 +0000 (20:08 +0530)]
tools/tools-common.h: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:36:17 +0000 (20:06 +0530)]
tools/tools-common.c: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:32:44 +0000 (20:02 +0530)]
tools/lssubsys: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:30:18 +0000 (20:00 +0530)]
tools/lscgroup: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:27:41 +0000 (19:57 +0530)]
tools/cgxget: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:22:42 +0000 (19:52 +0530)]
tools/cgxset: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:21:09 +0000 (19:51 +0530)]
tools/cgsnapshot: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:16:13 +0000 (19:46 +0530)]
tools/cgset: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:14:25 +0000 (19:44 +0530)]
tools/cgget: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:08:53 +0000 (19:38 +0530)]
tools/cgexec: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 14:02:56 +0000 (19:32 +0530)]
tools/cgcreate: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 08:30:09 +0000 (14:00 +0530)]
tools/cgconfig: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 08:29:11 +0000 (13:59 +0530)]
tools/cgdelete: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 08:26:34 +0000 (13:56 +0530)]
tools/cgclassify: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 08:23:38 +0000 (13:53 +0530)]
pam/pam_cgroup.c: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 08:22:11 +0000 (13:52 +0530)]
daemon/Makefile.am: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 08:21:22 +0000 (13:51 +0530)]
daemon/cgruleseng.h: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 08:18:46 +0000 (13:48 +0530)]
daemon/cgruleseng.c: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 07:33:11 +0000 (13:03 +0530)]
Makefile.am: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 07:33:11 +0000 (13:03 +0530)]
parse.y: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 07:33:11 +0000 (13:03 +0530)]
libcgroup-internal.h: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 07:33:11 +0000 (13:03 +0530)]
abstraction-map.h: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 07:33:11 +0000 (13:03 +0530)]
abstraction-map.c: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 07:33:11 +0000 (13:03 +0530)]
abstraction-cpuset.c: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 07:33:11 +0000 (13:03 +0530)]
abstraction-cpu.c: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 07:33:11 +0000 (13:03 +0530)]
abstraction-common.c: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across
the file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 07:33:11 +0000 (13:03 +0530)]
abstraction-common.c: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across the
file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 30 Jun 2022 07:33:11 +0000 (13:03 +0530)]
api.c: increase the column width to 100
100 column width is more comfortable to read over 80 columns, lets
increase it. This patch, also introduced/removes empty lines across the
file, making it more readable.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
wrapper.c: return on failure in cgroup_add_all_controllers()
Add missing goto statement, to return on failure, reported by Coverity
tool:
CID 258281 (#1 of 1): Unused value (UNUSED_VALUE)assigned_value:
Assigning value ECGINVAL to ret here, but that stored value is
overwritten before it can be used.
the tool reported about unused ret value, but it turned out that the
NULL ret value is for failed attempt to add a controller to the desired
cgroup and needs bailing out after losing the handle. Fix it by
introducing the goto statement in cgroup_add_all_controllers()
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Also fix unrelated grammar error near this change.
Fix non-terminated string warnings, reported by the Coverity tool:
CID 258293 (#2 of 2): Copy into fixed size buffer (STRING_OVERFLOW).
fixed_size_dest: You might overrun the 32-character fixed-size string
config_namespace_table[namespace_table_index].name by copying name
without checking the length.
fix one another similar string
config_namespace_table[namespace_table_index].mount.path in the same
function cgroup_config_insert_into_namespace_table() by explicitly
terminating by appending '\0';
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix non-terminated string warning, reported by Coverity tool:
CID 258266 (#1 of 1): String not null-terminated (STRING_NULL).
string_null: Passing unterminated string con to strtok, which expects a
null-terminated string.
Fix the warning in create_cgroup_from_name_value_pairs(), by adding
'\0'.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
config: cgroup_config_insert_into_mount_table() use strncpy()
Fix copy into fixed size buffer warning, reported by Coverity tool:
CID 258282 (#2 of 2): Copy into fixed size buffer (STRING_OVERFLOW)9.
fixed_size_dest: You might overrun the 4096-character fixed-size string
config_mount_table[config_table_index].mount.path by copying mount_point
without checking the length.
parameter_as_source: Note: This defect has an elevated risk because the
source argument is a parameter of the current function
Also, convert config_mount_table[config_table_index].name strcpy to
strncpy.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
calling "hasmntopt" to determine if the controller name exists in
"mntopt", may cause errors because of "hasmntopt" only match substring.
cpu controller may incorrectly match to cpuset when cpuset mount info
appeared before cpu,cpuacct in "/proc/mounts", so we need to validate
the last character to make sure the controller name matches exactly.
Tom Hromatka [Thu, 9 Jun 2022 18:45:29 +0000 (12:45 -0600)]
api.c: Fix handling of full cg_mount_table[]
Commit 9ce90c7edd28 ("api.c: fix segfault in cgroup_populate_mount_points()")
added logic to handle the case when there are 100+ cgroup mounts and
not overflow the cg_mount_table[]. But elsewhere in the libcgroup
code, it's expected that the last entry in the cg_mount_table[] has
a null name entry.
When the cg_mount_table[] is full, make the name of the last entry
null so that loops know to exit. Also, add a couple bail out points
in cgroup_populate_mount_points() to ensure that we don't write
beyond the end of the table.
Depending upon the order in which the tests are run, this failure can
manifest itself as follows:
$ cat tests/ftests/ftests-nocontainer.sh.log
free(): invalid pointer
./ftests-nocontainer.sh: line 18: 199390 Aborted
(core dumped) ./ftests.py -l 10 -L "$START_DIR/ftests-nocontainer.py.log" --no-container -n Libcg"$RANDOM"
FAIL ftests-nocontainer.sh (exit status: 134)
Fixes: 9ce90c7edd28 ("api.c: fix segfault in cgroup_populate_mount_points()") Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com> Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Fix copy into fixed size buffer warning, reported by Coverity tool:
CID 258279 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW).
fixed_size_dest: You might overrun the 4096-character fixed-size string
mnt_point->path by copying path without checking the length.
10. parameter_as_source: Note: This defect has an elevated risk
because the source argument is a parameter of the current function.
fix this issue by using strnpy(), in place of strcpy().
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
wrapper: null terminated string in cgroup_add_controller()
Fix non-terminated string warning, reported by Coverity tool:
CID 258271 (#1 of 1): String not null terminated (STRING_NULL).
string_null: Passing unterminated string cgc->name to strcmp, which
expects a null-terminated string.
This issue was reported following the path src/abstraction-common.c:
- cgroup_convert_cgroup()
- cgroup_add_controller()
Also, use CONTROL_NAMELEN_MAX macro, in place of calculating the size of
controller->name twice.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Tue, 31 May 2022 22:54:28 +0000 (16:54 -0600)]
api: null terminated string in cgroup_get_controller_next()
Fix non-terminated string warnings, reported by Coverity tool:
CID 258299 (#1-2 of 2): String not null terminated (STRING_NULL).
string_null: Passing unterminated string controller.path to strcmp,
which expects a null-terminated string
This issue was reported following the path src/tools/cgsnapshot.c:
- parse_controllers()
- cgroup_get_controller_begin()
- cgroup_get_controller_next()
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Tue, 31 May 2022 22:51:21 +0000 (16:51 -0600)]
config: add missing ret value check from getgrnam_r()
Fix Unchecked return values from library, reported by Coverity tool:
CID 258287 (#1 of 1): Unchecked return value from library
(CHECKED_RETURN).
check_return: Calling getgrnam_r(value, group, buffer, 20480UL,
&group_buffer) without checking return value. This library function may
fail and return an error code.
CID 258303 (#1 of 1): Unchecked return value from library
(CHECKED_RETURN).
check_return: Calling getgrnam_r(value, group, buffer, 20480UL,
&group_buffer) without checking return value. This library function may
fail and return an error code.
Coverity expects us to check for return value from getgrnam_r(), instead
of the current for group_buffer != NULL. Which is right, let's make
Coverity happy by moving the check to return value.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Fri, 27 May 2022 20:56:42 +0000 (14:56 -0600)]
api: fix coverity warning about uninitialized variable
Fix Uninitialized scalar variable, reported by Coverity tool:
CID 258269 (#1 of 1): Uninitialized scalar variable (UNINIT).
uninit_use: Using uninitialized value version.
In _cgroup_create_cgroup(), the (cg_version_t)version is uninitialized
and might be read the version in false path. It worked until now
because the version is assigned in the true path and given that its enum
the checks are not bounded by range, but rather specific.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 26 May 2022 14:12:30 +0000 (08:12 -0600)]
api.c: add cgroup error string for ECGNOVERSIONCONVERT
Add the missing error string for the error code ECGNOVERSIONCONVERT to
cgroup_strerror_codes[], that is looked upon to print string version of
the error encountered.
Reproducer:
-----------
$ cat cgrp-strerr.c
int main(void)
{
int err = ECGNOVERSIONCONVERT;
fprintf(stderr, "%s\n", cgroup_strerror(err));
return 0;
}
without the patch:
-----------------
$ ./cgrp-stderr
(null)
with the patch:
---------------
$ ./cgrp-stderr
Failed to convert from cgroup v1 to/from cgroup v2
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>