diff --git a/src/api/job_info.c b/src/api/job_info.c index d9ff2d290e371233aeacad4e93ebe35fcd43e3f2..f415ff3dd6ae4b1daa3fcb2cb6d238e6ca1ed24e 100644 --- a/src/api/job_info.c +++ b/src/api/job_info.c @@ -226,17 +226,17 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner ) xstrcat(out, "\n "); /****** Line 7 ******/ - convert_to_kilo(job_ptr->num_procs, tmp1); - convert_to_kilo(job_ptr->num_nodes, tmp3); + convert_num_unit((float)job_ptr->num_procs, tmp1, UNIT_NONE); + convert_num_unit((float)job_ptr->num_nodes, tmp3, UNIT_NONE); #ifdef HAVE_BG sprintf(tmp_line, "ReqProcs=%s MinBPs=%s ", tmp1, tmp3); #else sprintf(tmp_line, "ReqProcs=%s MinNodes=%s ", tmp1, tmp3); #endif xstrcat(out, tmp_line); - convert_to_kilo(job_ptr->shared, tmp1); - convert_to_kilo(job_ptr->contiguous, tmp2); - convert_to_kilo(job_ptr->cpus_per_task, tmp3); + convert_num_unit((float)job_ptr->shared, tmp1, UNIT_NONE); + convert_num_unit((float)job_ptr->contiguous, tmp2, UNIT_NONE); + convert_num_unit((float)job_ptr->cpus_per_task, tmp3, UNIT_NONE); snprintf(tmp_line, sizeof(tmp_line), "Shared=%s Contiguous=%s CPUs/task=%s", tmp1, tmp2, tmp3); xstrcat(out, tmp_line); @@ -246,9 +246,9 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner ) xstrcat(out, "\n "); /****** Line 8 ******/ - convert_to_kilo(job_ptr->min_procs, tmp1); - convert_to_kilo(job_ptr->min_memory, tmp2); - convert_to_kilo(job_ptr->min_tmp_disk, tmp3); + convert_num_unit((float)job_ptr->min_procs, tmp1, UNIT_NONE); + convert_num_unit((float)job_ptr->min_memory, tmp2, UNIT_NONE); + convert_num_unit((float)job_ptr->min_tmp_disk, tmp3, UNIT_NONE); snprintf(tmp_line, sizeof(tmp_line), "MinProcs=%s MinMemory=%s Features=%s MinTmpDisk=%s", tmp1, tmp2, job_ptr->features, tmp3); diff --git a/src/api/partition_info.c b/src/api/partition_info.c index 390d8277247e2f024d4bf73b69cdb412550b9da5..756df2d4d5a3bcf6af54c7d17b04c0956b4d8eab 100644 --- a/src/api/partition_info.c +++ b/src/api/partition_info.c @@ -99,8 +99,8 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr, char *out = NULL; /****** Line 1 ******/ - convert_to_kilo(part_ptr->total_nodes, tmp1); - convert_to_kilo(part_ptr->total_cpus, tmp2); + convert_num_unit((float)part_ptr->total_nodes, tmp1, UNIT_NONE); + convert_num_unit((float)part_ptr->total_cpus, tmp2, UNIT_NONE); snprintf(tmp_line, sizeof(tmp_line), "PartitionName=%s TotalNodes=%s TotalCPUs=%s ", part_ptr->name, tmp1, tmp2); @@ -149,13 +149,13 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr, xstrcat(out, "\n "); /****** Line 3 ******/ - convert_to_kilo(part_ptr->min_nodes, tmp1); + convert_num_unit((float)part_ptr->min_nodes, tmp1, UNIT_NONE); sprintf(tmp_line, "MinNodes=%s ", tmp1); xstrcat(out, tmp_line); if (part_ptr->max_nodes == INFINITE) sprintf(tmp_line, "MaxNodes=UNLIMITED "); else { - convert_to_kilo(part_ptr->max_nodes, tmp1); + convert_num_unit((float)part_ptr->max_nodes, tmp1, UNIT_NONE); sprintf(tmp_line, "MaxNodes=%s ", tmp1); } xstrcat(out, tmp_line); diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c index 1d18c0b6e9696200112bf4f57fdf1fbfa82352cd..f3cc46d97cd72b25e2696a612bab05e7aacd52a7 100644 --- a/src/common/slurm_protocol_api.c +++ b/src/common/slurm_protocol_api.c @@ -1903,28 +1903,6 @@ extern void slurm_free_msg(slurm_msg_t * msg) xfree(msg); } -extern int convert_to_kilo(int number, char *tmp) -{ - int i, j; - if(number >= 1024) { - i = number % 1024; - if(i > 0) { - j = number % 512; - if(j > 0) - sprintf(tmp, "%d", number); - else { - i *= 10; - i /= 1024; - sprintf(tmp, "%d.%dk", number/1024, i); - } - } else - sprintf(tmp, "%dk", number/1024); - } else - sprintf(tmp, "%d", number); - - return SLURM_SUCCESS; -} - extern char *nodelist_nth_host(const char *nodelist, int inx) { hostlist_t hl = hostlist_create(nodelist); @@ -1935,8 +1913,8 @@ extern char *nodelist_nth_host(const char *nodelist, int inx) void convert_num_unit(float num, char *buf, int orig_type) { +#ifdef HAVE_BG char *unit = "\0KMGP?"; - while(num>1024) { num /= 1024; orig_type++; @@ -1945,6 +1923,10 @@ void convert_num_unit(float num, char *buf, int orig_type) if(orig_type < UNIT_NONE || orig_type > UNIT_PETA) orig_type = UNIT_UNKNOWN; sprintf(buf, "%.2f%c", num, unit[orig_type]); +#else + sprintf(buf, "%d", (int)num); +#endif + } #if _DEBUG diff --git a/src/common/slurm_protocol_api.h b/src/common/slurm_protocol_api.h index afc3bdbfbeb150ca348f9c1036ed64078ff13871..c27027723cc105ae1bddba9a36696d40300a51fe 100644 --- a/src/common/slurm_protocol_api.h +++ b/src/common/slurm_protocol_api.h @@ -629,7 +629,6 @@ int slurm_send_only_node_msg(slurm_msg_t * request_msg); extern int *set_span(int total, uint16_t tree_width); extern void slurm_free_msg(slurm_msg_t * msg); -extern int convert_to_kilo(int number, char *tmp); /* must free this memory with free not xfree */ extern char *nodelist_nth_host(const char *nodelist, int inx); diff --git a/src/sinfo/print.c b/src/sinfo/print.c index 95a560b604713f8c65ab353664b25be5db604a07..170a18d8044fc82afd5cd346f91297189e86277f 100644 --- a/src/sinfo/print.c +++ b/src/sinfo/print.c @@ -161,8 +161,8 @@ _build_min_max_string(char *buffer, int buf_size, int min, int max, bool range) { char tmp_min[7]; char tmp_max[7]; - convert_to_kilo(min, tmp_min); - convert_to_kilo(max, tmp_max); + convert_num_unit((float)min, tmp_min, UNIT_NONE); + convert_num_unit((float)max, tmp_max, UNIT_NONE); if (max == min) return snprintf(buffer, buf_size, "%s", tmp_max); @@ -362,7 +362,7 @@ int _print_nodes_t(sinfo_data_t * sinfo_data, int width, char id[FORMAT_STRING_SIZE]; char tmp[7]; if (sinfo_data) { - convert_to_kilo(sinfo_data->nodes_tot, tmp); + convert_num_unit((float)sinfo_data->nodes_tot, tmp, UNIT_NONE); snprintf(id, FORMAT_STRING_SIZE, "%s", tmp); _print_str(id, width, right_justify, true); @@ -381,8 +381,10 @@ int _print_nodes_ai(sinfo_data_t * sinfo_data, int width, char tmpa[7]; char tmpi[7]; if (sinfo_data) { - convert_to_kilo(sinfo_data->nodes_alloc, tmpa); - convert_to_kilo(sinfo_data->nodes_idle, tmpi); + convert_num_unit((float)sinfo_data->nodes_alloc, + tmpa, UNIT_NONE); + convert_num_unit((float)sinfo_data->nodes_idle, + tmpi, UNIT_NONE); snprintf(id, FORMAT_STRING_SIZE, "%s/%s", tmpa, tmpi); @@ -404,10 +406,14 @@ int _print_nodes_aiot(sinfo_data_t * sinfo_data, int width, char tmpo[7]; char tmpt[7]; if (sinfo_data) { - convert_to_kilo(sinfo_data->nodes_alloc, tmpa); - convert_to_kilo(sinfo_data->nodes_idle, tmpi); - convert_to_kilo(sinfo_data->nodes_other, tmpo); - convert_to_kilo(sinfo_data->nodes_tot, tmpt); + convert_num_unit((float)sinfo_data->nodes_alloc, + tmpa, UNIT_NONE); + convert_num_unit((float)sinfo_data->nodes_idle, + tmpi, UNIT_NONE); + convert_num_unit((float)sinfo_data->nodes_other, + tmpo, UNIT_NONE); + convert_num_unit((float)sinfo_data->nodes_tot, + tmpt, UNIT_NONE); snprintf(id, FORMAT_STRING_SIZE, "%s/%s/%s/%s", tmpa, tmpi, tmpo, tmpt); _print_str(id, width, right_justify, true); diff --git a/src/smap/job_functions.c b/src/smap/job_functions.c index 4a9a246486637db608b271e9dc2376ce436dfc7c..5acde4a3397b44143515ac62635a688436ae4ca4 100644 --- a/src/smap/job_functions.c +++ b/src/smap/job_functions.c @@ -263,7 +263,7 @@ static int _print_text_job(job_info_t * job_ptr) #endif if ((node_cnt == 0) || (node_cnt == NO_VAL)) _get_node_cnt(job_ptr); - convert_to_kilo(node_cnt, tmp_cnt); + convert_num_unit((float)node_cnt, tmp_cnt, UNIT_NONE); if(!params.commandline) { mvwprintw(ba_system_ptr->text_win, ba_system_ptr->ycord, diff --git a/src/smap/partition_functions.c b/src/smap/partition_functions.c index d376ee70d7ee664b8981addc989dfe18ef7d7251..b494f30c688906d2108f41f454c0e0455fd75d83 100644 --- a/src/smap/partition_functions.c +++ b/src/smap/partition_functions.c @@ -524,7 +524,7 @@ static int _print_text_part(partition_info_t *part_ptr, char *nodes = NULL, time_buf[20]; char tmp_cnt[7]; - convert_to_kilo(part_ptr->total_nodes, tmp_cnt); + convert_num_unit((float)part_ptr->total_nodes, tmp_cnt, UNIT_NONE); if(!params.commandline) { mvwprintw(ba_system_ptr->text_win, diff --git a/src/squeue/print.c b/src/squeue/print.c index 777d50474516e6dc22e87961fad22f149480098f..74ebec04d416954cb27a0432eedfcff097951818 100644 --- a/src/squeue/print.c +++ b/src/squeue/print.c @@ -602,7 +602,7 @@ int _print_job_num_procs(job_info_t * job, int width, bool right, char* suffix) if (job == NULL) /* Print the Header instead */ _print_str("CPUS", width, right, true); else { - convert_to_kilo(job->num_procs, tmp_char); + convert_num_unit((float)job->num_procs, tmp_char, UNIT_NONE); _print_str(tmp_char, width, right, true); } if (suffix) @@ -626,7 +626,7 @@ int _print_job_num_nodes(job_info_t * job, int width, bool right_justify, #endif if ((node_cnt == 0) || (node_cnt == NO_VAL)) node_cnt = _get_node_cnt(job); - convert_to_kilo(node_cnt, tmp_char); + convert_num_unit((float)node_cnt, tmp_char, UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } if (suffix) @@ -679,7 +679,7 @@ int _print_job_shared(job_info_t * job, int width, bool right_justify, if (job == NULL) /* Print the Header instead */ _print_str("SHARED", width, right_justify, true); else { - convert_to_kilo(job->shared, tmp_char); + convert_num_unit((float)job->shared, tmp_char, UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } if (suffix) @@ -695,7 +695,7 @@ int _print_job_contiguous(job_info_t * job, int width, bool right_justify, if (job == NULL) /* Print the Header instead */ _print_str("CONTIGUOUS", width, right_justify, true); else { - convert_to_kilo(job->contiguous, tmp_char); + convert_num_unit((float)job->contiguous, tmp_char, UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } @@ -712,7 +712,7 @@ int _print_job_min_procs(job_info_t * job, int width, bool right_justify, if (job == NULL) /* Print the Header instead */ _print_str("MIN_PROCS", width, right_justify, true); else { - convert_to_kilo(job->min_procs, tmp_char); + convert_num_unit((float)job->min_procs, tmp_char, UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } @@ -729,7 +729,7 @@ int _print_job_min_memory(job_info_t * job, int width, bool right_justify, if (job == NULL) /* Print the Header instead */ _print_str("MIN_MEMORY", width, right_justify, true); else { - convert_to_kilo(job->min_memory, tmp_char); + convert_num_unit((float)job->min_memory, tmp_char, UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } @@ -747,7 +747,8 @@ _print_job_min_tmp_disk(job_info_t * job, int width, bool right_justify, if (job == NULL) /* Print the Header instead */ _print_str("MIN_TMP_DISK", width, right_justify, true); else { - convert_to_kilo(job->min_tmp_disk, tmp_char); + convert_num_unit((float)job->min_tmp_disk, + tmp_char, UNIT_NONE); _print_str(tmp_char, width, right_justify, true); } diff --git a/src/sview/block_info.c b/src/sview/block_info.c index d57c9c02b1f09ec096d50db429e8ef29a449565d..f6e160f0fc312fd729aeeb865714a0f4c3ed73af 100644 --- a/src/sview/block_info.c +++ b/src/sview/block_info.c @@ -380,7 +380,7 @@ static void _update_block_record(db2_block_info_t *block_ptr, gtk_tree_store_set(treestore, iter, SORTID_USE, _convert_node_use(block_ptr->bg_node_use), -1); - convert_to_kilo(block_ptr->node_cnt, tmp_cnt); + convert_num_unit((float)block_ptr->node_cnt, tmp_cnt, UNIT_NONE); gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_cnt, -1); nodes = block_ptr->nodes; diff --git a/src/sview/job_info.c b/src/sview/job_info.c index 61c0ff483498705eddc6a9214999e26a8b461a35..50098359c1a8186ce95cc906fa3b5696727251bc 100644 --- a/src/sview/job_info.c +++ b/src/sview/job_info.c @@ -222,11 +222,11 @@ static void _update_job_record(job_info_t *job_ptr, - convert_to_kilo(node_cnt, tmp_cnt); + convert_num_unit((float)node_cnt, tmp_cnt, UNIT_NONE); gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_cnt, -1); - convert_to_kilo(job_ptr->num_procs, tmp_cnt); + convert_num_unit((float)job_ptr->num_procs, tmp_cnt, UNIT_NONE); gtk_tree_store_set(treestore, iter, SORTID_NUM_PROCS, tmp_cnt, -1); @@ -277,7 +277,8 @@ static void _update_step_record(job_step_info_t *step_ptr, now_time -= step_ptr->start_time; snprint_time(time_buf, sizeof(time_buf), now_time); nodes = step_ptr->nodes; - convert_to_kilo(_nodes_in_list(nodes), tmp_cnt); + convert_num_unit((float)_nodes_in_list(nodes), + tmp_cnt, UNIT_NONE); gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_cnt, -1); state = JOB_RUNNING; @@ -310,7 +311,7 @@ static void _update_step_record(job_step_info_t *step_ptr, gtk_tree_store_set(treestore, iter, SORTID_NAME, step_ptr->name, -1); - convert_to_kilo(step_ptr->num_tasks, tmp_cnt); + convert_num_unit((float)step_ptr->num_tasks, tmp_cnt, UNIT_NONE); gtk_tree_store_set(treestore, iter, SORTID_TASKS, tmp_cnt, -1); diff --git a/src/sview/part_info.c b/src/sview/part_info.c index 20d15b3480bafdcf5b3f6dd244e9389651f7594c..73badffa416fca42c88015cac42add293312663a 100644 --- a/src/sview/part_info.c +++ b/src/sview/part_info.c @@ -32,6 +32,7 @@ DEF_TIMERS; typedef struct { + partition_info_t* part_ptr; uint16_t node_state; uint32_t nodes_alloc; @@ -78,6 +79,7 @@ enum { SORTID_DISK, SORTID_NODELIST, SORTID_STATE, + SORTID_STATE_NUM, SORTID_UPDATED, SORTID_CNT }; @@ -97,6 +99,7 @@ static display_data_t display_data_part[] = { {G_TYPE_STRING, SORTID_CPUS, "CPUs", FALSE, -1, refresh_part}, {G_TYPE_STRING, SORTID_DISK, "Disk", FALSE, -1, refresh_part}, {G_TYPE_STRING, SORTID_STATE, "State", TRUE, -1, refresh_part}, + {G_TYPE_INT, SORTID_STATE, NULL, FALSE, -1, refresh_part}, #ifdef HAVE_BG {G_TYPE_STRING, SORTID_NODELIST, "BP List", TRUE, -1, refresh_part}, #else @@ -124,13 +127,20 @@ static display_data_t options_data_part[] = { static display_data_t *local_display_data = NULL; +static void _update_part_sub_record(sview_part_sub_t *sview_part_sub, + GtkTreeStore *treestore, + GtkTreeIter *iter); +static void _append_part_sub_record(sview_part_sub_t *sview_part_sub, + GtkTreeStore *treestore, GtkTreeIter *iter, + int line); + static int _build_min_max_string(char *buffer, int buf_size, int min, int max, bool range) { char tmp_min[7]; char tmp_max[7]; - convert_to_kilo(min, tmp_min); - convert_to_kilo(max, tmp_max); + convert_num_unit((float)min, tmp_min, UNIT_NONE); + convert_num_unit((float)max, tmp_max, UNIT_NONE); if (max == min) return snprintf(buffer, buf_size, "%s", tmp_max); @@ -146,11 +156,16 @@ _build_min_max_string(char *buffer, int buf_size, int min, int max, bool range) } static void _subdivide_part(sview_part_info_t *sview_part_info, - GtkTreeModel *model, - GtkTreeIter *sub_iter, - GtkTreeIter *iter) + GtkTreeModel *model, + GtkTreeIter *sub_iter, + GtkTreeIter *iter) { GtkTreeIter *first_sub_iter = NULL; + ListIterator itr = NULL; + uint16_t state; + int i = 0, line = 0; + sview_part_sub_t *sview_part_sub = NULL; + /* make sure all the steps are still here */ if (sub_iter) { first_sub_iter = gtk_tree_iter_copy(sub_iter); @@ -163,12 +178,71 @@ static void _subdivide_part(sview_part_info_t *sview_part_info, } sub_iter = gtk_tree_iter_copy(first_sub_iter); } - - + itr = list_iterator_create(sview_part_info->sub_list); + while((sview_part_sub = list_next(itr))) { + if (!sub_iter) { + i = NO_VAL; + goto adding; + } + while(1) { + /* search for the jobid and check to see if + it is in the list */ + gtk_tree_model_get(model, sub_iter, SORTID_STATE_NUM, + &state, -1); + if(state == sview_part_sub->node_state) { + /* update with new info */ + _update_part_sub_record(sview_part_sub, + GTK_TREE_STORE(model), + sub_iter); + goto found; + } + + /* see what line we were on to add the next one + to the list */ + gtk_tree_model_get(model, sub_iter, SORTID_POS, + &line, -1); + if(!gtk_tree_model_iter_next(model, sub_iter)) { + sub_iter = NULL; + line++; + break; + } + } + adding: + _append_part_sub_record(sview_part_sub, GTK_TREE_STORE(model), + iter, line); + if(i == NO_VAL) + line++; + found: + ; + } + if(first_sub_iter) { + if(sub_iter) + gtk_tree_iter_free(sub_iter); + sub_iter = gtk_tree_iter_copy(first_sub_iter); + /* clear all steps that aren't active */ + while(1) { + gtk_tree_model_get(model, sub_iter, + SORTID_UPDATED, &i, -1); + if(!i) { + if(!gtk_tree_store_remove( + GTK_TREE_STORE(model), + sub_iter)) + break; + else + continue; + } + if(!gtk_tree_model_iter_next(model, sub_iter)) { + break; + } + } + gtk_tree_iter_free(first_sub_iter); + } + return; } static void _update_part_record(sview_part_info_t *sview_part_info, - GtkTreeStore *treestore, GtkTreeIter *iter) + GtkTreeStore *treestore, + GtkTreeIter *iter) { char time_buf[20]; char tmp_cnt[7]; @@ -218,7 +292,9 @@ static void _update_part_record(sview_part_info_t *sview_part_info, else gtk_tree_store_set(treestore, iter, SORTID_GROUPS, "all", -1); - convert_to_kilo(part_ptr->total_nodes, tmp_cnt); + gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_cnt, -1); + + convert_num_unit((float)part_ptr->total_nodes, tmp_cnt, UNIT_NONE); gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_cnt, -1); gtk_tree_store_set(treestore, iter, SORTID_NODELIST, @@ -237,6 +313,68 @@ static void _update_part_record(sview_part_info_t *sview_part_info, return; } + +static void _update_part_sub_record(sview_part_sub_t *sview_part_sub, + GtkTreeStore *treestore, GtkTreeIter *iter) +{ + char time_buf[20]; + char tmp_cnt[7]; + partition_info_t *part_ptr = sview_part_sub->part_ptr; + + + gtk_tree_store_set(treestore, iter, SORTID_NAME, part_ptr->name, -1); + + if(part_ptr->default_part) + gtk_tree_store_set(treestore, iter, SORTID_DEFAULT, "*", -1); + + if (part_ptr->state_up) + gtk_tree_store_set(treestore, iter, SORTID_AVAIL, "up", -1); + else + gtk_tree_store_set(treestore, iter, SORTID_AVAIL, "down", -1); + + if (part_ptr->max_time == INFINITE) + snprintf(time_buf, sizeof(time_buf), "infinite"); + else { + snprint_time(time_buf, sizeof(time_buf), + (part_ptr->max_time * 60)); + } + + gtk_tree_store_set(treestore, iter, SORTID_TIMELIMIT, time_buf, -1); + + _build_min_max_string(time_buf, sizeof(time_buf), + part_ptr->min_nodes, + part_ptr->max_nodes, true); + gtk_tree_store_set(treestore, iter, SORTID_JOB_SIZE, time_buf, -1); + + if(part_ptr->root_only) + gtk_tree_store_set(treestore, iter, SORTID_ROOT, "yes", -1); + else + gtk_tree_store_set(treestore, iter, SORTID_ROOT, "no", -1); + + if(part_ptr->shared > 1) + gtk_tree_store_set(treestore, iter, SORTID_SHARE, "force", -1); + else if(part_ptr->shared) + gtk_tree_store_set(treestore, iter, SORTID_SHARE, "yes", -1); + else + gtk_tree_store_set(treestore, iter, SORTID_SHARE, "no", -1); + + if(part_ptr->allow_groups) + gtk_tree_store_set(treestore, iter, SORTID_GROUPS, + part_ptr->allow_groups, -1); + else + gtk_tree_store_set(treestore, iter, SORTID_GROUPS, "all", -1); + + convert_num_unit((float)part_ptr->total_nodes, tmp_cnt, UNIT_NONE); + gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_cnt, -1); + + gtk_tree_store_set(treestore, iter, SORTID_NODELIST, + part_ptr->nodes, -1); + gtk_tree_store_set(treestore, iter, SORTID_UPDATED, 1, -1); + + + return; +} + static void _append_part_record(sview_part_info_t *sview_part_info, GtkTreeStore *treestore, GtkTreeIter *iter, int line) @@ -246,6 +384,17 @@ static void _append_part_record(sview_part_info_t *sview_part_info, _update_part_record(sview_part_info, treestore, iter); } +static void _append_part_sub_record(sview_part_sub_t *sview_part_sub, + GtkTreeStore *treestore, GtkTreeIter *iter, + int line) +{ + GtkTreeIter sub_iter; + + gtk_tree_store_append(treestore, &sub_iter, iter); + gtk_tree_store_set(treestore, &sub_iter, SORTID_POS, line, -1); + _update_part_sub_record(sview_part_sub, treestore, &sub_iter); +} + static void _update_info_part(List info_list, GtkTreeView *tree_view, specific_info_t *spec_info) @@ -491,7 +640,8 @@ static void _update_sview_part_sub(sview_part_sub_t *sview_part_sub, * the given partition * sview_part_sub OUT - ptr to an inited sview_part_sub_t */ -static sview_part_sub_t *_create_sview_part_sub(node_info_t *node_ptr, +static sview_part_sub_t *_create_sview_part_sub(partition_info_t *part_ptr, + node_info_t *node_ptr, int node_scaling) { sview_part_sub_t *sview_part_sub_ptr = @@ -501,11 +651,18 @@ static sview_part_sub_t *_create_sview_part_sub(node_info_t *node_ptr, if(!node_scaling) node_scaling = 1; + if (!part_ptr) { + g_print("got no part_ptr!\n"); + xfree(sview_part_sub_ptr); + return NULL; + } if (!node_ptr) { g_print("got no node_ptr!\n"); + xfree(sview_part_sub_ptr); return NULL; } - + sview_part_sub_ptr->part_ptr = part_ptr; + base_state = node_ptr->node_state & NODE_STATE_BASE; sview_part_sub_ptr->node_state = node_ptr->node_state; if ((base_state == NODE_STATE_ALLOCATED) @@ -593,17 +750,21 @@ static List _create_info_list(partition_info_msg_t *part_info_ptr, itr = list_iterator_create(sview_part_info->sub_list); while((sview_part_sub = list_next(itr))) { if(sview_part_sub->node_state - == node_ptr->node_state) + == node_ptr->node_state) { _update_sview_part_sub( sview_part_sub, node_ptr, part_ptr->node_scaling); + found = 1; + break; + } } list_iterator_destroy(itr); if(!found) { sview_part_sub = _create_sview_part_sub( + part_ptr, node_ptr, part_ptr->node_scaling); list_push(sview_part_info->sub_list,