Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/filed/backup.cc')
-rw-r--r--core/src/filed/backup.cc115
1 files changed, 59 insertions, 56 deletions
diff --git a/core/src/filed/backup.cc b/core/src/filed/backup.cc
index e81f7cea9..bf5006d31 100644
--- a/core/src/filed/backup.cc
+++ b/core/src/filed/backup.cc
@@ -35,7 +35,7 @@
#include "filed/crypto.h"
#include "filed/heartbeat.h"
#include "filed/backup.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "include/ch.h"
#include "findlib/attribs.h"
#include "findlib/hardlink.h"
@@ -90,7 +90,7 @@ static void CloseVssBackupSession(JobControlRecord* jcr);
* to the Storage daemon.
*
* Note, we normally carry on a one-way
- * conversation from this point on with the SD, simply blasting
+ * conversation from this point on with the SD, sfd_imply blasting
* data to him. To properly know what is going on, we
* also run a "heartbeat" monitor which reads the socket and
* reacts accordingly (at the moment it has nothing to do
@@ -131,47 +131,49 @@ bool BlastDataToStorageDaemon(JobControlRecord* jcr,
if (!CryptoSessionStart(jcr, cipher)) { return false; }
- SetFindOptions((FindFilesPacket*)jcr->impl->ff, jcr->impl->incremental,
- jcr->impl->since_time);
+ SetFindOptions((FindFilesPacket*)jcr->fd_impl->ff, jcr->fd_impl->incremental,
+ jcr->fd_impl->since_time);
// In accurate mode, we overload the find_one check function
if (jcr->accurate) {
- SetFindChangedFunction((FindFilesPacket*)jcr->impl->ff, AccurateCheckFile);
+ SetFindChangedFunction((FindFilesPacket*)jcr->fd_impl->ff,
+ AccurateCheckFile);
}
StartHeartbeatMonitor(jcr);
if (have_acl) {
- jcr->impl->acl_data = std::make_unique<AclData>();
- jcr->impl->acl_data->u.build
+ jcr->fd_impl->acl_data = std::make_unique<AclData>();
+ jcr->fd_impl->acl_data->u.build
= (acl_build_data_t*)malloc(sizeof(acl_build_data_t));
- memset(jcr->impl->acl_data->u.build, 0, sizeof(acl_build_data_t));
- jcr->impl->acl_data->u.build->content = GetPoolMemory(PM_MESSAGE);
+ memset(jcr->fd_impl->acl_data->u.build, 0, sizeof(acl_build_data_t));
+ jcr->fd_impl->acl_data->u.build->content = GetPoolMemory(PM_MESSAGE);
}
if (have_xattr) {
- jcr->impl->xattr_data = std::make_unique<XattrData>();
- jcr->impl->xattr_data->u.build
+ jcr->fd_impl->xattr_data = std::make_unique<XattrData>();
+ jcr->fd_impl->xattr_data->u.build
= (xattr_build_data_t*)malloc(sizeof(xattr_build_data_t));
- memset(jcr->impl->xattr_data->u.build, 0, sizeof(xattr_build_data_t));
- jcr->impl->xattr_data->u.build->content = GetPoolMemory(PM_MESSAGE);
+ memset(jcr->fd_impl->xattr_data->u.build, 0, sizeof(xattr_build_data_t));
+ jcr->fd_impl->xattr_data->u.build->content = GetPoolMemory(PM_MESSAGE);
}
// Subroutine SaveFile() is called for each file
- if (!FindFiles(jcr, (FindFilesPacket*)jcr->impl->ff, SaveFile, PluginSave)) {
+ if (!FindFiles(jcr, (FindFilesPacket*)jcr->fd_impl->ff, SaveFile,
+ PluginSave)) {
ok = false; /* error */
jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
- if (have_acl && jcr->impl->acl_data->u.build->nr_errors > 0) {
+ if (have_acl && jcr->fd_impl->acl_data->u.build->nr_errors > 0) {
Jmsg(jcr, M_WARNING, 0,
_("Encountered %ld acl errors while doing backup\n"),
- jcr->impl->acl_data->u.build->nr_errors);
+ jcr->fd_impl->acl_data->u.build->nr_errors);
}
- if (have_xattr && jcr->impl->xattr_data->u.build->nr_errors > 0) {
+ if (have_xattr && jcr->fd_impl->xattr_data->u.build->nr_errors > 0) {
Jmsg(jcr, M_WARNING, 0,
_("Encountered %ld xattr errors while doing backup\n"),
- jcr->impl->xattr_data->u.build->nr_errors);
+ jcr->fd_impl->xattr_data->u.build->nr_errors);
}
#if defined(WIN32_VSS)
@@ -184,19 +186,19 @@ bool BlastDataToStorageDaemon(JobControlRecord* jcr,
sd->signal(BNET_EOD); /* end of sending data */
- if (have_acl && jcr->impl->acl_data) {
- FreePoolMemory(jcr->impl->acl_data->u.build->content);
- free(jcr->impl->acl_data->u.build);
+ if (have_acl && jcr->fd_impl->acl_data) {
+ FreePoolMemory(jcr->fd_impl->acl_data->u.build->content);
+ free(jcr->fd_impl->acl_data->u.build);
}
- if (have_xattr && jcr->impl->xattr_data) {
- FreePoolMemory(jcr->impl->xattr_data->u.build->content);
- free(jcr->impl->xattr_data->u.build);
+ if (have_xattr && jcr->fd_impl->xattr_data) {
+ FreePoolMemory(jcr->fd_impl->xattr_data->u.build->content);
+ free(jcr->fd_impl->xattr_data->u.build);
}
- if (jcr->impl->big_buf) {
- free(jcr->impl->big_buf);
- jcr->impl->big_buf = NULL;
+ if (jcr->fd_impl->big_buf) {
+ free(jcr->fd_impl->big_buf);
+ jcr->fd_impl->big_buf = NULL;
}
CleanupCompression(jcr);
@@ -314,7 +316,7 @@ static inline bool SetupEncryptionDigests(b_save_ctx& bsctx)
/* TODO landonf: We should really only calculate the digest once, for
* both verification and signing.
*/
- if (bsctx.jcr->impl->crypto.pki_sign) {
+ if (bsctx.jcr->fd_impl->crypto.pki_sign) {
bsctx.signing_digest = crypto_digest_new(bsctx.jcr, signing_algorithm);
// Full-stop if a failure occurred initializing the signature digest
@@ -328,7 +330,7 @@ static inline bool SetupEncryptionDigests(b_save_ctx& bsctx)
}
// Enable encryption
- if (bsctx.jcr->impl->crypto.pki_encrypt) {
+ if (bsctx.jcr->fd_impl->crypto.pki_encrypt) {
SetBit(FO_ENCRYPT, bsctx.ff_pkt->flags);
}
retval = true;
@@ -352,7 +354,7 @@ static inline bool TerminateSigningDigest(b_save_ctx& bsctx)
}
if (!CryptoSignAddSigner(signature, bsctx.signing_digest,
- bsctx.jcr->impl->crypto.pki_keypair)) {
+ bsctx.jcr->fd_impl->crypto.pki_keypair)) {
Jmsg(bsctx.jcr, M_FATAL, 0,
_("An error occurred while signing the stream.\n"));
goto bail_out;
@@ -432,13 +434,13 @@ static inline bool DoBackupAcl(JobControlRecord* jcr, FindFilesPacket* ff_pkt)
{
bacl_exit_code retval;
- jcr->impl->acl_data->filetype = ff_pkt->type;
- jcr->impl->acl_data->last_fname = jcr->impl->last_fname;
+ jcr->fd_impl->acl_data->filetype = ff_pkt->type;
+ jcr->fd_impl->acl_data->last_fname = jcr->fd_impl->last_fname;
if (jcr->IsPlugin()) {
- retval = PluginBuildAclStreams(jcr, jcr->impl->acl_data.get(), ff_pkt);
+ retval = PluginBuildAclStreams(jcr, jcr->fd_impl->acl_data.get(), ff_pkt);
} else {
- retval = BuildAclStreams(jcr, jcr->impl->acl_data.get(), ff_pkt);
+ retval = BuildAclStreams(jcr, jcr->fd_impl->acl_data.get(), ff_pkt);
}
switch (retval) {
@@ -446,7 +448,7 @@ static inline bool DoBackupAcl(JobControlRecord* jcr, FindFilesPacket* ff_pkt)
return false;
case bacl_exit_error:
Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
- jcr->impl->acl_data->u.build->nr_errors++;
+ jcr->fd_impl->acl_data->u.build->nr_errors++;
break;
case bacl_exit_ok:
break;
@@ -459,12 +461,13 @@ static inline bool DoBackupXattr(JobControlRecord* jcr, FindFilesPacket* ff_pkt)
{
BxattrExitCode retval;
- jcr->impl->xattr_data->last_fname = jcr->impl->last_fname;
+ jcr->fd_impl->xattr_data->last_fname = jcr->fd_impl->last_fname;
if (jcr->IsPlugin()) {
- retval = PluginBuildXattrStreams(jcr, jcr->impl->xattr_data.get(), ff_pkt);
+ retval
+ = PluginBuildXattrStreams(jcr, jcr->fd_impl->xattr_data.get(), ff_pkt);
} else {
- retval = BuildXattrStreams(jcr, jcr->impl->xattr_data.get(), ff_pkt);
+ retval = BuildXattrStreams(jcr, jcr->fd_impl->xattr_data.get(), ff_pkt);
}
switch (retval) {
@@ -475,7 +478,7 @@ static inline bool DoBackupXattr(JobControlRecord* jcr, FindFilesPacket* ff_pkt)
break;
case BxattrExitCode::kError:
Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
- jcr->impl->xattr_data->u.build->nr_errors++;
+ jcr->fd_impl->xattr_data->u.build->nr_errors++;
break;
case BxattrExitCode::kSuccess:
break;
@@ -508,7 +511,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
if (jcr->IsCanceled() || jcr->IsIncomplete()) { return 0; }
- jcr->impl->num_files_examined++; /* bump total file count */
+ jcr->fd_impl->num_files_examined++; /* bump total file count */
switch (ff_pkt->type) {
case FT_LNKSAVED: /* Hard linked, file already saved */
@@ -533,8 +536,8 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
Dmsg1(100, "FT_PLUGIN_CONFIG saving: %s\n", ff_pkt->fname);
break;
case FT_DIRBEGIN:
- jcr->impl->num_files_examined--; /* correct file count */
- return 1; /* not used */
+ jcr->fd_impl->num_files_examined--; /* correct file count */
+ return 1; /* not used */
case FT_NORECURSE:
Jmsg(jcr, M_INFO, 1,
_(" Recursion turned off. Will not descend from %s into %s\n"),
@@ -659,7 +662,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
Dmsg2(10, "Option plugin %s will be used to backup %s\n",
ff_pkt->plugin, ff_pkt->fname);
jcr->opt_plugin = true;
- jcr->impl->plugin_sp = &sp;
+ jcr->fd_impl->plugin_sp = &sp;
PluginUpdateFfPkt(ff_pkt, &sp);
do_plugin_set = true;
break;
@@ -693,7 +696,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
if (ff_pkt->type == FT_DELETED) { goto good_rtn; }
// Set up the encryption context and send the session data to the SD
- if (has_file_data && jcr->impl->crypto.pki_encrypt) {
+ if (has_file_data && jcr->fd_impl->crypto.pki_encrypt) {
if (!CryptoSessionSend(jcr, sd)) { goto bail_out; }
}
@@ -825,7 +828,7 @@ bail_out:
SendPluginName(jcr, sd, false); /* signal end of plugin data */
}
if (ff_pkt->opt_plugin) {
- jcr->impl->plugin_sp = NULL; /* sp is local to this function */
+ jcr->fd_impl->plugin_sp = NULL; /* sp is local to this function */
jcr->opt_plugin = false;
}
if (bsctx.digest) { CryptoDigestFree(bsctx.digest); }
@@ -1121,7 +1124,7 @@ static int send_data(JobControlRecord* jcr,
} else if (BitIsSet(FO_ENCRYPT, ff_pkt->flags)) {
// For encryption, we must call finalize to push out any buffered data.
if (!CryptoCipherFinalize(bctx.cipher_ctx,
- (uint8_t*)jcr->impl->crypto.crypto_buf,
+ (uint8_t*)jcr->fd_impl->crypto.crypto_buf,
&bctx.encrypted_len)) {
// Padding failed. Shouldn't happen.
Jmsg(jcr, M_FATAL, 0, _("Encryption padding error\n"));
@@ -1130,8 +1133,8 @@ static int send_data(JobControlRecord* jcr,
// Note, on SSL pre-0.9.7, there is always some output
if (bctx.encrypted_len > 0) {
- sd->message_length = bctx.encrypted_len; /* set encrypted length */
- sd->msg = jcr->impl->crypto.crypto_buf; /* set correct write buffer */
+ sd->message_length = bctx.encrypted_len; /* set encrypted length */
+ sd->msg = jcr->fd_impl->crypto.crypto_buf; /* set correct write buffer */
if (!sd->send()) {
if (!jcr->IsJobCanceled()) {
Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
@@ -1209,7 +1212,7 @@ bool EncodeAndSendAttributes(JobControlRecord* jcr,
jcr->lock();
jcr->JobFiles++; /* increment number of files sent */
ff_pkt->FileIndex = jcr->JobFiles; /* return FileIndex */
- PmStrcpy(jcr->impl->last_fname, ff_pkt->fname);
+ PmStrcpy(jcr->fd_impl->last_fname, ff_pkt->fname);
jcr->unlock();
// Debug code: check if we must hangup
@@ -1445,29 +1448,29 @@ static void CloseVssBackupSession(JobControlRecord* jcr)
* STOP VSS ON WIN32
* Tell vss to close the backup session
*/
- if (jcr->impl->pVSSClient) {
+ if (jcr->fd_impl->pVSSClient) {
/*
* We are about to call the BackupComplete VSS method so let all plugins
* know that by raising the bEventVssBackupComplete event.
*/
GeneratePluginEvent(jcr, bEventVssBackupComplete);
- if (jcr->impl->pVSSClient->CloseBackup()) {
+ if (jcr->fd_impl->pVSSClient->CloseBackup()) {
// Inform user about writer states
- for (size_t i = 0; i < jcr->impl->pVSSClient->GetWriterCount(); i++) {
+ for (size_t i = 0; i < jcr->fd_impl->pVSSClient->GetWriterCount(); i++) {
int msg_type = M_INFO;
- if (jcr->impl->pVSSClient->GetWriterState(i) < 1) {
+ if (jcr->fd_impl->pVSSClient->GetWriterState(i) < 1) {
msg_type = M_WARNING;
jcr->JobErrors++;
}
Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"),
- jcr->impl->pVSSClient->GetWriterInfo(i));
+ jcr->fd_impl->pVSSClient->GetWriterInfo(i));
}
}
// Generate Job global writer metadata
- wchar_t* metadata = jcr->impl->pVSSClient->GetMetadata();
+ wchar_t* metadata = jcr->fd_impl->pVSSClient->GetMetadata();
if (metadata) {
- FindFilesPacket* ff_pkt = jcr->impl->ff;
+ FindFilesPacket* ff_pkt = jcr->fd_impl->ff;
ff_pkt->fname = (char*)"*all*"; /* for all plugins */
ff_pkt->type = FT_RESTORE_FIRST;
ff_pkt->LinkFI = 0;