From ea46034f43063ffb29435fd17f5b9d47b47012ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rados=C5=82aw=20Korzeniewski?= Date: Thu, 11 Feb 2021 10:59:19 +0100 Subject: [PATCH] Update files license header. --- bacula/src/plugins/fd/docker/dkcommctx.c | 17 +- bacula/src/plugins/fd/docker/dkcommctx.h | 17 +- bacula/src/plugins/fd/docker/dkid.c | 16 +- bacula/src/plugins/fd/docker/dkid.h | 16 +- bacula/src/plugins/fd/docker/dkid_test.c | 11 +- bacula/src/plugins/fd/docker/dkinfo.c | 17 +- bacula/src/plugins/fd/docker/dkinfo.h | 16 +- bacula/src/plugins/fd/docker/docker-fd.c | 16 +- bacula/src/plugins/fd/docker/docker-fd.h | 16 +- bacula/src/plugins/fd/pluginlib/commctx.h | 3 +- .../src/plugins/fd/pluginlib/metaplugin.cpp | 153 +++++++++--------- bacula/src/plugins/fd/pluginlib/metaplugin.h | 39 ++--- bacula/src/plugins/fd/pluginlib/pluginlib.cpp | 37 +++-- bacula/src/plugins/fd/pluginlib/pluginlib.h | 37 +++-- .../plugins/fd/pluginlib/pluginlib_test.cpp | 25 +-- bacula/src/plugins/fd/pluginlib/ptcomm.cpp | 26 +-- bacula/src/plugins/fd/pluginlib/ptcomm.h | 33 ++-- bacula/src/plugins/fd/pluginlib/smartalist.h | 2 +- .../plugins/fd/pluginlib/smartalist_test.cpp | 24 +-- bacula/src/plugins/fd/pluginlib/smartptr.h | 2 +- .../plugins/fd/pluginlib/smartptr_test.cpp | 24 +-- .../fd/pluginlib/test_metaplugin_backend.c | 42 ++--- 22 files changed, 315 insertions(+), 274 deletions(-) diff --git a/bacula/src/plugins/fd/docker/dkcommctx.c b/bacula/src/plugins/fd/docker/dkcommctx.c index 5891959a5..0e736a5c5 100644 --- a/bacula/src/plugins/fd/docker/dkcommctx.c +++ b/bacula/src/plugins/fd/docker/dkcommctx.c @@ -1,8 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright © 2000-2020 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -16,13 +15,15 @@ conveyed and/or propagated. Bacula(R) is a registered trademark of Kern Sibbald. -*/ -/* - * This is a Bacula plugin for backup/restore Docker using native tools. + */ +/** + * @file dkcommctx.c + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a Bacula plugin for backup/restore Docker using native tools. + * @version 1.2.1 + * @date 2020-01-05 * - * Author: Radosław Korzeniewski, MMXIX - * radoslaw@korzeniewski.net, radekk@inteos.pl - * Inteos Sp. z o.o. http://www.inteos.pl/ + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #include "dkcommctx.h" diff --git a/bacula/src/plugins/fd/docker/dkcommctx.h b/bacula/src/plugins/fd/docker/dkcommctx.h index de59dbb53..a9dc7be06 100644 --- a/bacula/src/plugins/fd/docker/dkcommctx.h +++ b/bacula/src/plugins/fd/docker/dkcommctx.h @@ -1,8 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright © 2000-2020 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -16,13 +15,15 @@ conveyed and/or propagated. Bacula(R) is a registered trademark of Kern Sibbald. -*/ -/* - * This is a Bacula plugin for backup/restore Docker using native tools. + */ +/** + * @file dkcommctx.h + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a Bacula plugin for backup/restore Docker using native tools. + * @version 1.2.1 + * @date 2020-01-05 * - * Author: Radosław Korzeniewski, MMXIX - * radoslaw@korzeniewski.net, radekk@inteos.pl - * Inteos Sp. z o.o. http://www.inteos.pl/ + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #ifndef _DKCOMMCTX_H_ diff --git a/bacula/src/plugins/fd/docker/dkid.c b/bacula/src/plugins/fd/docker/dkid.c index 3430aeb52..21da661d9 100644 --- a/bacula/src/plugins/fd/docker/dkid.c +++ b/bacula/src/plugins/fd/docker/dkid.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2019 Kern Sibbald + Copyright (C) 2000-2020 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -15,13 +15,15 @@ conveyed and/or propagated. Bacula(R) is a registered trademark of Kern Sibbald. -*/ -/* - * This is a Bacula plugin for backup/restore Docker using native tools. + */ +/** + * @file dkid.c + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a Bacula plugin for backup/restore Docker using native tools. + * @version 1.2.1 + * @date 2020-01-05 * - * Author: Radosław Korzeniewski, MMXIX - * radoslaw@korzeniewski.net, radekk@inteos.pl - * Inteos Sp. z o.o. http://www.inteos.pl/ + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #include "dkid.h" diff --git a/bacula/src/plugins/fd/docker/dkid.h b/bacula/src/plugins/fd/docker/dkid.h index 47e1ad5de..f2bcc7eed 100644 --- a/bacula/src/plugins/fd/docker/dkid.h +++ b/bacula/src/plugins/fd/docker/dkid.h @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2019 Kern Sibbald + Copyright (C) 2000-2020 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -15,13 +15,15 @@ conveyed and/or propagated. Bacula(R) is a registered trademark of Kern Sibbald. -*/ -/* - * This is a Bacula plugin for backup/restore Docker using native tools. + */ +/** + * @file dkid.h + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a Bacula plugin for backup/restore Docker using native tools. + * @version 1.2.1 + * @date 2020-01-05 * - * Author: Radosław Korzeniewski, MMXIX - * radoslaw@korzeniewski.net, radekk@inteos.pl - * Inteos Sp. z o.o. http://www.inteos.pl/ + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #ifndef _DKID_H_ diff --git a/bacula/src/plugins/fd/docker/dkid_test.c b/bacula/src/plugins/fd/docker/dkid_test.c index 8a7f3c67f..c35c3011c 100644 --- a/bacula/src/plugins/fd/docker/dkid_test.c +++ b/bacula/src/plugins/fd/docker/dkid_test.c @@ -18,10 +18,15 @@ */ /* * This is a Bacula plugin for backup/restore Docker using native tools. + */ +/** + * @file dkid_test.c + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a Bacula plugin for backup/restore Docker using native tools - unittest. + * @version 1.2.1 + * @date 2020-01-05 * - * Author: Radosław Korzeniewski, MMXIX - * radoslaw@korzeniewski.net, radekk@inteos.pl - * Inteos Sp. z o.o. http://www.inteos.pl/ + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #include "bacula.h" diff --git a/bacula/src/plugins/fd/docker/dkinfo.c b/bacula/src/plugins/fd/docker/dkinfo.c index 0f6740ce9..0bf1d9f90 100644 --- a/bacula/src/plugins/fd/docker/dkinfo.c +++ b/bacula/src/plugins/fd/docker/dkinfo.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2019 Kern Sibbald + Copyright (C) 2000-2020 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -15,14 +15,15 @@ conveyed and/or propagated. Bacula(R) is a registered trademark of Kern Sibbald. -*/ -/* - * This is a Bacula plugin for backup/restore Docker using native tools. - * - * Author: Radosław Korzeniewski, MMXIX - * radoslaw@korzeniewski.net, radekk@inteos.pl - * Inteos Sp. z o.o. http://www.inteos.pl/ + */ +/** + * @file dkinfo.c + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a Bacula plugin for backup/restore Docker using native tools. + * @version 1.2.1 + * @date 2020-01-05 * + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. * TODO: add unittests */ diff --git a/bacula/src/plugins/fd/docker/dkinfo.h b/bacula/src/plugins/fd/docker/dkinfo.h index 3f6a54f6a..218e92079 100644 --- a/bacula/src/plugins/fd/docker/dkinfo.h +++ b/bacula/src/plugins/fd/docker/dkinfo.h @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2019 Kern Sibbald + Copyright (C) 2000-2020 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -15,13 +15,15 @@ conveyed and/or propagated. Bacula(R) is a registered trademark of Kern Sibbald. -*/ -/* - * This is a Bacula plugin for backup/restore Docker using native tools. + */ +/** + * @file dkinfo.h + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a Bacula plugin for backup/restore Docker using native tools. + * @version 1.2.1 + * @date 2020-01-05 * - * Author: Radosław Korzeniewski, MMXIX - * radoslaw@korzeniewski.net, radekk@inteos.pl - * Inteos Sp. z o.o. http://www.inteos.pl/ + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #ifndef _DKINFO_H_ diff --git a/bacula/src/plugins/fd/docker/docker-fd.c b/bacula/src/plugins/fd/docker/docker-fd.c index c762faf45..1547d634c 100644 --- a/bacula/src/plugins/fd/docker/docker-fd.c +++ b/bacula/src/plugins/fd/docker/docker-fd.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2019 Kern Sibbald + Copyright (C) 2000-2020 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -15,13 +15,15 @@ conveyed and/or propagated. Bacula(R) is a registered trademark of Kern Sibbald. -*/ -/* - * This is a Bacula plugin for backup/restore Docker using native tools. + */ +/** + * @file docker-fd.c + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a Bacula plugin for backup/restore Docker using native tools. + * @version 1.2.1 + * @date 2020-01-05 * - * Author: Radosław Korzeniewski, MMXIX - * radoslaw@korzeniewski.net, radekk@inteos.pl - * Inteos Sp. z o.o. http://www.inteos.pl/ + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #include "docker-fd.h" diff --git a/bacula/src/plugins/fd/docker/docker-fd.h b/bacula/src/plugins/fd/docker/docker-fd.h index 35542ab71..bb6c6ce0b 100644 --- a/bacula/src/plugins/fd/docker/docker-fd.h +++ b/bacula/src/plugins/fd/docker/docker-fd.h @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2019 Kern Sibbald + Copyright (C) 2000-2020 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -15,13 +15,15 @@ conveyed and/or propagated. Bacula(R) is a registered trademark of Kern Sibbald. -*/ -/* - * This is a Bacula plugin for backup/restore Docker using native tools. + */ +/** + * @file docker-fd.h + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a Bacula plugin for backup/restore Docker using native tools. + * @version 1.2.1 + * @date 2020-01-05 * - * Author: Radosław Korzeniewski, MMXIX - * radoslaw@korzeniewski.net, radekk@inteos.pl - * Inteos Sp. z o.o. http://www.inteos.pl/ + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #ifndef _DOCKER_FD_H_ diff --git a/bacula/src/plugins/fd/pluginlib/commctx.h b/bacula/src/plugins/fd/pluginlib/commctx.h index 6c8e20f9d..7cbd06680 100644 --- a/bacula/src/plugins/fd/pluginlib/commctx.h +++ b/bacula/src/plugins/fd/pluginlib/commctx.h @@ -23,8 +23,7 @@ * @version 1.2.0 * @date 2020-01-05 * - * @copyright Copyright (c) 2021 All rights reserved. - * IP transferred to Bacula Systems according to agreement. + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #ifndef PLUGINLIB_COMMCTX_H diff --git a/bacula/src/plugins/fd/pluginlib/metaplugin.cpp b/bacula/src/plugins/fd/pluginlib/metaplugin.cpp index c365b148a..7e60b4683 100644 --- a/bacula/src/plugins/fd/pluginlib/metaplugin.cpp +++ b/bacula/src/plugins/fd/pluginlib/metaplugin.cpp @@ -1,19 +1,21 @@ /* - Bacula® - The Network Backup Solution + Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2017 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald - The main author of Bacula is Kern Sibbald, with contributions from many - others, a complete list can be found in the file AUTHORS. + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. - Licensees holding a valid Bacula Systems SA license may use this file - and others of this release in accordance with the proprietary license - agreement provided in the LICENSE file. Redistribution of any part of - this release is not permitted. + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. - Bacula® is a registered trademark of Kern Sibbald. -*/ + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. + */ /** * @file metaplugin.h * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) @@ -21,8 +23,7 @@ * @version 2.1.0 * @date 2020-12-23 * - * @copyright Copyright (c) 2021 All rights reserved. - * IP transferred to Bacula Systems according to agreement. + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #include "metaplugin.h" @@ -145,7 +146,7 @@ METAPLUGIN::METAPLUGIN(bpContext *bpctx) : ctx(NULL), backend_available(false), backend_error(PM_MESSAGE), - mode(MODE::NONE), + mode(NONE), JobId(0), JobName(NULL), since(0), @@ -376,7 +377,7 @@ bRC METAPLUGIN::parse_plugin_command(bpContext *ctx, const char *command, alist if (strcasecmp(parser.argk[i], "listing") == 0){ /* found, so check the value if provided */ if (parser.argv[i]){ - listing = Listing; + listing = ListingMode; DMSG0(ctx, DINFO, "listing procedure param found\n"); } } @@ -384,7 +385,7 @@ bRC METAPLUGIN::parse_plugin_command(bpContext *ctx, const char *command, alist if (strcasecmp(parser.argk[i], "query") == 0){ /* found, so check the value if provided */ if (parser.argv[i]){ - listing = QueryParams; + listing = ListingQueryParams; DMSG0(ctx, DINFO, "query procedure param found\n"); } } @@ -630,102 +631,98 @@ bRC METAPLUGIN::terminate_all_backends(bpContext *ctx) bRC METAPLUGIN::send_jobinfo(bpContext *ctx, char type) { int32_t rc; - int len; - bRC status = bRC_OK; - POOLMEM *cmd; + POOL_MEM cmd; char lvl; - cmd = get_pool_memory(PM_FNAME); - len = sizeof_pool_memory(cmd); /* we will be sending Job Info data */ - bsnprintf(cmd, len, "Job\n"); + pm_strcpy(cmd, "Job\n"); rc = backend.ctx->write_command(ctx, cmd); if (rc < 0){ /* error */ - status = bRC_Error; - goto bailout; + return bRC_Error; } /* required parameters */ - bsnprintf(cmd, len, "Name=%s\n", JobName); + Mmsg(cmd, "Name=%s\n", JobName); rc = backend.ctx->write_command(ctx, cmd); if (rc < 0){ /* error */ - status = bRC_Error; - goto bailout; + return bRC_Error; } - bsnprintf(cmd, len, "JobID=%i\n", JobId); + Mmsg(cmd, "JobID=%i\n", JobId); rc = backend.ctx->write_command(ctx, cmd); if (rc < 0){ /* error */ - status = bRC_Error; - goto bailout; + return bRC_Error; } - bsnprintf(cmd, len, "Type=%c\n", type); + Mmsg(cmd, "Type=%c\n", type); rc = backend.ctx->write_command(ctx, cmd); if (rc < 0){ /* error */ - status = bRC_Error; - goto bailout; + return bRC_Error; } /* optional parameters */ - if (mode != MODE::RESTORE){ + if (mode != RESTORE){ switch (mode){ - case MODE::BACKUP_FULL: + case BACKUP_FULL: lvl = 'F'; break; - case MODE::BACKUP_DIFF: + case BACKUP_DIFF: lvl = 'D'; break; - case MODE::BACKUP_INCR: + case BACKUP_INCR: lvl = 'I'; break; default: lvl = 0; } if (lvl){ - bsnprintf(cmd, len, "Level=%c\n", lvl); + Mmsg(cmd, "Level=%c\n", lvl); rc = backend.ctx->write_command(ctx, cmd); if (rc < 0){ /* error */ - status = bRC_Error; - goto bailout; + return bRC_Error; } } } if (since){ - bsnprintf(cmd, len, "Since=%ld\n", since); + Mmsg(cmd, "Since=%ld\n", since); rc = backend.ctx->write_command(ctx, cmd); if (rc < 0){ /* error */ - status = bRC_Error; - goto bailout; + return bRC_Error; } } if (where){ - bsnprintf(cmd, len, "Where=%s\n", where); + Mmsg(cmd, "Where=%s\n", where); rc = backend.ctx->write_command(ctx, cmd); if (rc < 0){ /* error */ - status = bRC_Error; - goto bailout; + return bRC_Error; } } if (regexwhere){ - bsnprintf(cmd, len, "RegexWhere=%s\n", regexwhere); + Mmsg(cmd, "RegexWhere=%s\n", regexwhere); rc = backend.ctx->write_command(ctx, cmd); if (rc < 0){ /* error */ - status = bRC_Error; - goto bailout; + return bRC_Error; } } if (replace){ - bsnprintf(cmd, len, "Replace=%c\n", replace); + Mmsg(cmd, "Replace=%c\n", replace); rc = backend.ctx->write_command(ctx, cmd); if (rc < 0){ /* error */ - status = bRC_Error; - goto bailout; + return bRC_Error; + } + } + + if (CUSTOMNAMESPACE){ + Mmsg(cmd, "Namespace=%s\n", PLUGINNAMESPACE); + rc = backend.ctx->write_command(ctx, cmd); + if (rc < 0){ + /* error */ + return bRC_Error; } } backend.ctx->signal_eod(ctx); @@ -733,12 +730,10 @@ bRC METAPLUGIN::send_jobinfo(bpContext *ctx, char type) if (!backend.ctx->read_ack(ctx)){ DMSG0(ctx, DERROR, "Wrong backend response to Job command.\n"); JMSG0(ctx, backend.ctx->jmsg_err_level(), "Wrong backend response to Job command.\n"); - status = bRC_Error; + return bRC_Error; } -bailout: - free_pool_memory(cmd); - return status; + return bRC_OK; } /* @@ -967,7 +962,7 @@ bRC METAPLUGIN::send_startrestore(bpContext *ctx) /* here we expect a PIPE: command only */ if (scan_parameter_str(cmd, "PIPE:", extpipename)){ /* got PIPE: */ - DMSG(ctx, DINFO, "PIPE:%s\n", extpipename); + DMSG(ctx, DINFO, "PIPE:%s\n", extpipename.c_str()); backend.ctx->set_extpipename(extpipename.c_str()); /* TODO: decide if plugin should verify if extpipe is available */ pm_strcpy(cmd, "OK\n"); @@ -1093,7 +1088,7 @@ bRC METAPLUGIN::prepare_backend(bpContext *ctx, char type, char *command) break; case BACKEND_JOB_INFO_ESTIMATE: /* Start Estimate or Listing (4) */ - if (listing){ + if (listing != ListingNone){ DMSG0(ctx, DINFO, "Start Listing (4) ...\n"); if (send_startlisting(ctx) != bRC_OK){ backend.ctx->terminate(ctx); @@ -1162,15 +1157,15 @@ bRC METAPLUGIN::handlePluginEvent(bpContext *ctx, bEvent *event, void *value) switch (lvl) { case 'F': DMSG0(ctx, D2, "backup level = Full\n"); - mode = MODE::BACKUP_FULL; + mode = BACKUP_FULL; break; case 'I': DMSG0(ctx, D2, "backup level = Incr\n"); - mode = MODE::BACKUP_INCR; + mode = BACKUP_INCR; break; case 'D': DMSG0(ctx, D2, "backup level = Diff\n"); - mode = MODE::BACKUP_DIFF; + mode = BACKUP_DIFF; break; default: DMSG0(ctx, D2, "unsupported backup level!\n"); @@ -1199,7 +1194,7 @@ bRC METAPLUGIN::handlePluginEvent(bpContext *ctx, bEvent *event, void *value) DMSG(ctx, DINFO, "RegexWhere=%s\n", NPRT(regexwhere)); getBaculaVar(bVarReplace, &replace); DMSG(ctx, DINFO, "Replace=%c\n", replace); - mode = MODE::RESTORE; + mode = RESTORE; break; case bEventEndRestoreJob: @@ -1740,11 +1735,11 @@ bRC METAPLUGIN::pluginIO(bpContext *ctx, struct io_pkt *io) case IO_OPEN: DMSG(ctx, D2, "IO_OPEN: (%s)\n", io->fname); switch (mode){ - case MODE::BACKUP_FULL: - case MODE::BACKUP_INCR: - case MODE::BACKUP_DIFF: + case BACKUP_FULL: + case BACKUP_INCR: + case BACKUP_DIFF: return perform_backup_open(ctx, io); - case MODE::RESTORE: + case RESTORE: nodata = true; break; default: @@ -1757,9 +1752,9 @@ bRC METAPLUGIN::pluginIO(bpContext *ctx, struct io_pkt *io) DMSG2(ctx, D2, "IO_READ buf=%p len=%d\n", io->buf, io->count); } switch (mode){ - case MODE::BACKUP_FULL: - case MODE::BACKUP_INCR: - case MODE::BACKUP_DIFF: + case BACKUP_FULL: + case BACKUP_INCR: + case BACKUP_DIFF: return perform_read_data(ctx, io); default: return bRC_Error; @@ -1771,7 +1766,7 @@ bRC METAPLUGIN::pluginIO(bpContext *ctx, struct io_pkt *io) DMSG2(ctx, D2, "IO_WRITE buf=%p len=%d\n", io->buf, io->count); } switch (mode){ - case MODE::RESTORE: + case RESTORE: return perform_write_data(ctx, io); default: return bRC_Error; @@ -1784,11 +1779,11 @@ bRC METAPLUGIN::pluginIO(bpContext *ctx, struct io_pkt *io) return bRC_Error; } switch (mode){ - case MODE::RESTORE: + case RESTORE: return perform_write_end(ctx, io); - case MODE::BACKUP_FULL: - case MODE::BACKUP_INCR: - case MODE::BACKUP_DIFF: + case BACKUP_FULL: + case BACKUP_INCR: + case BACKUP_DIFF: return perform_read_metadata(ctx); default: return bRC_Error; @@ -1844,7 +1839,7 @@ bRC METAPLUGIN::startBackupFile(bpContext *ctx, struct save_pkt *sp) int reqparams = 2; /* The first file in Full backup, is the RestoreObject */ - if (!estimate && mode == MODE::BACKUP_FULL && robjsent == false) { + if (!estimate && mode == BACKUP_FULL && robjsent == false) { ConfigFile ini; /* robj for the first time, allocate the buffer */ @@ -1910,8 +1905,8 @@ bRC METAPLUGIN::startBackupFile(bpContext *ctx, struct save_pkt *sp) default: /* we need to signal error */ sp->type = FT_REG; - DMSG2(ctx, DERROR, "Invalid file type: %c for %s\n", type, fname); - JMSG2(ctx, M_ERROR, "Invalid file type: %c for %s\n", type, fname); + DMSG2(ctx, DERROR, "Invalid file type: %c for %s\n", type, fname.c_str()); + JMSG2(ctx, M_ERROR, "Invalid file type: %c for %s\n", type, fname.c_str()); } DMSG6(ctx, DINFO, "STAT:%c size:%lld uid:%d gid:%d mode:%06o nl:%d\n", type, size, uid, gid, perms, nlinks); reqparams--; @@ -2003,7 +1998,7 @@ bRC METAPLUGIN::endBackupFile(bpContext *ctx) if (!estimate){ /* The current file was the restore object, so just ask for the next file */ - if (mode == MODE::BACKUP_FULL && robjsent == false) { + if (mode == BACKUP_FULL && robjsent == false) { robjsent = true; return bRC_More; } @@ -2219,7 +2214,7 @@ bRC METAPLUGIN::queryParameter(bpContext *ctx, struct query_pkt *qp) DMSG0(ctx, D1, "METAPLUGIN::queryParameter\n"); if (listing == ListingNone){ - listing = QueryParams; + listing = ListingQueryParams; Mmsg(cmd, "%s query=%s", qp->command, qp->parameter); if (prepare_backend(ctx, BACKEND_JOB_INFO_ESTIMATE, cmd.c_str()) == bRC_Error){ return bRC_Error; diff --git a/bacula/src/plugins/fd/pluginlib/metaplugin.h b/bacula/src/plugins/fd/pluginlib/metaplugin.h index 59fabad6f..680c2f953 100644 --- a/bacula/src/plugins/fd/pluginlib/metaplugin.h +++ b/bacula/src/plugins/fd/pluginlib/metaplugin.h @@ -1,19 +1,21 @@ /* - Bacula® - The Network Backup Solution + Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2017 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald - The main author of Bacula is Kern Sibbald, with contributions from many - others, a complete list can be found in the file AUTHORS. + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. - Licensees holding a valid Bacula Systems SA license may use this file - and others of this release in accordance with the proprietary license - agreement provided in the LICENSE file. Redistribution of any part of - this release is not permitted. + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. - Bacula® is a registered trademark of Kern Sibbald. -*/ + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. + */ /** * @file metaplugin.h * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) @@ -21,8 +23,7 @@ * @version 2.1.0 * @date 2020-12-23 * - * @copyright Copyright (c) 2021 All rights reserved. - * IP transferred to Bacula Systems according to agreement. + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #include "pluginlib.h" @@ -48,6 +49,8 @@ extern const char *PLUGIN_DESCRIPTION; // Plugin linking time variables extern const char *PLUGINPREFIX; extern const char *PLUGINNAME; +extern const char *PLUGINNAMESPACE; +extern const bool CUSTOMNAMESPACE; extern const char *PLUGINAPI; extern const char *BACKEND_CMD; @@ -65,7 +68,7 @@ extern const char *valid_params[]; class METAPLUGIN: public SMARTALLOC { public: - enum class MODE + enum MODE { NONE = 0, BACKUP_FULL, @@ -101,11 +104,11 @@ public: ~METAPLUGIN(); private: - enum ListingMode + enum LISTING { ListingNone, - Listing, - QueryParams, + ListingMode, + ListingQueryParams, }; // TODO: define a variable which will signal job cancel @@ -121,7 +124,7 @@ private: char replace; // the replace variable for restore job bool robjsent; // set when RestoreObject was sent during Full backup bool estimate; // used when mode is METAPLUGIN_BACKUP_* but we are doing estimate only - ListingMode listing; // used for a Listing procedure for estimate + LISTING listing; // used for a Listing procedure for estimate bool nodata; // set when backend signaled no data for backup or no data for restore bool nextfile; // set when IO_CLOSE got FNAME: command bool openerror; // show if "openfile" was unsuccessful diff --git a/bacula/src/plugins/fd/pluginlib/pluginlib.cpp b/bacula/src/plugins/fd/pluginlib/pluginlib.cpp index 67016d114..7d091a77a 100644 --- a/bacula/src/plugins/fd/pluginlib/pluginlib.cpp +++ b/bacula/src/plugins/fd/pluginlib/pluginlib.cpp @@ -1,26 +1,29 @@ /* - Bacula® - The Network Backup Solution + Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2017 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald - The main author of Bacula is Kern Sibbald, with contributions from many - others, a complete list can be found in the file AUTHORS. + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. - Licensees holding a valid Bacula Systems SA license may use this file - and others of this release in accordance with the proprietary license - agreement provided in the LICENSE file. Redistribution of any part of - this release is not permitted. + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. - Bacula® is a registered trademark of Kern Sibbald. -*/ -/* - * - * All rights reserved. IP transferred to Bacula Systems according to agreement. + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. + */ +/** + * @file commctx.h + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief Common definitions and utility functions for Inteos plugins. + * @version 2.1.0 + * @date 2021-02-10 * - * Common definitions and utility functions for Inteos plugins. - * Functions defines a common framework used in our utilities and plugins. - * Author: Radosław Korzeniewski, radekk@inteos.pl, Inteos Sp. z o.o. + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #include "pluginlib.h" diff --git a/bacula/src/plugins/fd/pluginlib/pluginlib.h b/bacula/src/plugins/fd/pluginlib/pluginlib.h index b0e4de058..4084ade89 100644 --- a/bacula/src/plugins/fd/pluginlib/pluginlib.h +++ b/bacula/src/plugins/fd/pluginlib/pluginlib.h @@ -1,26 +1,29 @@ /* - Bacula® - The Network Backup Solution + Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2017 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald - The main author of Bacula is Kern Sibbald, with contributions from many - others, a complete list can be found in the file AUTHORS. + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. - Licensees holding a valid Bacula Systems SA license may use this file - and others of this release in accordance with the proprietary license - agreement provided in the LICENSE file. Redistribution of any part of - this release is not permitted. + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. - Bacula® is a registered trademark of Kern Sibbald. -*/ -/* - * - * All rights reserved. IP transferred to Bacula Systems according to agreement. + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. + */ +/** + * @file commctx.h + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief Common definitions and utility functions for Inteos plugins. + * @version 2.1.0 + * @date 2021-02-10 * - * Common definitions and utility functions for Inteos plugins. - * Functions defines a common framework used in our utilities and plugins. - * Author: Radosław Korzeniewski, radekk@inteos.pl, Inteos Sp. z o.o. + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #ifndef _PLUGINLIB_H_ diff --git a/bacula/src/plugins/fd/pluginlib/pluginlib_test.cpp b/bacula/src/plugins/fd/pluginlib/pluginlib_test.cpp index fbcc60c0b..7352fcd08 100644 --- a/bacula/src/plugins/fd/pluginlib/pluginlib_test.cpp +++ b/bacula/src/plugins/fd/pluginlib/pluginlib_test.cpp @@ -1,19 +1,21 @@ /* - Bacula® - The Network Backup Solution + Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2017 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald - The main author of Bacula is Kern Sibbald, with contributions from many - others, a complete list can be found in the file AUTHORS. + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. - Licensees holding a valid Bacula Systems SA license may use this file - and others of this release in accordance with the proprietary license - agreement provided in the LICENSE file. Redistribution of any part of - this release is not permitted. + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. - Bacula® is a registered trademark of Kern Sibbald. -*/ + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. + */ /** * @file commctx.h * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) @@ -21,6 +23,7 @@ * @version 1.1.0 * @date 2020-12-23 * + * @copyright Copyright (c) 2020 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #include "pluginlib.h" diff --git a/bacula/src/plugins/fd/pluginlib/ptcomm.cpp b/bacula/src/plugins/fd/pluginlib/ptcomm.cpp index 46fb6352a..38c87d2af 100644 --- a/bacula/src/plugins/fd/pluginlib/ptcomm.cpp +++ b/bacula/src/plugins/fd/pluginlib/ptcomm.cpp @@ -1,23 +1,25 @@ /* - Bacula® - The Network Backup Solution + Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2017 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald - The main author of Bacula is Kern Sibbald, with contributions from many - others, a complete list can be found in the file AUTHORS. + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. - Licensees holding a valid Bacula Systems SA license may use this file - and others of this release in accordance with the proprietary license - agreement provided in the LICENSE file. Redistribution of any part of - this release is not permitted. + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. - Bacula® is a registered trademark of Kern Sibbald. -*/ + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. + */ /** * @file ptcomm.cpp * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) - * @brief This is a Bacula plugin library for interfacing with Metaplugin backend. + * @brief This is a process communication lowlevel library for Bacula plugin. * @version 2.0.0 * @date 2020-11-20 * diff --git a/bacula/src/plugins/fd/pluginlib/ptcomm.h b/bacula/src/plugins/fd/pluginlib/ptcomm.h index e4eb8672c..c869f46e7 100644 --- a/bacula/src/plugins/fd/pluginlib/ptcomm.h +++ b/bacula/src/plugins/fd/pluginlib/ptcomm.h @@ -1,22 +1,29 @@ /* - Bacula® - The Network Backup Solution + Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2017 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald - The main author of Bacula is Kern Sibbald, with contributions from many - others, a complete list can be found in the file AUTHORS. + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. - Licensees holding a valid Bacula Systems SA license may use this file - and others of this release in accordance with the proprietary license - agreement provided in the LICENSE file. Redistribution of any part of - this release is not permitted. + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. - Bacula® is a registered trademark of Kern Sibbald. -*/ + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. + */ /** - * This is a process communication lowlevel library for Bacula plugin. - * Author: Radoslaw Korzeniewski, radekk@inteos.pl, Inteos Sp. z o.o. + * @file ptcomm.h + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a process communication lowlevel library for Bacula plugin. + * @version 2.0.0 + * @date 2021-02-10 + * + * @copyright Copyright (c) 2021 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #ifndef _PTCOMM_H_ diff --git a/bacula/src/plugins/fd/pluginlib/smartalist.h b/bacula/src/plugins/fd/pluginlib/smartalist.h index adb5ad88b..178d9e188 100644 --- a/bacula/src/plugins/fd/pluginlib/smartalist.h +++ b/bacula/src/plugins/fd/pluginlib/smartalist.h @@ -17,7 +17,7 @@ Bacula(R) is a registered trademark of Kern Sibbald. */ /** - * @file commctx.h + * @file smartalist.h * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) * @brief This is a simple smart array list (alist) resource guard conceptually based on C++11 - RAII. * @version 1.1.0 diff --git a/bacula/src/plugins/fd/pluginlib/smartalist_test.cpp b/bacula/src/plugins/fd/pluginlib/smartalist_test.cpp index b9d584e23..24841213d 100644 --- a/bacula/src/plugins/fd/pluginlib/smartalist_test.cpp +++ b/bacula/src/plugins/fd/pluginlib/smartalist_test.cpp @@ -1,19 +1,21 @@ /* - Bacula® - The Network Backup Solution + Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2017 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald - The main author of Bacula is Kern Sibbald, with contributions from many - others, a complete list can be found in the file AUTHORS. + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. - Licensees holding a valid Bacula Systems SA license may use this file - and others of this release in accordance with the proprietary license - agreement provided in the LICENSE file. Redistribution of any part of - this release is not permitted. + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. - Bacula® is a registered trademark of Kern Sibbald. -*/ + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. + */ /** * @file smartalist_test.cpp * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) diff --git a/bacula/src/plugins/fd/pluginlib/smartptr.h b/bacula/src/plugins/fd/pluginlib/smartptr.h index a08cfdfb3..32cf68c2a 100644 --- a/bacula/src/plugins/fd/pluginlib/smartptr.h +++ b/bacula/src/plugins/fd/pluginlib/smartptr.h @@ -17,7 +17,7 @@ Bacula(R) is a registered trademark of Kern Sibbald. */ /** - * @file commctx.h + * @file smartptr.h * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) * @brief This is a simple smart pointer guard conceptually based on C++11 smart pointers - unique_ptr. * @version 1.1.0 diff --git a/bacula/src/plugins/fd/pluginlib/smartptr_test.cpp b/bacula/src/plugins/fd/pluginlib/smartptr_test.cpp index a05203519..0b44fe50c 100644 --- a/bacula/src/plugins/fd/pluginlib/smartptr_test.cpp +++ b/bacula/src/plugins/fd/pluginlib/smartptr_test.cpp @@ -1,19 +1,21 @@ /* - Bacula® - The Network Backup Solution + Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2017 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald - The main author of Bacula is Kern Sibbald, with contributions from many - others, a complete list can be found in the file AUTHORS. + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. - Licensees holding a valid Bacula Systems SA license may use this file - and others of this release in accordance with the proprietary license - agreement provided in the LICENSE file. Redistribution of any part of - this release is not permitted. + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. - Bacula® is a registered trademark of Kern Sibbald. -*/ + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. + */ /** * @file smartptr_test.cpp * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) diff --git a/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c b/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c index 9b3156433..7e15c48e5 100644 --- a/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c +++ b/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c @@ -1,27 +1,29 @@ /* - Bacula® - The Network Backup Solution + Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2017 Bacula Systems SA - All rights reserved. + Copyright (C) 2000-2020 Kern Sibbald - The main author of Bacula is Kern Sibbald, with contributions from many - others, a complete list can be found in the file AUTHORS. + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. - Licensees holding a valid Bacula Systems SA license may use this file - and others of this release in accordance with the proprietary license - agreement provided in the LICENSE file. Redistribution of any part of - this release is not permitted. + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. - Bacula® is a registered trademark of Kern Sibbald. -*/ -/* - * File: test_rhv_backend.c - * Author: radekk, radoslaw@korzeniewski.net - * - * Copyright (c) 2017 by Inteos sp. z o.o. - * All rights reserved. IP transferred to Bacula Systems according to agreement. - * This is a dumb and extremely simple backend simulator used for test swift Plugin. + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. + */ +/** + * @file test_metaplugin_backend.cpp + * @author Radosław Korzeniewski (radoslaw@korzeniewski.net) + * @brief This is a dumb and extremely simple backend simulator used for test Metaplugin. + * @version 2.1.0 + * @date 2020-12-23 * + * @copyright Copyright (c) 2020 All rights reserved. IP transferred to Bacula Systems according to agreement. */ #include @@ -60,7 +62,7 @@ bool regress_backup_other_file = false; #define BUFLEN 4096 #define BIGBUFLEN 65536 - void LOG(const char *txt) +void LOG(const char *txt) { char _buf[BUFLEN]; @@ -371,7 +373,9 @@ void perform_backup() const char *longfilename = longfilenamestr; // test for fname > 500c +#if __cplusplus > 201103L static_assert(sizeof(longfilenamestr) > 500); +#endif snprintf(buf, BIGBUFLEN, "FNAME:%s/%s\n", PLUGINPREFIX, longfilename); write_plugin('C', buf); write_plugin('C', "STAT:F 234560 901 901 0100640 1\n"); -- 2.47.3