When cgconfigparser fails to mount a hierarchy, it should unmount only the hierarchies it mounted before, not those which existed before cgconfigparser was called.
Signed-off-by: Jan Safranek <jsafr...@redhat.com> --- src/config.c | 7 +++++++ src/libcgroup-internal.h | 5 +++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/src/config.c b/src/config.c index 0dd70d8..0a0acf5 100644 --- a/src/config.c +++ b/src/config.c @@ -435,6 +435,7 @@ static int cgroup_config_mount_fs(void) for (i = 0; i < config_table_index; i++) { struct cg_mount_table_s *curr = &(config_mount_table[i]); + curr->mount.mounted = 0; ret = stat(curr->mount.path, &buff); if (ret < 0 && errno != ENOENT) { @@ -461,6 +462,7 @@ static int cgroup_config_mount_fs(void) if (ret < 0) return ECGMOUNTFAIL; + curr->mount.mounted = 1; } return 0; } @@ -515,6 +517,11 @@ static int cgroup_config_unmount_controllers(void) for (i = 0; i < config_table_index; i++) { /* + * Do not unmount anything we did not mount before. + */ + if (!config_mount_table[i].mount.mounted) + continue; + /* * We ignore failures and ensure that all mounted * containers are unmounted */ diff --git a/src/libcgroup-internal.h b/src/libcgroup-internal.h index 45c1ded..c1048eb 100644 --- a/src/libcgroup-internal.h +++ b/src/libcgroup-internal.h @@ -91,6 +91,11 @@ struct cgroup { struct cg_mount_point { char path[FILENAME_MAX]; struct cg_mount_point *next; + /** + * Flag, set if we actually mounted the mount point (and should unmount + * it during error cleanup). + */ + int mounted; }; struct cg_mount_table_s { ------------------------------------------------------------------------------ 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