This adds an environment variable which is received by the prologue and epilogue scripts and can be used to modify the system based on the "-lnodes=" request made by the user. --- pbs-2.3.12-pw/src/resmom/prolog.c | 31 ++++++++++++++++++++++++++++++- pbs-2.3.12-pw/src/server/resc_def_all.c | 3 ++- 2 files changed, 32 insertions(+), 2 deletions(-) diff -puN src/resmom/prolog.c~prologue-environment src/resmom/prolog.c --- pbs-2.3.12/src/resmom/prolog.c~prologue-environment 2004-04-17 10:12:57.000000000 -0400 +++ pbs-2.3.12-pw/src/resmom/prolog.c 2004-04-17 10:12:57.000000000 -0400 @@ -87,6 +87,7 @@ #include #include #include +#include #include "libpbs.h" #include "list_link.h" #include "server_limits.h" @@ -95,6 +96,7 @@ #include "log.h" #include "mom_mach.h" #include "mom_func.h" +#include "resource.h" static char ident[] = "@(#) $RCSfile: prologue-environment.patch,v $ $Revision: 1.1 $"; @@ -299,9 +301,36 @@ int run_pelog(which, pelog, pjob, pe_io_ arg[4] = (char *)0; } + { + /* + * Pass Resource_List.nodes request in environment + * to allow pro/epi-logue setup/teardown of system + * settings. --pw, 2 Jan 02 + * Fixed to use putenv for sysV compatibility. + * --troy, 11 jun 03 + */ + resource *r = find_resc_entry( + &pjob->ji_wattr[(int)JOB_ATR_resource], + find_resc_def(svr_resc_def, "nodes", svr_resc_size)); + if (r) { + /* + setenv("PBS_RESOURCE_NODES", + r->rs_value.at_val.at_str, 1); + */ + const char *envname = "PBS_RESOURCE_NODES="; + char *envstr = malloc((strlen(envname) + + strlen(r->rs_value.at_val.at_str) + 1) + * sizeof(char)); + strcpy(envstr, envname); + strcat(envstr, r->rs_value.at_val.at_str); + putenv(envstr); + /* do _not_ free the string when using putenv */ + } + } + execv(pelog, arg); - log_err(errno, "run_pelog", "execle of prologue failed"); + log_err(errno, "run_pelog", "execv of prologue failed"); exit (255); } if (run_exit) diff -puN src/server/resc_def_all.c~prologue-environment src/server/resc_def_all.c --- pbs-2.3.12/src/server/resc_def_all.c~prologue-environment 2004-04-17 10:12:57.000000000 -0400 +++ pbs-2.3.12-pw/src/server/resc_def_all.c 2004-04-17 10:12:57.000000000 -0400 @@ -83,6 +83,7 @@ #include /* the master config generated by configure */ +#include #include #include "pbs_ifl.h" #include @@ -260,7 +261,7 @@ resource_def svr_resc_def[] = { comp_str, free_str, set_node_ct, - READ_WRITE | ATR_DFLAG_RMOMIG, + READ_WRITE | ATR_DFLAG_MOM | ATR_DFLAG_RMOMIG, ATR_TYPE_STR }, { "neednodes", /* scheduler modified specification */ _