#include "amanda.h"
#include "util.h"
#include "holding.h"
+#include "diskfile.h"
#include "fileheader.h"
#include "logfile.h"
holding_walk_fn per_file_fn,
holding_walk_fn per_chunk_fn)
{
+ identlist_t il;
holdingdisk_t *hdisk_conf;
char *hdisk;
int proceed = 1;
- for (hdisk_conf = getconf_holdingdisks();
- hdisk_conf != NULL;
- hdisk_conf = holdingdisk_next(hdisk_conf)) {
+ for (il = getconf_identlist(CNF_HOLDINGDISK);
+ il != NULL;
+ il = il->next) {
int is_cruft = 0;
+ hdisk_conf = lookup_holdingdisk(il->data);
hdisk = holdingdisk_get_diskdir(hdisk_conf);
if (!is_dir(hdisk))
GSList *file_list, *file_elt;
GSList *date;
int date_matches;
- disk_t *dp;
dumpfile_t file;
GSList *result_list = NULL;
continue;
}
- /* check that the hostname and disk are in the disklist */
- dp = lookup_disk(file.name, file.disk);
- if (dp == NULL) {
- dbprintf(_("%s: disk %s:%s not in database, skipping it."),
- (char *)file_elt->data, file.name, file.disk);
- dumpfile_free_data(&file);
- continue;
- }
-
/* passed all tests -- we'll flush this file */
result_list = g_slist_insert_sorted(result_list,
stralloc(file_elt->data),
dumpfile_free_data(&file);
}
- if (file_list) g_slist_free_full(file_list);
+ if (file_list) slist_free_full(file_list, g_free);
return result_list;
}
dumpfile_free_data(&dfile);
}
- g_slist_free_full(all_files);
+ slist_free_full(all_files, g_free);
return datestamps;
}
* Application support
*/
+void
+holding_set_origsize(
+ char *holding_file,
+ off_t orig_size)
+{
+ int fd;
+ size_t buflen;
+ char buffer[DISK_BLOCK_BYTES];
+ char *read_buffer;
+ dumpfile_t file;
+
+ if((fd = robust_open(holding_file, O_RDWR, 0)) == -1) {
+ dbprintf(_("holding_set_origsize: open of %s failed: %s\n"),
+ holding_file, strerror(errno));
+ return;
+ }
+
+ buflen = full_read(fd, buffer, SIZEOF(buffer));
+ if (buflen <= 0) {
+ dbprintf(_("holding_set_origsize: %s: empty file?\n"), holding_file);
+ return;
+ }
+ parse_file_header(buffer, &file, (size_t)buflen);
+ lseek(fd, (off_t)0, SEEK_SET);
+ file.orig_size = orig_size;
+ read_buffer = build_header(&file, NULL, DISK_BLOCK_BYTES);
+ full_write(fd, read_buffer, DISK_BLOCK_BYTES);
+ dumpfile_free_data(&file);
+ amfree(read_buffer);
+ close(fd);
+}
+
int
rename_tmp_holding(
char * holding_file,
}
file.is_partial = 1;
- header = build_header(&file, DISK_BLOCK_BYTES);
+ if (debug_holding > 1)
+ dump_dumpfile_t(&file);
+ header = build_header(&file, NULL, DISK_BLOCK_BYTES);
+ if (!header) /* this shouldn't happen */
+ error(_("header does not fit in %zd bytes"), (size_t)DISK_BLOCK_BYTES);
if (full_write(fd, header, DISK_BLOCK_BYTES) != DISK_BLOCK_BYTES) {
dbprintf(_("rename_tmp_holding: writing new header failed: %s"),
strerror(errno));
dumpfile_free_data(&file);
amfree(filename);
amfree(filename_tmp);
+ free(header);
close(fd);
return 0;
}
+ free(header);
close(fd);
}
filename = newstralloc(filename, file.cont_filename);