+ if (!ISSET(status, HEADER_DONE)) {
+ dump_result = max(dump_result, 2);
+ if (!errstr) errstr = stralloc(_("got no header information"));
+ }
+
+ dumpsize -= headersize; /* don't count the header */
+ if (dumpsize <= (off_t)0 && data_path == DATA_PATH_AMANDA) {
+ dumpsize = (off_t)0;
+ dump_result = max(dump_result, 2);
+ if (!errstr) errstr = stralloc(_("got no data"));
+ }
+
+ if (data_path == DATA_PATH_DIRECTTCP) {
+ dumpsize = origsize;
+ }
+
+ if (!ISSET(status, HEADER_DONE)) {
+ dump_result = max(dump_result, 2);
+ if (!errstr) errstr = stralloc(_("got no header information"));
+ }
+
+ if (dumpsize == 0 && data_path == DATA_PATH_AMANDA) {
+ dump_result = max(dump_result, 2);
+ if (!errstr) errstr = stralloc(_("got no data"));
+ }
+
+ if (indexfile_tmp) {
+ amwait_t index_status;
+
+ /*@i@*/ aclose(indexout);
+ waitpid(indexpid,&index_status,0);
+ log_add(L_INFO, "pid-done %ld", (long)indexpid);
+ if (rename(indexfile_tmp, indexfile_real) != 0) {
+ log_add(L_WARNING, _("could not rename \"%s\" to \"%s\": %s"),
+ indexfile_tmp, indexfile_real, strerror(errno));
+ }
+ amfree(indexfile_tmp);
+ amfree(indexfile_real);
+ }
+
+ /* copy the header in a file on the index dir */
+ if (ISSET(status, HEADER_DONE)) {
+ FILE *a;
+ char *s;
+ char *f = getheaderfname(hostname, diskname, dumper_timestamp, level);
+ a = fopen(f,"w");
+ if (a) {
+ s = build_header(&file, NULL, DISK_BLOCK_BYTES);
+ fprintf(a,"%s", s);
+ g_free(s);
+ fclose(a);
+ }
+ g_free(f);
+ }
+
+ if (db->compresspid != -1 && dump_result < 2) {
+ amwait_t wait_status;
+ char *errmsg = NULL;
+
+ waitpid(db->compresspid, &wait_status, 0);
+ if (WIFSIGNALED(wait_status)) {
+ errmsg = g_strdup_printf(_("%s terminated with signal %d"),
+ "compress", WTERMSIG(wait_status));
+ } else if (WIFEXITED(wait_status)) {
+ if (WEXITSTATUS(wait_status) != 0) {
+ errmsg = g_strdup_printf(_("%s exited with status %d"),
+ "compress", WEXITSTATUS(wait_status));
+ }
+ } else {
+ errmsg = g_strdup_printf(_("%s got bad exit"),
+ "compress");
+ }
+ if (errmsg) {
+ g_fprintf(errf, _("? %s\n"), errmsg);
+ g_debug("%s", errmsg);
+ dump_result = max(dump_result, 2);
+ if (!errstr)
+ errstr = errmsg;
+ else
+ g_free(errmsg);
+ }
+ log_add(L_INFO, "pid-done %ld", (long)db->compresspid);
+ db->compresspid = -1;
+ }
+
+ if (db->encryptpid != -1 && dump_result < 2) {
+ amwait_t wait_status;
+ char *errmsg = NULL;
+
+ waitpid(db->encryptpid, &wait_status, 0);
+ if (WIFSIGNALED(wait_status)) {
+ errmsg = g_strdup_printf(_("%s terminated with signal %d"),
+ "encrypt", WTERMSIG(wait_status));
+ } else if (WIFEXITED(wait_status)) {
+ if (WEXITSTATUS(wait_status) != 0) {
+ errmsg = g_strdup_printf(_("%s exited with status %d"),
+ "encrypt", WEXITSTATUS(wait_status));
+ }
+ } else {
+ errmsg = g_strdup_printf(_("%s got bad exit"),
+ "encrypt");
+ }
+ if (errmsg) {
+ g_fprintf(errf, _("? %s\n"), errmsg);
+ g_debug("%s", errmsg);
+ dump_result = max(dump_result, 2);
+ if (!errstr)
+ errstr = errmsg;
+ else
+ g_free(errmsg);
+ }
+ log_add(L_INFO, "pid-done %ld", (long)db->encryptpid);
+ db->encryptpid = -1;
+ }
+