]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
3 years agosrc/config.c: remove log level prefix
Kamalesh Babulal [Thu, 17 Mar 2022 12:47:27 +0000 (18:17 +0530)] 
src/config.c: remove log level prefix

With commit 97a0e195ddd7 ("log: add log level string prefix to
logging functions"), log level prefixes gets added to message
printed by cgroup_{err,warn,info} functions, remove them from
message passed to these functions.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/api.c: remove log level prefix
Kamalesh Babulal [Sat, 19 Mar 2022 14:14:40 +0000 (19:44 +0530)] 
src/api.c: remove log level prefix

With commit 97a0e195ddd7 ("log: add log level string prefix to
logging functions"), log level prefixes gets added to message
printed by cgroup_{err,warn,info} functions, remove them from
message passed to these functions.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/abstraction-common.c: remove log level prefix
Kamalesh Babulal [Sat, 19 Mar 2022 14:14:29 +0000 (19:44 +0530)] 
src/abstraction-common.c: remove log level prefix

With commit 97a0e195ddd7 ("log: add log level string prefix to
logging functions"), log level prefixes gets added to message
printed by cgroup_{err,warn,info} functions, remove them from
message passed to these functions.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi.c: fix a memory leak in cgroup_init()
Kamalesh Babulal [Sat, 19 Mar 2022 06:41:50 +0000 (12:11 +0530)] 
api.c: fix a memory leak in cgroup_init()

temp_ent is not free'ed in the error path if cgroup_process_v1_mnt() or
cgroup_process_v2_mnt() fails.  Move the free'ing of temp_ent to error
path.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoMakefile: fix samples/c build dependency
Kamalesh Babulal [Sat, 19 Mar 2022 06:55:25 +0000 (12:25 +0530)] 
Makefile: fix samples/c build dependency

If the user chooses to build the samples/c programs, it will fail to
build, with the error:

config.status: creating samples/c/Makefile
  CC       setuid.o
make: *** No rule to make target '../../src/.libs/libcgroup.la', needed by 'setuid'.  Stop.

it is due to the dependency on libcgroup.la, which is currently built
after samples. Fix it by moving the samples directory to be built after
src directory.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoModernise cgconfig initscript.
Vladimir Nikishkin [Thu, 17 Mar 2022 16:15:05 +0000 (10:15 -0600)] 
Modernise cgconfig initscript.

1. Remove obsolete constructions from scripts/init/cgconfig.in
2. Add fallback logging functions for non-lsb systems.

Signed-off-by: Vladimir Nikishkin <libcgroup@lockywolf.net>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Merged the original patch and review comments patch into one commit

3 years agoCOPYING: fix trailing white spaces
Kamalesh Babulal [Wed, 16 Mar 2022 16:23:02 +0000 (21:53 +0530)] 
COPYING: fix trailing white spaces

checkpatch.pl reported trailing white spaces, fix them.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoscripts/init.d/cgred.in: fix trailing white spaces
Kamalesh Babulal [Wed, 16 Mar 2022 16:22:32 +0000 (21:52 +0530)] 
scripts/init.d/cgred.in: fix trailing white spaces

checkpatch.pl reported trailing white spaces, fix them.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoman/cgexec.1: fix trailing white spaces
Kamalesh Babulal [Wed, 16 Mar 2022 16:20:06 +0000 (21:50 +0530)] 
man/cgexec.1: fix trailing white spaces

checkpatch.pl reported trailing white spaces, fix them.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoman/cgexec.1: fix trailing white spaces
Kamalesh Babulal [Wed, 16 Mar 2022 16:19:45 +0000 (21:49 +0530)] 
man/cgexec.1: fix trailing white spaces

checkpatch.pl reported trailing white spaces, fix them.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoman/cgconfig.conf.5: fix trailing white spaces
Kamalesh Babulal [Wed, 16 Mar 2022 16:19:26 +0000 (21:49 +0530)] 
man/cgconfig.conf.5: fix trailing white spaces

checkpatch.pl reported trailing white spaces, fix them.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoman/cgrules.conf.5: fix trailing white spaces
Kamalesh Babulal [Wed, 16 Mar 2022 16:18:56 +0000 (21:48 +0530)] 
man/cgrules.conf.5: fix trailing white spaces

checkpatch.pl reported trailing white spaces, fix them.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agodist/libcgroup.spec.in: fix trailing white spaces
Kamalesh Babulal [Wed, 16 Mar 2022 16:18:29 +0000 (21:48 +0530)] 
dist/libcgroup.spec.in: fix trailing white spaces

checkpatch.pl reported trailing white spaces, fix them.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agolibcgroup.doxyfile: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:18:08 +0000 (21:48 +0530)] 
libcgroup.doxyfile: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types.  It also introduces
reverse xmas tree local variable declarations and header file
reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 1 warnings, 1519 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoinclude/tools.h: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:17:38 +0000 (21:47 +0530)] 
include/tools.h: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 3 warnings, 73 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoinclude/tasks.h: introduce coding style changes
Kamalesh Babulal [Wed, 16 Mar 2022 16:17:11 +0000 (21:47 +0530)] 
include/tasks.h: introduce coding style changes

This patch introduces coding style changes such as reverse xmas tree
local variable declarations, header file reordering, and many other
minor tweaks such as line spacing, removing trailing white spaces.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoinclude/log.h: introduce coding style changes
Kamalesh Babulal [Wed, 16 Mar 2022 16:16:41 +0000 (21:46 +0530)] 
include/log.h: introduce coding style changes

This patch introduces coding style changes such as reverse xmas tree
local variable declarations, header file reordering, and many other
minor tweaks such as line spacing, removing trailing white spaces.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoinclude/iterators.h: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:16:22 +0000 (21:46 +0530)] 
include/iterators.h: fix checkpatch.pl warnings

This patch introduces coding style changes such as reverse xmas tree
local variable declarations, header file reordering, and many other
minor tweaks such as line spacing, removing trailing white spaces.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 25 warnings, 432 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoinclude/init.h: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:16:04 +0000 (21:46 +0530)] 
include/init.h: fix checkpatch.pl warnings

This patch introduces coding style changes such as reverse xmas tree
local variable declarations, header file reordering, and many other
minor tweaks such as line spacing, removing trailing white spaces.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 1 warnings, 86 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoinclude/groups.h: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:15:44 +0000 (21:45 +0530)] 
include/groups.h: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 27 warnings, 630 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/config/cgred.conf: fix trailing white spaces
Kamalesh Babulal [Wed, 16 Mar 2022 16:15:06 +0000 (21:45 +0530)] 
samples/config/cgred.conf: fix trailing white spaces

checkpatch.pl reported trailing white space, fix it.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/test_functions.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:14:46 +0000 (21:44 +0530)] 
samples/test_functions.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 2 errors, 19 warnings, 927 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/wrapper_test.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:14:20 +0000 (21:44 +0530)] 
samples/wrapper_test.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 0 warnings, 44 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/walk_test.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:13:15 +0000 (21:43 +0530)] 
samples/walk_test.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 0 warnings, 121 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/walk_task.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:12:57 +0000 (21:42 +0530)] 
samples/walk_task.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 1 warnings, 49 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/test_named_hierarchy.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:09:07 +0000 (21:39 +0530)] 
samples/test_named_hierarchy.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 0 warnings, 47 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/setuid.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:07:47 +0000 (21:37 +0530)] 
samples/setuid.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
0 errors, 1 warnings, 82 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/read_stats.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:07:14 +0000 (21:37 +0530)] 
samples/read_stats.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 0 warnings, 84 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/proctest.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:05:16 +0000 (21:35 +0530)] 
samples/proctest.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
0 errors, 1 warnings, 55 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/logger.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:04:27 +0000 (21:34 +0530)] 
samples/logger.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 0 warnings, 53 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/get_variable_names.c:fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:04:00 +0000 (21:34 +0530)] 
samples/get_variable_names.c:fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 2 warnings, 59 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/get_procs.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:00:10 +0000 (21:30 +0530)] 
samples/get_procs.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 0 warnings, 36 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/get_mount_point.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:57:25 +0000 (21:27 +0530)] 
samples/get_mount_point.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 1 warnings, 49 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/get_controller.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:55:22 +0000 (21:25 +0530)] 
samples/get_controller.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 0 warnings, 34 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/get_all_controller.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:54:28 +0000 (21:24 +0530)] 
samples/get_all_controller.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG.  It also introduces reverse xmas tree local
variable declarations and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 0 warnings, 34 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgrulesengd.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:54:04 +0000 (21:24 +0530)] 
cgrulesengd.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 10 errors, 36 warnings, 1306 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgrulesengd.h: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:53:45 +0000 (21:23 +0530)] 
cgrulesengd.h: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 18 warnings, 129 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agopam/pam_cgroup.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:51:53 +0000 (21:21 +0530)] 
pam/pam_cgroup.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types.  It also introduces
reverse xmas tree local variable declarations and header file
reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 10 warnings, 163 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotools-common.h: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:51:36 +0000 (21:21 +0530)] 
tools-common.h: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 7 warnings, 145 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotools-common.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:50:38 +0000 (21:20 +0530)] 
tools-common.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 2 warnings, 312 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agolssubsys.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 16:24:34 +0000 (21:54 +0530)] 
lssubsys.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 16 warnings, 295 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agolscgroup.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:45:33 +0000 (21:15 +0530)] 
lscgroup.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 9 warnings, 328 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgxset.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:45:01 +0000 (21:15 +0530)] 
cgxset.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 20 warnings, 385 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgxget.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:42:43 +0000 (21:12 +0530)] 
cgxget.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 2 errors, 17 warnings, 921 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgsnapshot.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:37:43 +0000 (21:07 +0530)] 
cgsnapshot.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 39 warnings, 847 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgset.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:36:34 +0000 (21:06 +0530)] 
cgset.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 16 warnings, 284 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgget.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:32:16 +0000 (21:02 +0530)] 
cgget.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 2 errors, 13 warnings, 772 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgexec.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:25:09 +0000 (20:55 +0530)] 
cgexec.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 2 errors, 8 warnings, 178 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgdelete.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:24:30 +0000 (20:54 +0530)] 
cgdelete.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 6 warnings, 303 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgcreate.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:23:50 +0000 (20:53 +0530)] 
cgcreate.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 10 warnings, 247 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgconfig.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:22:59 +0000 (20:52 +0530)] 
cgconfig.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 11 warnings, 213 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgclassify.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 16 Mar 2022 15:22:23 +0000 (20:52 +0530)] 
cgclassify.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types.  It
also introduces reverse xmas tree local variable declarations and header
file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 2 errors, 10 warnings, 203 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years ago.checkpatch.conf: add NEW_TYPEDEFS to ignore-list
Kamalesh Babulal [Mon, 14 Mar 2022 10:35:06 +0000 (16:05 +0530)] 
.checkpatch.conf: add NEW_TYPEDEFS to ignore-list

There are tools/files, that introduce new typdefs and checkpatch.pl is
unhappy about it. It takes some re-work on removing and for now let's
teach checkpatch to ignore it.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoAdopt SPDX License tag for files missing license information
Kamalesh Babulal [Mon, 14 Mar 2022 04:38:44 +0000 (10:08 +0530)] 
Adopt SPDX License tag for files missing license information

Adopt SPDX license tag for all the source files, those missing License
information.  All the files in the project fall under project license,
hence explicitly adding LGPL-2.1-only identifier to them.  The SPDX
license identifier is added for the files, reported by checkpatch.pl.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoAdopt SPDX License tag
Kamalesh Babulal [Mon, 14 Mar 2022 04:35:01 +0000 (10:05 +0530)] 
Adopt SPDX License tag

Adopt SPDX license tag for all the source files, those already have
LGPL 2.1 bolierplate in them.  Adopting SPDX license helps the
compliance tools to determine the license and also helps in reducing the
repetitive license boilerplate across source files.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosamples/c: drop the test suites
Kamalesh Babulal [Fri, 11 Mar 2022 14:54:43 +0000 (07:54 -0700)] 
samples/c: drop the test suites

samples/c contains test cases, those do serve as good examples on how to
use some APIs, but there are also very elaborate test cases, which are
test suites in themselves.  Let's drop these examples and allow users to
look at gunit/ftests for how to contribute to test cases.  This patch
also modifies the Makefile to help users to build the examples, in case
they want to give it a quick try.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agolog: add log level string prefix to logging functions
Kamalesh Babulal [Fri, 11 Mar 2022 14:51:09 +0000 (07:51 -0700)] 
log: add log level string prefix to logging functions

Usage of cgroup_{err, warn, info} functions, expects the log level to be
prefixed to the message like: cgroup_warn("Warning: ...").  This patch
removes this need to prefix and automatically adds the desired prefix to
the logger function, so the usage becomes cgroup_warn("...").  This
helps in readability and avoiding typos in setting the right log level
string to the message.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocheckpatch.conf: introduce checkpatch.pl configuration
Kamalesh Babulal [Wed, 9 Mar 2022 11:52:35 +0000 (17:22 +0530)] 
checkpatch.conf: introduce checkpatch.pl configuration

Introduce checkpatch.conf, which defines the rules those are exempted in
libcgroup when running scripts/checkpatch.pl from Linux Kernel sources.

This helps us in introducing a coding standard and stay close to already
well defined and debated coding style that of the Linux Kernel.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/abstraction-map.c: re-arrange the header files
Kamalesh Babulal [Wed, 9 Mar 2022 11:51:33 +0000 (17:21 +0530)] 
src/abstraction-map.c: re-arrange the header files

Re-arrange the headers files, in the following order:
1. Header files that declare the functions, are defined in this file.
2. Other header files from the libcgroup.
3. Standard header file.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/abstraction-cpuset.c: re-arrange the header files
Kamalesh Babulal [Wed, 9 Mar 2022 11:49:42 +0000 (17:19 +0530)] 
src/abstraction-cpuset.c: re-arrange the header files

Re-arrange the headers files, in the following order:
1. Header files that declare the functions, are defined in this file.
2. Other header files from the libcgroup.
3. Standard header file.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/abstraction-cpu.c: re-arrange the header files
Kamalesh Babulal [Wed, 9 Mar 2022 11:46:32 +0000 (17:16 +0530)] 
src/abstraction-cpu.c: re-arrange the header files

Re-arrange the headers files, in the following order:
1. Header files that declare the functions, are defined in this file.
2. Other header files from the libcgroup.
3. Standard header file.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/api.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 9 Mar 2022 13:59:57 +0000 (19:29 +0530)] 
src/api.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types.  It also introduces
reverse xmas tree local variable declarations and header file
reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 26 errors, 204 warnings, 5855 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/wrapper.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 9 Mar 2022 10:09:49 +0000 (15:39 +0530)] 
src/wrapper.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types.  It also introduces
reverse xmas tree local variable declarations and header file
reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 55 warnings, 743 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/log.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 9 Mar 2022 10:03:41 +0000 (15:33 +0530)] 
src/log.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types.  It also introduces
reverse xmas tree local variable declarations and header file
reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 3 warnings, 96 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/config.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 9 Mar 2022 07:54:35 +0000 (13:24 +0530)] 
src/config.c: fix checkpatch.pl warnings

Fix most of the warnings/errors reported by Linux Kernel's
checkpatch.pl, except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types.
It also introduces reverse xmas tree local variable declarations
and header file reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 4 errors, 36 warnings, 1899 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/libcgroup-internal.h: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 9 Mar 2022 13:58:31 +0000 (19:28 +0530)] 
src/libcgroup-internal.h: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types.  It also introduces
reverse xmas tree local variable declarations and header file
reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 5 errors, 2 warnings, 438 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/abstraction-common.h: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 9 Mar 2022 07:11:03 +0000 (12:41 +0530)] 
src/abstraction-common.h: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types.  It also introduces
reverse xmas tree local variable declarations and header file
reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 4 warnings, 150 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agosrc/abstraction-common.c: fix checkpatch.pl warnings
Kamalesh Babulal [Wed, 9 Mar 2022 06:54:27 +0000 (12:24 +0530)] 
src/abstraction-common.c: fix checkpatch.pl warnings

Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types.  It also introduces
reverse xmas tree local variable declarations and header file
reordering.

In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 7 warnings, 320 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotools/lssubsys: fix strncpy() warning
Kamalesh Babulal [Mon, 28 Feb 2022 14:11:43 +0000 (19:41 +0530)] 
tools/lssubsys: fix strncpy() warning

GCC complains about string truncations in
print_all_controllers_in_hierarchy:

In function 'print_all_controllers_in_hierarchy',
    inlined from 'cgroup_list_all_controllers' at lssubsys.c:226:9,
    inlined from 'main' at lssubsys.c:294:8:
lssubsys.c:127:25: warning: 'strncpy' output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  127 |                         strncpy(cont_name, info.name, FILENAME_MAX-1);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lssubsys.c:131:25: warning: 'strncpy' output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  131 |                         strncpy(cont_names, info.name, FILENAME_MAX-1);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

this warning seems to be a little odd when the current code is already
explicitly truncating the string. Digging deeper, it looks like the
memset(), followed by strncpy() with -O >= 2 triggers this warning on
GCC 11. A simple and safe fix would be removing the memset(). As per
the standard's strncpy() will fill the destination string with '\0', if
the source string length is lesser than that of the destination.  This
fix, take this approach.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi: fix strncpy() warning in cgroup_process_v2_mnt
Kamalesh Babulal [Mon, 28 Feb 2022 14:07:20 +0000 (19:37 +0530)] 
api: fix strncpy() warning in cgroup_process_v2_mnt

Fix a GCC warning about un-truncated strncpy() in
cgroup_process_v2_mnt():

In function 'cgroup_process_v2_mnt',
    inlined from 'cgroup_init' at api.c:1387:10:
api.c:1205:9: warning: 'strncpy' specified bound 4096 equals destination size [-Wstringop-truncation]
 1205 |         strncpy(cg_cgroup_v2_mount_path, ent->mnt_dir, FILENAME_MAX);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi.c: Allow creation of a v2 cgroup with no controllers 102/head
Tom Hromatka [Thu, 17 Feb 2022 21:17:15 +0000 (14:17 -0700)] 
api.c: Allow creation of a v2 cgroup with no controllers

Commit 498530a1d744 ("cgcreate, tools: Allow cgroup creation with
no controllers attached") attempted to add support to allow the
creation of a cgroup v2 cgroup with no controllers attached.  This
patch did create the requested cgroup, but it still required there
to be at least one valid controller _available_ to attach to.

Rework the aforementioned logic so that the cgroup can be created
if there's a valid cgroup v2 mount - even if there are no v2
controllers available.

Fixes: 498530a1d744 ("cgcreate, tools: Allow cgroup creation with no controllers attached")
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agosamples: Add C samples
Tom Hromatka [Wed, 23 Feb 2022 15:01:38 +0000 (08:01 -0700)] 
samples: Add C samples

Move the legacy tests from libcgroup-tests [1] to the
samples/c/ directory.  While these files are no longer
being run as automated tests, they provide helpful insight
into how to utilize the libcgroup C APIs.

[1] https://github.com/libcgroup/libcgroup-tests/

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agosamples: Move the config examples to samples/config/
Tom Hromatka [Wed, 23 Feb 2022 15:01:03 +0000 (08:01 -0700)] 
samples: Move the config examples to samples/config/

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoconfigure: Delete legacy test artifacts
Tom Hromatka [Wed, 23 Feb 2022 15:00:29 +0000 (08:00 -0700)] 
configure: Delete legacy test artifacts

The legacy tests (now located in the libcgroup-tests)
repository have been moved to
https://github.com/libcgroup/libcgroup-tests/tree/main/examples
and are no longer being run.  Remove all references to
the tests from the configure.ac file.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agopython/setup.py: make it PEP8 compliant
Kamalesh Babulal [Thu, 17 Feb 2022 19:39:43 +0000 (12:39 -0700)] 
python/setup.py: make it PEP8 compliant

Make setup.py PEP-8 compliant, it fixes the following two issues
reported by flake8:
- E128 continuation line under-indented for visual indent
- E251 unexpected spaces around keyword/parameter equals

also, adopt single quotes for strings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoREADME.md: Add python code quality badge
Tom Hromatka [Wed, 16 Feb 2022 19:27:05 +0000 (12:27 -0700)] 
README.md: Add python code quality badge

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoREADME.md: Update the LGTM link
Tom Hromatka [Mon, 14 Feb 2022 15:25:15 +0000 (08:25 -0700)] 
README.md: Update the LGTM link

The LGTM badge linked to a comparison of libcgroup with
other open source projects.  Change the link to go directly
to libcgroup's alerts.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi.c: Fix TOCTOU race cgroup_get_cg_type()
Kamalesh Babulal [Mon, 14 Feb 2022 15:11:56 +0000 (08:11 -0700)] 
api.c: Fix TOCTOU race cgroup_get_cg_type()

Fix a TOCTOU race condition, that checks for file existence versus file
open in cgroup_get_cg_type() by opening the file and check for errno for
file existence.

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi.c: fix a comparison error in cgroup_delete_cgroup_ext()
Kamalesh Babulal [Mon, 14 Feb 2022 15:11:39 +0000 (08:11 -0700)] 
api.c: fix a comparison error in cgroup_delete_cgroup_ext()

Fix a comparison logic in the first_errno assignment, that would
never get executed in the case of first_errno == ECGNONEMPTY in
cgroup_delete_cgroup_ext().

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi: make cgroup_get_subsys_mount_point_end() more useful
Kamalesh Babulal [Mon, 14 Feb 2022 15:11:25 +0000 (08:11 -0700)] 
api: make cgroup_get_subsys_mount_point_end() more useful

Currently cgroup_get_subsys_mount_point_end(), does nothing more than
returning zero, it was caught by LGTM altering:
"This expression has no effect (because
cgroup_get_subsys_mount_point_end has no external side effects)."

make the function more useful like other *_end() functions by including
the check for cgroup_initialized and assigning NULL to the handle used
for iterating over controller mount points.

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agowrapper: remove false checks for snprintf
Kamalesh Babulal [Mon, 14 Feb 2022 15:11:08 +0000 (08:11 -0700)] 
wrapper: remove false checks for snprintf

LGTM, reported that the negative value checks for snprintf() will
always be false.  The reason being the snprintf() are used to print
into a character buffer, hence chances of stream error or wide
characters encoding error are not valid here. Remove the negative
return value check across the file done after snprintf().

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotools/cgsnapshot: rename FILE *of to output_f
Kamalesh Babulal [Mon, 14 Feb 2022 15:10:43 +0000 (08:10 -0700)] 
tools/cgsnapshot: rename FILE *of to output_f

LGTM, complained about using FILE *of as shorthand for the output file
and recommended using something descriptive. Rename usage of with
output_f, to keep it happy.

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoIntroduce vim modeline for python sources
Kamalesh Babulal [Mon, 14 Feb 2022 14:54:19 +0000 (07:54 -0700)] 
Introduce vim modeline for python sources

Introduce vim modeline to python source files. This sets up the
vim editor to PEP-8 recommend editing style. The vim modeline added:
"# vim: set et ts=4 sw=4:"

'et' converts the tabs to spaces, 'ts' set the tabs indentation/tabstop
to 4 characters and 'sw' sets the shiftwidth to 4 characters.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agodocs: add library version updates to release process
Kamalesh Babulal [Thu, 10 Feb 2022 21:49:29 +0000 (14:49 -0700)] 
docs: add library version updates to release process

Add step to update Major, Minor and Release versions in configure.ac to
both release documents.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoMerge pull request #94 from drakenclimber/issues/emptycgcreate
Tom Hromatka [Thu, 10 Feb 2022 21:39:43 +0000 (14:39 -0700)] 
Merge pull request #94 from drakenclimber/issues/emptycgcreate

Add support for creating an empty cgroup v2 cgroup

3 years agopython: Add support to create a cgroup on-disk 94/head
Tom Hromatka [Wed, 9 Feb 2022 19:28:57 +0000 (12:28 -0700)] 
python: Add support to create a cgroup on-disk

Add support to the python bindings to create a cgroup
on disk.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgcreate, tools: Allow cgroup creation with no controllers attached
Tom Hromatka [Wed, 9 Feb 2022 19:28:44 +0000 (12:28 -0700)] 
cgcreate, tools: Allow cgroup creation with no controllers attached

Add support for creating a cgroup with no controllers attached.  This
is only supported on cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoapi.c: Refactor cgroup_create_cgroup()
Tom Hromatka [Wed, 9 Feb 2022 19:27:43 +0000 (12:27 -0700)] 
api.c: Refactor cgroup_create_cgroup()

Non-functional change to refactor cgroup_create_cgroup().  Move
the contents of this "for" loop to its own function:
for (k = 0; k < cgroup->index; k++)

This will be used as a building block for the next commit to allow
the creation of cgroups with no controllers attached.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoapi.c: fix the buffer size to read /proc/cgroups
Kamalesh Babulal [Tue, 8 Feb 2022 16:44:50 +0000 (09:44 -0700)] 
api.c: fix the buffer size to read /proc/cgroups

In cgroup_init(), the first line/header of /proc/cgroups helps in
interpreting the values in the remaining of the file.  We are interested
in the rest of the file and a temporary buffer of size FILENAME_MAX is
allocated/deallocated after reading the header. The length of the header
is only 56 characters in length, excluding the newline. This patch
reduces it to LL_MAX a.k.a 100 characters.

LL_MAX is used instead of introducing another new length macro.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agolibcgroup-internal.h: remove FIXME comment
Kamalesh Babulal [Tue, 8 Feb 2022 16:44:36 +0000 (09:44 -0700)] 
libcgroup-internal.h: remove FIXME comment

As per Linux Kernel uidgid.h file, that represents internal Kernel types
for uids/gids. Initialized invalid uids/gids to -1:

  #define INVALID_UID KUIDT_INIT(-1)
  #define INVALID_GID KGIDT_INIT(-1)

initializing them to -1 is a valid, remove the FIXME comment that says
otherwise.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi.c: add return value check for strdup()
Kamalesh Babulal [Tue, 8 Feb 2022 16:44:19 +0000 (09:44 -0700)] 
api.c: add return value check for strdup()

In function cg_build_path_locked(), check for return value from
strdup(). This fixes, one of the long pending FIXME.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoerror.h: make errno number reading easier
Kamalesh Babulal [Tue, 8 Feb 2022 16:15:13 +0000 (09:15 -0700)] 
error.h: make errno number reading easier

Trying to match error number with enum requires manual effort. Make it
easier by adding a comment with errno for every enum value.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agogit: tools: Ignore cgxget and cgxset
Tom Hromatka [Wed, 15 Dec 2021 21:27:39 +0000 (21:27 +0000)] 
git: tools: Ignore cgxget and cgxset

Git ignore the executables cgxget and cgxset

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agogithub: Add a code coverage action
Tom Hromatka [Wed, 15 Dec 2021 21:27:26 +0000 (21:27 +0000)] 
github: Add a code coverage action

Add a code coverage action to the Github workflow.  As part
of this code coverage action, ignore the C file that is
auto-generated from the Cython code.  Also ignore a couple Python
header files that were confusing lcov.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agopython: Add python bindings using Cython
Tom Hromatka [Wed, 15 Dec 2021 21:26:02 +0000 (21:26 +0000)] 
python: Add python bindings using Cython

Add python bindings via the --enable-python configure flag.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agolibcgroup.so: Add a function to get the library version
Tom Hromatka [Wed, 15 Dec 2021 21:22:20 +0000 (21:22 +0000)] 
libcgroup.so: Add a function to get the library version

Add a function, cgroup_version(), that returns the current
version of the libcgroup library.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgxset: libcgroup.so: Add cgroup_cgxset() to library
Tom Hromatka [Fri, 28 Jan 2022 21:29:44 +0000 (14:29 -0700)] 
cgxset: libcgroup.so: Add cgroup_cgxset() to library

Add cgroup_cgxset() to libcgroup.so.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgxget: libcgroup.so: Add cgroup_cgxget() to library
Tom Hromatka [Fri, 28 Jan 2022 21:28:57 +0000 (14:28 -0700)] 
cgxget: libcgroup.so: Add cgroup_cgxget() to library

Add cgroup_cgxget() to libcgroup.so.  Create a new header
file, libcgroup/tools.h, to hold C APIs that are exported
from the tools folder.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agopython: Delete old python bindings
Tom Hromatka [Wed, 15 Dec 2021 21:04:06 +0000 (21:04 +0000)] 
python: Delete old python bindings

Remove the old python bindings.  They will be replaced with Cython
bindings in a subsequent commit.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agogithub: Skip test 38 (cpuset) on VMs hosted by Github Actions
Tom Hromatka [Wed, 15 Dec 2021 21:03:28 +0000 (21:03 +0000)] 
github: Skip test 38 (cpuset) on VMs hosted by Github Actions

Skip test #38 - 038-cgxget-cpuset_settings.py - on servers hosted
by Github Actions.  Test #38 sets/clears the cpuset exclusive bit
and this is not allowed on Github's servers.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>