cgconfig: Do not touch subsystems not mounted by cgconfig
In its failure path, cgconfig should only touch the subsystems
it had something to do with. Currently, it unmounts all the
subsystems in the config file. Correct this.
Signed-off-by: Dhaval Giani <dhaval.gi...@gmail.com>
---
src/config.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
Index: libcg/src/config.c
===================================================================
--- libcg.orig/src/config.c
+++ libcg/src/config.c
@@ -431,6 +431,7 @@ static int cgroup_config_mount_fs(void)
int ret;
struct stat buff;
int i;
+ int error;
for (i = 0; i < config_table_index; i++) {
struct cg_mount_table_s *curr = &(config_mount_table[i]);
@@ -439,30 +440,43 @@ static int cgroup_config_mount_fs(void)
if (ret < 0 && errno != ENOENT) {
last_errno = errno;
- return ECGOTHER;
+ error = ECGOTHER;
+ goto out_err;
}
if (errno == ENOENT) {
ret = cg_mkdir_p(curr->mount.path);
- if (ret)
- return ret;
+ if (ret) {
+ error = ret;
+ goto out_err;
+ }
} else if (!S_ISDIR(buff.st_mode)) {
errno = ENOTDIR;
last_errno = errno;
- return ECGOTHER;
+ error = ECGOTHER;
+ goto out_err;
}
- ret = cgroup_config_ajdust_mount_options(curr);
- if (ret)
- return ret;
+ error = cgroup_config_ajdust_mount_options(curr);
+ if (error)
+ goto out_err;
ret = mount(CGROUP_FILESYSTEM, curr->mount.path,
CGROUP_FILESYSTEM, 0, curr->name);
- if (ret < 0)
- return ECGMOUNTFAIL;
+ if (ret < 0) {
+ error = ECGMOUNTFAIL;
+ goto out_err;
+ }
}
return 0;
+out_err:
+ /*
+ * If we come here, we have failed. Since we have touched only
+ * mountpoints prior to i, we shall operate on only them now.
+ */
+ config_table_index = i;
+ return error;
}
/*
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel