Skip to content

Commit 43f37af

Browse files
Merge pull request #22 from eth-cscs/feat/uenv-mount-vars
set environment variables for slurm plugin
2 parents ffbc010 + db4d139 commit 43f37af

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

squashfs-mount.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
#include <libmount/libmount.h>
1919

20+
#define ENV_MOUNT_FILE "UENV_MOUNT_FILE"
21+
#define ENV_MOUNT_POINT "UENV_MOUNT_POINT"
22+
2023
#define exit_with_error(...) \
2124
do { \
2225
fprintf(stderr, __VA_ARGS__); \
@@ -132,5 +135,12 @@ int main(int argc, char **argv) {
132135
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) != 0)
133136
err(EXIT_FAILURE, "PR_SET_NO_NEW_PRIVS failed");
134137

138+
// set env variables allowing to detect the spank plugin if
139+
// squashfs file has been mounted before calling srun,etc.
140+
if (setenv(ENV_MOUNT_FILE, squashfs_file, 1 /* overwite if exists */) ||
141+
setenv(ENV_MOUNT_POINT, mountpoint, 1 /* overwrite if exists */)) {
142+
err(EXIT_FAILURE, "failed to set environment variables");
143+
}
144+
135145
return execvp(argv[0], argv);
136146
}

0 commit comments

Comments
 (0)