X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Ffiled%2Frestore.c;h=299b78f9e2a5b33902fbe92add40c289f14028d2;hb=f5571f4e4916261503020df01b6f9d30d17ae194;hp=7869df4b4e9a463614701f01cdc77e64913c0e3f;hpb=ee2249b63ec2940a2c8c1b82c1b3b4d9ead27c09;p=bacula%2Fbacula diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 7869df4b4e..299b78f9e2 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -120,7 +120,7 @@ bool flush_cipher(JCR *jcr, BFILE *bfd, uint64_t *addr, int flags, /* * Close a bfd check that we are at the expected file offset. - * Makes some code in set_attributes(). + * Makes use of some code from set_attributes(). */ static int bclose_chksize(JCR *jcr, BFILE *bfd, boffset_t osize) { @@ -299,7 +299,11 @@ void do_restore(JCR *jcr) deallocate_fork_cipher(rctx); } - set_attributes(jcr, attr, &rctx.bfd); + if (jcr->plugin) { + plugin_set_attributes(jcr, attr, &rctx.bfd); + } else { + set_attributes(jcr, attr, &rctx.bfd); + } extract = false; /* Verify the cryptographic signature, if any */ @@ -316,6 +320,11 @@ void do_restore(JCR *jcr) bclose(&rctx.bfd); } + /* TODO: manage deleted files */ + if (rctx.type == FT_DELETED) { /* deleted file */ + continue; + } + /* * Unpack attributes and do sanity check them */ @@ -345,11 +354,16 @@ void do_restore(JCR *jcr) build_attr_output_fnames(jcr, attr); /* - * Now determine if we are extracting or not. + * Try to actually create the file, which returns a status telling + * us if we need to extract or not. */ jcr->num_files_examined++; extract = false; - stat = create_file(jcr, attr, &rctx.bfd, jcr->replace); + if (jcr->plugin) { + stat = plugin_create_file(jcr, attr, &rctx.bfd, jcr->replace); + } else { + stat = create_file(jcr, attr, &rctx.bfd, jcr->replace); + } Dmsg2(30, "Outfile=%s create_file stat=%d\n", attr->ofname, stat); switch (stat) { case CF_ERROR: @@ -376,7 +390,11 @@ void do_restore(JCR *jcr) } if (!extract) { /* set attributes now because file will not be extracted */ - set_attributes(jcr, attr, &rctx.bfd); + if (jcr->plugin) { + plugin_set_attributes(jcr, attr, &rctx.bfd); + } else { + set_attributes(jcr, attr, &rctx.bfd); + } } break; } @@ -631,6 +649,11 @@ void do_restore(JCR *jcr) } break; + case STREAM_PLUGIN_NAME: + Dmsg1(000, "restore stream_plugin_name=%s\n", sd->msg); + plugin_name_stream(jcr, sd->msg); + break; + default: /* If extracting, wierd stream (not 1 or 2), close output file anyway */ if (extract) { @@ -642,7 +665,11 @@ void do_restore(JCR *jcr) deallocate_cipher(rctx); deallocate_fork_cipher(rctx); - set_attributes(jcr, attr, &rctx.bfd); + if (jcr->plugin) { + plugin_set_attributes(jcr, attr, &rctx.bfd); + } else { + set_attributes(jcr, attr, &rctx.bfd); + } /* Verify the cryptographic signature if any */ rctx.type = attr->type; @@ -671,7 +698,11 @@ void do_restore(JCR *jcr) deallocate_cipher(rctx); deallocate_fork_cipher(rctx); - set_attributes(jcr, attr, &rctx.bfd); + if (jcr->plugin) { + plugin_set_attributes(jcr, attr, &rctx.bfd); + } else { + set_attributes(jcr, attr, &rctx.bfd); + } /* Verify the cryptographic signature on the last file, if any */ rctx.type = attr->type; @@ -775,9 +806,8 @@ static const char *zlib_strerror(int stat) } #endif -static int do_file_digest(FF_PKT *ff_pkt, void *pkt, bool top_level) +static int do_file_digest(JCR *jcr, FF_PKT *ff_pkt, bool top_level) { - JCR *jcr = (JCR *)pkt; Dmsg1(50, "do_file_digest jcr=%p\n", jcr); return (digest_file(jcr, ff_pkt, jcr->crypto.digest)); } @@ -1084,7 +1114,6 @@ int32_t extract_data(JCR *jcr, BFILE *bfd, POOLMEM *buf, int32_t buflen, * packet length may be re-read by unser_crypto_packet_len() */ cipher_ctx->packet_len = 0; } - return wsize; }