diff --git a/SOURCES/cgconfig.service b/SOURCES/cgconfig.service
index 9b546a6..d9a491f 100644
--- a/SOURCES/cgconfig.service
+++ b/SOURCES/cgconfig.service
@@ -10,8 +10,8 @@ Before=basic.target shutdown.target
 [Service]
 Type=oneshot
 RemainAfterExit=yes
-ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf -s 1664
-ExecStop=/usr/sbin/cgclear -l /etc/cgconfig.conf -e
+ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf -L /etc/cgconfig.d -s 1664
+ExecStop=/usr/sbin/cgclear -l /etc/cgconfig.conf -L /etc/cgconfig.d -e
 
 [Install]
 WantedBy=sysinit.target
diff --git a/SOURCES/libcgroup-0.40.rc1-retry-to-set-control-file.patch b/SOURCES/libcgroup-0.40.rc1-retry-to-set-control-file.patch
new file mode 100644
index 0000000..60e21ec
--- /dev/null
+++ b/SOURCES/libcgroup-0.40.rc1-retry-to-set-control-file.patch
@@ -0,0 +1,85 @@
+From c81248e53bd43a2132ce0b0a5aee4951c8618b6f Mon Sep 17 00:00:00 2001
+From: Jan Chaloupka <jchaloup@redhat.com>
+Date: Thu, 7 Aug 2014 07:17:23 +0200
+Subject: [PATCH] retry to set control file
+
+---
+ src/api.c | 35 +++++++++++++++++++++++++++++++++++
+ 1 file changed, 35 insertions(+)
+
+diff --git a/src/api.c b/src/api.c
+index ae8396e..03c8068 100644
+--- a/src/api.c
++++ b/src/api.c
+@@ -1432,6 +1432,8 @@ static int cg_set_control_value(char *path, const char *val)
+ 	return 0;
+ }
+ 
++
++
+ /** cgroup_modify_cgroup modifies the cgroup control files.
+  * struct cgroup *cgroup: The name will be the cgroup to be modified.
+  * The values will be the values to be modified, those not mentioned
+@@ -1449,6 +1451,9 @@ int cgroup_modify_cgroup(struct cgroup *cgroup)
+ 	int i;
+ 	int error = 0;
+ 	int ret;
++	int retry_list[CG_CONTROLLER_MAX];
++	int retry_index;
++	struct control_value **cvalues;
+ 
+ 	if (!cgroup_initialized)
+ 		return ECGROUPNOTINITIALIZED;
+@@ -1469,6 +1474,8 @@ int cgroup_modify_cgroup(struct cgroup *cgroup)
+ 		if (!cg_build_path(cgroup->name, base,
+ 			cgroup->controller[i]->name))
+ 			continue;
++
++		retry_index = -1;
+ 		for (j = 0; j < cgroup->controller[i]->index; j++) {
+ 			ret = asprintf(&path, "%s%s", base,
+ 				cgroup->controller[i]->values[j]->name);
+@@ -1485,12 +1492,40 @@ int cgroup_modify_cgroup(struct cgroup *cgroup)
+ 			 * the user as fatal */
+ 			if (error && !cgroup->controller[i]->values[j]->dirty) {
+ 				error = 0;
++				/* Let's retry to set it in the second round */
++				++retry_index;
++				retry_list[retry_index] = j;
+ 				continue;
+ 			}
+ 			if (error)
+ 				goto err;
+ 			cgroup->controller[i]->values[j]->dirty = false;
+ 		}
++		if (retry_index > -1) {
++			for (j = 0; j <= retry_index; j++) {
++				cvalues = cgroup->controller[i]->values;
++				ret = asprintf(&path, "%s%s", base,
++					cvalues[retry_list[j]]->name);
++				if (ret < 0) {
++					last_errno = errno;
++					error = ECGOTHER;
++					goto err;
++				}
++				error = cg_set_control_value(path,
++					cvalues[retry_list[j]]->value);
++				free(path);
++				path = NULL;
++				/* don't consider error in files directly
++				 * written by the user as fatal */
++				if (error && !cvalues[retry_list[j]]->dirty) {
++					error = 0;
++					continue;
++				}
++				if (error)
++					goto err;
++				cvalues[retry_list[j]]->dirty = false;
++			}
++		}
+ 	}
+ err:
+ 	return error;
+-- 
+1.9.3
+
diff --git a/SOURCES/libcgroup-0.41-add-examples-to-man-pages.patch b/SOURCES/libcgroup-0.41-add-examples-to-man-pages.patch
new file mode 100644
index 0000000..cbc0116
--- /dev/null
+++ b/SOURCES/libcgroup-0.41-add-examples-to-man-pages.patch
@@ -0,0 +1,280 @@
+From d58a95615a146f868106411aecd61af182d7c7e2 Mon Sep 17 00:00:00 2001
+From: Jan Chaloupka <jchaloup@redhat.com>
+Date: Sun, 21 Sep 2014 12:05:11 +0200
+Subject: [PATCH] add examples to man pages
+
+---
+ doc/man/cgclassify.1     | 18 ++++++++++++++++++
+ doc/man/cgclear.1        | 21 ++++++++++++++++++++-
+ doc/man/cgconfig.conf.5  |  5 +----
+ doc/man/cgconfigparser.8 | 14 ++++++++++++++
+ doc/man/cgcreate.1       |  9 ++++++++-
+ doc/man/cgdelete.1       |  8 +++++++-
+ doc/man/cgred.conf.5     |  2 +-
+ doc/man/cgrulesengd.8    |  3 ---
+ doc/man/cgset.1          | 11 +++++++++++
+ doc/man/cgsnapshot.1     | 15 ++++++++++++++-
+ doc/man/lscgroup.1       | 15 +++++++++++++++
+ 11 files changed, 109 insertions(+), 12 deletions(-)
+
+diff --git a/doc/man/cgclassify.1 b/doc/man/cgclassify.1
+index db4e086..1facd2b 100644
+--- a/doc/man/cgclassify.1
++++ b/doc/man/cgclassify.1
+@@ -57,7 +57,25 @@ controls verbosity of the tool. Allowed values are \fBDEBUG\fR,
+ .TP
+ .B /etc/cgrules.conf
+ default libcgroup configuration file
++.TP
++.B /etc/cgrules.d
++default libcgroup configuration files directory
++
++.SH EXAMPLES
++.TP
++.B cgclassify -g cpu:student 1234
++moves process with pid number 1234 to control group student in cpu hierarchy.
+ 
++.TP
++.B cgclassify 1234
++moves process with pid number 1234 to control groups based on
++\fB/etc/cgrules.conf\fR configuration file.
++
++.TP
++.B cgclassify --sticky -g cpu:/student 1234
++moves process with pid number 1234 to control group student in cpu hierarchy.
++The daemon of service cgred does not change cgroups of pid 1234 and its children
++(based on \fB/etc/cgrules.conf\fR).
+ 
+ .SH SEE ALSO
+ cgrules.conf (5), cgexec (1)
+diff --git a/doc/man/cgclear.1 b/doc/man/cgclear.1
+index 318c925..241a095 100644
+--- a/doc/man/cgclear.1
++++ b/doc/man/cgclear.1
+@@ -43,5 +43,24 @@ option works only with \fB-l\fR or \fB-L\fR options.
+ 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)
++cgconfigparser(1), cgconfig.conf(5)
+diff --git a/doc/man/cgconfig.conf.5 b/doc/man/cgconfig.conf.5
+index a7d9935..f3a4ba9 100644
+--- a/doc/man/cgconfig.conf.5
++++ b/doc/man/cgconfig.conf.5
+@@ -784,15 +784,12 @@ better to explicitly specify all groups and all controllers
+ related to them.
+ 
+ .SH FILES
+-.LP
+-.PD .1v
+ .TP
+ .B /etc/cgconfig.conf
+-.TP
+ default libcgroup configuration file
++.TP
+ .B /etc/cgconfig.d/
+ default libcgroup configuration files directory
+-.PD 
+ 
+ .SH SEE ALSO
+ cgconfigparser (8)
+diff --git a/doc/man/cgconfigparser.8 b/doc/man/cgconfigparser.8
+index 0a20f95..8fff95f 100644
+--- a/doc/man/cgconfigparser.8
++++ b/doc/man/cgconfigparser.8
+@@ -74,5 +74,19 @@ of this group have write access to the file.
+ 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 libcgroup configuration file
++.TP
++.B /etc/cgconfig.d/
++default libcgroup configuration files directory
++
++.SH EXAMPLES
++.TP
++.B cgconfigparser -l /etc/cgconfig.conf
++setup control group file system based on \fB/etc/cgconfig.conf\fR configuration file
++
++
+ .SH SEE ALSO
+ cgconfig.conf (5)
+diff --git a/doc/man/cgcreate.1 b/doc/man/cgcreate.1
+index 557b5ae..17c33d8 100644
+--- a/doc/man/cgcreate.1
++++ b/doc/man/cgcreate.1
+@@ -70,7 +70,14 @@ The default value is the same as has the parent cgroup.
+ controls verbosity of the tool. Allowed values are \fBDEBUG\fR,
+ \fBINFO\fR, \fBWARNING\fR or \fBERROR\fR.
+ 
+-.SH FILES
++.SH EXAMPLES
++.TP
++.B cgcreate -g *:student -g devices:teacher
++create control group student in all mounted hierarchies and create
++control group teacher in hierarchy containing controller devices.
++
++
++
+ 
+ .SH SEE ALSO
+ cgrules.conf (5)
+diff --git a/doc/man/cgdelete.1 b/doc/man/cgdelete.1
+index 025a799..9572287 100644
+--- a/doc/man/cgdelete.1
++++ b/doc/man/cgdelete.1
+@@ -16,7 +16,7 @@ program removes all specified control groups.
+ 
+ .TP
+ .B [-g] <controllers>:<path>
+-Defines the control group to delete. Multiple control groups nay be
++Defines the control group to delete. Multiple control groups may be
+ specified.
+ .B -g
+ is optional.
+@@ -35,5 +35,11 @@ Recursively remove all subgroups.
+ controls verbosity of the tool. Allowed values are \fBDEBUG\fR,
+ \fBINFO\fR, \fBWARNING\fR or \fBERROR\fR.
+ 
++.SH EXAMPLES
++.TP
++.B cgdelete -g cpu,devices:/test
++remove control group test from hierarchies containing cpu and device controllers
++
++
+ .SH SEE ALSO
+ cgcreate (1), lscgroup (1), cgclear (1)
+diff --git a/doc/man/cgred.conf.5 b/doc/man/cgred.conf.5
+index 3fe760f..1c0922f 100644
+--- a/doc/man/cgred.conf.5
++++ b/doc/man/cgred.conf.5
+@@ -42,7 +42,7 @@ default libcgroup configuration file
+ 
+ .SH SEE ALSO
+ cgrules.conf (5),
+-cgconfig.conf (5)
++cgconfig.conf (5), cgrules.d (5)
+ 
+ 
+ 
+diff --git a/doc/man/cgrulesengd.8 b/doc/man/cgrulesengd.8
+index 749b6fc..2810aa5 100644
+--- a/doc/man/cgrulesengd.8
++++ b/doc/man/cgrulesengd.8
+@@ -63,11 +63,8 @@ controls verbosity of the tool. Allowed values are \fBDEBUG\fR,
+ \fBINFO\fR, \fBWARNING\fR or \fBERROR\fR.
+ 
+ .SH FILES
+-.LP
+-.PD .1v
+ .TP
+ .B /etc/cgrules.conf
+-.TP
+ the default libcgroup configuration file
+ .TP
+ .B /etc/cgconfig.conf
+diff --git a/doc/man/cgset.1 b/doc/man/cgset.1
+index be886c6..b05473f 100644
+--- a/doc/man/cgset.1
++++ b/doc/man/cgset.1
+@@ -36,5 +36,16 @@ copied to the input cgroup.
+ controls verbosity of the tool. Allowed values are \fBDEBUG\fR,
+ \fBINFO\fR, \fBWARNING\fR or \fBERROR\fR.
+ 
++.SH EXAMPLES
++.TP
++.B cgset -r cpuset.cpus=0-1 student
++set variable cpus in control group student (controller cpuset) to 0-1
++
++.TP
++.B cgset --copy-from group1/ group2/
++copy all parameters of group group1 to group group2
++(for all path where both cgroups are defined)
++
++
+ .SH SEE ALSO
+ cgrules.conf (1), cgcreate (1), cgget (1)
+diff --git a/doc/man/cgsnapshot.1 b/doc/man/cgsnapshot.1
+index 03c85f6..48a038e 100644
+--- a/doc/man/cgsnapshot.1
++++ b/doc/man/cgsnapshot.1
+@@ -8,7 +8,7 @@ cgsnapshot \- generate the configuration file for given controllers
+ 
+ .SH SYNOPSIS
+ \fBcgsnapshot\fR [\fB-h\fR] [\fB-s\fR] [\fB-t\fR] [\fB-b\fR \fIfile\fR]
+-[\fB-w\fR \fIfile\fR] [\fB-f\fR \fIoutput_file\fR]  [\fBcontroller\fR] [...]
++[\fB-w\fR \fIfile\fR] [\fB-f\fR \fIoutput_file\fR] [\fBcontroller\fR] [...]
+ 
+ .SH DESCRIPTION
+ \fBcgsnapshot\fR
+@@ -96,5 +96,18 @@ default whitelist
+ .B /etc/cgconfig.conf
+ default libcgroup configuration file
+ 
++.SH EXAMPLES
++.TP
++.B cgsnapshot -s -f /etc/cgconfig.conf.cgsnapshot
++create configuration file which contains all mounted controllers and all
++control groups which are on the actual system
++
++.TP
++.B cgsnapshot -s -f /etc/cgconfig.conf.cgsnapshot cpu
++create configuration file which contains hierarchy containing cpu controller and all its
++control groups on the actual system
++
++
++
+ .SH SEE ALSO
+ cgconfig.conf (5)
+diff --git a/doc/man/lscgroup.1 b/doc/man/lscgroup.1
+index 693fbbc..124379e 100644
+--- a/doc/man/lscgroup.1
++++ b/doc/man/lscgroup.1
+@@ -26,6 +26,21 @@ list all existing cgroups.
+ controls verbosity of the tool. Allowed values are \fBDEBUG\fR,
+ \fBINFO\fR, \fBWARNING\fR or \fBERROR\fR.
+ 
++.SH EXAMPLES
++.TP
++.B lscgroup -g cpu:/
++list all cgroups which are in hierarchy containing cpu controller
++
++.TP
++.B lscgroup -g cpu:/student
++list all cgroups which are in hierarchy containing cpu controller
++in subgroup student
++
++.TP
++.B lscgroup
++list all cgroups which in all hierarchies
++
++
+ .SH SEE ALSO
+ lssubsys (1), cgcreate (1), cgdelete (1),
+ cgconfig.conf (5)
+-- 
+1.9.3
+
diff --git a/SOURCES/libcgroup-0.41-api.c-support-for-setting-multiline-values-in-contro.patch b/SOURCES/libcgroup-0.41-api.c-support-for-setting-multiline-values-in-contro.patch
new file mode 100644
index 0000000..fba6b9b
--- /dev/null
+++ b/SOURCES/libcgroup-0.41-api.c-support-for-setting-multiline-values-in-contro.patch
@@ -0,0 +1,150 @@
+From 691430206f1104b752b0e52386f317e639137788 Mon Sep 17 00:00:00 2001
+From: Jan Chaloupka <jchaloup@redhat.com>
+Date: Mon, 15 Sep 2014 13:29:39 +0200
+Subject: [PATCH] api.c: support for setting multiline values in control files
+
+As of now, libcgroup does not support multiline values setting from configuration files. i.e. values in a form:
+
+net_prio.ifpriomap="lo 7
+eth0 66
+eth1 5
+eth2 4
+eth3 3";
+
+Thus, setting of more network interfaces can not be done from configuration file. Or
+
+devices.allow="a *:* w
+c 8:* r";
+
+thus setting list of allow devices can not be set as well. The only way is to set it from userspace, e.g.:
+# echo "lo 7" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap
+# echo "eth 0" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap
+# echo "eth 1" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap
+# echo "eth 2" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap
+# echo "eth 3" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap
+
+This patch allows setting of multiline variables.
+
+How this support works:
+Multiline value is broken in lines and each line is set by write (man 2 write) syscall (without bufferring).
+This implies change of fopen with open, fclose with close.
+There is no control on multiline value, thus "eth0\n  \t\n" can be set. However, setting
+of "  \t" will fail as write command returns -1. Thus administrator has to set correct
+multiline values.
+
+Tested on virtual machine with fedora and rhel with network interface lo, eth0-eth3. Configuration file:
+
+# cat /etc/cgconfig.conf
+group testGroup {
+        net_prio {
+                net_prio.ifpriomap="lo 7
+eth0    66
+eth1 5
+eth2 4
+eth3 3";
+        }
+}
+
+net_prio has to be created before:
+# modprobe netprio_cgroup
+# mkdir /sys/fs/cgroup/net_prio
+# mount -t cgroup -onet_prio none /sys/fs/cgroup/net_prio
+
+Changelog:
+	test of success of strdup call
+	free str_val before return (str_val is changing in while cycle,
+		thus str_start_val points to the start of str_val before while)
+
+Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
+---
+ src/api.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------
+ 1 file changed, 44 insertions(+), 6 deletions(-)
+
+diff --git a/src/api.c b/src/api.c
+index 5751b8f..d6c9d3a 100644
+--- a/src/api.c
++++ b/src/api.c
+@@ -1495,13 +1495,18 @@ static int cg_create_control_group(const char *path)
+  */
+ static int cg_set_control_value(char *path, const char *val)
+ {
+-	FILE *control_file = NULL;
++	int ctl_file;
++	char *str_val;
++	char *str_val_start;
++	char *pos;
++	size_t len;
++
+ 	if (!cg_test_mounted_fs())
+ 		return ECGROUPNOTMOUNTED;
+ 
+-	control_file = fopen(path, "r+e");
++	ctl_file = open(path, O_RDWR | O_CLOEXEC);
+ 
+-	if (!control_file) {
++	if (ctl_file == -1) {
+ 		if (errno == EPERM) {
+ 			/*
+ 			 * We need to set the correct error value, does the
+@@ -1512,6 +1517,7 @@ static int cg_set_control_value(char *path, const char *val)
+ 			 */
+ 			char *path_dir_end;
+ 			char *tasks_path;
++			FILE *control_file;
+ 
+ 			path_dir_end = strrchr(path, '/');
+ 			if (path_dir_end == NULL)
+@@ -1543,15 +1549,47 @@ static int cg_set_control_value(char *path, const char *val)
+ 		return ECGROUPVALUENOTEXIST;
+ 	}
+ 
+-	if (fprintf(control_file, "%s", val) < 0) {
++	/* Split the multiline value into lines. */
++	/* One line is a special case of multiline value. */
++	str_val = strdup(val);
++	if (str_val == NULL) {
+ 		last_errno = errno;
+-		fclose(control_file);
++		close(ctl_file);
+ 		return ECGOTHER;
+ 	}
+-	if (fclose(control_file) < 0) {
++
++	str_val_start = str_val;
++	pos = str_val;
++
++	do {
++		str_val = pos;
++		pos = strchr(str_val, '\n');
++
++		if (pos) {
++			*pos = '\0';
++			++pos;
++		}
++
++		len = strlen(str_val);
++		if (len > 0) {
++			if (write(ctl_file, str_val, len) == -1) {
++				last_errno = errno;
++				free(str_val_start);
++				close(ctl_file);
++				return ECGOTHER;
++			}
++		} else
++			cgroup_warn("Warning: skipping empty line for %s\n",
++				path);
++	} while(pos);
++
++	if (close(ctl_file)) {
+ 		last_errno = errno;
++		free(str_val_start);
+ 		return ECGOTHER;
+ 	}
++
++	free(str_val_start);
+ 	return 0;
+ }
+ 
+-- 
+1.9.3
+
diff --git a/SOURCES/libcgroup-0.41-config.c-xfs-file-system-sets-item-d_type-to-zero-st.patch b/SOURCES/libcgroup-0.41-config.c-xfs-file-system-sets-item-d_type-to-zero-st.patch
new file mode 100644
index 0000000..0bc2b62
--- /dev/null
+++ b/SOURCES/libcgroup-0.41-config.c-xfs-file-system-sets-item-d_type-to-zero-st.patch
@@ -0,0 +1,58 @@
+From 982a59755252f8a263e8004a09eceb6fdfbd5242 Mon Sep 17 00:00:00 2001
+From: Jan Chaloupka <jchaloup@redhat.com>
+Date: Sat, 20 Sep 2014 21:06:33 +0200
+Subject: [PATCH] config.c: xfs file system sets item->d_type to zero, stat()
+ and S_ISREG() test added
+
+---
+ src/tools/tools-common.c | 21 ++++++++++++++++-----
+ 1 file changed, 16 insertions(+), 5 deletions(-)
+
+diff --git a/src/tools/tools-common.c b/src/tools/tools-common.c
+index 211a49a..f1b7711 100644
+--- a/src/tools/tools-common.c
++++ b/src/tools/tools-common.c
+@@ -201,17 +201,24 @@ int cgroup_string_list_add_directory(struct cgroup_string_list *list,
+ 	do {
+ 		errno = 0;
+ 		item = readdir(d);
+-		if (item && (item->d_type == DT_REG
+-				|| item->d_type == DT_LNK)) {
+-			char *tmp;
++
++		struct stat st;
++
++		char * tmp;
++
++		if (item) {
+ 			ret = asprintf(&tmp, "%s/%s", dirname, item->d_name);
+ 			if (ret < 0) {
+ 				fprintf(stderr, "%s: out of memory\n",
+ 						program_name);
+ 				exit(1);
+ 			}
+-			ret = cgroup_string_list_add_item(list, tmp);
+-			free(tmp);
++		}
++
++		if (item && (item->d_type == DT_REG
++			|| item->d_type == DT_LNK
++			|| (stat(tmp, &st) >= 0 && S_ISREG(st.st_mode)) ) ) {
++			ret = cgroup_string_list_add_item(list, tmp); 
+ 			count++;
+ 			if (ret) {
+ 				fprintf(stderr, "%s: %s\n",
+@@ -225,6 +232,10 @@ int cgroup_string_list_add_directory(struct cgroup_string_list *list,
+ 					program_name, dirname, strerror(errno));
+ 			exit(1);
+ 		}
++
++		if (item) {
++			free(tmp);
++		} 
+ 	} while (item != NULL);
+ 	closedir(d);
+ 
+-- 
+1.9.3
+
diff --git a/SOURCES/libcgroup-0.41-extending-cgroup-names-with-default.patch b/SOURCES/libcgroup-0.41-extending-cgroup-names-with-default.patch
new file mode 100644
index 0000000..18ef105
--- /dev/null
+++ b/SOURCES/libcgroup-0.41-extending-cgroup-names-with-default.patch
@@ -0,0 +1,65 @@
+From c3b2fbe31273ea71a02c86e780f0f3c0a0fa845f Mon Sep 17 00:00:00 2001
+From: Jan Chaloupka <jchaloup@redhat.com>
+Date: Sat, 20 Sep 2014 23:46:57 +0200
+Subject: [PATCH] extending cgroup names with default
+
+---
+ src/lex.l   |  2 +-
+ src/parse.y | 14 ++++++++++++--
+ 2 files changed, 13 insertions(+), 3 deletions(-)
+
+diff --git a/src/lex.l b/src/lex.l
+index 1b357db..ff2b3e5 100644
+--- a/src/lex.l
++++ b/src/lex.l
+@@ -42,7 +42,7 @@ jmp_buf parser_error_env;
+ "group"		{return GROUP;}
+ "namespace"	{return NAMESPACE;}
+ "template"	{return TEMPLATE;}
+-"default"	{return DEFAULT;}
++"default"	{yylval.name = strdup(yytext); return DEFAULT;}
+ [a-zA-Z0-9_\-\/\.\,\%\@]+ {yylval.name = strdup(yytext); return ID;}
+ \"[^"]*\" {yylval.name = strdup(yytext+1); yylval.name[strlen(yylval.name)-1] = '\0'; return ID; }
+ .	{return yytext[0];}
+diff --git a/src/parse.y b/src/parse.y
+index 9adbc0e..e67ad54 100644
+--- a/src/parse.y
++++ b/src/parse.y
+@@ -45,7 +45,7 @@ int yywrap(void)
+ 	int val;
+ 	struct cgroup_dictionary *values;
+ }
+-%type <name> ID
++%type <name> ID DEFAULT group_name
+ %type <val> mountvalue_conf mount task_namevalue_conf admin_namevalue_conf
+ %type <val> admin_conf task_conf task_or_admin group_conf group start
+ %type <val> namespace namespace_conf default default_conf
+@@ -99,7 +99,7 @@ default_conf
+ 	}
+ 	;
+ 
+-group   :       GROUP ID '{' group_conf '}'
++group   :       GROUP group_name '{' group_conf '}'
+ 	{
+ 		$$ = $4;
+ 		if ($$) {
+@@ -119,6 +119,16 @@ group   :       GROUP ID '{' group_conf '}'
+ 	}
+         ;
+ 
++group_name
++	:	ID
++	{
++		$$ = $1;
++	}
++	|	DEFAULT
++	{
++		$$ = $1;
++	}
++
+ group_conf
+         :       ID '{' namevalue_conf '}'
+ 	{
+-- 
+1.9.3
+
diff --git a/SOURCES/libcgroup-0.41-loading-configuration-files-from-etc-cgconfig.d-dire.patch b/SOURCES/libcgroup-0.41-loading-configuration-files-from-etc-cgconfig.d-dire.patch
new file mode 100644
index 0000000..019459e
--- /dev/null
+++ b/SOURCES/libcgroup-0.41-loading-configuration-files-from-etc-cgconfig.d-dire.patch
@@ -0,0 +1,571 @@
+From 7b1b0409f5fc1828f0feb2086fe5b8184f7eb2c6 Mon Sep 17 00:00:00 2001
+From: Jan Chaloupka <jchaloup@redhat.com>
+Date: Sat, 20 Sep 2014 20:02:13 +0200
+Subject: [PATCH] loading configuration files from /etc/cgconfig.d/ directory
+
+---
+ Makefile.in                |   2 +-
+ doc/man/cgconfig.conf.5    |   7 +-
+ doc/man/cgrulesengd.8      |   8 +-
+ include/libcgroup/config.h |  21 ++++++
+ src/config.c               | 181 +++++++++++++++++++++++++++++++++++++++++++--
+ src/daemon/Makefile.am     |   4 +-
+ src/daemon/Makefile.in     |  25 ++++++-
+ src/daemon/cgrulesengd.c   |  51 +++++++++++--
+ src/libcgroup-internal.h   |   3 +
+ src/libcgroup.map          |   5 ++
+ src/tools/tools-common.h   |   2 +-
+ 11 files changed, 286 insertions(+), 23 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index af6e89c..0349c93 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -84,7 +84,7 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ 	$(srcdir)/config.h.in $(top_srcdir)/scripts/init.d/cgconfig.in \
+ 	$(top_srcdir)/scripts/init.d/cgred.in \
+ 	$(srcdir)/libcgroup.pc.in COPYING INSTALL README config.guess \
+-	config.sub install-sh missing ltmain.sh
++	config.sub depcomp install-sh missing ylwrap ltmain.sh
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/configure.in
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+diff --git a/doc/man/cgconfig.conf.5 b/doc/man/cgconfig.conf.5
+index be80e4e..a7d9935 100644
+--- a/doc/man/cgconfig.conf.5
++++ b/doc/man/cgconfig.conf.5
+@@ -251,6 +251,9 @@ Templates does not use
+ .B default
+ section settings.
+ 
++.I /etc/cgconfig.d/
++directory can be used for additional configuration files. cgrulesengd searches this directory for additional templates.
++
+ .\"********************************************"
+ .SH EXAMPLES
+ .LP
+@@ -783,10 +786,12 @@ related to them.
+ .SH FILES
+ .LP
+ .PD .1v
+-.TP 20
++.TP
+ .B /etc/cgconfig.conf
+ .TP
+ default libcgroup configuration file
++.B /etc/cgconfig.d/
++default libcgroup configuration files directory
+ .PD 
+ 
+ .SH SEE ALSO
+diff --git a/doc/man/cgrulesengd.8 b/doc/man/cgrulesengd.8
+index 2e89c5b..749b6fc 100644
+--- a/doc/man/cgrulesengd.8
++++ b/doc/man/cgrulesengd.8
+@@ -65,10 +65,16 @@ controls verbosity of the tool. Allowed values are \fBDEBUG\fR,
+ .SH FILES
+ .LP
+ .PD .1v
+-.TP 20
++.TP
+ .B /etc/cgrules.conf
+ .TP
+ the default libcgroup configuration file
++.TP
++.B /etc/cgconfig.conf
++the default templates file
++.TP
++.B /etc/cgconfig.d/
++the default templates directory
+ 
+ .SH SEE ALSO
+ cgrules.conf (5)
+diff --git a/include/libcgroup/config.h b/include/libcgroup/config.h
+index 43568e1..9aaa390 100644
+--- a/include/libcgroup/config.h
++++ b/include/libcgroup/config.h
+@@ -84,11 +84,32 @@ int cgroup_init_templates_cache(char *pathname);
+ int cgroup_reload_cached_templates(char *pathname);
+ 
+ /**
++ * Load the templates cache from files. Before calling this function,
++ * cgroup_templates_cache_set_source_files has to be called first.
++ * @param file_index index of file which was unable to be parsed
++ * @return 0 on success, > 0 on error
++ */
++int cgroup_load_templates_cache_from_files(int *file_index);
++
++/**
++ * Setting source files of templates. This function has to be called before
++ * any call of cgroup_load_templates_cache_from_files.
++ * @param tmpl_files
++ */
++struct cgroup_string_list;
++void cgroup_templates_cache_set_source_files(
++	struct cgroup_string_list *tmpl_files);
++
++/**
+  * Physically create a new control group in kernel, based on given control
+  * group template and configuration file. If given template is not set in
+  * configuration file, then the procedure works create the control group
+  * using  cgroup_create_cgroup() function
+  *
++ * Templates are loaded using cgroup_load_templates_cache_from_files
++ * function, which must be preceded by cgroup_templates_cache_set_source_files
++ * call.
++ *
+  * The flags can alter the behavior of this function:
+  * CGFLAG_USE_TEMPLATE_CACHE: Use cached templates instead of
+  * parsing the config file
+diff --git a/src/config.c b/src/config.c
+index e1ee0a8..1c5fc14 100644
+--- a/src/config.c
++++ b/src/config.c
+@@ -41,6 +41,8 @@
+ #include <sys/stat.h>
+ #include <sys/types.h>
+ 
++#include "tools/tools-common.h"
++
+ unsigned int MAX_CGROUPS = 64;	/* NOTE: This value changes dynamically */
+ unsigned int MAX_TEMPLATES = 64;
+ 				/* NOTE: This value changes dynamically */
+@@ -89,6 +91,7 @@ static int config_template_table_index;
+  */
+ static struct cgroup *template_table;
+ static int template_table_index;
++static struct cgroup_string_list *template_files;
+ 
+ 
+ /*
+@@ -1572,6 +1575,161 @@ int cgroup_init_templates_cache(char *pathname)
+ 
+ }
+ 
++/**
++ * Setting source files of templates. This function has to be called before
++ * any call of cgroup_load_templates_cache_from_files.
++ * @param tmpl_files
++ */
++void cgroup_templates_cache_set_source_files(
++	struct cgroup_string_list *tmpl_files)
++{
++	template_files = tmpl_files;
++}
++
++/**
++ * Appending cgroup templates parsed by parser to template_table
++ * @param offset number of templates already in the table
++ */
++int cgroup_add_cgroup_templates(int offset)
++{
++	int i, ti, ret;
++
++	for (i = 0; i < config_template_table_index; i++) {
++		ti = i + offset;
++		ret = cgroup_copy_cgroup(&template_table[ti],
++			&config_template_table[i]);
++		if (ret)
++			return ret;
++
++		strcpy((template_table[ti]).name,
++			(config_template_table[i]).name);
++		template_table[ti].tasks_uid =
++			config_template_table[i].tasks_uid;
++		template_table[ti].tasks_gid =
++			config_template_table[i].tasks_gid;
++		template_table[ti].task_fperm =
++			config_template_table[i].task_fperm;
++		template_table[ti].control_uid =
++			config_template_table[i].control_uid;
++		template_table[ti].control_gid =
++			config_template_table[i].control_gid;
++		template_table[ti].control_fperm =
++			config_template_table[i].control_fperm;
++		template_table[ti].control_dperm =
++			config_template_table[i].control_dperm;
++	}
++
++	return 0;
++}
++
++/**
++ * Expand template table based on new number of parsed templates, i.e.
++ * on value of config_template_table_index.
++ * Change value of template_table_index.
++ * @return 0 on success, < 0 on error
++ */
++int cgroup_expand_template_table(void)
++{
++	int i;
++
++	template_table = realloc(template_table,
++		(template_table_index + config_template_table_index)
++		*sizeof(struct cgroup));
++
++	if (template_table == NULL)
++		return -ECGOTHER;
++
++	for (i = 0; i < config_template_table_index; i++)
++		template_table[i + template_table_index].index = 0;
++
++	template_table_index += config_template_table_index;
++
++	return 0;
++}
++
++/**
++ * Load the templates cache from files. Before calling this function,
++ * cgroup_templates_cache_set_source_files has to be called first.
++ * @param file_index index of file which was unable to be parsed
++ * @return 0 on success, > 0 on error
++ */
++int cgroup_load_templates_cache_from_files(int *file_index)
++{
++	int ret;
++	int i, j;
++	int template_table_last_index;
++	char *pathname;
++
++	if (!template_files) {
++		/* source files has not been set */
++		cgroup_dbg("Template source files have not been set. ");
++		cgroup_dbg("Using only %s\n", CGCONFIG_CONF_FILE);
++
++		if (template_table_index == 0)
++			/* the rules cache is empty */
++			return cgroup_init_templates_cache(
++				CGCONFIG_CONF_FILE);
++		else
++			/* cache is not empty */
++			return cgroup_reload_cached_templates(
++				CGCONFIG_CONF_FILE);
++	}
++
++	if (template_table) {
++		/* template structures have to be free */
++		for (i = 0; i < template_table_index; i++)
++			cgroup_free_controllers(&template_table[i]);
++		free(template_table);
++		template_table = NULL;
++	}
++	template_table_index = 0;
++
++	if ((config_template_table_index != 0) || (config_table_index != 0)) {
++		/* config structures have to be clean before parsing */
++		cgroup_free_config();
++	}
++
++	for (j = 0; j < template_files->count; j++) {
++		pathname = template_files->items[j];
++
++		cgroup_dbg("Parsing templates from %s.\n", pathname);
++		/* Attempt to read the configuration file
++		 * and cache the rules. */
++		ret = cgroup_parse_config(pathname);
++		if (ret) {
++			cgroup_dbg("Could not initialize rule cache, ");
++			cgroup_dbg("error was: %d\n", ret);
++			*file_index = j;
++			return ret;
++		}
++
++		if (config_template_table_index > 0) {
++			template_table_last_index = template_table_index;
++			ret = cgroup_expand_template_table();
++			if (ret) {
++				cgroup_dbg("Could not expand template table, ");
++				cgroup_dbg("error was: %d\n", -ret);
++				*file_index = j;
++				return -ret;
++			}
++
++			/* copy template data to templates cache structures */
++			cgroup_dbg("Copying templates to template table ");
++			cgroup_dbg("from %s.\n", pathname);
++			ret = cgroup_add_cgroup_templates(
++				template_table_last_index);
++			if (ret) {
++				cgroup_dbg("Unable to copy cgroup\n");
++				*file_index = j;
++				return ret;
++			}
++			cgroup_dbg("Templates to template table copied\n");
++		}
++	}
++
++	return 0;
++}
++
+ /*
+  * Create a given cgroup, based on template configuration if it is present
+  * if the template is not present cgroup is creted using cgroup_create_cgroup
+@@ -1593,13 +1751,22 @@ int cgroup_config_create_template_group(struct cgroup *cgroup,
+ 	 * use CGCONFIG_CONF_FILE by default
+ 	 */
+ 	if (!(flags & CGFLAG_USE_TEMPLATE_CACHE)) {
+-		if (template_table_index == 0)
+-			/* the rules cache is empty */
+-			ret = cgroup_init_templates_cache(CGCONFIG_CONF_FILE);
+-		else
+-			/* cache is not empty */
+-			ret = cgroup_reload_cached_templates(
+-				CGCONFIG_CONF_FILE);
++		int fileindex;
++
++		/* the rules cache is empty */
++		ret = cgroup_load_templates_cache_from_files(
++			&fileindex);
++		if (ret != 0) {
++			if (fileindex < 0) {
++				cgroup_dbg("Error: Template source files ");
++				cgroup_dbg("have not been set\n");
++			} else {
++			    cgroup_dbg("Error: Failed to load template");
++			    cgroup_dbg("rules from %s. ",
++				    template_files->items[fileindex]);
++			}
++		}
++
+ 		if (ret != 0) {
+ 			cgroup_dbg("Failed initialize templates cache.\n");
+ 			return ret;
+diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
+index f3100ed..abbbe30 100644
+--- a/src/daemon/Makefile.am
++++ b/src/daemon/Makefile.am
+@@ -1,9 +1,9 @@
+-INCLUDES = -I $(top_srcdir)/include
++INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/include
+ 
+ if WITH_DAEMON
+ 
+ sbin_PROGRAMS = cgrulesengd
+-cgrulesengd_SOURCES = cgrulesengd.c cgrulesengd.h
++cgrulesengd_SOURCES = cgrulesengd.c cgrulesengd.h ../tools/tools-common.h ../tools/tools-common.c
+ cgrulesengd_LDADD = $(top_builddir)/src/.libs/libcgroup.la -lrt
+ cgrulesengd_LDFLAGS = -L$(top_builddir)/src/.libs
+ 
+diff --git a/src/daemon/Makefile.in b/src/daemon/Makefile.in
+index 76f7e07..f3efc65 100644
+--- a/src/daemon/Makefile.in
++++ b/src/daemon/Makefile.in
+@@ -92,8 +92,10 @@ CONFIG_CLEAN_FILES =
+ CONFIG_CLEAN_VPATH_FILES =
+ am__installdirs = "$(DESTDIR)$(sbindir)"
+ PROGRAMS = $(sbin_PROGRAMS)
+-am__cgrulesengd_SOURCES_DIST = cgrulesengd.c cgrulesengd.h
+-@WITH_DAEMON_TRUE@am_cgrulesengd_OBJECTS = cgrulesengd.$(OBJEXT)
++am__cgrulesengd_SOURCES_DIST = cgrulesengd.c cgrulesengd.h \
++	../tools/tools-common.h ../tools/tools-common.c
++@WITH_DAEMON_TRUE@am_cgrulesengd_OBJECTS = cgrulesengd.$(OBJEXT) \
++@WITH_DAEMON_TRUE@	tools-common.$(OBJEXT)
+ cgrulesengd_OBJECTS = $(am_cgrulesengd_OBJECTS)
+ @WITH_DAEMON_TRUE@cgrulesengd_DEPENDENCIES =  \
+ @WITH_DAEMON_TRUE@	$(top_builddir)/src/.libs/libcgroup.la
+@@ -294,8 +296,8 @@ target_alias = @target_alias@
+ top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-INCLUDES = -I $(top_srcdir)/include
+-@WITH_DAEMON_TRUE@cgrulesengd_SOURCES = cgrulesengd.c cgrulesengd.h
++INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/include
++@WITH_DAEMON_TRUE@cgrulesengd_SOURCES = cgrulesengd.c cgrulesengd.h ../tools/tools-common.h ../tools/tools-common.c
+ @WITH_DAEMON_TRUE@cgrulesengd_LDADD = $(top_builddir)/src/.libs/libcgroup.la -lrt
+ @WITH_DAEMON_TRUE@cgrulesengd_LDFLAGS = -L$(top_builddir)/src/.libs
+ all: all-am
+@@ -393,6 +395,7 @@ distclean-compile:
+ 	-rm -f *.tab.c
+ 
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cgrulesengd.Po@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tools-common.Po@am__quote@
+ 
+ .c.o:
+ @am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@@ -415,6 +418,20 @@ distclean-compile:
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+ 
++tools-common.o: ../tools/tools-common.c
++@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools-common.o -MD -MP -MF $(DEPDIR)/tools-common.Tpo -c -o tools-common.o `test -f '../tools/tools-common.c' || echo '$(srcdir)/'`../tools/tools-common.c
++@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/tools-common.Tpo $(DEPDIR)/tools-common.Po
++@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='../tools/tools-common.c' object='tools-common.o' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools-common.o `test -f '../tools/tools-common.c' || echo '$(srcdir)/'`../tools/tools-common.c
++
++tools-common.obj: ../tools/tools-common.c
++@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools-common.obj -MD -MP -MF $(DEPDIR)/tools-common.Tpo -c -o tools-common.obj `if test -f '../tools/tools-common.c'; then $(CYGPATH_W) '../tools/tools-common.c'; else $(CYGPATH_W) '$(srcdir)/../tools/tools-common.c'; fi`
++@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/tools-common.Tpo $(DEPDIR)/tools-common.Po
++@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='../tools/tools-common.c' object='tools-common.obj' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools-common.obj `if test -f '../tools/tools-common.c'; then $(CYGPATH_W) '../tools/tools-common.c'; else $(CYGPATH_W) '$(srcdir)/../tools/tools-common.c'; fi`
++
+ mostlyclean-libtool:
+ 	-rm -f *.lo
+ 
+diff --git a/src/daemon/cgrulesengd.c b/src/daemon/cgrulesengd.c
+index 170837a..d959eff 100644
+--- a/src/daemon/cgrulesengd.c
++++ b/src/daemon/cgrulesengd.c
+@@ -34,6 +34,7 @@
+ #include "libcgroup.h"
+ #include "cgrulesengd.h"
+ #include "../libcgroup-internal.h"
++#include "../tools/tools-common.h"
+ 
+ #include <errno.h>
+ #include <stdarg.h>
+@@ -59,6 +60,9 @@
+ 
+ #define NUM_PER_REALLOCATIOM	(100)
+ 
++/* list of config files from CGCONFIG_CONF_FILE and CGCONFIG_CONF_DIR */
++static struct cgroup_string_list template_files;
++
+ /* Log file, NULL if logging to file is disabled */
+ FILE* logfile;
+ 
+@@ -936,6 +940,8 @@ void cgre_flash_rules(int signum)
+ 	/* Current time */
+ 	time_t tm = time(0);
+ 
++	int fileindex;
++
+ 	flog(LOG_INFO, "Reloading rules configuration\n");
+ 	flog(LOG_DEBUG, "Current time: %s\n", ctime(&tm));
+ 
+@@ -949,7 +955,7 @@ void cgre_flash_rules(int signum)
+ 	}
+ 
+ 	/* Ask libcgroup to reload the template rules table. */
+-	cgroup_reload_cached_templates(CGCONFIG_CONF_FILE);
++	cgroup_load_templates_cache_from_files(&fileindex);
+ }
+ 
+ /**
+@@ -962,11 +968,13 @@ void cgre_flash_templates(int signum)
+ 	/* Current time */
+ 	time_t tm = time(0);
+ 
++	int fileindex;
++
+ 	flog(LOG_INFO, "Reloading templates configuration.\n");
+ 	flog(LOG_DEBUG, "Current time: %s\n", ctime(&tm));
+ 
+ 	/* Ask libcgroup to reload the templates table. */
+-	cgroup_reload_cached_templates(CGCONFIG_CONF_FILE);
++	cgroup_load_templates_cache_from_files(&fileindex);
+ }
+ 
+ /**
+@@ -1069,6 +1077,8 @@ int main(int argc, char *argv[])
+ 		{NULL, 0, NULL, 0}
+ 	};
+ 
++	int fileindex;
++
+ 	/* Make sure the user is root. */
+ 	if (getuid() != 0) {
+ 		fprintf(stderr, "Error: Only root can start/stop the control"
+@@ -1180,6 +1190,25 @@ int main(int argc, char *argv[])
+ 	}
+ 
+ 	/* Ask libcgroup to load the configuration rules. */
++	ret = cgroup_string_list_init(&template_files,
++		CGCONFIG_CONF_FILES_LIST_MINIMUM_SIZE);
++	if (ret) {
++		fprintf(stderr, "%s: cannot init file list, out of memory?\n",
++			argv[0]);
++		goto finished_without_temp_files;
++	}
++	/* first add CGCONFIG_CONF_FILE into file list */
++	ret = cgroup_string_list_add_item(&template_files, CGCONFIG_CONF_FILE);
++	if (ret) {
++		fprintf(stderr, "%s: cannot add file to list, out of memory?\n"
++			, argv[0]);
++		goto finished;
++	}
++
++	/* then read CGCONFIG_CONF_DIR directory for additional config files */
++	cgroup_string_list_add_directory(&template_files, CGCONFIG_CONF_DIR,
++		argv[0]);
++
+ 	if ((ret = cgroup_init_rules_cache()) != 0) {
+ 		fprintf(stderr, "Error: libcgroup failed to initialize rules"
+ 				"cache from %s. %s\n", CGRULES_CONF_FILE,
+@@ -1188,11 +1217,18 @@ int main(int argc, char *argv[])
+ 	}
+ 
+ 	/* ask libcgroup to load template rules as well */
+-	ret = cgroup_init_templates_cache(CGCONFIG_CONF_FILE);
++	cgroup_templates_cache_set_source_files(&template_files);
++	ret = cgroup_load_templates_cache_from_files(&fileindex);
+ 	if (ret != 0) {
+-		fprintf(stderr, "Error: libcgroup failed to initialize teplate"\
+-				"rules from %s. %s\n", CGCONFIG_CONF_FILE,
+-				cgroup_strerror(ret));
++		if (fileindex < 0) {
++			fprintf(stderr, "Error: Template source files ");
++			fprintf(stderr, "have not been set\n");
++		} else {
++			fprintf(stderr, "Error: Failed to initialize template");
++			fprintf(stderr, "rules from %s. ",
++				template_files.items[fileindex]);
++			fprintf(stderr, "%s\n", cgroup_strerror(-ret));
++		}
+ 		goto finished;
+ 	}
+ 
+@@ -1259,6 +1295,9 @@ int main(int argc, char *argv[])
+ 	ret =  cgre_create_netlink_socket_process_msg();
+ 
+ finished:
++	cgroup_string_list_free(&template_files);
++
++finished_without_temp_files:
+ 	if (logfile && logfile != stdout)
+ 		fclose(logfile);
+ 
+diff --git a/src/libcgroup-internal.h b/src/libcgroup-internal.h
+index 4c0f46c..c128788 100644
+--- a/src/libcgroup-internal.h
++++ b/src/libcgroup-internal.h
+@@ -48,6 +48,9 @@ __BEGIN_DECLS
+ 
+ 
+ #define CGCONFIG_CONF_FILE		"/etc/cgconfig.conf"
++/* Minimum number of file in template file list for cgrulesengd */
++#define CGCONFIG_CONF_FILES_LIST_MINIMUM_SIZE   4
++#define CGCONFIG_CONF_DIR               "/etc/cgconfig.d"
+ 
+ #define CGRULES_CONF_FILE       "/etc/cgrules.conf"
+ #define CGRULES_MAX_FIELDS_PER_LINE		3
+diff --git a/src/libcgroup.map b/src/libcgroup.map
+index b0c162c..f8b0fb9 100644
+--- a/src/libcgroup.map
++++ b/src/libcgroup.map
+@@ -117,3 +117,8 @@ CGROUP_0.39 {
+ 	cgroup_log;
+ 	cgroup_parse_log_level_str;
+ } CGROUP_0.38;
++
++CGROUP_0.40 {
++	cgroup_templates_cache_set_source_files;
++	cgroup_load_templates_cache_from_files;
++} CGROUP_0.39;
+diff --git a/src/tools/tools-common.h b/src/tools/tools-common.h
+index e05465f..c723eb4 100644
+--- a/src/tools/tools-common.h
++++ b/src/tools/tools-common.h
+@@ -20,7 +20,7 @@
+ 
+ #include "config.h"
+ #include <libcgroup.h>
+-#include <libcgroup-internal.h>
++#include "../libcgroup-internal.h"
+ 
+ #define cgroup_err(x...) cgroup_log(CGROUP_LOG_ERROR, x)
+ #define cgroup_warn(x...) cgroup_log(CGROUP_LOG_WARNING, x)
+-- 
+1.9.3
+
diff --git a/SOURCES/libcgroup-0.41-use-character-as-a-meta-character-for-all-mounted-co.patch b/SOURCES/libcgroup-0.41-use-character-as-a-meta-character-for-all-mounted-co.patch
new file mode 100644
index 0000000..98a4281
--- /dev/null
+++ b/SOURCES/libcgroup-0.41-use-character-as-a-meta-character-for-all-mounted-co.patch
@@ -0,0 +1,179 @@
+From 2102de58417416a3051fee17e012964b56971fb3 Mon Sep 17 00:00:00 2001
+From: Jan Chaloupka <jchaloup@redhat.com>
+Date: Sat, 20 Sep 2014 19:13:01 +0200
+Subject: [PATCH] use * character as a meta character for all mounted
+ controllers
+
+---
+ doc/man/cgcreate.1         |  3 ++-
+ include/libcgroup/groups.h | 10 ++++++++++
+ src/libcgroup.map          |  7 +++++++
+ src/tools/cgcreate.c       | 32 +++++++++++++++++++----------
+ src/wrapper.c              | 50 ++++++++++++++++++++++++++++++++++++++++++++++
+ 5 files changed, 91 insertions(+), 11 deletions(-)
+
+diff --git a/doc/man/cgcreate.1 b/doc/man/cgcreate.1
+index 7068073..557b5ae 100644
+--- a/doc/man/cgcreate.1
++++ b/doc/man/cgcreate.1
+@@ -38,7 +38,8 @@ others permissions to the owners permissions).
+ .TP
+ .B -g <controllers>:<path>
+ defines control groups to be added.
+-\fBcontrollers\fR is a list of controllers and
++\fBcontrollers\fR is a list of controllers. Character "*" can be used
++as a shortcut for "all mounted controllers".
+ \fBpath\fR is the relative path to control groups
+ in the given controllers list. This option can be specified
+ multiple times.
+diff --git a/include/libcgroup/groups.h b/include/libcgroup/groups.h
+index d5c87aa..201558f 100644
+--- a/include/libcgroup/groups.h
++++ b/include/libcgroup/groups.h
+@@ -150,6 +150,16 @@ struct cgroup_controller *cgroup_add_controller(struct cgroup *cgroup,
+ 						const char *name);
+ 
+ /**
++ * Attach all mounted controllers to given cgroup. This function just modifies
++ * internal libcgroup structure, not the kernel control group.
++ *
++ * @param cgroup
++ * @return zero or error number
++ */
++int cgroup_add_all_controllers(struct cgroup *cgroup);
++
++
++/**
+  * Return appropriate controller from given group.
+  * The controller must be added before using cgroup_add_controller() or loaded
+  * from kernel using cgroup_get_cgroup().
+diff --git a/src/libcgroup.map b/src/libcgroup.map
+index f8b0fb9..8fe1990 100644
+--- a/src/libcgroup.map
++++ b/src/libcgroup.map
+@@ -122,3 +122,10 @@ CGROUP_0.40 {
+ 	cgroup_templates_cache_set_source_files;
+ 	cgroup_load_templates_cache_from_files;
+ } CGROUP_0.39;
++
++CGROUP_0.41 {
++} CGROUP_0.40;
++
++CGROUP_0.42 {
++	cgroup_add_all_controllers;
++} CGROUP_0.41;
+diff --git a/src/tools/cgcreate.c b/src/tools/cgcreate.c
+index 73abd91..65b188a 100644
+--- a/src/tools/cgcreate.c
++++ b/src/tools/cgcreate.c
+@@ -54,7 +54,6 @@ static void usage(int status, const char *program_name)
+ 	printf("  -t <tuid>:<tgid>		Owner of the tasks file\n");
+ }
+ 
+-
+ int main(int argc, char *argv[])
+ {
+ 	int ret = 0;
+@@ -195,16 +194,29 @@ int main(int argc, char *argv[])
+ 		/* add controllers to the new cgroup */
+ 		j = 0;
+ 		while (cgroup_list[i]->controllers[j]) {
+-			cgc = cgroup_add_controller(cgroup,
+-				cgroup_list[i]->controllers[j]);
+-			if (!cgc) {
+-				ret = ECGINVAL;
+-				fprintf(stderr, "%s: "
+-					"controller %s can't be add\n",
+-					argv[0],
++			if (strcmp(cgroup_list[i]->controllers[j], "*") == 0) {
++				/* it is meta character, add all controllers */
++				ret = cgroup_add_all_controllers(cgroup);
++				if (ret != 0) {
++					ret = ECGINVAL;
++					fprintf(stderr, "%s: can't add ",
++						argv[0]);
++					fprintf(stderr, "all controllers\n");
++					cgroup_free(&cgroup);
++					goto err;
++				}
++			} else {
++				cgc = cgroup_add_controller(cgroup,
+ 					cgroup_list[i]->controllers[j]);
+-				cgroup_free(&cgroup);
+-				goto err;
++				if (!cgc) {
++					ret = ECGINVAL;
++					fprintf(stderr, "%s: ", argv[0]);
++					fprintf(stderr, "controller %s",
++						cgroup_list[i]->controllers[j]);
++					fprintf(stderr, "can't be add\n");
++					cgroup_free(&cgroup);
++					goto err;
++				}
+ 			}
+ 			j++;
+ 		}
+diff --git a/src/wrapper.c b/src/wrapper.c
+index c03472a..3a9331f 100644
+--- a/src/wrapper.c
++++ b/src/wrapper.c
+@@ -92,6 +92,56 @@ struct cgroup_controller *cgroup_add_controller(struct cgroup *cgroup,
+ 	return controller;
+ }
+ 
++int cgroup_add_all_controllers(struct cgroup *cgroup)
++{
++	int ret;
++	void *handle;
++	struct controller_data info;
++	struct cgroup_controller *cgc;
++
++	/* go through the controller list */
++	ret = cgroup_get_all_controller_begin(&handle, &info);
++	if ((ret != 0) && (ret != ECGEOF)) {
++		fprintf(stderr, "cannot read controller data: %s\n",
++			cgroup_strerror(ret));
++		return ret;
++	}
++
++	while (ret == 0) {
++		if (info.hierarchy == 0) {
++			/* the controller is not attached to any hierarchy
++			   skip it */
++			goto next;
++		}
++
++		/* add mounted controller to cgroup structure */
++		cgc = cgroup_add_controller(cgroup, info.name);
++		if (!cgc) {
++			ret = ECGINVAL;
++			fprintf(stderr, "controller %s can't be add\n",
++				info.name);
++		}
++
++next:
++		ret = cgroup_get_all_controller_next(&handle, &info);
++		if (ret && ret != ECGEOF)
++			goto end;
++	}
++
++end:
++	cgroup_get_all_controller_end(&handle);
++
++	if (ret == ECGEOF)
++		ret = 0;
++
++	if (ret)
++		fprintf(stderr,
++			"cgroup_get_controller_begin/next failed (%s)\n",
++			cgroup_strerror(ret));
++
++	return ret;
++}
++
+ void cgroup_free_controllers(struct cgroup *cgroup)
+ {
+ 	int i, j;
+-- 
+1.9.3
+
diff --git a/SPECS/libcgroup.spec b/SPECS/libcgroup.spec
index c0f8c1b..f2df25a 100644
--- a/SPECS/libcgroup.spec
+++ b/SPECS/libcgroup.spec
@@ -5,7 +5,7 @@
 Summary: Library to control and monitor control groups
 Name: libcgroup
 Version: 0.41
-Release: 6%{?dist}
+Release: 8%{?dist}
 License: LGPLv2+
 Group: Development/Libraries
 URL: http://libcg.sourceforge.net/
@@ -20,6 +20,13 @@ Patch2: libcgroup-0.40.rc1-coverity.patch
 Patch3: libcgroup-0.40.rc1-fread.patch
 Patch4: libcgroup-0.40.rc1-templates-fix.patch
 Patch5: libcgroup-0.41-runlibcgrouptest-systemd-fix.patch 
+Patch6: libcgroup-0.40.rc1-retry-to-set-control-file.patch
+Patch7: libcgroup-0.41-config.c-xfs-file-system-sets-item-d_type-to-zero-st.patch
+Patch8: libcgroup-0.41-loading-configuration-files-from-etc-cgconfig.d-dire.patch
+Patch9: libcgroup-0.41-use-character-as-a-meta-character-for-all-mounted-co.patch
+Patch10: libcgroup-0.41-add-examples-to-man-pages.patch
+Patch11: libcgroup-0.41-extending-cgroup-names-with-default.patch
+Patch12: libcgroup-0.41-api.c-support-for-setting-multiline-values-in-contro.patch
 
 BuildRequires: byacc, coreutils, flex, pam-devel, systemd
 Requires(pre): shadow-utils
@@ -67,6 +74,13 @@ provide scripts to manage that configuration.
 %patch3 -p1 -b .fread
 %patch4 -p1 -b .templates-fix
 %patch5 -p1 -b .runlibcgrouptest-systemd-fix
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
+%patch9 -p1
+%patch10 -p1
+%patch11 -p1
+%patch12 -p1
 
 %build
 %configure --enable-pam-module-dir=%{_libdir}/security \
@@ -80,6 +94,7 @@ make DESTDIR=$RPM_BUILD_ROOT install
 # install config files
 install -d ${RPM_BUILD_ROOT}%{_sysconfdir}
 install -m 644 samples/cgconfig.conf $RPM_BUILD_ROOT/%{_sysconfdir}/cgconfig.conf
+install -d $RPM_BUILD_ROOT/%{_sysconfdir}/cgconfig.d
 install -m 644 samples/cgrules.conf $RPM_BUILD_ROOT/%{_sysconfdir}/cgrules.conf
 install -m 644 samples/cgsnapshot_blacklist.conf $RPM_BUILD_ROOT/%{_sysconfdir}/cgsnapshot_blacklist.conf
 
@@ -152,6 +167,7 @@ fi
 %files tools
 %doc COPYING README README_systemd
 %config(noreplace) %{_sysconfdir}/cgconfig.conf
+%config(noreplace) %{_sysconfdir}/cgconfig.d
 %config(noreplace) %{_sysconfdir}/cgrules.conf
 %config(noreplace) %{_sysconfdir}/cgsnapshot_blacklist.conf
 %config(noreplace) %{_sysconfdir}/sysconfig/cgred
@@ -185,6 +201,23 @@ fi
 %{_libdir}/pkgconfig/libcgroup.pc
 
 %changelog
+* Sat Sep 20 2014 jchaloup <jchaloup@redhat.com> - 0.41-8
+- resolves: #885174
+  loading configuration files from /etc/cgconfig.d/ directory
+- resolves: #885166
+  use * character as a meta character for all mounted
+- resolves: #886920
+  add examples to man pages
+- resolves: #1143851
+  extending cgroup names with default
+- resolves: #1142807
+  api.c: support for setting multiline values in control files
+  config.c: xfs file system sets item->d_type to zero, stat() and S_ISREG() test added (#885174)
+
+* Thu Sep 11 2014 jchaloup <jchaloup@redhat.com> - 0.41-7
+- resolves: #963515
+  retry to set control file in cgroup_modify_cgroup
+
 * Tue Mar 04 2014 jchaloup <jchaloup@redhat.com> - 0.41-6
 - related: #1016810
   specfile corrected, make was not fired