.I /proc/cgroups
file. Named hierarchy can be specified as controller
\fB"name=<somename>"\fR. Do not forget to use double quotes around
-this controller name (see examples below).
+this controller name (see examples below). Apart from named hierarchy,
+additional mount options may be specified by putting the controller and
+the options in quotes. Options supported are \fB nosuid, noexec\fR and\fB nodev\fR.
.B Libcgroup
merges all subsystems mounted to the same directory (see
The situation is the similar as in Example 4. The only difference is template,
which is used if some rule uses "/students/%u" as a destination.
+.SS Example 8
+.LP
+The configuration file:
+
+.LP
+.RS
+.nf
+mount {
+.RS
+"cpu,nodev,nosuid,noexec" = /mnt/cgroups/cpu;
+.RE
+}
+
+.fi
+.RE
+
+This is the same as
+mount -t cgroup cgroup -o nodev,nosuid,noexec,cpu /mnt/cgroups/cpu
+It mounts the cpu controller with MS_NODEV, MS_NOSUID and MS_NOEXEC
+options passed.
.SH RECOMMENDATIONS
* Add necessary options for mount. Currently only 'none' option is added
* for mounts with only 'name=xxx' and without real controller.
*/
-static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount)
+static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount,
+ unsigned long *flags)
{
char *save = NULL;
char *opts = strdup(mount->name);
char *token;
int name_only = 1;
+ char *controller= NULL;
+ *flags = 0;
if (opts == NULL)
return ECGFAIL;
while (token != NULL) {
if (strncmp(token, "name=", 5) != 0) {
name_only = 0;
- break;
+
+ if (!controller) {
+ controller = strdup(token);
+ if (controller == NULL)
+ break;
+ strncpy(mount->name, controller, sizeof(mount->name));
+ }
+
+ if (strncmp(token, "nodev", strlen("nodev")) == 0) {
+ *flags |= MS_NODEV;
+ }
+ if (strncmp(token, "noexec", strlen("noexec")) == 0) {
+ *flags |= MS_NOEXEC;
+ }
+ if (strncmp(token, "nosuid", strlen("nosuid")) == 0) {
+ *flags |= MS_NOSUID;
+ }
+
+ } else if (!name_only) {
+ /*
+ * We have controller + name=, do the right thing, since
+ * we are rebuuilding mount->name
+ */
+ strncat(mount->name, ",", FILENAME_MAX - strlen(mount->name)-1);
+ strncat(mount->name, token,
+ FILENAME_MAX - strlen(mount->name) - 1);
}
token = strtok_r(NULL, ",", &save);
}
+ free(controller);
free(opts);
+
if (name_only) {
strncat(mount->name, ",", FILENAME_MAX - strlen(mount->name)-1);
strncat(mount->name, "none",
struct stat buff;
int i;
int error;
+ unsigned long flags;
for (i = 0; i < config_table_index; i++) {
struct cg_mount_table_s *curr = &(config_mount_table[i]);
goto out_err;
}
- error = cgroup_config_ajdust_mount_options(curr);
+ error = cgroup_config_ajdust_mount_options(curr, &flags);
if (error)
goto out_err;
ret = mount(CGROUP_FILESYSTEM, curr->mount.path,
- CGROUP_FILESYSTEM, 0, curr->name);
+ CGROUP_FILESYSTEM, flags, curr->name);
if (ret < 0) {
cgroup_err("Error: cannot mount %s to %s: %s\n",