extern int bcast_file(struct bcast_parameters *params) { int rc; if ((rc = _file_state(params)) != SLURM_SUCCESS) return rc; if ((rc = _get_job_info(params)) != SLURM_SUCCESS) return rc; if ((rc = _bcast_file(params)) != SLURM_SUCCESS) return rc; /* slurm_free_sbcast_cred_msg(sbcast_cred); */ return rc; }
int main(int argc, char *argv[]) { log_options_t opts = LOG_OPTS_STDERR_ONLY; log_init("sbcast", opts, SYSLOG_FACILITY_DAEMON, NULL); #ifdef HAVE_ALPS_CRAY error("The sbcast command is not supported on Cray systems"); return 1; #endif #ifdef HAVE_BG error("The sbcast command is not supported on IBM BlueGene systems"); return 1; #endif slurm_conf_init(NULL); parse_command_line(argc, argv); if (params.verbose) { opts.stderr_level += params.verbose; log_alter(opts, SYSLOG_FACILITY_DAEMON, NULL); } /* validate the source file */ if ((fd = open(params.src_fname, O_RDONLY)) < 0) { error("Can't open `%s`: %s", params.src_fname, strerror(errno)); exit(1); } if (fstat(fd, &f_stat)) { error("Can't stat `%s`: %s", params.src_fname, strerror(errno)); exit(1); } verbose("modes = %o", (unsigned int) f_stat.st_mode); verbose("uid = %d", (int) f_stat.st_uid); verbose("gid = %d", (int) f_stat.st_gid); verbose("atime = %s", slurm_ctime(&f_stat.st_atime)); verbose("mtime = %s", slurm_ctime(&f_stat.st_mtime)); verbose("ctime = %s", slurm_ctime(&f_stat.st_ctime)); verbose("size = %ld", (long) f_stat.st_size); verbose("-----------------------------"); /* identify the nodes allocated to the job */ _get_job_info(); /* transmit the file */ _bcast_file(); /* slurm_free_sbcast_cred_msg(sbcast_cred); */ exit(0); }
/* _get_job_ids() */ static uint32_t * _get_job_ids(const char *jobid, uint32_t *num_ids) { job_info_msg_t *job_info; uint32_t *job_ids; uint32_t task_id; int i; int cc; task_id = 0; job_info = _get_job_info(jobid, &task_id); if (job_info == NULL) return NULL; if (_is_array_task_id(jobid)) { job_ids = xmalloc(sizeof(uint32_t)); *num_ids = 1; /* Search for the job_id of the specified * task. */ for (cc = 0; cc < job_info->record_count; cc++) { if (task_id == job_info->job_array[cc].array_task_id) { job_ids[0] = job_info->job_array[cc].job_id; break; } } slurm_free_job_info_msg(job_info); return job_ids; } if (job_info->record_count == 1) { /* No task elements beside the * job itself so it cannot be * a job array. */ job_ids = xmalloc(sizeof(uint32_t)); *num_ids = 1; job_ids[0] = job_info->job_array[0].job_id; slurm_free_job_info_msg(job_info); return job_ids; } *num_ids = job_info->record_count; job_ids = xmalloc((*num_ids) * sizeof(uint32_t)); /* First save the pending jobs */ i = 0; for (cc = 0; cc < job_info->record_count; cc++) { if (job_info->job_array[cc].job_state == JOB_PENDING) { job_ids[i] = job_info->job_array[cc].job_id; ++i; } } /* then the rest of the states */ for (cc = 0; cc < job_info->record_count; cc++) { if (job_info->job_array[cc].job_state != JOB_PENDING) { job_ids[i] = job_info->job_array[cc].job_id; ++i; } } xassert(i == *num_ids); slurm_free_job_info_msg(job_info); return job_ids; }