With systemd managing the mounting/unmounting of
cgroups, cgclear no longer makes sense.  Remove it.

Signed-off-by: Tom Hromatka <tom.hroma...@oracle.com>
---
 .github/workflows/continuous-integration.yml |   2 -
 README_systemd                               |   2 +-
 dist/cgconfig.service                        |   1 -
 dist/libcgroup.spec.in                       |   1 -
 doc/man/Makefile.am                          |   2 +-
 doc/man/cgclear.1                            |  66 ---------
 doc/man/cgdelete.1                           |   2 +-
 scripts/init.d/cgconfig.in                   |   1 -
 src/tools/.gitignore                         |   1 -
 src/tools/Makefile.am                        |   6 +-
 src/tools/cgclear.c                          | 142 -------------------
 11 files changed, 4 insertions(+), 222 deletions(-)
 delete mode 100644 doc/man/cgclear.1
 delete mode 100644 src/tools/cgclear.c

diff --git a/.github/workflows/continuous-integration.yml 
b/.github/workflows/continuous-integration.yml
index 2045b358bfb0..126d6b8838d8 100644
--- a/.github/workflows/continuous-integration.yml
+++ b/.github/workflows/continuous-integration.yml
@@ -67,7 +67,6 @@ jobs:
       run: |
         make check
         pushd tests/ftests
-        ./028-cgclear-basic_cgclear.py --no-container -l 10 -L ftests-28.log
         popd
     - name: Display test logs
       if: ${{ always() }}
@@ -116,7 +115,6 @@ jobs:
       run: |
         make check
         pushd tests/ftests
-        ./028-cgclear-basic_cgclear.py --no-container -l 10 -L ftests-28.log
         popd
     - name: Display test logs
       if: ${{ always() }}
diff --git a/README_systemd b/README_systemd
index 6733c2c49d6a..ac53b9909cbb 100644
--- a/README_systemd
+++ b/README_systemd
@@ -30,7 +30,7 @@ to do so:
 
 Consequently, the 'name=systemd' hierarchy will not be visible to libcgroup and
 all of its tools. For example, the lscgroup command will not list systemd
-cgroups and the cgclear command will not remove them.
+cgroups.
 
 Start-up and services
 ====================
diff --git a/dist/cgconfig.service b/dist/cgconfig.service
index e63f26dcd5c6..00bd056c389f 100644
--- a/dist/cgconfig.service
+++ b/dist/cgconfig.service
@@ -11,7 +11,6 @@ Before=basic.target shutdown.target
 Type=oneshot
 RemainAfterExit=yes
 ExecStart=/sbin/cgconfigparser -l /etc/cgconfig.conf -s 1664
-ExecStop=/sbin/cgclear -l /etc/cgconfig.conf -e
 
 [Install]
 WantedBy=sysinit.target
diff --git a/dist/libcgroup.spec.in b/dist/libcgroup.spec.in
index 838290d87a4d..9c83db0bdc80 100644
--- a/dist/libcgroup.spec.in
+++ b/dist/libcgroup.spec.in
@@ -113,7 +113,6 @@ fi
 /bin/lssubsys
 /sbin/cgconfigparser
 /sbin/cgrulesengd
-/sbin/cgclear
 /bin/cgsnapshot
 %attr(0644, root, root) %{_mandir}/man1/*
 %attr(0644, root, root) %{_mandir}/man5/*
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
index 26338d82a395..f14fe4e3b287 100644
--- a/doc/man/Makefile.am
+++ b/doc/man/Makefile.am
@@ -1,5 +1,5 @@
 man_MANS = cgclassify.1 cgconfig.conf.5 cgconfigparser.8 cgexec.1 cgred.conf.5 
\
-           cgrules.conf.5 cgrulesengd.8 cgcreate.1 cgset.1 cgclear.1 cgget.1 \
+           cgrules.conf.5 cgrulesengd.8 cgcreate.1 cgset.1 cgget.1 \
            cgdelete.1 lssubsys.1 lscgroup.1 cgsnapshot.1
 
 EXTRA_DIST = $(man_MANS)
diff --git a/doc/man/cgclear.1 b/doc/man/cgclear.1
deleted file mode 100644
index 241a095626c1..000000000000
--- a/doc/man/cgclear.1
+++ /dev/null
@@ -1,66 +0,0 @@
-.\" Copyright IBM Corporation. 2009.
-.\" Written by Dhaval Giani <dha...@linux.vnet.ibm.com>.
-
-.TH CGCLEAR  1 2009-10-23 "Linux" "libcgroup Manual"
-.SH NAME
-cgclear \- unload the cgroup filesystem
-
-.SH SYNOPSIS
-\fBcgclear\fR [\fB-e\fR] [\fB-l\fR <\fIfilename\fR>] [\fB-L\fR 
<\fIdirectory\fR>] [...]
-
-.SH DESCRIPTION
-
-Without parameters, this command moves all the tasks inside the various cgroups
-to the root cgroup, deletes all the cgroups and finally
-unmounts the cgroup filesystem from the system.
-
-If one or more config files are specified, only groups defined in the config
-files are removed. The files are processed in reverse order, i.e. the last
-file on command line is processed first, so \fBcgclear\fR can have the same
-command line arguments as appropriate \fBcgconfigparser\fR.
-
-.TP
-.B -l, --load=<filename>
-specifies the config file to read. This option can be used multiple times and
-can be mixed with \fB-L\fR option.
-
-.TP
-.B -L, --load-directory=<directory>
-specifies the directory, which is searched for configuration files. All files
-in this directory will be processed in alphabetical order as they were 
specified
-by \fB-l\fR option. This option can be used multiple times and
-can be mixed with \fB-l\fR option.
-
-.TP
-.B -e
-specifies that only empty groups should be removed. If a group defined in a
-config file has tasks inside or has a subgroup, it won't be removed. This
-option works only with \fB-l\fR or \fB-L\fR options.
-
-.SH ENVIRONMENT VARIABLES
-.TP
-.B CGROUP_LOGLEVEL
-controls verbosity of the tool. Allowed values are \fBDEBUG\fR,
-\fBINFO\fR, \fBWARNING\fR or \fBERROR\fR.
-
-.SH FILES
-.TP
-.B /etc/cgconfig.conf
-default templates file
-.TP
-.B /etc/cgconfig.d/
-default templates files directory
-.RE
-
-
-.SH EXAMPLES
-.TP
-.B cgclear
-unload the whole cgroup filesystem
-
-.TP
-.B cgclear -l /etc/cgconfig.conf
-unload a subsystem of cgroup filesystem based on \fB/etc/cgconfig.conf\fR 
definition.
-
-.SH SEE ALSO
-cgconfigparser(1), cgconfig.conf(5)
diff --git a/doc/man/cgdelete.1 b/doc/man/cgdelete.1
index 957228713142..566830d10b2b 100644
--- a/doc/man/cgdelete.1
+++ b/doc/man/cgdelete.1
@@ -42,4 +42,4 @@ remove control group test from hierarchies containing cpu and 
device controllers
 
 
 .SH SEE ALSO
-cgcreate (1), lscgroup (1), cgclear (1)
+cgcreate (1), lscgroup (1)
diff --git a/scripts/init.d/cgconfig.in b/scripts/init.d/cgconfig.in
index f299d0ff3f73..0d7446edf598 100644
--- a/scripts/init.d/cgconfig.in
+++ b/scripts/init.d/cgconfig.in
@@ -132,7 +132,6 @@ start() {
 
 stop() {
     echo -n "Stopping cgconfig service: "
-    cgclear
     rm -f "$lockfile"
     log_success_msg
     return 0
diff --git a/src/tools/.gitignore b/src/tools/.gitignore
index d87e9452da72..2293fcf34872 100644
--- a/src/tools/.gitignore
+++ b/src/tools/.gitignore
@@ -1,5 +1,4 @@
 cgclassify
-cgclear
 cgconfigparser
 cgcreate
 cgdelete
diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am
index 0fc1f36e3daf..dc8ec9d4b6dd 100644
--- a/src/tools/Makefile.am
+++ b/src/tools/Makefile.am
@@ -8,7 +8,7 @@ if WITH_TOOLS
 bin_PROGRAMS = cgexec cgclassify cgcreate cgset cgget cgdelete lssubsys\
                lscgroup cgsnapshot
 
-sbin_PROGRAMS = cgconfigparser cgclear
+sbin_PROGRAMS = cgconfigparser
 
 lib_LTLIBRARIES = libcgset.la
 
@@ -40,10 +40,6 @@ cgconfigparser_SOURCES = cgconfig.c tools-common.c 
tools-common.h
 cgconfigparser_LIBS = $(CODE_COVERAGE_LIBS)
 cgconfigparser_CFLAGS = $(CODE_COVERAGE_CFLAGS)
 
-cgclear_SOURCES = cgclear.c tools-common.c tools-common.h
-cgclear_LIBS = $(CODE_COVERAGE_LIBS)
-cgclear_CFLAGS = $(CODE_COVERAGE_CFLAGS)
-
 cgdelete_SOURCES = cgdelete.c tools-common.c tools-common.h
 cgdelete_LIBS = $(CODE_COVERAGE_LIBS)
 cgdelete_CFLAGS = $(CODE_COVERAGE_CFLAGS)
diff --git a/src/tools/cgclear.c b/src/tools/cgclear.c
deleted file mode 100644
index 27cc47acbf87..000000000000
--- a/src/tools/cgclear.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright IBM Corporation. 2009
- *
- * Authors:    Dhaval Giani <dha...@linux.vnet.ibm.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Code initiated and designed by Dhaval Giani. All faults are most likely
- * his mistake.
- */
-
-#include <libcgroup.h>
-#include <libcgroup-internal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <getopt.h>
-#include "tools-common.h"
-
-static struct cgroup_string_list cfg_files;
-
-static void usage(int status, const char *program_name)
-{
-       if (status != 0) {
-               fprintf(stderr, "Wrong input parameters,"
-                       " try %s -h' for more information.\n",
-                       program_name);
-               return;
-       }
-       printf("Usage: %s [-h] [-l FILE] [-L DIR] [-e]\n",
-               program_name);
-       printf("Unload the cgroup filesystem\n");
-       printf("  -e, --empty                   Remove only empty cgroups\n");
-       printf("  -h, --help                    Display this help\n");
-       printf("  -l, --load=FILE               Parse and load the cgroups "\
-               "configuration file\n");
-       printf("  -L, --load-directory=DIR      Parse and load the cgroups "\
-               "configuration files from a directory\n");
-}
-
-static void report_error(int error, const char *program_name)
-{
-       /* Don't spit an error when there is nothing to clear. */
-       if (error == ECGROUPNOTMOUNTED)
-               error = 0;
-       if (error) {
-               printf("%s failed with %s\n", program_name,
-                               cgroup_strerror(error));
-       }
-}
-
-
-int main(int argc, char *argv[])
-{
-       int error = 0, ret;
-       int c;
-       int unload_all = 1;
-       int flags = CGFLAG_DELETE_RECURSIVE;
-
-       struct option longopts[] = {
-                       {"load", required_argument, 0,  'l' },
-                       {"load-directory", required_argument, 0,  'L' },
-                       {"only-empty", no_argument, 0,  'e' },
-                       {"help", no_argument, 0, 'h'},
-                       { 0, 0, 0, 0}
-       };
-
-       ret = cgroup_string_list_init(&cfg_files, argc/2);
-       if (ret) {
-               fprintf(stderr, "%s: cannot initialize list of files,"
-                               " out of memory?\n",
-                               argv[0]);
-               exit(1);
-       }
-
-       while ((c = getopt_long(argc, argv, "hl:L:e", longopts, NULL)) > 0) {
-               switch (c) {
-               case 'e':
-                       flags = CGFLAG_DELETE_EMPTY_ONLY;
-                       break;
-
-               case 'l':
-                       unload_all = 0;
-                       ret = cgroup_string_list_add_item(&cfg_files, optarg);
-                       if (ret) {
-                               fprintf(stderr, "%s: cannot add file to list,"\
-                                               " out of memory?\n", argv[0]);
-                               exit(1);
-                       }
-                       break;
-
-               case 'L':
-                       unload_all = 0;
-                       cgroup_string_list_add_directory(&cfg_files, optarg,
-                                       argv[0]);
-                       break;
-
-               case 'h':
-                       usage(0, argv[0]);
-                       exit(0);
-               default:
-                       usage(1, argv[0]);
-                       exit(1);
-               }
-       }
-
-       if (unload_all) {
-               error = cgroup_unload_cgroups();
-               if (error)
-                       report_error(error, argv[0]);
-       } else {
-               int i;
-
-               ret = cgroup_init();
-               if (ret) {
-                       report_error(ret, argv[0]);
-                       exit(4);
-               }
-               /* process the config files in reverse order */
-               for (i = cfg_files.count-1; i >= 0 ; i--) {
-                       ret = cgroup_config_unload_config(cfg_files.items[i],
-                                       flags);
-                       if (ret && ret != ECGNONEMPTY) {
-                               report_error(ret, argv[0]);
-                               if (!error)
-                                       error = ret;
-                       }
-               }
-       }
-       cgroup_string_list_free(&cfg_files);
-       if (error)
-               exit(3);
-
-       return 0;
-}
-- 
2.26.3



_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to