Skip to content
Snippets Groups Projects
Commit 55b36bf3 authored by Danny Auble's avatar Danny Auble
Browse files

Make it so the tmpfs plugin doesn't load on FreeBSD.

The mount command relies on bind mounting and being able to
create private mounts and bind mount namespaces to it.  At the time of
writing this it doesn't work there.

Bug 8993
parent 41690288
No related branches found
No related tags found
No related merge requests found
...@@ -134,6 +134,10 @@ extern void container_p_reconfig(void) ...@@ -134,6 +134,10 @@ extern void container_p_reconfig(void)
*/ */
extern int init(void) extern int init(void)
{ {
#if defined(__APPLE__) || defined(__FreeBSD__)
fatal("%s is not available on this system. (mount bind limitation)", plugin_name);
#endif
debug("%s loaded", plugin_name); debug("%s loaded", plugin_name);
return SLURM_SUCCESS; return SLURM_SUCCESS;
...@@ -233,6 +237,7 @@ extern int container_p_restore(char *dir_name, bool recover) ...@@ -233,6 +237,7 @@ extern int container_p_restore(char *dir_name, bool recover)
return SLURM_ERROR; return SLURM_ERROR;
} }
#if !defined(__APPLE__) && !defined(__FreeBSD__)
/* /*
* MS_BIND mountflag would make mount() ignore all other mountflags * MS_BIND mountflag would make mount() ignore all other mountflags
* except MS_REC. We need MS_PRIVATE mountflag as well to make the * except MS_REC. We need MS_PRIVATE mountflag as well to make the
...@@ -251,6 +256,7 @@ extern int container_p_restore(char *dir_name, bool recover) ...@@ -251,6 +256,7 @@ extern int container_p_restore(char *dir_name, bool recover)
__func__, strerror(errno)); __func__, strerror(errno));
return SLURM_ERROR; return SLURM_ERROR;
} }
#endif
debug3("tmpfs: Base namespace created"); debug3("tmpfs: Base namespace created");
return SLURM_SUCCESS; return SLURM_SUCCESS;
...@@ -262,6 +268,7 @@ static int _mount_private_tmp(char *path) ...@@ -262,6 +268,7 @@ static int _mount_private_tmp(char *path)
error("%s: cannot mount /tmp", __func__); error("%s: cannot mount /tmp", __func__);
return -1; return -1;
} }
#if !defined(__APPLE__) && !defined(__FreeBSD__)
if (mount(NULL, "/", NULL, MS_PRIVATE|MS_REC, NULL)) { if (mount(NULL, "/", NULL, MS_PRIVATE|MS_REC, NULL)) {
error("%s: making root private: failed: %s", error("%s: making root private: failed: %s",
__func__, strerror(errno)); __func__, strerror(errno));
...@@ -272,7 +279,7 @@ static int _mount_private_tmp(char *path) ...@@ -272,7 +279,7 @@ static int _mount_private_tmp(char *path)
__func__, strerror(errno)); __func__, strerror(errno));
return -1; return -1;
} }
#endif
return 0; return 0;
} }
...@@ -286,12 +293,14 @@ static int _mount_private_shm(void) ...@@ -286,12 +293,14 @@ static int _mount_private_shm(void)
__func__, strerror(errno)); __func__, strerror(errno));
return rc; return rc;
} }
#if !defined(__APPLE__) && !defined(__FreeBSD__)
rc = mount("tmpfs", "/dev/shm", "tmpfs", 0, NULL); rc = mount("tmpfs", "/dev/shm", "tmpfs", 0, NULL);
if (rc) { if (rc) {
error("%s: mounting private /dev/shm failed: %s\n", error("%s: mounting private /dev/shm failed: %s\n",
__func__, strerror(errno)); __func__, strerror(errno));
return -1; return -1;
} }
#endif
return rc; return rc;
} }
...@@ -511,6 +520,7 @@ extern int container_p_create(uint32_t job_id) ...@@ -511,6 +520,7 @@ extern int container_p_create(uint32_t job_id)
* Bind mount /proc/pid/ns/mnt to hold namespace active * Bind mount /proc/pid/ns/mnt to hold namespace active
* without a process attached to it * without a process attached to it
*/ */
#if !defined(__APPLE__) && !defined(__FreeBSD__)
rc = mount(proc_path, ns_holder, NULL, MS_BIND, NULL); rc = mount(proc_path, ns_holder, NULL, MS_BIND, NULL);
if (rc) { if (rc) {
error("%s: ns base mount failed: %s", error("%s: ns base mount failed: %s",
...@@ -520,6 +530,7 @@ extern int container_p_create(uint32_t job_id) ...@@ -520,6 +530,7 @@ extern int container_p_create(uint32_t job_id)
__func__, strerror(errno)); __func__, strerror(errno));
goto exit1; goto exit1;
} }
#endif
if (sem_post(sem2) < 0) { if (sem_post(sem2) < 0) {
error("%s: sem_post failed: %s", error("%s: sem_post failed: %s",
__func__, strerror(errno)); __func__, strerror(errno));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment