We have cgclear tool to umount all subsystems, so let's use it. We don't need
the mount point parsing then.

Also, cgclear should success if there are no controllers to remove. Otherwise
it prints error when stopping already stopped cgconfig services.

Signed-off-by: Jan Safranek <[email protected]>
---

 scripts/init.d/cgconfig.in |   60 +-------------------------------------------
 src/tools/cgclear.c        |    4 +++
 2 files changed, 5 insertions(+), 59 deletions(-)

diff --git a/scripts/init.d/cgconfig.in b/scripts/init.d/cgconfig.in
index 445a328..87ab42b 100644
--- a/scripts/init.d/cgconfig.in
+++ b/scripts/init.d/cgconfig.in
@@ -38,10 +38,6 @@ CGROUP_FS=cgroup
 CONFIG_FILE=/etc/cgconfig.conf
 RULES_FILE=/etc/cgrules.conf
 
-# support multiple mount points
-declare -a MOUNTPOINT
-declare -a MOUNTOPTS
-maxindex=0
 servicename=cgconfig
 
 #
@@ -49,28 +45,6 @@ servicename=cgconfig
 #
 . /lib/lsb/init-functions
 
-parse_mounts() {
-    while read name mountpt fs opts other
-    do
-        if echo $name | grep -q $CGROUP_FS
-        then
-            maxindex=$(($maxindex+1))
-            MOUNTPOINT[$maxindex]=$mountpt
-            MOUNTOPTS[$maxindex]=$opts
-        fi
-    done < $MOUNTS_FILE
-
-    return 0;
-}
-
-umount_fs() {
-        for i in `seq 1 $maxindex`
-        do
-                umount ${MOUNTPOINT[$i]}
-                rmdir ${MOUNTPOINT[$i]}
-        done
-}
-
 start() {
         echo -n "Starting cgconfig service: "
        if [ -f /var/lock/subsys/$servicename ]
@@ -108,39 +82,9 @@ start() {
         return 0
 }
 
-move_all_to_init_class() {
-    for i in `seq 1 $maxindex`
-    do
-        cd ${MOUNTPOINT[$i]}
-        cat /proc/mounts | grep -wq ${MOUNTPOINT[$i]}
-        if [ $? -ne 0 ]
-        then
-            log_failure_msg "resource control filesystem not mounted"
-            exit 1
-        fi
-
-        for i in `find . -depth -type d`
-        do
-            case $i in
-            '.')
-                ;;
-            *)
-                class=${i#./*}
-                #log_progress_msg "Removing class $class"
-                sed -nu p < ./$i/tasks > tasks
-                rmdir $i
-                ;;
-            esac
-        done
-        cd - > /dev/null
-    done
-}
-
-
 stop() {
     echo -n "Stopping cgconfig service: "
-    move_all_to_init_class
-    umount_fs
+    /sbin/cgclear
     rm -f /var/lock/subsys/$servicename
     log_success_msg
 }
@@ -165,8 +109,6 @@ common() {
     trap "trapped QUIT" QUIT
     trap "trapped TERM" TERM
     trap "trapped INT"   INT
-
-    parse_mounts
 }
 
 case $1 in
diff --git a/src/tools/cgclear.c b/src/tools/cgclear.c
index 1485768..d93d94a 100644
--- a/src/tools/cgclear.c
+++ b/src/tools/cgclear.c
@@ -28,6 +28,10 @@ int main(int argc, char *argv[])
 
        error = cgroup_unload_cgroups();
 
+       /* Don't spit an error when there is nothing to clear. */
+       if (error = ECGROUPNOTMOUNTED)
+               error = 0;
+
        if (error) {
                printf("%s failed with %s\n", argv[0], cgroup_strerror(error));
                exit(3);


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to