static void _print_version(void) { print_slurm_version(); if (quiet_flag == -1) { long version = slurm_api_version(); printf("slurm_api_version: %ld, %ld.%ld.%ld\n", version, SLURM_VERSION_MAJOR(version), SLURM_VERSION_MINOR(version), SLURM_VERSION_MICRO(version)); } }
int plugin_peek( const char *fq_path, char *plugin_type, const size_t type_len, uint32_t *plugin_version ) { plugin_handle_t plug; char *type; uint32_t *version; plug = dlopen( fq_path, RTLD_LAZY ); if ( plug == NULL ) { debug3( "plugin_peek: dlopen(%s): %s", fq_path, _dlerror() ); return SLURM_ERROR; } if ( ( type = dlsym( plug, PLUGIN_TYPE ) ) != NULL ) { if ( plugin_type != NULL ) { strlcpy(plugin_type, type, type_len); } } else { dlclose( plug ); /* could be vestigial library, don't treat as an error */ verbose( "%s: not a Slurm plugin", fq_path ); return SLURM_ERROR; } version = (uint32_t *) dlsym(plug, PLUGIN_VERSION); if (!version) { verbose("%s: plugin_version symbol not defined", fq_path); } else if ((*version != SLURM_VERSION_NUMBER) && xstrcmp(type,"spank")){ /* NOTE: We could alternatly test just the MAJOR.MINOR values */ int plugin_major, plugin_minor, plugin_micro; plugin_major = SLURM_VERSION_MAJOR(*version); plugin_minor = SLURM_VERSION_MINOR(*version); plugin_micro = SLURM_VERSION_MICRO(*version); dlclose(plug); info("%s: Incompatible Slurm plugin version (%d.%d.%d)", fq_path, plugin_major, plugin_minor, plugin_micro); return SLURM_ERROR; } dlclose( plug ); return SLURM_SUCCESS; }
plugin_err_t plugin_load_from_file(plugin_handle_t *p, const char *fq_path) { plugin_handle_t plug; int (*init)(void); uint32_t *version; char *type = NULL; *p = PLUGIN_INVALID_HANDLE; /* * Check for file existence and access permissions */ if (access(fq_path, R_OK) < 0) { if (errno == ENOENT) return EPLUGIN_NOTFOUND; else return EPLUGIN_ACCESS_ERROR; } /* * Try to open the shared object. * * Use RTLD_LAZY to allow plugins to use symbols that may be * defined in only one slurm entity (e.g. srun and not slurmd), * when the use of that symbol is restricted to within the * entity from which it is available. (i.e. srun symbols are only * used in the context of srun, not slurmd.) * */ plug = dlopen(fq_path, RTLD_LAZY); if (plug == NULL) { error("plugin_load_from_file: dlopen(%s): %s", fq_path, _dlerror()); return EPLUGIN_DLOPEN_FAILED; } /* Now see if our required symbols are defined. */ if ((dlsym(plug, PLUGIN_NAME) == NULL) || ((type = dlsym(plug, PLUGIN_TYPE)) == NULL)) { dlclose(plug); return EPLUGIN_MISSING_NAME; } version = (uint32_t *) dlsym(plug, PLUGIN_VERSION); if (!version) { verbose("%s: plugin_version symbol not defined", fq_path); } else if ((*version != SLURM_VERSION_NUMBER) && xstrcmp(type,"spank")){ /* NOTE: We could alternatly test just the MAJOR.MINOR values */ int plugin_major, plugin_minor, plugin_micro; plugin_major = SLURM_VERSION_MAJOR(*version); plugin_minor = SLURM_VERSION_MINOR(*version); plugin_micro = SLURM_VERSION_MICRO(*version); dlclose(plug); info("%s: Incompatible Slurm plugin version (%d.%d.%d)", fq_path, plugin_major, plugin_minor, plugin_micro); return EPLUGIN_BAD_VERSION; } /* * Now call its init() function, if present. If the function * returns nonzero, unload the plugin and signal an error. */ if ((init = dlsym(plug, "init")) != NULL) { if ((*init)() != 0) { dlclose(plug); return EPLUGIN_INIT_FAILED; } } *p = plug; return EPLUGIN_SUCCESS; }