X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Ffiled%2Fbackup.c;h=95d70cb6b0efdbde5d46bd7555f48207dd4d5a64;hb=10cfd798ced2d27f61ead2de6fe9b1bcc8e3468d;hp=6e06cbd3d38f8c4833c812bece21359bbbfb0850;hpb=86da6147f63b29cb85d51620b55bae7266f1c890;p=bacula%2Fbacula diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 6e06cbd3d3..95d70cb6b0 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -155,24 +155,31 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) } start_heartbeat_monitor(jcr); - jcr->xacl = (XACL*)new_xacl(); +#ifdef HAVE_ACL + jcr->bacl = (BACL*)new_bacl(); +#endif +#ifdef HAVE_XATTR + jcr->bxattr = (BXATTR*)new_bxattr(); +#endif /* Subroutine save_file() is called for each file */ if (!find_files(jcr, (FF_PKT *)jcr->ff, save_file, plugin_save)) { ok = false; /* error */ jcr->setJobStatus(JS_ErrorTerminated); } - - if (jcr->xacl) { - if (jcr->xacl->get_acl_nr_errors() > 0) { - Jmsg(jcr, M_WARNING, 0, _("Had %ld acl errors while doing backup\n"), - jcr->xacl->get_acl_nr_errors()); - } - if (jcr->xacl->get_xattr_nr_errors() > 0) { - Jmsg(jcr, M_WARNING, 0, _("Had %ld xattr errors while doing backup\n"), - jcr->xacl->get_xattr_nr_errors()); - } +#ifdef HAVE_ACL + if (jcr->bacl && jcr->bacl->get_acl_nr_errors() > 0) { + Jmsg(jcr, M_WARNING, 0, _("Had %ld acl errors while doing backup\n"), + jcr->bacl->get_acl_nr_errors()); + } +#endif +#ifdef HAVE_XATTR + if (jcr->bxattr && jcr->bxattr->get_xattr_nr_errors() > 0) { + Jmsg(jcr, M_WARNING, 0, _("Had %ld xattr errors while doing backup\n"), + jcr->bxattr->get_xattr_nr_errors()); } +#endif + /* Delete or keep snapshots */ close_snapshot_backup_session(jcr); close_vss_backup_session(jcr); @@ -183,10 +190,18 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) sd->signal(BNET_EOD); /* end of sending data */ - if (jcr->xacl) { - delete(jcr->xacl); - jcr->xacl = NULL; +#ifdef HAVE_ACL + if (jcr->bacl) { + delete(jcr->bacl); + jcr->bacl = NULL; } +#endif +#ifdef HAVE_XATTR + if (jcr->bxattr) { + delete(jcr->bxattr); + jcr->bxattr = NULL; + } +#endif if (jcr->big_buf) { bfree_and_null(jcr->big_buf); } @@ -245,8 +260,8 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) jcr->last_stat_time = now; jcr->stat_interval = 30; /* Default 30 seconds */ } else if (now >= jcr->last_stat_time + jcr->stat_interval) { - jcr->dir_bsock->fsend("Progress JobId=x files=%ld bytes=%lld bps=%ld\n", - jcr->JobFiles, jcr->JobBytes, jcr->LastRate); + jcr->dir_bsock->fsend("Progress JobId=%ld files=%ld bytes=%lld bps=%ld\n", + jcr->JobId, jcr->JobFiles, jcr->JobBytes, jcr->LastRate); jcr->last_stat_time = now; } @@ -505,16 +520,18 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) /* * Save ACLs and Extended Attributes when requested and available - * for anything not being a symlink and not being a plugin (why not?). + * for anything not being a symlink. */ - if (jcr->xacl){ - if (jcr->xacl->backup_acl(jcr, ff_pkt) == bRC_XACL_error) { - goto bail_out; - } - if (jcr->xacl->backup_xattr(jcr, ff_pkt) == bRC_XACL_error) { - goto bail_out; - } +#ifdef HAVE_ACL + if (jcr->bacl && jcr->bacl->backup_acl(jcr, ff_pkt) == bRC_BACL_error) { + goto bail_out; } +#endif +#ifdef HAVE_XATTR + if (jcr->bxattr && jcr->bxattr->backup_xattr(jcr, ff_pkt) == bRC_BXATTR_error) { + goto bail_out; + } +#endif if (!crypto_terminate_digests(bctx)) { goto bail_out; @@ -1030,10 +1047,10 @@ static bool setup_compression(bctx_t &bctx) if ((bctx.ff_pkt->flags & FO_COMPRESS) && bctx.ff_pkt->Compress_algo == COMPRESS_GZIP) { if ((bctx.ff_pkt->flags & FO_SPARSE) || (bctx.ff_pkt->flags & FO_OFFSETS)) { - bctx.cbuf = (Bytef *)jcr->compress_buf + OFFSET_FADDR_SIZE; + bctx.cbuf = (unsigned char *)jcr->compress_buf + OFFSET_FADDR_SIZE; bctx.max_compress_len = jcr->compress_buf_size - OFFSET_FADDR_SIZE; } else { - bctx.cbuf = (Bytef *)jcr->compress_buf; + bctx.cbuf = (unsigned char *)jcr->compress_buf; bctx.max_compress_len = jcr->compress_buf_size; /* set max length */ } bctx.wbuf = jcr->compress_buf; /* compressed output here */ @@ -1062,12 +1079,12 @@ static bool setup_compression(bctx_t &bctx) if ((bctx.ff_pkt->flags & FO_COMPRESS) && bctx.ff_pkt->Compress_algo == COMPRESS_LZO1X) { if ((bctx.ff_pkt->flags & FO_SPARSE) || (bctx.ff_pkt->flags & FO_OFFSETS)) { - bctx.cbuf = (Bytef *)jcr->compress_buf + OFFSET_FADDR_SIZE; - bctx.cbuf2 = (Bytef *)jcr->compress_buf + OFFSET_FADDR_SIZE + sizeof(comp_stream_header); + bctx.cbuf = (unsigned char *)jcr->compress_buf + OFFSET_FADDR_SIZE; + bctx.cbuf2 = (unsigned char *)jcr->compress_buf + OFFSET_FADDR_SIZE + sizeof(comp_stream_header); bctx.max_compress_len = jcr->compress_buf_size - OFFSET_FADDR_SIZE; } else { - bctx.cbuf = (Bytef *)jcr->compress_buf; - bctx.cbuf2 = (Bytef *)jcr->compress_buf + sizeof(comp_stream_header); + bctx.cbuf = (unsigned char *)jcr->compress_buf; + bctx.cbuf2 = (unsigned char *)jcr->compress_buf + sizeof(comp_stream_header); bctx.max_compress_len = jcr->compress_buf_size; /* set max length */ } bctx.ch.magic = COMPRESS_LZO1X; @@ -1076,8 +1093,6 @@ static bool setup_compression(bctx_t &bctx) bctx.cipher_input = (uint8_t *)jcr->compress_buf; /* encrypt compressed data */ } #endif -#else - bctx.max_compress_len = 0; #endif return true; } @@ -1154,7 +1169,7 @@ static bool do_libz_compression(bctx_t &bctx) if (bctx.ff_pkt->flags & FO_COMPRESS && bctx.ff_pkt->Compress_algo == COMPRESS_GZIP && jcr->pZLIB_compress_workset) { Dmsg3(400, "cbuf=0x%x rbuf=0x%x len=%u\n", bctx.cbuf, bctx.rbuf, sd->msglen); - ((z_stream*)jcr->pZLIB_compress_workset)->next_in = (Bytef *)bctx.rbuf; + ((z_stream*)jcr->pZLIB_compress_workset)->next_in = (unsigned char *)bctx.rbuf; ((z_stream*)jcr->pZLIB_compress_workset)->avail_in = sd->msglen; ((z_stream*)jcr->pZLIB_compress_workset)->next_out = bctx.cbuf; ((z_stream*)jcr->pZLIB_compress_workset)->avail_out = bctx.max_compress_len; @@ -1410,20 +1425,21 @@ static void close_vss_backup_session(JCR *jcr) #if defined(WIN32_VSS) /* STOP VSS ON WIN32 */ /* tell vss to close the backup session */ - if (jcr->Snapshot) { - if (g_pVSSClient->CloseBackup()) { + if (jcr->Snapshot && jcr->pVSSClient) { + if (jcr->pVSSClient->CloseBackup()) { /* inform user about writer states */ - for (int i=0; i<(int)g_pVSSClient->GetWriterCount(); i++) { + for (int i=0; i<(int)jcr->pVSSClient->GetWriterCount(); i++) { int msg_type = M_INFO; - if (g_pVSSClient->GetWriterState(i) < 1) { + if (jcr->pVSSClient->GetWriterState(i) < 1) { msg_type = M_WARNING; jcr->JobErrors++; } - Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), g_pVSSClient->GetWriterInfo(i)); + Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), + jcr->pVSSClient->GetWriterInfo(i)); } } /* Generate Job global writer metadata */ - WCHAR *metadata = g_pVSSClient->GetMetadata(); + WCHAR *metadata = jcr->pVSSClient->GetMetadata(); if (metadata) { FF_PKT *ff_pkt = jcr->ff; ff_pkt->fname = (char *)"*all*"; /* for all plugins */