From 557c52d1698bc5ecc538c3e6aab76109cfcc74dd Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Tue, 31 Jul 2012 12:47:40 -0700
Subject: [PATCH] remove last patch to give author credit

---
 NEWS                                          |  2 -
 src/common/xcgroup.c                          | 52 +++++++++++--------
 src/common/xcgroup.h                          |  4 --
 .../cgroup/jobacct_gather_cgroup_cpuacct.c    |  3 +-
 .../cgroup/jobacct_gather_cgroup_memory.c     |  3 +-
 .../proctrack/cgroup/proctrack_cgroup.c       |  3 +-
 src/plugins/task/cgroup/task_cgroup_cpuset.c  |  2 +-
 src/plugins/task/cgroup/task_cgroup_devices.c |  2 +-
 src/plugins/task/cgroup/task_cgroup_memory.c  |  2 +-
 9 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/NEWS b/NEWS
index cb2babd3558..89c6ee95883 100644
--- a/NEWS
+++ b/NEWS
@@ -44,8 +44,6 @@ documents those changes that are of interest to users and admins.
     with "none" (e.g. "none.o").
  -- BGQ - added version string to the load of the runjob_mux plugin to verify
     the current plugin has been loaded when using runjob_mux_refresh_config
- -- CGROUPS - Use system mount/umount function calls instead of doing fork
-    exec of mount/umount from Janne Blomqvist.
 
 * Changes in SLURM 2.4.1
 ========================
diff --git a/src/common/xcgroup.c b/src/common/xcgroup.c
index 64661d2ebe9..2a03ec0dce0 100644
--- a/src/common/xcgroup.c
+++ b/src/common/xcgroup.c
@@ -54,7 +54,6 @@
 #include <string.h>
 #include <strings.h>
 #include <dirent.h>
-#include <sys/mount.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
@@ -130,14 +129,12 @@ int xcgroup_ns_destroy(xcgroup_ns_t* cgns) {
  * returned values:
  *  - XCGROUP_ERROR
  *  - XCGROUP_SUCCESS
- *
- * If an error occurs, errno will be set.
  */
 int xcgroup_ns_mount(xcgroup_ns_t* cgns)
 {
 	int fstatus;
-	char* options;
-	char opt_combined[1024];
+	char* mount_cmd_fmt;
+	char mount_cmd[1024];
 
 	char* mnt_point;
 	char* p;
@@ -185,20 +182,21 @@ int xcgroup_ns_mount(xcgroup_ns_t* cgns)
 	umask(omask);
 
 	if (cgns->mnt_args == NULL ||
-	    strlen(cgns->mnt_args) == 0)
-		options = cgns->subsystems;
-	else {
-		if (snprintf(opt_combined, sizeof(opt_combined), "%s,%s",
-			     cgns->subsystems, cgns->mnt_args)
-		    >= sizeof(opt_combined)) {
-			debug2("unable to build cgroup options string");
-			return XCGROUP_ERROR;
-		}
-		options = opt_combined;
+	     strlen(cgns->mnt_args) == 0) {
+		mount_cmd_fmt = "/bin/mount -o %s%s -t cgroup none %s";
+	}
+	else
+		mount_cmd_fmt = "/bin/mount -o %s, %s -t cgroup none %s";
+
+	if (snprintf(mount_cmd, 1024, mount_cmd_fmt, cgns->subsystems,
+		      cgns->mnt_args, cgns->mnt_point) >= 1024) {
+		debug2("unable to build cgroup ns mount cmd line");
+		return XCGROUP_ERROR;
 	}
+	else
+		debug3("cgroup mount cmd line is '%s'", mount_cmd);
 
-	if (mount("cgroup", cgns->mnt_point, "cgroup",
-		  MS_NOSUID|MS_NOEXEC|MS_NODEV, options))
+	if (system(mount_cmd))
 		return XCGROUP_ERROR;
 	else {
 		/* we then set the release_agent if necessary */
@@ -219,14 +217,26 @@ int xcgroup_ns_mount(xcgroup_ns_t* cgns)
  * returned values:
  *  - XCGROUP_ERROR
  *  - XCGROUP_SUCCESS
- *
- * If an error occurs, errno will be set.
  */
 int xcgroup_ns_umount(xcgroup_ns_t* cgns)
 {
-	if (umount(cgns->mnt_point))
+	char* umount_cmd_fmt;
+	char umount_cmd[1024];
+
+	umount_cmd_fmt = "/bin/umount %s";
+
+	if (snprintf(umount_cmd, 1024, umount_cmd_fmt,
+		      cgns->mnt_point) >= 1024) {
+		debug2("unable to build cgroup ns umount cmd line");
 		return XCGROUP_ERROR;
-	return XCGROUP_SUCCESS;
+	}
+	else
+		debug3("cgroup ns umount cmd line is '%s'", umount_cmd);
+
+	if (system(umount_cmd))
+		return XCGROUP_ERROR;
+	else
+		return XCGROUP_SUCCESS;
 }
 
 /*
diff --git a/src/common/xcgroup.h b/src/common/xcgroup.h
index a5861f8eabf..4f03b5cef7a 100644
--- a/src/common/xcgroup.h
+++ b/src/common/xcgroup.h
@@ -97,8 +97,6 @@ int xcgroup_ns_destroy(xcgroup_ns_t* cgns);
  * returned values:
  *  - XCGROUP_ERROR
  *  - XCGROUP_SUCCESS
- *
- * If an error occurs, errno will be set.
  */
 int xcgroup_ns_mount(xcgroup_ns_t* cgns);
 
@@ -108,8 +106,6 @@ int xcgroup_ns_mount(xcgroup_ns_t* cgns);
  * returned values:
  *  - XCGROUP_ERROR
  *  - XCGROUP_SUCCESS
- *
- * If an error occurs, errno will be set.
  */
 int xcgroup_ns_umount(xcgroup_ns_t* cgns);
 
diff --git a/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup_cpuacct.c b/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup_cpuacct.c
index 449d4641d6a..4918d93ae6c 100644
--- a/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup_cpuacct.c
+++ b/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup_cpuacct.c
@@ -98,8 +98,7 @@ extern int jobacct_gather_cgroup_cpuacct_init(
 		if (slurm_cgroup_conf->cgroup_automount) {
 			if (xcgroup_ns_mount(&cpuacct_ns)) {
 				error("jobacct_gather/cgroup: unable to mount "
-				      "cpuacct namespace: %s",
-				      slurm_strerror(errno));
+				      "cpuacct namespace");
 				goto clean;
 			}
 			info("jobacct_gather/cgroup: cpuacct namespace is now "
diff --git a/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup_memory.c b/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup_memory.c
index e311faa5f53..4220f02a1d8 100644
--- a/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup_memory.c
+++ b/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup_memory.c
@@ -98,8 +98,7 @@ extern int jobacct_gather_cgroup_memory_init(
 		if (slurm_cgroup_conf->cgroup_automount) {
 			if (xcgroup_ns_mount(&memory_ns)) {
 				error("jobacct_gather/cgroup: unable to mount "
-				      "memory namespace: %s",
-				      slurm_strerror(errno));
+				      "memory namespace");
 				goto clean;
 			}
 			info("jobacct_gather/cgroup: memory namespace is now "
diff --git a/src/plugins/proctrack/cgroup/proctrack_cgroup.c b/src/plugins/proctrack/cgroup/proctrack_cgroup.c
index d7026f9adf4..f6f73995d05 100644
--- a/src/plugins/proctrack/cgroup/proctrack_cgroup.c
+++ b/src/plugins/proctrack/cgroup/proctrack_cgroup.c
@@ -147,8 +147,7 @@ int _slurm_cgroup_init(void)
 		if (slurm_cgroup_conf.cgroup_automount) {
 			if (xcgroup_ns_mount(&freezer_ns)) {
 				error("unable to mount freezer cgroup"
-				      " namespace: %s",
-				      slurm_strerror(errno));
+				      " namespace");
 				return SLURM_ERROR;
 			}
 			info("cgroup namespace '%s' is now mounted", "freezer");
diff --git a/src/plugins/task/cgroup/task_cgroup_cpuset.c b/src/plugins/task/cgroup/task_cgroup_cpuset.c
index c547341c189..8779a7f97a2 100644
--- a/src/plugins/task/cgroup/task_cgroup_cpuset.c
+++ b/src/plugins/task/cgroup/task_cgroup_cpuset.c
@@ -416,7 +416,7 @@ extern int task_cgroup_cpuset_init(slurm_cgroup_conf_t *slurm_cgroup_conf)
 		if (slurm_cgroup_conf->cgroup_automount) {
 			if (xcgroup_ns_mount(&cpuset_ns)) {
 				error("task/cgroup: unable to mount cpuset "
-				      "namespace: %s", slurm_strerror(errno));
+				      "namespace");
 				goto clean;
 			}
 			info("task/cgroup: cpuset namespace is now mounted");
diff --git a/src/plugins/task/cgroup/task_cgroup_devices.c b/src/plugins/task/cgroup/task_cgroup_devices.c
index 82f802d4645..303bb43841e 100644
--- a/src/plugins/task/cgroup/task_cgroup_devices.c
+++ b/src/plugins/task/cgroup/task_cgroup_devices.c
@@ -123,7 +123,7 @@ extern int task_cgroup_devices_init(slurm_cgroup_conf_t *slurm_cgroup_conf)
 		if ( slurm_cgroup_conf->cgroup_automount ) {
 			if ( xcgroup_ns_mount(&devices_ns) ) {
 				error("task/cgroup: unable to mount devices "
-				      "namespace: %s", slurm_strerror(errno));
+				      "namespace");
 				goto clean;
 			}
 			info("task/cgroup: devices namespace is now mounted");
diff --git a/src/plugins/task/cgroup/task_cgroup_memory.c b/src/plugins/task/cgroup/task_cgroup_memory.c
index a2e24806629..ef37a0685d6 100644
--- a/src/plugins/task/cgroup/task_cgroup_memory.c
+++ b/src/plugins/task/cgroup/task_cgroup_memory.c
@@ -109,7 +109,7 @@ extern int task_cgroup_memory_init(slurm_cgroup_conf_t *slurm_cgroup_conf)
 		if (slurm_cgroup_conf->cgroup_automount) {
 			if (xcgroup_ns_mount(&memory_ns)) {
 				error("task/cgroup: unable to mount memory "
-				      "namespace: %s", slurm_strerror(errno));
+				      "namespace");
 				goto clean;
 			}
 			info("task/cgroup: memory namespace is now mounted");
-- 
GitLab