GSList * cmdline_match_holding( GSList *dumpspec_list) { dumpspec_t *de; GSList *li, *hi; GSList *holding_files; GSList *matching_files = NULL; dumpfile_t file; holding_files = holding_get_files(NULL, 1); for (hi = holding_files; hi != NULL; hi = hi->next) { /* TODO add level */ if (!holding_file_get_dumpfile((char *)hi->data, &file)) continue; if (file.type != F_DUMPFILE) { dumpfile_free_data(&file); continue; } for (li = dumpspec_list; li != NULL; li = li->next) { de = (dumpspec_t *)(li->data); if (de->host && de->host[0] && !match_host(de->host, file.name)) continue; if (de->disk && de->disk[0] && !match_disk(de->disk, file.disk)) continue; if (de->datestamp && de->datestamp[0] && !match_datestamp(de->datestamp, file.datestamp)) continue; matching_files = g_slist_append(matching_files, g_strdup((char *)hi->data)); break; } dumpfile_free_data(&file); } slist_free_full(holding_files, g_free); return matching_files; }
GSList * holding_get_all_datestamps(void) { GSList *all_files, *file; GSList *datestamps = NULL; /* enumerate all files */ all_files = holding_get_files(NULL, 1); for (file = all_files; file != NULL; file = file->next) { dumpfile_t dfile; if (!holding_file_get_dumpfile((char *)file->data, &dfile)) continue; if (!g_slist_find_custom(datestamps, dfile.datestamp, g_compare_strings)) { datestamps = g_slist_insert_sorted(datestamps, g_strdup(dfile.datestamp), g_compare_strings); } dumpfile_free_data(&dfile); } slist_free_full(all_files, g_free); return datestamps; }
GSList * holding_get_files_for_flush( GSList *dateargs) { GSList *file_list, *file_elt; GSList *date; int date_matches; dumpfile_t file; GSList *result_list = NULL; /* loop over *all* files, checking each one's datestamp against the expressions * in dateargs */ file_list = holding_get_files(NULL, 1); for (file_elt = file_list; file_elt != NULL; file_elt = file_elt->next) { /* get info on that file */ if (!holding_file_get_dumpfile((char *)file_elt->data, &file)) continue; if (file.type != F_DUMPFILE) { dumpfile_free_data(&file); continue; } if (dateargs) { date_matches = 0; /* loop over date args, until we find a match */ for (date = dateargs; date !=NULL; date = date->next) { if (g_str_equal((char *)date->data, file.datestamp)) { date_matches = 1; break; } } } else { /* if no date list was provided, then all dates match */ date_matches = 1; } if (!date_matches) { dumpfile_free_data(&file); continue; } /* passed all tests -- we'll flush this file */ result_list = g_slist_insert_sorted(result_list, g_strdup(file_elt->data), g_compare_strings); dumpfile_free_data(&file); } if (file_list) slist_free_full(file_list, g_free); return result_list; }
void search_holding_disk( find_result_t **output_find, disklist_t * dynamic_disklist) { GSList *holding_file_list; GSList *e; char *holding_file; disk_t *dp; char *orig_name; holding_file_list = holding_get_files(NULL, 1); if (string_chunk == NULL) { string_chunk = g_string_chunk_new(32768); } for(e = holding_file_list; e != NULL; e = e->next) { dumpfile_t file; holding_file = (char *)e->data; if (!holding_file_get_dumpfile(holding_file, &file)) continue; if (file.dumplevel < 0 || file.dumplevel >= DUMP_LEVELS) { dumpfile_free_data(&file); continue; } dp = NULL; orig_name = g_strdup(file.name); for(;;) { char *s; if((dp = lookup_disk(file.name, file.disk))) break; if((s = strrchr(file.name,'.')) == NULL) break; *s = '\0'; } strcpy(file.name, orig_name); /* restore munged string */ g_free(orig_name); if ( dp == NULL ) { if (dynamic_disklist == NULL) { dumpfile_free_data(&file); continue; } dp = add_disk(dynamic_disklist, file.name, file.disk); enqueue_disk(dynamic_disklist, dp); } if(find_match(file.name,file.disk)) { find_result_t *new_output_find = g_new0(find_result_t, 1); new_output_find->next=*output_find; new_output_find->timestamp = g_string_chunk_insert_const(string_chunk, file.datestamp); new_output_find->write_timestamp = g_string_chunk_insert_const(string_chunk, "00000000000000"); new_output_find->hostname = g_string_chunk_insert_const(string_chunk, file.name); new_output_find->diskname = g_string_chunk_insert_const(string_chunk, file.disk); new_output_find->level=file.dumplevel; new_output_find->label=g_string_chunk_insert_const(string_chunk, holding_file); new_output_find->partnum = -1; new_output_find->totalparts = -1; new_output_find->filenum=0; if (file.is_partial) { new_output_find->status="PARTIAL"; new_output_find->dump_status="PARTIAL"; } else { new_output_find->status="OK"; new_output_find->dump_status="OK"; } new_output_find->message=""; new_output_find->kb = holding_file_size(holding_file, 1); new_output_find->bytes = 0; new_output_find->orig_kb = file.orig_size; *output_find=new_output_find; } dumpfile_free_data(&file); } slist_free_full(holding_file_list, g_free); }