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:
authorSebastian Lederer <slederer@dass-it.de>2022-11-09 20:34:13 +0300
committerGitHub <noreply@github.com>2022-11-09 20:34:13 +0300
commitf61a7062b6013fdec551b3d36078163f3d3b3437 (patch)
tree2cba5dc9901b10edce53c1285938ee12289be076
parent366134a5b02eb53c6449b19e1727d2df6545d57a (diff)
parent6032bd7c005a461c5dc43d4d01889ca884375703 (diff)
Merge branch 'master' into dev/fbergkemper/master/fix-timeline
-rw-r--r--.gitignore10
-rw-r--r--CHANGELOG.md17
-rw-r--r--CMakeLists.txt3
-rw-r--r--cmake/BareosSetVariableDefaults.cmake18
-rw-r--r--contrib/CMakeLists.txt1
-rw-r--r--core/CMakeLists.txt17
-rw-r--r--core/platforms/freebsd/bareos-freebsd/bareos.com-common/pkg-plist.storage1
-rw-r--r--core/platforms/freebsd/bareos-freebsd/bareos.com-common/pkg-plist.storage-tape1
-rw-r--r--core/platforms/packaging/bareos.spec6
-rw-r--r--core/src/cats/sql_create.cc36
-rw-r--r--core/src/cats/sql_update.cc2
-rw-r--r--core/src/dird/admin.cc29
-rw-r--r--core/src/dird/archive.cc29
-rw-r--r--core/src/dird/authenticate.cc12
-rw-r--r--core/src/dird/autoprune.cc15
-rw-r--r--core/src/dird/backup.cc291
-rw-r--r--core/src/dird/bsr.cc19
-rw-r--r--core/src/dird/catreq.cc35
-rw-r--r--core/src/dird/consolidate.cc86
-rw-r--r--core/src/dird/dbcopy/database_connection.h10
-rw-r--r--core/src/dird/dbcopy/dbcopy.cc2
-rw-r--r--core/src/dird/dir_plugins.cc65
-rw-r--r--core/src/dird/dird_conf.cc24
-rw-r--r--core/src/dird/dird_conf.h7
-rw-r--r--core/src/dird/director_jcr_impl.h (renamed from core/src/dird/jcr_private.h)42
-rw-r--r--core/src/dird/expand.cc24
-rw-r--r--core/src/dird/fd_cmds.cc187
-rw-r--r--core/src/dird/get_database_connection.cc23
-rw-r--r--core/src/dird/getmsg.cc12
-rw-r--r--core/src/dird/inc_conf.cc6
-rw-r--r--core/src/dird/jcr_util.cc5
-rw-r--r--core/src/dird/jcr_util.h2
-rw-r--r--core/src/dird/job.cc609
-rw-r--r--core/src/dird/jobq.cc261
-rw-r--r--core/src/dird/migrate.cc497
-rw-r--r--core/src/dird/msgchan.cc95
-rw-r--r--core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc57
-rw-r--r--core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc60
-rw-r--r--core/src/dird/ndmp_dma_backup_common.cc39
-rw-r--r--core/src/dird/ndmp_dma_generic.cc41
-rw-r--r--core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc83
-rw-r--r--core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc24
-rw-r--r--core/src/dird/ndmp_dma_restore_common.cc16
-rw-r--r--core/src/dird/ndmp_dma_storage.cc10
-rw-r--r--core/src/dird/newvol.cc8
-rw-r--r--core/src/dird/next_vol.cc23
-rw-r--r--core/src/dird/quota.cc183
-rw-r--r--core/src/dird/recycle.cc8
-rw-r--r--core/src/dird/restore.cc131
-rw-r--r--core/src/dird/run_on_incoming_connect_interval.cc2
-rw-r--r--core/src/dird/scheduler.cc2
-rw-r--r--core/src/dird/scheduler_private.cc34
-rw-r--r--core/src/dird/sd_cmds.cc68
-rw-r--r--core/src/dird/stats.cc8
-rw-r--r--core/src/dird/storage.cc241
-rw-r--r--core/src/dird/testfind.cc14
-rw-r--r--core/src/dird/ua_cmds.cc52
-rw-r--r--core/src/dird/ua_db.cc6
-rw-r--r--core/src/dird/ua_dotcmds.cc4
-rw-r--r--core/src/dird/ua_label.cc25
-rw-r--r--core/src/dird/ua_output.cc18
-rw-r--r--core/src/dird/ua_purge.cc6
-rw-r--r--core/src/dird/ua_restore.cc4
-rw-r--r--core/src/dird/ua_run.cc472
-rw-r--r--core/src/dird/ua_select.cc28
-rw-r--r--core/src/dird/ua_server.cc10
-rw-r--r--core/src/dird/ua_status.cc52
-rw-r--r--core/src/dird/ua_update.cc4
-rw-r--r--core/src/dird/vbackup.cc154
-rw-r--r--core/src/dird/verify.cc203
-rw-r--r--core/src/droplet/CMakeLists.txt3
-rw-r--r--core/src/droplet/libdroplet/CMakeLists.txt7
-rw-r--r--core/src/fastlz/CMakeLists.txt1
-rw-r--r--core/src/filed/accurate.cc62
-rw-r--r--core/src/filed/authenticate.cc4
-rw-r--r--core/src/filed/backup.cc123
-rw-r--r--core/src/filed/compression.cc10
-rw-r--r--core/src/filed/crypto.cc119
-rw-r--r--core/src/filed/dir_cmd.cc290
-rw-r--r--core/src/filed/estimate.cc17
-rw-r--r--core/src/filed/evaluate_job_command.cc6
-rw-r--r--core/src/filed/fd_plugins.cc54
-rw-r--r--core/src/filed/filed.cc4
-rw-r--r--core/src/filed/filed_jcr_impl.h (renamed from core/src/filed/jcr_private.h)10
-rw-r--r--core/src/filed/fileset.cc42
-rw-r--r--core/src/filed/heartbeat.cc76
-rw-r--r--core/src/filed/restore.cc144
-rw-r--r--core/src/filed/sd_cmds.cc10
-rw-r--r--core/src/filed/status.cc46
-rw-r--r--core/src/filed/verify.cc34
-rw-r--r--core/src/filed/verify_vol.cc20
-rw-r--r--core/src/findlib/attribs.cc10
-rw-r--r--core/src/include/config.h.in3
-rw-r--r--core/src/include/jcr.h40
-rw-r--r--core/src/lib/alist.h56
-rw-r--r--core/src/lib/attribs.cc17
-rw-r--r--core/src/lib/bareos_resource.cc6
-rw-r--r--core/src/lib/bareos_resource.h4
-rw-r--r--core/src/lib/bsock.cc6
-rw-r--r--core/src/lib/bsock.h38
-rw-r--r--core/src/lib/bsock_tcp.cc12
-rw-r--r--core/src/lib/compression.cc12
-rw-r--r--core/src/lib/connection_pool.h4
-rw-r--r--core/src/lib/dlist.h21
-rw-r--r--core/src/lib/htable.h13
-rw-r--r--core/src/lib/implementation_factory.h67
-rw-r--r--core/src/lib/jcr.cc37
-rw-r--r--core/src/lib/message.cc6
-rw-r--r--core/src/lib/output_formatter_resource.cc10
-rw-r--r--core/src/lib/output_formatter_resource.h17
-rw-r--r--core/src/lib/parse_conf.h26
-rw-r--r--core/src/lib/plugins.cc4
-rw-r--r--core/src/lib/rblist.h21
-rw-r--r--core/src/lib/recent_job_results_list.cc4
-rw-r--r--core/src/lib/res.cc2
-rw-r--r--core/src/lib/runscript.cc31
-rw-r--r--core/src/lib/util.cc9
-rw-r--r--core/src/lib/util.h1
-rw-r--r--core/src/plugins/filed/python/CMakeLists.txt2
-rw-r--r--core/src/plugins/stored/autoxflate/autoxflate-sd.cc4
-rw-r--r--core/src/plugins/stored/scsicrypto/scsicrypto-sd.cc6
-rw-r--r--core/src/qt-tray-monitor/CMakeLists.txt3
-rw-r--r--core/src/stored/CMakeLists.txt42
-rw-r--r--core/src/stored/acquire.cc26
-rw-r--r--core/src/stored/ansi_label.cc49
-rw-r--r--core/src/stored/append.cc110
-rw-r--r--core/src/stored/authenticate.cc6
-rw-r--r--core/src/stored/autochanger.cc37
-rw-r--r--core/src/stored/backends/CMakeLists.txt56
-rw-r--r--core/src/stored/backends/cephfs_device.h61
-rw-r--r--core/src/stored/backends/droplet_device.cc19
-rw-r--r--core/src/stored/backends/droplet_device.h4
-rw-r--r--core/src/stored/backends/generic_tape_device.h3
-rw-r--r--core/src/stored/backends/gfapi_device.cc21
-rw-r--r--core/src/stored/backends/gfapi_device.h6
-rw-r--r--core/src/stored/backends/unix_fifo_device.cc21
-rw-r--r--core/src/stored/backends/unix_fifo_device.h3
-rw-r--r--core/src/stored/backends/unix_file_device.cc8
-rw-r--r--core/src/stored/backends/unix_file_device.h7
-rw-r--r--core/src/stored/backends/unix_tape_device.cc22
-rw-r--r--core/src/stored/backends/win32_fifo_device.cc (renamed from core/src/win32/stored/backends/win32_fifo_device.cc)3
-rw-r--r--core/src/stored/backends/win32_fifo_device.h (renamed from core/src/win32/stored/backends/win32_fifo_device.h)9
-rw-r--r--core/src/stored/backends/win32_file_device.cc (renamed from core/src/win32/stored/backends/win32_file_device.cc)8
-rw-r--r--core/src/stored/backends/win32_file_device.h (renamed from core/src/win32/stored/backends/win32_file_device.h)11
-rw-r--r--core/src/stored/backends/win32_tape_device.cc (renamed from core/src/win32/stored/backends/win32_tape_device.cc)3
-rw-r--r--core/src/stored/backends/win32_tape_device.h (renamed from core/src/win32/stored/backends/win32_tape_device.h)8
-rw-r--r--core/src/stored/bcopy.cc28
-rw-r--r--core/src/stored/bextract.cc8
-rw-r--r--core/src/stored/bls.cc12
-rw-r--r--core/src/stored/bscan.cc72
-rw-r--r--core/src/stored/bsr.cc28
-rw-r--r--core/src/stored/btape.cc44
-rw-r--r--core/src/stored/butil.cc64
-rw-r--r--core/src/stored/dev.cc370
-rw-r--r--core/src/stored/dev.h65
-rw-r--r--core/src/stored/device.cc22
-rw-r--r--core/src/stored/device_control_record.h2
-rw-r--r--core/src/stored/device_resource.cc13
-rw-r--r--core/src/stored/device_resource.h22
-rw-r--r--core/src/stored/dir_cmd.cc49
-rw-r--r--core/src/stored/fd_cmds.cc70
-rw-r--r--core/src/stored/job.cc114
-rw-r--r--core/src/stored/label.cc117
-rw-r--r--core/src/stored/mac.cc172
-rw-r--r--core/src/stored/mount.cc156
-rw-r--r--core/src/stored/ndmp_tape.cc67
-rw-r--r--core/src/stored/read.cc14
-rw-r--r--core/src/stored/read_record.cc24
-rw-r--r--core/src/stored/record.cc5
-rw-r--r--core/src/stored/reserve.cc72
-rw-r--r--core/src/stored/reserve.h4
-rw-r--r--core/src/stored/scan.cc11
-rw-r--r--core/src/stored/sd_backends.cc217
-rw-r--r--core/src/stored/sd_backends.h49
-rw-r--r--core/src/stored/sd_backends_dynamic.cc78
-rw-r--r--core/src/stored/sd_cmds.cc24
-rw-r--r--core/src/stored/sd_plugins.cc34
-rw-r--r--core/src/stored/sd_stats.cc7
-rw-r--r--core/src/stored/spool.cc58
-rw-r--r--core/src/stored/status.cc46
-rw-r--r--core/src/stored/stored.cc32
-rw-r--r--core/src/stored/stored_conf.cc125
-rw-r--r--core/src/stored/stored_jcr_impl.h (renamed from core/src/stored/jcr_private.h)10
-rw-r--r--core/src/stored/vol_mgr.cc101
-rw-r--r--core/src/stored/vol_mgr.h28
-rw-r--r--core/src/tests/CMakeLists.txt2
-rw-r--r--core/src/tests/alist_test.cc4
-rw-r--r--core/src/tests/catalog.cc6
-rw-r--r--core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/device/FileStorage.conf1
-rw-r--r--core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/storage/bareos-sd.conf.in (renamed from core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/storage/bareos-sd.conf)2
-rw-r--r--core/src/tests/configs/droplet_backend/bareos-sd.d/device/droplet.conf.in (renamed from core/src/tests/configs/sd_backend/bareos-sd.d/device/droplet.conf.in)2
-rw-r--r--core/src/tests/configs/droplet_backend/bareos-sd.d/storage/myself.conf.in5
-rw-r--r--core/src/tests/configs/droplet_backend/droplet.profile.in (renamed from core/src/tests/configs/sd_backend/droplet.profile.in)0
-rw-r--r--core/src/tests/configs/sd_reservation/bareos-sd.d/device/auto1.conf3
-rw-r--r--core/src/tests/configs/sd_reservation/bareos-sd.d/device/auto2.conf5
-rw-r--r--core/src/tests/configs/sd_reservation/bareos-sd.d/device/single2.conf1
-rw-r--r--core/src/tests/configs/statistics_thread/sd_statistics_thread/default_config/bareos-sd.d/storage/myself.conf3
-rw-r--r--core/src/tests/configs/statistics_thread/sd_statistics_thread/default_config/bareos-sd.d/storage/myself.conf.in4
-rw-r--r--core/src/tests/configs/statistics_thread/sd_statistics_thread/only_collect_set/bareos-sd.d/storage/myself.conf4
-rw-r--r--core/src/tests/configs/statistics_thread/sd_statistics_thread/only_collect_set/bareos-sd.d/storage/myself.conf.in5
-rw-r--r--core/src/tests/configs/statistics_thread/sd_statistics_thread/only_interval_set/bareos-sd.d/storage/myself.conf4
-rw-r--r--core/src/tests/configs/statistics_thread/sd_statistics_thread/only_interval_set/bareos-sd.d/storage/myself.conf.in5
-rw-r--r--core/src/tests/configs/stored_multiplied_device/bareos-sd.d/device/FileStorage.conf9
-rw-r--r--core/src/tests/configs/stored_multiplied_device/bareos-sd.d/storage/bareos-sd.conf11
-rw-r--r--core/src/tests/configs/stored_multiplied_device/bareos-sd.d/storage/bareos-sd.conf.in4
-rw-r--r--core/src/tests/dir_fd_connection.cc2
-rw-r--r--core/src/tests/droplet_backend.cc192
-rw-r--r--core/src/tests/messages_resource.cc2
-rw-r--r--core/src/tests/run_on_incoming_connect_interval.cc4
-rw-r--r--core/src/tests/scheduler.cc6
-rw-r--r--core/src/tests/sd_backend.cc235
-rw-r--r--core/src/tests/sd_backend_tests.h75
-rw-r--r--core/src/tests/sd_reservation.cc11
-rw-r--r--core/src/tests/test_config_parser_dir.cc66
-rw-r--r--core/src/tests/thread_list.cc3
-rw-r--r--core/src/tests/version_strings.cc17
-rw-r--r--core/src/vmware/CMakeLists.txt3
-rw-r--r--core/src/win32/filed/vss.cc22
-rw-r--r--debian/bareos-storage-droplet.install.in2
-rw-r--r--debian/bareos-storage-tape.install.in1
-rw-r--r--debian/bareos-storage.install.in1
-rw-r--r--debian/control2
-rw-r--r--debian/control.src2
-rw-r--r--docs/manuals/CMakeLists.txt2
-rw-r--r--docs/manuals/source/include/autogenerated/bareos-dir-config-schema.json4
-rw-r--r--docs/manuals/source/include/autogenerated/bareos-sd-config-schema.json3
-rw-r--r--get_version.cmake5
-rw-r--r--systemtests/CMakeLists.txt1
-rw-r--r--systemtests/cmake/BareosSystemtestFunctions.cmake12
-rw-r--r--systemtests/scripts/functions3
-rwxr-xr-xsystemtests/scripts/start_bareos.sh3
-rw-r--r--systemtests/tests/acl/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/always-incremental-consolidate/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/autochanger/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in2
-rwxr-xr-xsystemtests/tests/autochanger/test-setup1
-rw-r--r--systemtests/tests/bareos-acl/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/bareos/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in2
-rwxr-xr-xsystemtests/tests/bareos/test-setup3
-rwxr-xr-xsystemtests/tests/bareos/testrunner-filesettext-is-updated68
-rw-r--r--systemtests/tests/bconsole/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/bconsole/etc/bareos/bconsole.conf.in1
-rw-r--r--systemtests/tests/block-size/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in2
-rw-r--r--systemtests/tests/bscan-bextract-bls-bcopy/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/checkpoints/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rwxr-xr-xsystemtests/tests/checkpoints/test-setup1
-rwxr-xr-xsystemtests/tests/checkpoints/testrunner-checkpoints-on-stop1
-rw-r--r--systemtests/tests/chflags/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/client-initiated/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/commandline-options/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/config-syntax-crash/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/copy-archive-job/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/copy-migrate/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/copy-remote-bscan/etc/bareos-remote/bareos-sd.d/device/FileStorage.conf2
-rw-r--r--systemtests/tests/copy-remote-bscan/etc/bareos-remote/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/copy-remote-bscan/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/dbcopy-mysql-postgresql/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/deprecation/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/droplet-s3/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in2
-rw-r--r--systemtests/tests/encrypt-signature-no-tls/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/encrypt-signature-tls-cert/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/fileset-multiple-blocks/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/filesets/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/gfapi-fd/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/glusterfs-backend/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in2
-rw-r--r--systemtests/tests/list-backups/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/multiplied-device/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/ndmp/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/notls/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/parallel-jobs/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rwxr-xr-xsystemtests/tests/parallel-jobs/test-setup1
-rw-r--r--systemtests/tests/passive/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/pruning/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-dir/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-dir/lsan-suppressions.txt1
-rwxr-xr-xsystemtests/tests/py2plug-dir/testrunner3
-rw-r--r--systemtests/tests/py2plug-fd-contrib-bareos_tasks_mysql/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-fd-ldap/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-fd-libcloud/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-fd-local-fileset-basic/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-fd-local-fileset-restoreobject/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-fd-mariabackup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-fd-ovirt/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-fd-percona-xtrabackup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-fd-vmware/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py2plug-sd/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py3plug-fd-contrib-mysql_dump/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/py3plug-fd-postgres/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/python-bareos/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rwxr-xr-xsystemtests/tests/python-bareos/test-setup1
-rw-r--r--systemtests/tests/quota-softquota/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/restapi/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/scheduler-backup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rwxr-xr-xsystemtests/tests/scheduler-backup/test-setup1
-rw-r--r--systemtests/tests/sparse-file/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/spool/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/stresstest/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rwxr-xr-xsystemtests/tests/stresstest/test-setup1
-rw-r--r--systemtests/tests/truncate-command/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/virtualfull-bscan/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/virtualfull/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/webui-common/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--systemtests/tests/xattr/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in1
-rw-r--r--webui/CMakeLists.txt3
-rw-r--r--webui/module/Job/view/job/job/details.phtml2
-rw-r--r--webui/module/Job/view/job/job/index.phtml2
-rw-r--r--write_version_files.cmake5
306 files changed, 5085 insertions, 4974 deletions
diff --git a/.gitignore b/.gitignore
index f6667e418..773072ed6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -110,6 +110,7 @@ core/src/defaultconfigs/tray-monitor.d/storage/StorageDaemon-local.conf
core/src/include/config.h
core/src/qt-tray-monitor/bareos-tray-monitor.desktop
core/src/tests/configs/bareos-configparser-tests/bareos-dir-CFG_TYPE_STR_VECTOR_OF_DIRS.conf
+core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/storage/bareos-sd.conf
core/src/tests/configs/catalog/bareos-dir.d/catalog/MyCatalog.conf
core/src/tests/configs/console-director/tls_disabled/bareos-dir.d/director/bareos-dir.conf
core/src/tests/configs/console-director/tls_disabled/bareos-dir.d/fileset/Catalog.conf
@@ -127,10 +128,15 @@ core/src/tests/configs/console-director/tls_psk_default_enabled/bareos-dir.d/job
core/src/tests/configs/console-director/tls_psk_default_enabled/bareos-dir.d/jobdefs/DefaultJob.conf
core/src/tests/configs/console-director/tls_psk_default_enabled/bareos-dir.d/messages/Daemon.conf
core/src/tests/configs/console-director/tls_psk_default_enabled/bareos-dir.d/messages/Standard.conf
-core/src/tests/configs/sd_backend/bareos-sd.d/device/droplet.conf
+core/src/tests/configs/droplet_backend/bareos-sd.d/device/droplet.conf
+core/src/tests/configs/droplet_backend/bareos-sd.d/storage/myself.conf
+core/src/tests/configs/droplet_backend/droplet.profile
core/src/tests/configs/sd_backend/bareos-sd.d/storage/myself.conf
-core/src/tests/configs/sd_backend/droplet.profile
core/src/tests/configs/sd_reservation/bareos-sd.d/storage/myself.conf
+core/src/tests/configs/statistics_thread/sd_statistics_thread/default_config/bareos-sd.d/storage/myself.conf
+core/src/tests/configs/statistics_thread/sd_statistics_thread/only_collect_set/bareos-sd.d/storage/myself.conf
+core/src/tests/configs/statistics_thread/sd_statistics_thread/only_interval_set/bareos-sd.d/storage/myself.conf
+core/src/tests/configs/stored_multiplied_device/bareos-sd.d/storage/bareos-sd.conf
core/src/win32/console/consoleres.rc
core/src/win32/dird/dbcheckres.rc
core/src/win32/dird/dirdres.rc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0f3998fb2..ef6a67beb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -50,6 +50,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- stored: dird: added backup checkpoints that save backup metadata to the Catalog during the execution of the backup. [PR #1074]
- stored: dird: add backup checkpoints that save backup metadata to the Catalog during the execution of the backup. [PR #1074]
- build: run a build and test with sanitizers enabled [PR #1244]
+- catalog: update fileset text in fileset record [PR #1300]
### Fixed
- webui: fix job timeline x-axis UTC timestamp issue [PR #1283]
@@ -104,8 +105,9 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- testfind: remove unnecessary libraries and fix systemtest [PR #1250]
- stored: systemtests: docs: checkpoints improvements [PR #1277]
- winbareos.nsi: fix working directory in configure.sed [PR #1288]
-- core: BareosDb::FindLastJobStartTimeForJobAndClient: take into account Running job [PR #1265] [BUG #1466]
+- core: BareosDb::FindLastJobStartTimeForJobAndClient: take into account Running job [PR #1265] [Issue #1466]
- backup.cc: fail backup when `Write Bootstrap` to pipe fails [PR #1296]
+- webui: fix pool link in job details formatter [PR 1306] [BUG #1489]
### Changed
- contrib: rename Python modules to satisfy PEP8 [PR #768]
@@ -143,6 +145,10 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- build: enable compiling on ARM [PR #1270]
- core and webui: adapt binary info messages to new wording [PR #1298]
- build: enable -Wextra warning level and apply required changes [PR #1261]
+- lib: make foreach_res() reload-safe [PR #1279]
+- Prepare Bareos for an upgrade to the C++20 standard [PR #1271]
+- stored: refactor the SD's backend interface [PR #1272]
+- core: use distinct names for JobControlRecordPrivate [PR #1307]
### Deprecated
- make_catalog_backup.pl is now a shell wrapper script which will be removed in version 23.
@@ -202,6 +208,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
[Issue #1445]: https://bugs.bareos.org/view.php?id=1445
[Issue #1450]: https://bugs.bareos.org/view.php?id=1450
[Issue #1452]: https://bugs.bareos.org/view.php?id=1452
+[Issue #1466]: https://bugs.bareos.org/view.php?id=1466
[Issue #1477]: https://bugs.bareos.org/view.php?id=1477
[Issue #1480]: https://bugs.bareos.org/view.php?id=1480
[Issue #4607]: https://bugs.bareos.org/view.php?id=4607
@@ -332,16 +339,24 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
[PR #1254]: https://github.com/bareos/bareos/pull/1254
[PR #1255]: https://github.com/bareos/bareos/pull/1255
[PR #1260]: https://github.com/bareos/bareos/pull/1260
+[PR #1261]: https://github.com/bareos/bareos/pull/1261
[PR #1262]: https://github.com/bareos/bareos/pull/1262
[PR #1265]: https://github.com/bareos/bareos/pull/1265
[PR #1266]: https://github.com/bareos/bareos/pull/1266
[PR #1267]: https://github.com/bareos/bareos/pull/1267
[PR #1268]: https://github.com/bareos/bareos/pull/1268
[PR #1270]: https://github.com/bareos/bareos/pull/1270
+[PR #1271]: https://github.com/bareos/bareos/pull/1271
+[PR #1272]: https://github.com/bareos/bareos/pull/1272
[PR #1275]: https://github.com/bareos/bareos/pull/1275
[PR #1277]: https://github.com/bareos/bareos/pull/1277
[PR #1278]: https://github.com/bareos/bareos/pull/1278
+[PR #1279]: https://github.com/bareos/bareos/pull/1279
[PR #1283]: https://github.com/bareos/bareos/pull/1283
[PR #1284]: https://github.com/bareos/bareos/pull/1284
[PR #1285]: https://github.com/bareos/bareos/pull/1285
+[PR #1288]: https://github.com/bareos/bareos/pull/1288
+[PR #1296]: https://github.com/bareos/bareos/pull/1296
+[PR #1298]: https://github.com/bareos/bareos/pull/1298
+[PR #1300]: https://github.com/bareos/bareos/pull/1300
[unreleased]: https://github.com/bareos/bareos/tree/master
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5f2690ef5..929edd985 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,7 +18,8 @@
# 02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.17)
+cmake_policy(VERSION 3.17...3.19)
project(bareos NONE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
diff --git a/cmake/BareosSetVariableDefaults.cmake b/cmake/BareosSetVariableDefaults.cmake
index 811298982..eb7c56087 100644
--- a/cmake/BareosSetVariableDefaults.cmake
+++ b/cmake/BareosSetVariableDefaults.cmake
@@ -1,6 +1,6 @@
# BAREOSĀ® - Backup Archiving REcovery Open Sourced
#
-# Copyright (C) 2017-2021 Bareos GmbH & Co. KG
+# Copyright (C) 2017-2022 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
@@ -394,15 +394,17 @@ else()
endif()
# dynamic-storage-backends
-if(NOT DEFINED dynamic-storage-backends)
+if(NOT DEFINED dynamic-storage-backends OR dynamic-storage-backends)
set(dynamic-storage-backends ON)
- set(HAVE_DYNAMIC_SD_BACKENDS 1)
+ set(HAVE_DYNAMIC_SD_BACKENDS
+ 1
+ CACHE INTERNAL ""
+ )
else()
- if(${dynamic-storage-backends})
- set(HAVE_DYNAMIC_SD_BACKENDS 1)
- else()
- set(HAVE_DYNAMIC_SD_BACKENDS 0)
- endif()
+ set(HAVE_DYNAMIC_SD_BACKENDS
+ 0
+ CACHE INTERNAL ""
+ )
endif()
# scsi-crypto
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
index e0086aa4c..45a8ee57d 100644
--- a/contrib/CMakeLists.txt
+++ b/contrib/CMakeLists.txt
@@ -17,7 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
-cmake_minimum_required(VERSION 3.0)
project(bareos-contrib)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index e8a1c1467..489b2825e 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -17,8 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
-
-cmake_minimum_required(VERSION 3.12)
project(bareos C CXX)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
@@ -28,13 +26,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
)
endif()
-cmake_policy(SET CMP0054 NEW)
-cmake_policy(SET CMP0057 NEW)
-
-if(POLICY CMP0109)
- cmake_policy(SET CMP0109 NEW)
-endif(POLICY CMP0109)
-
# disable in-source builds
if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed.")
@@ -422,14 +413,6 @@ if(NOT client-only
# directory it is also not safe on 32-bit systems, so we only build it on
# 64-bit
add_subdirectory(src/droplet)
- if(TARGET droplet)
- set_target_properties(
- droplet
- PROPERTIES VERSION "${BAREOS_NUMERIC_VERSION}"
- SOVERSION "${BAREOS_VERSION_MAJOR}"
- PREFIX "libbareos"
- )
- endif()
endif()
include(BareosGenerateDebianInfo)
diff --git a/core/platforms/freebsd/bareos-freebsd/bareos.com-common/pkg-plist.storage b/core/platforms/freebsd/bareos-freebsd/bareos.com-common/pkg-plist.storage
index 4e19878bb..fd456b2ec 100644
--- a/core/platforms/freebsd/bareos-freebsd/bareos.com-common/pkg-plist.storage
+++ b/core/platforms/freebsd/bareos-freebsd/bareos.com-common/pkg-plist.storage
@@ -13,6 +13,7 @@
sbin/bareos-sd
lib/bareos/scripts/disk-changer
lib/bareos/plugins/autoxflate-sd.so
+lib/libbareossd-file.so
man/man8/bareos-sd.8.gz
@dir(bareos,bareos,0775) /var/lib/bareos/storage
etc/rc.d/bareos-sd
diff --git a/core/platforms/freebsd/bareos-freebsd/bareos.com-common/pkg-plist.storage-tape b/core/platforms/freebsd/bareos-freebsd/bareos.com-common/pkg-plist.storage-tape
index b455bfc63..d1aeae197 100644
--- a/core/platforms/freebsd/bareos-freebsd/bareos.com-common/pkg-plist.storage-tape
+++ b/core/platforms/freebsd/bareos-freebsd/bareos.com-common/pkg-plist.storage-tape
@@ -1,5 +1,4 @@
-lib/libbareossd-gentape.so
lib/libbareossd-tape.so
lib/bareos/scripts/mtx-changer
@sample %%ETCDIR%%/mtx-changer.conf.sample
diff --git a/core/platforms/packaging/bareos.spec b/core/platforms/packaging/bareos.spec
index a51f5c05c..bd87de891 100644
--- a/core/platforms/packaging/bareos.spec
+++ b/core/platforms/packaging/bareos.spec
@@ -148,7 +148,7 @@ BuildRequires: git-core
Source0: %{name}-%{version}.tar.gz
-BuildRequires: cmake >= 3.12
+BuildRequires: cmake >= 3.17
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: make
@@ -1300,6 +1300,7 @@ mkdir -p %{?buildroot}/%{_libdir}/bareos/plugins/vmware_plugin
%{_sbindir}/bareos-sd
%{script_dir}/disk-changer
%{plugin_dir}/autoxflate-sd.so
+%{backend_dir}/libbareossd-file*.so
%{_mandir}/man8/bareos-sd.8.gz
%if 0%{?systemd_support}
%{_unitdir}/bareos-sd.service
@@ -1309,7 +1310,6 @@ mkdir -p %{?buildroot}/%{_libdir}/bareos/plugins/vmware_plugin
%files storage-tape
# tape specific files
%defattr(-, root, root)
-%{backend_dir}/libbareossd-gentape*.so
%{backend_dir}/libbareossd-tape*.so
%{script_dir}/mtx-changer
%config(noreplace) %{_sysconfdir}/%{name}/mtx-changer.conf
@@ -1332,9 +1332,7 @@ mkdir -p %{?buildroot}/%{_libdir}/bareos/plugins/vmware_plugin
%if 0%{?droplet}
%files storage-droplet
%defattr(-, root, root)
-%{backend_dir}/libbareossd-chunked*.so
%{backend_dir}/libbareossd-droplet*.so
-%{library_dir}/libbareosdroplet.so*
%attr(0640, %{director_daemon_user},%{daemon_group}) %{_sysconfdir}/%{name}/bareos-dir.d/storage/S3_Object.conf.example
%attr(0640, %{storage_daemon_user},%{daemon_group}) %{_sysconfdir}/%{name}/bareos-sd.d/device/S3_ObjectStorage.conf.example
%dir %{_sysconfdir}/%{name}/bareos-sd.d/device/droplet/
diff --git a/core/src/cats/sql_create.cc b/core/src/cats/sql_create.cc
index 3d26ceba9..dea5346e9 100644
--- a/core/src/cats/sql_create.cc
+++ b/core/src/cats/sql_create.cc
@@ -704,11 +704,13 @@ bool BareosDb::CreateFilesetRecord(JobControlRecord* jcr, FileSetDbRecord* fsr)
fsr->FileSetId = 0;
if (QUERY_DB(jcr, cmd)) {
num_rows = SqlNumRows();
+
if (num_rows > 1) {
- Mmsg1(errmsg, _("More than one FileSet!: %d\n"), num_rows);
+ Mmsg2(errmsg, _("More than one FileSet! %s: %d\n"), esc_fs, num_rows);
Jmsg(jcr, M_ERROR, 0, "%s", errmsg);
}
if (num_rows >= 1) {
+ // fileset record found
if ((row = SqlFetchRow()) == NULL) {
Mmsg1(errmsg, _("error fetching FileSet row: ERR=%s\n"),
sql_strerror());
@@ -722,8 +724,30 @@ bool BareosDb::CreateFilesetRecord(JobControlRecord* jcr, FileSetDbRecord* fsr)
} else {
bstrncpy(fsr->cCreateTime, row[1], sizeof(fsr->cCreateTime));
}
+ // Update existing fileset record to make sure the fileset text is
+ // inserted
+ PoolMem esc_filesettext(PM_MESSAGE);
+
+ len = strlen(fsr->FileSetText);
+ esc_filesettext.check_size(len * 2 + 1);
+ EscapeString(jcr, esc_filesettext.c_str(), fsr->FileSetText, len);
+
+ Mmsg(cmd,
+ "UPDATE FileSet SET (FileSet,MD5,CreateTime,FileSetText) "
+ "= ('%s','%s','%s','%s') WHERE FileSet='%s' AND MD5='%s' ",
+ esc_fs, esc_md5, fsr->cCreateTime, esc_filesettext.c_str(), esc_fs,
+ esc_md5);
+ if (QUERY_DB(jcr, cmd)) {
+ SqlFreeResult();
+ return true;
+ } else {
+ Mmsg1(errmsg, _("error updating FileSet row: ERR=%s\n"),
+ sql_strerror());
+ Jmsg(jcr, M_ERROR, 0, "%s", errmsg);
+ SqlFreeResult();
+ return false;
+ }
SqlFreeResult();
- return true;
}
SqlFreeResult();
}
@@ -739,7 +763,6 @@ bool BareosDb::CreateFilesetRecord(JobControlRecord* jcr, FileSetDbRecord* fsr)
len = strlen(fsr->FileSetText);
esc_filesettext.check_size(len * 2 + 1);
EscapeString(jcr, esc_filesettext.c_str(), fsr->FileSetText, len);
-
Mmsg(cmd,
"INSERT INTO FileSet (FileSet,MD5,CreateTime,FileSetText) "
"VALUES ('%s','%s','%s','%s')",
@@ -779,7 +802,7 @@ bool BareosDb::CreateFilesetRecord(JobControlRecord* jcr, FileSetDbRecord* fsr)
bool BareosDb::WriteBatchFileRecords(JobControlRecord* jcr)
{
bool retval = false;
- int JobStatus = jcr->JobStatus;
+ int JobStatus = jcr->getJobStatus();
if (!jcr->batch_started) { /* no files to backup ? */
Dmsg0(50, "db_create_file_record : no files\n");
@@ -788,7 +811,7 @@ bool BareosDb::WriteBatchFileRecords(JobControlRecord* jcr)
Dmsg1(50, "db_create_file_record changes=%u\n", changes);
- jcr->JobStatus = JS_AttrInserting;
+ jcr->setJobStatus(JS_AttrInserting);
Jmsg(jcr, M_INFO, 0,
"Insert of attributes batch table with %u entries start\n",
@@ -827,7 +850,7 @@ bool BareosDb::WriteBatchFileRecords(JobControlRecord* jcr)
}
/* clang-format on */
- jcr->JobStatus = JobStatus; /* reset entry status */
+ jcr->setJobStatus(JobStatus); /* reset entry status */
Jmsg(jcr, M_INFO, 0, "Insert of attributes batch table done\n");
retval = true;
@@ -902,7 +925,6 @@ bool BareosDb::CreateFileAttributesRecord(JobControlRecord* jcr,
DbLocker _{this};
Dmsg1(dbglevel, "Fname=%s\n", ar->fname);
Dmsg0(dbglevel, "put_file_into_catalog\n");
-
SplitPathAndFile(jcr, ar->fname);
if (!CreatePathRecord(jcr, ar)) { return false; }
diff --git a/core/src/cats/sql_update.cc b/core/src/cats/sql_update.cc
index 55f558a7d..df1826a6c 100644
--- a/core/src/cats/sql_update.cc
+++ b/core/src/cats/sql_update.cc
@@ -102,7 +102,7 @@ bool BareosDb::UpdateJobStartRecord(JobControlRecord* jcr, JobDbRecord* jr)
"UPDATE Job SET JobStatus='%c',Level='%c',StartTime='%s',"
"ClientId=%s,JobTDate=%s,PoolId=%s,FileSetId=%s,VolSessionId=%lu,"
"VolSessionTime=%lu WHERE JobId=%s",
- (char)(jcr->JobStatus), (char)(jr->JobLevel), dt,
+ (char)(jcr->getJobStatus()), (char)(jr->JobLevel), dt,
edit_int64(jr->ClientId, ed1), edit_uint64(JobTDate, ed2),
edit_int64(jr->PoolId, ed3), edit_int64(jr->FileSetId, ed4),
jcr->VolSessionId, jcr->VolSessionTime, edit_int64(jr->JobId, ed5));
diff --git a/core/src/dird/admin.cc b/core/src/dird/admin.cc
index ce71d9db7..889ab476d 100644
--- a/core/src/dird/admin.cc
+++ b/core/src/dird/admin.cc
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2003-2012 Free Software Foundation Europe e.V.
- Copyright (C) 2016-2020 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -30,7 +30,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/admin.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/storage.h"
@@ -52,14 +52,14 @@ bool DoAdminInit(JobControlRecord* jcr)
*/
bool do_admin(JobControlRecord* jcr)
{
- jcr->impl->jr.JobId = jcr->JobId;
+ jcr->dir_impl->jr.JobId = jcr->JobId;
- jcr->impl->fname = (char*)GetPoolMemory(PM_FNAME);
+ jcr->dir_impl->fname = (char*)GetPoolMemory(PM_FNAME);
Jmsg(jcr, M_INFO, 0, _("Start Admin JobId %d, Job=%s\n"), jcr->JobId,
jcr->Job);
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
AdminCleanup(jcr, JS_Terminated);
return true;
@@ -76,15 +76,15 @@ void AdminCleanup(JobControlRecord* jcr, int TermCode)
UpdateJobEnd(jcr, TermCode);
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error getting Job record for Job report: ERR=%s\n"),
jcr->db->strerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
msg_type = M_INFO; /* by default INFO message */
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
TermMsg = _("Admin OK");
break;
@@ -98,12 +98,13 @@ void AdminCleanup(JobControlRecord* jcr, int TermCode)
break;
default:
TermMsg = term_code;
- sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
+ sprintf(term_code, _("Inappropriate term code: %c\n"),
+ jcr->getJobStatus());
break;
}
- bstrftimes(schedt, sizeof(schedt), jcr->impl->jr.SchedTime);
- bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime);
- bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime);
+ bstrftimes(schedt, sizeof(schedt), jcr->dir_impl->jr.SchedTime);
+ bstrftimes(sdt, sizeof(sdt), jcr->dir_impl->jr.StartTime);
+ bstrftimes(edt, sizeof(edt), jcr->dir_impl->jr.EndTime);
Jmsg(jcr, msg_type, 0,
_("BAREOS %s (%s): %s\n"
@@ -116,9 +117,9 @@ void AdminCleanup(JobControlRecord* jcr, int TermCode)
" Job triggered by: %s\n"
" Termination: %s\n\n"),
kBareosVersionStrings.Full, kBareosVersionStrings.ShortDate, edt,
- jcr->impl->jr.JobId, jcr->impl->jr.Job, schedt, sdt, edt,
+ jcr->dir_impl->jr.JobId, jcr->dir_impl->jr.Job, schedt, sdt, edt,
kBareosVersionStrings.JoblogMessage,
- JobTriggerToString(jcr->impl->job_trigger).c_str(), TermMsg);
+ JobTriggerToString(jcr->dir_impl->job_trigger).c_str(), TermMsg);
Dmsg0(debuglevel, "Leave AdminCleanup()\n");
}
diff --git a/core/src/dird/archive.cc b/core/src/dird/archive.cc
index 44d957767..d1f0c8ea7 100644
--- a/core/src/dird/archive.cc
+++ b/core/src/dird/archive.cc
@@ -1,7 +1,7 @@
/*
BAREOSĀ® - Backup Archiving REcovery Open Sourced
- Copyright (C) 2016-2020 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -30,7 +30,7 @@
#include "dird.h"
#include "dird/archive.h"
#include "dird/job.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/storage.h"
namespace directordaemon {
@@ -51,14 +51,14 @@ bool DoArchiveInit(JobControlRecord* jcr)
*/
bool DoArchive(JobControlRecord* jcr)
{
- jcr->impl->jr.JobId = jcr->JobId;
+ jcr->dir_impl->jr.JobId = jcr->JobId;
- jcr->impl->fname = (char*)GetPoolMemory(PM_FNAME);
+ jcr->dir_impl->fname = (char*)GetPoolMemory(PM_FNAME);
Jmsg(jcr, M_INFO, 0, _("Start Archive JobId %d, Job=%s\n"), jcr->JobId,
jcr->Job);
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
ArchiveCleanup(jcr, JS_Terminated);
return true;
@@ -75,15 +75,15 @@ void ArchiveCleanup(JobControlRecord* jcr, int TermCode)
UpdateJobEnd(jcr, TermCode);
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error getting Job record for Job report: ERR=%s\n"),
jcr->db->strerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
msg_type = M_INFO; /* by default INFO message */
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
TermMsg = _("Archive OK");
break;
@@ -97,13 +97,14 @@ void ArchiveCleanup(JobControlRecord* jcr, int TermCode)
break;
default:
TermMsg = term_code;
- sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
+ sprintf(term_code, _("Inappropriate term code: %c\n"),
+ jcr->getJobStatus());
break;
}
- bstrftimes(schedt, sizeof(schedt), jcr->impl->jr.SchedTime);
- bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime);
- bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime);
+ bstrftimes(schedt, sizeof(schedt), jcr->dir_impl->jr.SchedTime);
+ bstrftimes(sdt, sizeof(sdt), jcr->dir_impl->jr.StartTime);
+ bstrftimes(edt, sizeof(edt), jcr->dir_impl->jr.EndTime);
Jmsg(jcr, msg_type, 0,
_("BAREOS %s (%s): %s\n"
@@ -116,9 +117,9 @@ void ArchiveCleanup(JobControlRecord* jcr, int TermCode)
" Job triggered by: %s\n"
" Termination: %s\n\n"),
kBareosVersionStrings.Full, kBareosVersionStrings.ShortDate, edt,
- jcr->impl->jr.JobId, jcr->impl->jr.Job, schedt, sdt, edt,
+ jcr->dir_impl->jr.JobId, jcr->dir_impl->jr.Job, schedt, sdt, edt,
kBareosVersionStrings.JoblogMessage,
- JobTriggerToString(jcr->impl->job_trigger).c_str(), TermMsg);
+ JobTriggerToString(jcr->dir_impl->job_trigger).c_str(), TermMsg);
Dmsg0(debuglevel, "Leave ArchiveCleanup()\n");
}
diff --git a/core/src/dird/authenticate.cc b/core/src/dird/authenticate.cc
index 4cbc2315b..db8584339 100644
--- a/core/src/dird/authenticate.cc
+++ b/core/src/dird/authenticate.cc
@@ -3,7 +3,7 @@
Copyright (C) 2001-2008 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2020 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -37,7 +37,7 @@
#include "dird/fd_cmds.h"
#include "dird/client_connection_handshake_mode.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "lib/bnet.h"
#include "lib/qualified_resource_name_type_converter.h"
#include "lib/bstringlist.h"
@@ -124,9 +124,9 @@ bool AuthenticateWithFileDaemon(JobControlRecord* jcr)
if (jcr->authenticated) { return true; }
BareosSocket* fd = jcr->file_bsock;
- ClientResource* client = jcr->impl->res.client;
+ ClientResource* client = jcr->dir_impl->res.client;
- if (jcr->impl->connection_handshake_try_
+ if (jcr->dir_impl->connection_handshake_try_
== ClientConnectionHandshakeMode::kTlsFirst) {
std::string qualified_resource_name;
if (!my_config->GetQualifiedResourceNameTypeConverter()->ResourceToString(
@@ -186,9 +186,9 @@ bool AuthenticateWithFileDaemon(JobControlRecord* jcr)
}
Dmsg1(110, "<filed: %s", fd->msg);
- jcr->impl->FDVersion = 0;
+ jcr->dir_impl->FDVersion = 0;
if (!bstrncmp(fd->msg, FDOKhello, sizeof(FDOKhello))
- && sscanf(fd->msg, FDOKnewHello, &jcr->impl->FDVersion) != 1) {
+ && sscanf(fd->msg, FDOKnewHello, &jcr->dir_impl->FDVersion) != 1) {
Dmsg0(debuglevel, _("File daemon rejected Hello command\n"));
Jmsg(jcr, M_FATAL, 0,
_("File daemon at \"%s:%d\" rejected Hello command\n"), fd->host(),
diff --git a/core/src/dird/autoprune.cc b/core/src/dird/autoprune.cc
index e63a956bd..6634d103a 100644
--- a/core/src/dird/autoprune.cc
+++ b/core/src/dird/autoprune.cc
@@ -28,7 +28,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/next_vol.h"
#include "dird/ua_server.h"
#include "dird/ua_prune.h"
@@ -49,14 +49,14 @@ void DoAutoprune(JobControlRecord* jcr)
PoolResource* pool;
bool pruned;
- if (!jcr->impl->res.client) { /* temp -- remove me */
+ if (!jcr->dir_impl->res.client) { /* temp -- remove me */
return;
}
ua = new_ua_context(jcr);
- job = jcr->impl->res.job;
- client = jcr->impl->res.client;
- pool = jcr->impl->res.pool;
+ job = jcr->dir_impl->res.job;
+ client = jcr->dir_impl->res.client;
+ pool = jcr->dir_impl->res.pool;
if (job->PruneJobs || client->AutoPrune) {
PruneJobs(ua, client, pool);
@@ -92,8 +92,9 @@ void PruneVolumes(JobControlRecord* jcr,
PoolMem query(PM_MESSAGE);
char ed1[50], ed2[100], ed3[50];
- Dmsg1(100, "Prune volumes PoolId=%d\n", jcr->impl->jr.PoolId);
- if (!jcr->impl->res.job->PruneVolumes && !jcr->impl->res.pool->AutoPrune) {
+ Dmsg1(100, "Prune volumes PoolId=%d\n", jcr->dir_impl->jr.PoolId);
+ if (!jcr->dir_impl->res.job->PruneVolumes
+ && !jcr->dir_impl->res.pool->AutoPrune) {
Dmsg0(100, "AutoPrune not set in Pool.\n");
return;
}
diff --git a/core/src/dird/backup.cc b/core/src/dird/backup.cc
index 07a57ab6d..65ad1e5a7 100644
--- a/core/src/dird/backup.cc
+++ b/core/src/dird/backup.cc
@@ -39,7 +39,7 @@
#include "dird/fd_cmds.h"
#include "dird/getmsg.h"
#include "dird/inc_conf.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/msgchan.h"
#include "dird/quota.h"
@@ -73,14 +73,15 @@ static char EndJob[]
static inline bool ValidateClient(JobControlRecord* jcr)
{
- switch (jcr->impl->res.client->Protocol) {
+ switch (jcr->dir_impl->res.client->Protocol) {
case APT_NATIVE:
return true;
default:
Jmsg(jcr, M_FATAL, 0,
_("Client %s has illegal backup protocol %s for Native backup\n"),
- jcr->impl->res.client->resource_name_,
- AuthenticationProtocolTypeToString(jcr->impl->res.client->Protocol));
+ jcr->dir_impl->res.client->resource_name_,
+ AuthenticationProtocolTypeToString(
+ jcr->dir_impl->res.client->Protocol));
return false;
}
}
@@ -131,7 +132,7 @@ static inline bool ValidateStorage(JobControlRecord* jcr)
{
StorageResource* store = nullptr;
- foreach_alist (store, jcr->impl->res.write_storage_list) {
+ foreach_alist (store, jcr->dir_impl->res.write_storage_list) {
switch (store->Protocol) {
case APT_NATIVE:
continue;
@@ -153,13 +154,13 @@ bool DoNativeBackupInit(JobControlRecord* jcr)
if (!AllowDuplicateJob(jcr)) { return false; }
- jcr->impl->jr.PoolId
- = GetOrCreatePoolRecord(jcr, jcr->impl->res.pool->resource_name_);
- if (jcr->impl->jr.PoolId == 0) { return false; }
+ jcr->dir_impl->jr.PoolId
+ = GetOrCreatePoolRecord(jcr, jcr->dir_impl->res.pool->resource_name_);
+ if (jcr->dir_impl->jr.PoolId == 0) { return false; }
// If pool storage specified, use it instead of job storage
- CopyWstorage(jcr, jcr->impl->res.pool->storage, _("Pool resource"));
- if (!jcr->impl->res.write_storage_list) {
+ CopyWstorage(jcr, jcr->dir_impl->res.pool->storage, _("Pool resource"));
+ if (!jcr->dir_impl->res.write_storage_list) {
Jmsg(jcr, M_FATAL, 0,
_("No Storage specification found in Job or Pool.\n"));
return false;
@@ -179,13 +180,13 @@ static bool GetBaseJobids(JobControlRecord* jcr, db_list_ctx* jobids)
JobResource* job = nullptr;
JobId_t id;
- if (!jcr->impl->res.job->base) {
+ if (!jcr->dir_impl->res.job->base) {
return false; /* no base job, stop accurate */
}
- jr.StartTime = jcr->impl->jr.StartTime;
+ jr.StartTime = jcr->dir_impl->jr.StartTime;
- foreach_alist (job, jcr->impl->res.job->base) {
+ foreach_alist (job, jcr->dir_impl->res.job->base) {
bstrncpy(jr.Name, job->resource_name_, sizeof(jr.Name));
jcr->db->GetBaseJobid(jcr, &jr, &id);
@@ -211,7 +212,7 @@ static int AccurateListHandler(void* ctx, int num_fields, char** row)
}
/* sending with checksum */
- if (jcr->impl->use_accurate_chksum && num_fields == 9 && row[6][0]
+ if (jcr->dir_impl->use_accurate_chksum && num_fields == 9 && row[6][0]
&& /* skip checksum = '0' */
row[6][1]) {
jcr->file_bsock->fsend("%s%s%c%s%c%s%c%s", row[0], row[1], 0, row[4], 0,
@@ -235,9 +236,11 @@ static bool IsChecksumNeededByFileset(JobControlRecord* jcr)
bool in_block = false;
bool have_basejob_option = false;
- if (!jcr->impl->res.job || !jcr->impl->res.job->fileset) { return false; }
+ if (!jcr->dir_impl->res.job || !jcr->dir_impl->res.job->fileset) {
+ return false;
+ }
- fs = jcr->impl->res.job->fileset;
+ fs = jcr->dir_impl->res.job->fileset;
for (std::size_t i = 0; i < fs->include_items.size(); i++) {
inc = fs->include_items[i];
@@ -309,7 +312,7 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr)
}
} else {
// For Incr/Diff level, we search for older jobs
- jcr->db->AccurateGetJobids(jcr, &jcr->impl->jr, &jobids);
+ jcr->db->AccurateGetJobids(jcr, &jcr->dir_impl->jr, &jobids);
// We are in Incr/Diff, but no Full to build the accurate list...
if (jobids.empty()) {
@@ -319,7 +322,7 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr)
}
// Don't send and store the checksum if fileset doesn't require it
- jcr->impl->use_accurate_chksum = IsChecksumNeededByFileset(jcr);
+ jcr->dir_impl->use_accurate_chksum = IsChecksumNeededByFileset(jcr);
if (jcr->JobId) { /* display the message only for real jobs */
Jmsg(jcr, M_INFO, 0, _("Sending Accurate information.\n"));
}
@@ -339,7 +342,7 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr)
jcr->db->strerror());
return false;
}
- if (!jcr->db->GetBaseFileList(jcr, jcr->impl->use_accurate_chksum,
+ if (!jcr->db->GetBaseFileList(jcr, jcr->dir_impl->use_accurate_chksum,
AccurateListHandler, (void*)jcr)) {
Jmsg(jcr, M_FATAL, 0, "error in jcr->db->GetBaseFileList:%s\n",
jcr->db->strerror());
@@ -351,9 +354,10 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr)
return false; /* Fail */
}
- if (!jcr->db_batch->GetFileList(
- jcr, jobids.GetAsString().c_str(), jcr->impl->use_accurate_chksum,
- false /* no delta */, AccurateListHandler, (void*)jcr)) {
+ if (!jcr->db_batch->GetFileList(jcr, jobids.GetAsString().c_str(),
+ jcr->dir_impl->use_accurate_chksum,
+ false /* no delta */, AccurateListHandler,
+ (void*)jcr)) {
Jmsg(jcr, M_FATAL, 0, "error in jcr->db_batch->GetBaseFileList:%s\n",
jcr->db_batch->strerror());
return false;
@@ -385,10 +389,10 @@ bool DoNativeBackup(JobControlRecord* jcr)
Jmsg(jcr, M_INFO, 0, _("Start Backup JobId %s, Job=%s\n"),
edit_uint64(jcr->JobId, ed1), jcr->Job);
- jcr->setJobStatus(JS_Running);
- Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl->jr.JobId,
- jcr->impl->jr.JobLevel);
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
+ Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->dir_impl->jr.JobId,
+ jcr->dir_impl->jr.JobLevel);
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
return false;
}
@@ -411,14 +415,15 @@ bool DoNativeBackup(JobControlRecord* jcr)
* will be contacting him for a backup session.
*/
Dmsg0(110, "Open connection with storage daemon\n");
- jcr->setJobStatus(JS_WaitSD);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitSD);
if (!ConnectToStorageDaemon(jcr, 10, me->SDConnectTimeout, true)) {
return false;
}
sd = jcr->store_bsock;
- if (!StartStorageDaemonJob(jcr, NULL, jcr->impl->res.write_storage_list)) {
+ if (!StartStorageDaemonJob(jcr, NULL,
+ jcr->dir_impl->res.write_storage_list)) {
return false;
}
@@ -426,7 +431,7 @@ bool DoNativeBackup(JobControlRecord* jcr)
* When the client is not in passive mode we can put the SD in
* listen mode for the FD connection.
*/
- jcr->passive_client = jcr->impl->res.client->passive;
+ jcr->passive_client = jcr->dir_impl->res.client->passive;
if (!jcr->passive_client) {
/*
* Start the job prior to starting the message thread below
@@ -446,7 +451,7 @@ bool DoNativeBackup(JobControlRecord* jcr)
Dmsg0(150, "Storage daemon connection OK\n");
}
- jcr->setJobStatus(JS_WaitFD);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitFD);
if (!ConnectToFileDaemon(jcr, 10, me->FDConnectTimeout, true)) {
goto bail_out;
}
@@ -454,15 +459,15 @@ bool DoNativeBackup(JobControlRecord* jcr)
SendJobInfoToFileDaemon(jcr);
fd = jcr->file_bsock;
- if (jcr->passive_client && jcr->impl->FDVersion < FD_VERSION_51) {
+ if (jcr->passive_client && jcr->dir_impl->FDVersion < FD_VERSION_51) {
Jmsg(jcr, M_FATAL, 0,
_("Client \"%s\" doesn't support passive client mode. "
"Please upgrade your client or disable compat mode.\n"),
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
goto close_fd;
}
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
if (!SendLevelCommand(jcr)) { goto bail_out; }
@@ -478,25 +483,25 @@ bool DoNativeBackup(JobControlRecord* jcr)
Dmsg1(500, "Unexpected %s secure erase\n", "client");
}
- if (jcr->impl->res.job->max_bandwidth > 0) {
- jcr->max_bandwidth = jcr->impl->res.job->max_bandwidth;
- } else if (jcr->impl->res.client->max_bandwidth > 0) {
- jcr->max_bandwidth = jcr->impl->res.client->max_bandwidth;
+ if (jcr->dir_impl->res.job->max_bandwidth > 0) {
+ jcr->max_bandwidth = jcr->dir_impl->res.job->max_bandwidth;
+ } else if (jcr->dir_impl->res.client->max_bandwidth > 0) {
+ jcr->max_bandwidth = jcr->dir_impl->res.client->max_bandwidth;
}
if (jcr->max_bandwidth > 0) {
SendBwlimitToFd(jcr, jcr->Job); /* Old clients don't have this command */
}
- client = jcr->impl->res.client;
- store = jcr->impl->res.write_storage;
+ client = jcr->dir_impl->res.client;
+ store = jcr->dir_impl->res.write_storage;
char* connection_target_address;
if (!jcr->passive_client) {
// TLS Requirement
TlsPolicy tls_policy;
- if (jcr->impl->res.client->connection_successful_handshake_
+ if (jcr->dir_impl->res.client->connection_successful_handshake_
!= ClientConnectionHandshakeMode::kTlsFirst) {
tls_policy = store->GetPolicy();
} else {
@@ -518,7 +523,7 @@ bool DoNativeBackup(JobControlRecord* jcr)
} else { /* passive client */
TlsPolicy tls_policy;
- if (jcr->impl->res.client->connection_successful_handshake_
+ if (jcr->dir_impl->res.client->connection_successful_handshake_
!= ClientConnectionHandshakeMode::kTlsFirst) {
tls_policy = client->GetPolicy();
} else {
@@ -570,8 +575,8 @@ bool DoNativeBackup(JobControlRecord* jcr)
* is after the start of this run.
*/
jcr->start_time = time(NULL);
- jcr->impl->jr.StartTime = jcr->start_time;
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->dir_impl->jr.StartTime = jcr->start_time;
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
}
@@ -616,7 +621,7 @@ close_fd:
}
bail_out:
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
WaitForJobTermination(jcr, me->FDConnectTimeout);
return false;
@@ -642,7 +647,7 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout)
int Encrypt = 0;
btimer_t* tid = NULL;
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
if (fd) {
if (timeout) {
@@ -652,12 +657,12 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout)
// Wait for Client to terminate
while ((n = BgetDirmsg(fd)) >= 0) {
if (!fd_ok
- && sscanf(fd->msg, EndJob, &jcr->impl->FDJobStatus, &JobFiles,
+ && sscanf(fd->msg, EndJob, &jcr->dir_impl->FDJobStatus, &JobFiles,
&ReadBytes, &JobBytes, &JobErrors, &VSS, &Encrypt)
== 7) {
fd_ok = true;
- jcr->setJobStatus(jcr->impl->FDJobStatus);
- Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus);
+ jcr->setJobStatusWithPriorityCheck(jcr->dir_impl->FDJobStatus);
+ Dmsg1(100, "FDStatus=%c\n", (char)jcr->getJobStatus());
} else {
Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Job message: %s\n"),
fd->msg);
@@ -670,7 +675,7 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout)
int i = 0;
Jmsg(jcr, M_FATAL, 0, _("Network error with FD during %s: ERR=%s\n"),
job_type_to_str(jcr->getJobType()), fd->bstrerror());
- while (i++ < 10 && jcr->impl->res.job->RescheduleIncompleteJobs
+ while (i++ < 10 && jcr->dir_impl->res.job->RescheduleIncompleteJobs
&& jcr->IsCanceled()) {
Bmicrosleep(3, 0);
}
@@ -683,11 +688,13 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout)
* the SD despool.
*/
Dmsg5(100, "cancel=%d fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", jcr->IsCanceled(),
- fd_ok, jcr->impl->FDJobStatus, jcr->JobStatus, jcr->impl->SDJobStatus);
+ fd_ok, jcr->dir_impl->FDJobStatus.load(), jcr->getJobStatus(),
+ jcr->dir_impl->SDJobStatus.load());
if (jcr->IsCanceled()
- || (!jcr->impl->res.job->RescheduleIncompleteJobs && !fd_ok)) {
+ || (!jcr->dir_impl->res.job->RescheduleIncompleteJobs && !fd_ok)) {
Dmsg4(100, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok,
- jcr->impl->FDJobStatus, jcr->JobStatus, jcr->impl->SDJobStatus);
+ jcr->dir_impl->FDJobStatus.load(), jcr->getJobStatus(),
+ jcr->dir_impl->SDJobStatus.load());
CancelStorageDaemonJob(jcr);
}
@@ -701,25 +708,25 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout)
jcr->ReadBytes = ReadBytes;
jcr->JobBytes = JobBytes;
jcr->JobWarnings = JobWarnings;
- jcr->impl->VSS = VSS;
- jcr->impl->Encrypt = Encrypt;
+ jcr->dir_impl->VSS = VSS;
+ jcr->dir_impl->Encrypt = Encrypt;
} else {
Jmsg(jcr, M_FATAL, 0, _("No Job status returned from FD.\n"));
}
// Dmsg4(100, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok,
- // jcr->impl_->FDJobStatus,
- // jcr->JobStatus, jcr->impl_->SDJobStatus);
+ // jcr->dir_impl_->FDJobStatus,
+ // jcr->JobStatus, jcr->dir_impl_->SDJobStatus);
// Return the first error status we find Dir, FD, or SD
if (!fd_ok || IsBnetError(fd)) { /* if fd not set, that use !fd_ok */
- jcr->impl->FDJobStatus = JS_ErrorTerminated;
+ jcr->dir_impl->FDJobStatus = JS_ErrorTerminated;
}
- if (jcr->JobStatus != JS_Terminated) { return jcr->JobStatus; }
- if (jcr->impl->FDJobStatus != JS_Terminated) {
- return jcr->impl->FDJobStatus;
+ if (jcr->getJobStatus() != JS_Terminated) { return jcr->getJobStatus(); }
+ if (jcr->dir_impl->FDJobStatus != JS_Terminated) {
+ return jcr->dir_impl->FDJobStatus;
}
- return jcr->impl->SDJobStatus;
+ return jcr->dir_impl->SDJobStatus;
}
// Release resources allocated during backup.
@@ -733,20 +740,20 @@ void NativeBackupCleanup(JobControlRecord* jcr, int TermCode)
Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode);
if (jcr->is_JobStatus(JS_Terminated)
- && (jcr->JobErrors || jcr->impl->SDErrors || jcr->JobWarnings)) {
+ && (jcr->JobErrors || jcr->dir_impl->SDErrors || jcr->JobWarnings)) {
TermCode = JS_Warnings;
}
UpdateJobEnd(jcr, TermCode);
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error getting Job record for Job report: ERR=%s\n"),
jcr->db->strerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
- bstrncpy(cr.Name, jcr->impl->res.client->resource_name_, sizeof(cr.Name));
+ bstrncpy(cr.Name, jcr->dir_impl->res.client->resource_name_, sizeof(cr.Name));
if (!jcr->db->GetClientRecord(jcr, &cr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error getting Client record for Job report: ERR=%s\n"),
@@ -755,7 +762,7 @@ void NativeBackupCleanup(JobControlRecord* jcr, int TermCode)
UpdateBootstrapFile(jcr);
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
TermMsg = _("Backup OK");
break;
@@ -771,8 +778,8 @@ void NativeBackupCleanup(JobControlRecord* jcr, int TermCode)
msg_type = M_ERROR; /* Generate error message */
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
break;
@@ -780,14 +787,15 @@ void NativeBackupCleanup(JobControlRecord* jcr, int TermCode)
TermMsg = _("Backup Canceled");
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
break;
default:
TermMsg = term_code;
- sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
+ sprintf(term_code, _("Inappropriate term code: %c\n"),
+ jcr->getJobStatus());
break;
}
@@ -799,8 +807,8 @@ void NativeBackupCleanup(JobControlRecord* jcr, int TermCode)
void UpdateBootstrapFile(JobControlRecord* jcr)
{
// Now update the bootstrap file if any
- if (jcr->IsTerminatedOk() && jcr->impl->jr.JobBytes
- && jcr->impl->res.job->WriteBootstrap) {
+ if (jcr->IsTerminatedOk() && jcr->dir_impl->jr.JobBytes
+ && jcr->dir_impl->res.job->WriteBootstrap) {
FILE* fd;
int VolCount;
int got_pipe = 0;
@@ -809,7 +817,8 @@ void UpdateBootstrapFile(JobControlRecord* jcr)
char edt[50], ed1[50], ed2[50];
POOLMEM* fname = GetPoolMemory(PM_FNAME);
- fname = edit_job_codes(jcr, fname, jcr->impl->res.job->WriteBootstrap, "");
+ fname = edit_job_codes(jcr, fname, jcr->dir_impl->res.job->WriteBootstrap,
+ "");
if (*fname == '|') {
got_pipe = 1;
bpipe = OpenBpipe(fname + 1, 0, "w"); /* skip first char "|" */
@@ -825,14 +834,14 @@ void UpdateBootstrapFile(JobControlRecord* jcr)
_("Could not get Job Volume Parameters to "
"update Bootstrap file. ERR=%s\n"),
jcr->db->strerror());
- if (jcr->impl->SDJobFiles != 0) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ if (jcr->dir_impl->SDJobFiles != 0) {
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
}
/* Start output with when and who wrote it */
bstrftimes(edt, sizeof(edt), time(NULL));
- fprintf(fd, "# %s - %s - %s%s\n", edt, jcr->impl->jr.Job,
- JobLevelToString(jcr->getJobLevel()), jcr->impl->since);
+ fprintf(fd, "# %s - %s - %s%s\n", edt, jcr->dir_impl->jr.Job,
+ JobLevelToString(jcr->getJobLevel()), jcr->dir_impl->since);
for (int i = 0; i < VolCount; i++) {
/* Write the record */
fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName);
@@ -867,7 +876,7 @@ void UpdateBootstrapFile(JobControlRecord* jcr)
_("Could not open WriteBootstrap file:\n"
"%s: ERR=%s\n"),
fname, be.bstrerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
FreePoolMemory(fname);
}
@@ -900,28 +909,28 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
secure_erase_status,
compress_algo_list;
- bstrftimes(schedt, sizeof(schedt), jcr->impl->jr.SchedTime);
- bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime);
- bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime);
- RunTime = jcr->impl->jr.EndTime - jcr->impl->jr.StartTime;
+ bstrftimes(schedt, sizeof(schedt), jcr->dir_impl->jr.SchedTime);
+ bstrftimes(sdt, sizeof(sdt), jcr->dir_impl->jr.StartTime);
+ bstrftimes(edt, sizeof(edt), jcr->dir_impl->jr.EndTime);
+ RunTime = jcr->dir_impl->jr.EndTime - jcr->dir_impl->jr.StartTime;
bstrftimes(gdt, sizeof(gdt),
- jcr->impl->res.client->GraceTime +
- jcr->impl->res.client->SoftQuotaGracePeriod);
+ jcr->dir_impl->res.client->GraceTime +
+ jcr->dir_impl->res.client->SoftQuotaGracePeriod);
if (RunTime <= 0) {
kbps = 0;
} else {
- kbps = ((double)jcr->impl->jr.JobBytes) / (1000.0 * (double)RunTime);
+ kbps = ((double)jcr->dir_impl->jr.JobBytes) / (1000.0 * (double)RunTime);
}
- if (!jcr->db->GetJobVolumeNames(jcr, jcr->impl->jr.JobId, jcr->VolumeName)) {
+ if (!jcr->db->GetJobVolumeNames(jcr, jcr->dir_impl->jr.JobId, jcr->VolumeName)) {
/*
* Note, if the job has erred, most likely it did not write any
* tape, so suppress this "error" message since in that case
* it is normal. Or look at it the other way, only for a
* normal exit should we complain about this error.
*/
- if (jcr->IsTerminatedOk() && jcr->impl->jr.JobBytes) {
+ if (jcr->IsTerminatedOk() && jcr->dir_impl->jr.JobBytes) {
Jmsg(jcr, M_ERROR, 0, "%s", jcr->db->strerror());
}
jcr->VolumeName[0] = 0; /* none */
@@ -954,36 +963,36 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
}
}
- JobstatusToAscii(jcr->impl->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
- JobstatusToAscii(jcr->impl->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
+ JobstatusToAscii(jcr->dir_impl->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
+ JobstatusToAscii(jcr->dir_impl->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
switch (jcr->getJobProtocol()) {
case PT_NDMP_BAREOS:
Mmsg(level_info, _(
" Backup Level: %s%s\n"),
- JobLevelToString(jcr->getJobLevel()), jcr->impl->since);
+ JobLevelToString(jcr->getJobLevel()), jcr->dir_impl->since);
Mmsg(statistics, _(
" NDMP Files Written: %s\n"
" SD Files Written: %s\n"
" NDMP Bytes Written: %s (%sB)\n"
" SD Bytes Written: %s (%sB)\n"),
- edit_uint64_with_commas(jcr->impl->jr.JobFiles, ec1),
- edit_uint64_with_commas(jcr->impl->SDJobFiles, ec2),
- edit_uint64_with_commas(jcr->impl->jr.JobBytes, ec3),
- edit_uint64_with_suffix(jcr->impl->jr.JobBytes, ec4),
- edit_uint64_with_commas(jcr->impl->SDJobBytes, ec5),
- edit_uint64_with_suffix(jcr->impl->SDJobBytes, ec6));
+ edit_uint64_with_commas(jcr->dir_impl->jr.JobFiles, ec1),
+ edit_uint64_with_commas(jcr->dir_impl->SDJobFiles, ec2),
+ edit_uint64_with_commas(jcr->dir_impl->jr.JobBytes, ec3),
+ edit_uint64_with_suffix(jcr->dir_impl->jr.JobBytes, ec4),
+ edit_uint64_with_commas(jcr->dir_impl->SDJobBytes, ec5),
+ edit_uint64_with_suffix(jcr->dir_impl->SDJobBytes, ec6));
break;
case PT_NDMP_NATIVE:
Mmsg(level_info, _(
" Backup Level: %s%s\n"),
- JobLevelToString(jcr->getJobLevel()), jcr->impl->since);
+ JobLevelToString(jcr->getJobLevel()), jcr->dir_impl->since);
Mmsg(statistics, _(
" NDMP Files Written: %s\n"
" NDMP Bytes Written: %s (%sB)\n"),
- edit_uint64_with_commas(jcr->impl->jr.JobFiles, ec1),
- edit_uint64_with_commas(jcr->impl->jr.JobBytes, ec3),
- edit_uint64_with_suffix(jcr->impl->jr.JobBytes, ec4));
+ edit_uint64_with_commas(jcr->dir_impl->jr.JobFiles, ec1),
+ edit_uint64_with_commas(jcr->dir_impl->jr.JobBytes, ec3),
+ edit_uint64_with_suffix(jcr->dir_impl->jr.JobBytes, ec4));
break;
default:
if (jcr->is_JobLevel(L_VIRTUAL_FULL)) {
@@ -992,32 +1001,32 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
Mmsg(statistics, _(
" SD Files Written: %s\n"
" SD Bytes Written: %s (%sB)\n"),
- edit_uint64_with_commas(jcr->impl->SDJobFiles, ec2),
- edit_uint64_with_commas(jcr->impl->SDJobBytes, ec5),
- edit_uint64_with_suffix(jcr->impl->SDJobBytes, ec6));
+ edit_uint64_with_commas(jcr->dir_impl->SDJobFiles, ec2),
+ edit_uint64_with_commas(jcr->dir_impl->SDJobBytes, ec5),
+ edit_uint64_with_suffix(jcr->dir_impl->SDJobBytes, ec6));
} else {
Mmsg(level_info, _(
" Backup Level: %s%s\n"),
- JobLevelToString(jcr->getJobLevel()), jcr->impl->since);
+ JobLevelToString(jcr->getJobLevel()), jcr->dir_impl->since);
Mmsg(statistics, _(
" FD Files Written: %s\n"
" SD Files Written: %s\n"
" FD Bytes Written: %s (%sB)\n"
" SD Bytes Written: %s (%sB)\n"),
- edit_uint64_with_commas(jcr->impl->jr.JobFiles, ec1),
- edit_uint64_with_commas(jcr->impl->SDJobFiles, ec2),
- edit_uint64_with_commas(jcr->impl->jr.JobBytes, ec3),
- edit_uint64_with_suffix(jcr->impl->jr.JobBytes, ec4),
- edit_uint64_with_commas(jcr->impl->SDJobBytes, ec5),
- edit_uint64_with_suffix(jcr->impl->SDJobBytes, ec6));
+ edit_uint64_with_commas(jcr->dir_impl->jr.JobFiles, ec1),
+ edit_uint64_with_commas(jcr->dir_impl->SDJobFiles, ec2),
+ edit_uint64_with_commas(jcr->dir_impl->jr.JobBytes, ec3),
+ edit_uint64_with_suffix(jcr->dir_impl->jr.JobBytes, ec4),
+ edit_uint64_with_commas(jcr->dir_impl->SDJobBytes, ec5),
+ edit_uint64_with_suffix(jcr->dir_impl->SDJobBytes, ec6));
}
break;
}
- if (jcr->impl->HasQuota) {
- if (jcr->impl->res.client->GraceTime != 0) {
- bstrftimes(gdt, sizeof(gdt), jcr->impl->res.client->GraceTime +
- jcr->impl->res.client->SoftQuotaGracePeriod);
+ if (jcr->dir_impl->HasQuota) {
+ if (jcr->dir_impl->res.client->GraceTime != 0) {
+ bstrftimes(gdt, sizeof(gdt), jcr->dir_impl->res.client->GraceTime +
+ jcr->dir_impl->res.client->SoftQuotaGracePeriod);
} else {
bstrncpy(gdt, "Soft Quota not exceeded", sizeof(gdt));
}
@@ -1027,14 +1036,14 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
" Soft Quota: %s (%sB)\n"
" Hard Quota: %s (%sB)\n"
" Grace Expiry Date: %s\n"),
- edit_uint64_with_commas(jcr->impl->jr.JobSumTotalBytes+jcr->impl->SDJobBytes, ec1),
- edit_uint64_with_suffix(jcr->impl->jr.JobSumTotalBytes+jcr->impl->SDJobBytes, ec2),
- edit_uint64_with_commas(jcr->impl->res.client->QuotaLimit, ec3),
- edit_uint64_with_suffix(jcr->impl->res.client->QuotaLimit, ec4),
- edit_uint64_with_commas(jcr->impl->res.client->SoftQuota, ec5),
- edit_uint64_with_suffix(jcr->impl->res.client->SoftQuota, ec6),
- edit_uint64_with_commas(jcr->impl->res.client->HardQuota, ec7),
- edit_uint64_with_suffix(jcr->impl->res.client->HardQuota, ec8),
+ edit_uint64_with_commas(jcr->dir_impl->jr.JobSumTotalBytes+jcr->dir_impl->SDJobBytes, ec1),
+ edit_uint64_with_suffix(jcr->dir_impl->jr.JobSumTotalBytes+jcr->dir_impl->SDJobBytes, ec2),
+ edit_uint64_with_commas(jcr->dir_impl->res.client->QuotaLimit, ec3),
+ edit_uint64_with_suffix(jcr->dir_impl->res.client->QuotaLimit, ec4),
+ edit_uint64_with_commas(jcr->dir_impl->res.client->SoftQuota, ec5),
+ edit_uint64_with_suffix(jcr->dir_impl->res.client->SoftQuota, ec6),
+ edit_uint64_with_commas(jcr->dir_impl->res.client->HardQuota, ec7),
+ edit_uint64_with_suffix(jcr->dir_impl->res.client->HardQuota, ec8),
gdt);
}
@@ -1048,7 +1057,7 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
" SD Errors: %d\n"
" SD termination status: %s\n"
" Accurate: %s\n"),
- jcr->impl->SDErrors,
+ jcr->dir_impl->SDErrors,
sd_term_msg,
jcr->accurate ? _("yes") : _("no"));
} else {
@@ -1064,8 +1073,8 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
jcr->nb_base_files,
jcr->nb_base_files_used,
jcr->nb_base_files_used * 100.0 / jcr->nb_base_files,
- jcr->impl->VSS ? _("yes") : _("no"),
- jcr->impl->Encrypt ? _("yes") : _("no"),
+ jcr->dir_impl->VSS ? _("yes") : _("no"),
+ jcr->dir_impl->Encrypt ? _("yes") : _("no"),
jcr->accurate ? _("yes") : _("no"));
} else {
Mmsg(client_options, _(
@@ -1075,8 +1084,8 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
" Accurate: %s\n"),
compress,
compress_algo_list.c_str(),
- jcr->impl->VSS ? _("yes") : _("no"),
- jcr->impl->Encrypt ? _("yes") : _("no"),
+ jcr->dir_impl->VSS ? _("yes") : _("no"),
+ jcr->dir_impl->Encrypt ? _("yes") : _("no"),
jcr->accurate ? _("yes") : _("no"));
}
@@ -1086,7 +1095,7 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
" FD termination status: %s\n"
" SD termination status: %s\n"),
jcr->JobErrors,
- jcr->impl->SDErrors,
+ jcr->dir_impl->SDErrors,
fd_term_msg,
sd_term_msg);
@@ -1094,12 +1103,12 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
Mmsg(temp," Dir Secure Erase Cmd: %s\n", me->secure_erase_cmdline);
PmStrcat(secure_erase_status, temp.c_str());
}
- if (!bstrcmp(jcr->impl->FDSecureEraseCmd, "*None*")) {
- Mmsg(temp, " FD Secure Erase Cmd: %s\n", jcr->impl->FDSecureEraseCmd);
+ if (!bstrcmp(jcr->dir_impl->FDSecureEraseCmd, "*None*")) {
+ Mmsg(temp, " FD Secure Erase Cmd: %s\n", jcr->dir_impl->FDSecureEraseCmd);
PmStrcat(secure_erase_status, temp.c_str());
}
- if (!bstrcmp(jcr->impl->SDSecureEraseCmd, "*None*")) {
- Mmsg(temp, " SD Secure Erase Cmd: %s\n", jcr->impl->SDSecureEraseCmd);
+ if (!bstrcmp(jcr->dir_impl->SDSecureEraseCmd, "*None*")) {
+ Mmsg(temp, " SD Secure Erase Cmd: %s\n", jcr->dir_impl->SDSecureEraseCmd);
PmStrcat(secure_erase_status, temp.c_str());
}
}
@@ -1138,14 +1147,14 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
" Termination: %s\n\n"),
BAREOS, my_name, kBareosVersionStrings.Full,
kBareosVersionStrings.ShortDate, kBareosVersionStrings.GetOsInfo(),
- jcr->impl->jr.JobId,
- jcr->impl->jr.Job,
+ jcr->dir_impl->jr.JobId,
+ jcr->dir_impl->jr.Job,
level_info.c_str(),
- jcr->impl->res.client->resource_name_, cr->Uname,
- jcr->impl->res.fileset->resource_name_, jcr->impl->FSCreateTime,
- jcr->impl->res.pool->resource_name_, jcr->impl->res.pool_source,
- jcr->impl->res.catalog->resource_name_, jcr->impl->res.catalog_source,
- jcr->impl->res.write_storage->resource_name_, jcr->impl->res.wstore_source,
+ jcr->dir_impl->res.client->resource_name_, cr->Uname,
+ jcr->dir_impl->res.fileset->resource_name_, jcr->dir_impl->FSCreateTime,
+ jcr->dir_impl->res.pool->resource_name_, jcr->dir_impl->res.pool_source,
+ jcr->dir_impl->res.catalog->resource_name_, jcr->dir_impl->res.catalog_source,
+ jcr->dir_impl->res.write_storage->resource_name_, jcr->dir_impl->res.wstore_source,
schedt,
sdt,
edt,
@@ -1163,7 +1172,7 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
daemon_status.c_str(),
secure_erase_status.c_str(),
kBareosVersionStrings.JoblogMessage,
- JobTriggerToString(jcr->impl->job_trigger).c_str(),
+ JobTriggerToString(jcr->dir_impl->job_trigger).c_str(),
TermMsg);
/* clang-format on */
diff --git a/core/src/dird/bsr.cc b/core/src/dird/bsr.cc
index a66c94d20..767041555 100644
--- a/core/src/dird/bsr.cc
+++ b/core/src/dird/bsr.cc
@@ -29,7 +29,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/ua_input.h"
#include "dird/ua_restore.h"
#include "dird/ua_server.h"
@@ -247,13 +247,13 @@ static void MakeUniqueRestoreFilename(UaContext* ua, PoolMem& fname)
int i = FindArgWithValue(ua, "bootstrap");
if (i >= 0) {
Mmsg(fname, "%s", ua->argv[i]);
- jcr->impl->unlink_bsr = false;
+ jcr->dir_impl->unlink_bsr = false;
} else {
lock_mutex(mutex);
uniq++;
unlock_mutex(mutex);
Mmsg(fname, "%s/%s.restore.%u.bsr", working_directory, my_name, uniq);
- jcr->impl->unlink_bsr = true;
+ jcr->dir_impl->unlink_bsr = true;
}
if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); }
jcr->RestoreBootstrap = strdup(fname.c_str());
@@ -572,7 +572,7 @@ bool OpenBootstrapFile(JobControlRecord* jcr, bootstrap_info& info)
info.ua = NULL;
if (!jcr->RestoreBootstrap) { return false; }
- bstrncpy(info.storage, jcr->impl->res.read_storage->resource_name_,
+ bstrncpy(info.storage, jcr->dir_impl->res.read_storage->resource_name_,
MAX_NAME_LENGTH);
bs = fopen(jcr->RestoreBootstrap, "rb");
@@ -580,7 +580,7 @@ bool OpenBootstrapFile(JobControlRecord* jcr, bootstrap_info& info)
BErrNo be;
Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"),
jcr->RestoreBootstrap, be.bstrerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -610,13 +610,13 @@ static inline bool IsOnSameStorage(JobControlRecord* jcr, char* new_one)
StorageResource* new_store;
// With old FD, we send the whole bootstrap to the storage
- if (jcr->impl->FDVersion < FD_VERSION_2) { return true; }
+ if (jcr->dir_impl->FDVersion < FD_VERSION_2) { return true; }
// We are in init loop ? shoudn't fail here
if (!*new_one) { return true; }
// Same name
- if (bstrcmp(new_one, jcr->impl->res.read_storage->resource_name_)) {
+ if (bstrcmp(new_one, jcr->dir_impl->res.read_storage->resource_name_)) {
return true;
}
@@ -631,8 +631,9 @@ static inline bool IsOnSameStorage(JobControlRecord* jcr, char* new_one)
* If Port and Hostname/IP are same, we are talking to the same
* Storage Daemon
*/
- if (jcr->impl->res.read_storage->SDport != new_store->SDport
- || !bstrcmp(jcr->impl->res.read_storage->address, new_store->address)) {
+ if (jcr->dir_impl->res.read_storage->SDport != new_store->SDport
+ || !bstrcmp(jcr->dir_impl->res.read_storage->address,
+ new_store->address)) {
return false;
}
diff --git a/core/src/dird/catreq.cc b/core/src/dird/catreq.cc
index 4650a0dc4..b9dc5f533 100644
--- a/core/src/dird/catreq.cc
+++ b/core/src/dird/catreq.cc
@@ -35,7 +35,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/next_vol.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/sd_cmds.h"
#include "findlib/find.h"
#include "lib/berrno.h"
@@ -88,7 +88,7 @@ static int SendVolumeInfoToStorageDaemon(JobControlRecord* jcr,
int status;
char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50], ed6[50];
- jcr->impl->MediaId = mr->MediaId;
+ jcr->dir_impl->MediaId = mr->MediaId;
PmStrcpy(jcr->VolumeName, mr->VolumeName);
BashSpaces(mr->VolumeName);
status = sd->fsend(
@@ -145,7 +145,7 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs)
ok = jcr->db->GetPoolRecord(jcr, &pr);
if (ok) {
mr.PoolId = pr.PoolId;
- SetStorageidInMr(jcr->impl->res.write_storage, &mr);
+ SetStorageidInMr(jcr->dir_impl->res.write_storage, &mr);
mr.ScratchPoolId = pr.ScratchPoolId;
ok = FindNextVolumeForAppend(jcr, &mr, index, unwanted_volumes.c_str(),
fnv_create_vol, fnv_prune);
@@ -179,10 +179,10 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs)
* Pool matches, and it is either Append or Recycle
* and Media Type matches and Pool allows any volume.
*/
- if (mr.PoolId != jcr->impl->jr.PoolId) {
+ if (mr.PoolId != jcr->dir_impl->jr.PoolId) {
reason = _("not in Pool");
} else if (!bstrcmp(mr.MediaType,
- jcr->impl->res.write_storage->media_type)) {
+ jcr->dir_impl->res.write_storage->media_type)) {
reason = _("not correct MediaType");
} else {
/*
@@ -280,11 +280,11 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs)
* However, do so only if we are writing the tape, i.e.
* the number of VolWrites has increased.
*/
- if (jcr->impl->res.write_storage && sdmr.VolWrites > mr.VolWrites) {
+ if (jcr->dir_impl->res.write_storage && sdmr.VolWrites > mr.VolWrites) {
Dmsg2(050, "Update StorageId old=%d new=%d\n", mr.StorageId,
- jcr->impl->res.write_storage->StorageId);
+ jcr->dir_impl->res.write_storage->StorageId);
// Update StorageId after write
- SetStorageidInMr(jcr->impl->res.write_storage, &mr);
+ SetStorageidInMr(jcr->dir_impl->res.write_storage, &mr);
} else {
// Nothing written, reset same StorageId
SetStorageidInMr(NULL, &mr);
@@ -331,8 +331,8 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs)
&jm.EndBlock, &Copy, &Stripe, &MediaId)
== 10) {
// Request to create a JobMedia record
- if (jcr->impl->mig_jcr) {
- jm.JobId = jcr->impl->mig_jcr->JobId;
+ if (jcr->dir_impl->mig_jcr) {
+ jm.JobId = jcr->dir_impl->mig_jcr->JobId;
} else {
jm.JobId = jcr->JobId;
}
@@ -465,7 +465,7 @@ static void UpdateAttribute(JobControlRecord* jcr,
Dmsg5(400, "UpdCat VolSessId=%d VolSessT=%d FI=%d Strm=%d reclen=%d\n",
VolSessionId, VolSessionTime, FileIndex, Stream, reclen);
- jcr->impl->SDJobBytes
+ jcr->dir_impl->SDJobBytes
+= reclen; /* update number of bytes transferred for quotas */
switch (Stream) {
@@ -515,8 +515,8 @@ static void UpdateAttribute(JobControlRecord* jcr,
}
ar->Stream = Stream;
ar->link = NULL;
- if (jcr->impl->mig_jcr) {
- ar->JobId = jcr->impl->mig_jcr->JobId;
+ if (jcr->dir_impl->mig_jcr) {
+ ar->JobId = jcr->dir_impl->mig_jcr->JobId;
} else {
ar->JobId = jcr->JobId;
}
@@ -542,8 +542,8 @@ static void UpdateAttribute(JobControlRecord* jcr,
ro.Stream = Stream;
ro.FileIndex = FileIndex;
- if (jcr->impl->mig_jcr) {
- ro.JobId = jcr->impl->mig_jcr->JobId;
+ if (jcr->dir_impl->mig_jcr) {
+ ro.JobId = jcr->dir_impl->mig_jcr->JobId;
} else {
ro.JobId = jcr->JobId;
}
@@ -659,7 +659,7 @@ static void UpdateAttribute(JobControlRecord* jcr,
// Update File Attributes in the catalog with data sent by the Storage daemon.
void CatalogUpdate(JobControlRecord* jcr, BareosSocket* bs)
{
- if (!jcr->impl->res.pool->catalog_files) {
+ if (!jcr->dir_impl->res.pool->catalog_files) {
return; /* user disabled cataloging */
}
@@ -696,7 +696,8 @@ bool DespoolAttributesFromFile(JobControlRecord* jcr, const char* file)
Dmsg0(100, "Begin DespoolAttributesFromFile\n");
- if (jcr->IsJobCanceled() || !jcr->impl->res.pool->catalog_files || !jcr->db) {
+ if (jcr->IsJobCanceled() || !jcr->dir_impl->res.pool->catalog_files
+ || !jcr->db) {
goto bail_out; /* user disabled cataloging */
}
diff --git a/core/src/dird/consolidate.cc b/core/src/dird/consolidate.cc
index eb91d833c..f4c5b46e6 100644
--- a/core/src/dird/consolidate.cc
+++ b/core/src/dird/consolidate.cc
@@ -31,7 +31,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/consolidate.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/storage.h"
#include "dird/ua_input.h"
@@ -54,7 +54,7 @@ bool DoConsolidateInit(JobControlRecord* jcr)
/**
* Start a Virtual(Full) Job that creates a new virtual backup
- * containing the jobids given in jcr->impl_->vf_jobids
+ * containing the jobids given in jcr->dir_impl_->vf_jobids
*/
static inline void StartNewConsolidationJob(JobControlRecord* jcr,
char* jobname)
@@ -66,7 +66,8 @@ static inline void StartNewConsolidationJob(JobControlRecord* jcr,
ua = new_ua_context(jcr);
ua->batch = true;
Mmsg(ua->cmd, "run job=\"%s\" jobid=%s level=VirtualFull %s", jobname,
- jcr->impl->vf_jobids, jcr->accurate ? "accurate=yes" : "accurate=no");
+ jcr->dir_impl->vf_jobids,
+ jcr->accurate ? "accurate=yes" : "accurate=no");
Dmsg1(debuglevel, "=============== consolidate cmd=%s\n", ua->cmd);
ParseUaArgs(ua); /* parse command */
@@ -100,22 +101,22 @@ bool DoConsolidate(JobControlRecord* jcr)
int32_t fullconsolidations_started = 0;
int32_t max_full_consolidations = 0;
- tmpjob = jcr->impl->res.job; /* Memorize job */
+ tmpjob = jcr->dir_impl->res.job; /* Memorize job */
// Get Value for MaxFullConsolidations from Consolidation job
- max_full_consolidations = jcr->impl->res.job->MaxFullConsolidations;
+ max_full_consolidations = jcr->dir_impl->res.job->MaxFullConsolidations;
- jcr->impl->jr.JobId = jcr->JobId;
- jcr->impl->fname = (char*)GetPoolMemory(PM_FNAME);
+ jcr->dir_impl->jr.JobId = jcr->JobId;
+ jcr->dir_impl->fname = (char*)GetPoolMemory(PM_FNAME);
// do not cancel virtual fulls started by consolidation
- jcr->impl->IgnoreDuplicateJobChecking = true;
+ jcr->dir_impl->IgnoreDuplicateJobChecking = true;
// Print Job Start message
Jmsg(jcr, M_INFO, 0, _("Start Consolidate JobId %d, Job=%s\n"), jcr->JobId,
jcr->Job);
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
foreach_res (job, R_JOB) {
if (job->AlwaysIncremental) {
@@ -123,12 +124,12 @@ bool DoConsolidate(JobControlRecord* jcr)
job->resource_name_);
// Fake always incremental job as job of current jcr.
- jcr->impl->res.job = job;
- jcr->impl->res.fileset = job->fileset;
- jcr->impl->res.client = job->client;
- jcr->impl->jr.JobLevel = L_INCREMENTAL;
- jcr->impl->jr.limit = 0;
- jcr->impl->jr.StartTime = 0;
+ jcr->dir_impl->res.job = job;
+ jcr->dir_impl->res.fileset = job->fileset;
+ jcr->dir_impl->res.client = job->client;
+ jcr->dir_impl->jr.JobLevel = L_INCREMENTAL;
+ jcr->dir_impl->jr.limit = 0;
+ jcr->dir_impl->jr.StartTime = 0;
if (!GetOrCreateFilesetRecord(jcr)) {
Jmsg(jcr, M_FATAL, 0, _("JobId=%d no FileSet\n"), (int)jcr->JobId);
@@ -144,7 +145,7 @@ bool DoConsolidate(JobControlRecord* jcr)
// First determine the number of total incrementals
db_list_ctx all_jobids_ctx;
- jcr->db->AccurateGetJobids(jcr, &jcr->impl->jr, &all_jobids_ctx);
+ jcr->db->AccurateGetJobids(jcr, &jcr->dir_impl->jr, &all_jobids_ctx);
Dmsg1(10, "unlimited jobids list: %s.\n",
all_jobids_ctx.GetAsString().c_str());
@@ -156,20 +157,20 @@ bool DoConsolidate(JobControlRecord* jcr)
if (job->AlwaysIncrementalJobRetention) {
char sdt[50];
- jcr->impl->jr.StartTime = now - job->AlwaysIncrementalJobRetention;
- bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime);
+ jcr->dir_impl->jr.StartTime = now - job->AlwaysIncrementalJobRetention;
+ bstrftimes(sdt, sizeof(sdt), jcr->dir_impl->jr.StartTime);
Jmsg(jcr, M_INFO, 0,
_("%s: considering jobs older than %s for consolidation.\n"),
job->resource_name_, sdt);
Dmsg4(10,
_("%s: considering jobs with ClientId %d and FilesetId %d older "
"than %s for consolidation.\n"),
- job->resource_name_, jcr->impl->jr.ClientId,
- jcr->impl->jr.FileSetId, sdt);
+ job->resource_name_, jcr->dir_impl->jr.ClientId,
+ jcr->dir_impl->jr.FileSetId, sdt);
}
db_list_ctx jobids_ctx;
- jcr->db->AccurateGetJobids(jcr, &jcr->impl->jr, &jobids_ctx);
+ jcr->db->AccurateGetJobids(jcr, &jcr->dir_impl->jr, &jobids_ctx);
Dmsg1(10, "consolidate candidates: %s.\n",
jobids_ctx.GetAsString().c_str());
@@ -212,12 +213,12 @@ bool DoConsolidate(JobControlRecord* jcr)
const int32_t max_incrementals_to_consolidate
= incrementals_total - job->AlwaysIncrementalKeepNumber;
- jcr->impl->jr.limit = max_incrementals_to_consolidate + 1;
+ jcr->dir_impl->jr.limit = max_incrementals_to_consolidate + 1;
Dmsg3(10, "total: %d, to_consolidate: %d, limit: %d.\n",
incrementals_total, max_incrementals_to_consolidate,
- jcr->impl->jr.limit);
+ jcr->dir_impl->jr.limit);
jobids_ctx.clear();
- jcr->db->AccurateGetJobids(jcr, &jcr->impl->jr, &jobids_ctx);
+ jcr->db->AccurateGetJobids(jcr, &jcr->dir_impl->jr, &jobids_ctx);
const int32_t incrementals_to_consolidate = jobids_ctx.size() - 1;
Dmsg2(10, "%d consolidate ids after limit: %s.\n", jobids_ctx.size(),
jobids_ctx.GetAsString().c_str());
@@ -256,18 +257,18 @@ bool DoConsolidate(JobControlRecord* jcr)
if (p) { *p = '\0'; }
// Get db record of oldest jobid and check its age
- jcr->impl->previous_jr = JobDbRecord{};
- jcr->impl->previous_jr.JobId = str_to_int64(jobids);
+ jcr->dir_impl->previous_jr = JobDbRecord{};
+ jcr->dir_impl->previous_jr.JobId = str_to_int64(jobids);
Dmsg1(10, "Previous JobId=%s\n", jobids);
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) {
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->previous_jr)) {
Jmsg(jcr, M_FATAL, 0,
_("Error getting Job record for first Job: ERR=%s\n"),
jcr->db->strerror());
goto bail_out;
}
- starttime = jcr->impl->previous_jr.JobTDate;
+ starttime = jcr->dir_impl->previous_jr.JobTDate;
oldest_allowed_starttime = now - job->AlwaysIncrementalMaxFullAge;
bstrftimes(sdt_allowed, sizeof(sdt_allowed), oldest_allowed_starttime);
bstrftimes(sdt_starttime, sizeof(sdt_starttime), starttime);
@@ -305,10 +306,10 @@ bool DoConsolidate(JobControlRecord* jcr)
}
// Set the virtualfull jobids to be consolidated
- if (!jcr->impl->vf_jobids) {
- jcr->impl->vf_jobids = GetPoolMemory(PM_MESSAGE);
+ if (!jcr->dir_impl->vf_jobids) {
+ jcr->dir_impl->vf_jobids = GetPoolMemory(PM_MESSAGE);
}
- PmStrcpy(jcr->impl->vf_jobids, p);
+ PmStrcpy(jcr->dir_impl->vf_jobids, p);
Jmsg(jcr, M_INFO, 0, _("%s: Start new consolidation\n"),
job->resource_name_);
@@ -318,8 +319,8 @@ bool DoConsolidate(JobControlRecord* jcr)
bail_out:
// Restore original job back to jcr.
- jcr->impl->res.job = tmpjob;
- jcr->setJobStatus(JS_Terminated);
+ jcr->dir_impl->res.job = tmpjob;
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
ConsolidateCleanup(jcr, JS_Terminated);
if (jobids) { free(jobids); }
@@ -339,15 +340,15 @@ void ConsolidateCleanup(JobControlRecord* jcr, int TermCode)
UpdateJobEnd(jcr, TermCode);
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error getting Job record for Job report: ERR=%s\n"),
jcr->db->strerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
msg_type = M_INFO; /* by default INFO message */
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
TermMsg = _("Consolidate OK");
break;
@@ -361,12 +362,13 @@ void ConsolidateCleanup(JobControlRecord* jcr, int TermCode)
break;
default:
TermMsg = term_code;
- sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
+ sprintf(term_code, _("Inappropriate term code: %c\n"),
+ jcr->getJobStatus());
break;
}
- bstrftimes(schedt, sizeof(schedt), jcr->impl->jr.SchedTime);
- bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime);
- bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime);
+ bstrftimes(schedt, sizeof(schedt), jcr->dir_impl->jr.SchedTime);
+ bstrftimes(sdt, sizeof(sdt), jcr->dir_impl->jr.StartTime);
+ bstrftimes(edt, sizeof(edt), jcr->dir_impl->jr.EndTime);
Jmsg(jcr, msg_type, 0,
_("BAREOS %s (%s): %s\n"
@@ -379,9 +381,9 @@ void ConsolidateCleanup(JobControlRecord* jcr, int TermCode)
" Job triggered by: %s\n"
" Termination: %s\n\n"),
kBareosVersionStrings.Full, kBareosVersionStrings.ShortDate, edt,
- jcr->impl->jr.JobId, jcr->impl->jr.Job, schedt, sdt, edt,
+ jcr->dir_impl->jr.JobId, jcr->dir_impl->jr.Job, schedt, sdt, edt,
kBareosVersionStrings.JoblogMessage,
- JobTriggerToString(jcr->impl->job_trigger).c_str(), TermMsg);
+ JobTriggerToString(jcr->dir_impl->job_trigger).c_str(), TermMsg);
Dmsg0(debuglevel, "Leave ConsolidateCleanup()\n");
}
diff --git a/core/src/dird/dbcopy/database_connection.h b/core/src/dird/dbcopy/database_connection.h
index 3d758ae80..10ffff845 100644
--- a/core/src/dird/dbcopy/database_connection.h
+++ b/core/src/dird/dbcopy/database_connection.h
@@ -1,7 +1,7 @@
/*
BAREOSĀ® - Backup Archiving REcovery Open Sourced
- Copyright (C) 2020-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2020-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -25,7 +25,7 @@
#include "include/bareos.h"
#include "dird/dird_globals.h"
#include "dird/job.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/dird_conf.h"
#include "dird/get_database_connection.h"
#include "dird/dbcopy/database_type.h"
@@ -47,11 +47,11 @@ class DatabaseConnection {
{
jcr_.reset(directordaemon::NewDirectorJcr());
- jcr_->impl->res.catalog
+ jcr_->dir_impl->res.catalog
= static_cast<directordaemon::CatalogResource*>(config->GetResWithName(
directordaemon::R_CATALOG, catalog_resource_name.c_str()));
- if (jcr_->impl->res.catalog == nullptr) {
+ if (jcr_->dir_impl->res.catalog == nullptr) {
std::string err{"Could not find catalog resource "};
err += catalog_resource_name;
err += ".";
@@ -67,7 +67,7 @@ class DatabaseConnection {
throw std::runtime_error(err);
}
- db_type = DatabaseType::Convert(jcr_->impl->res.catalog->db_driver);
+ db_type = DatabaseType::Convert(jcr_->dir_impl->res.catalog->db_driver);
}
private:
diff --git a/core/src/dird/dbcopy/dbcopy.cc b/core/src/dird/dbcopy/dbcopy.cc
index 7a96bf82c..7f2ce6dee 100644
--- a/core/src/dird/dbcopy/dbcopy.cc
+++ b/core/src/dird/dbcopy/dbcopy.cc
@@ -30,7 +30,7 @@
#include "dird/dird_conf.h"
#include "dird/dird_globals.h"
#include "dird/get_database_connection.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "lib/parse_conf.h"
#include "lib/util.h"
diff --git a/core/src/dird/dir_plugins.cc b/core/src/dird/dir_plugins.cc
index 23ecbb092..c9a05c98e 100644
--- a/core/src/dird/dir_plugins.cc
+++ b/core/src/dird/dir_plugins.cc
@@ -27,7 +27,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dir_plugins.h"
#include "lib/edit.h"
@@ -387,7 +387,7 @@ static inline PluginContext* instantiate_plugin(JobControlRecord* jcr,
/**
* Send a bDirEventNewPluginOptions event to all plugins configured in
- * jcr->impl_->res.Job.DirPluginOptions
+ * jcr->dir_impl_->res.Job.DirPluginOptions
*/
void DispatchNewPluginOptions(JobControlRecord* jcr)
{
@@ -403,13 +403,13 @@ void DispatchNewPluginOptions(JobControlRecord* jcr)
if (!dird_plugin_list || dird_plugin_list->empty()) { return; }
- if (jcr->impl->res.job && jcr->impl->res.job->DirPluginOptions
- && jcr->impl->res.job->DirPluginOptions->size()) {
+ if (jcr->dir_impl->res.job && jcr->dir_impl->res.job->DirPluginOptions
+ && jcr->dir_impl->res.job->DirPluginOptions->size()) {
eventType = bDirEventNewPluginOptions;
event.eventType = eventType;
foreach_alist_index (i, plugin_options,
- jcr->impl->res.job->DirPluginOptions) {
+ jcr->dir_impl->res.job->DirPluginOptions) {
// Make a private copy of plugin options.
PmStrcpy(priv_plugin_options, plugin_options);
@@ -559,7 +559,7 @@ static bRC bareosGetValue(PluginContext* ctx, brDirVariable var, void* value)
NPRT(*((char**)value)));
break;
case bDirVarJob:
- *((char**)value) = jcr->impl->res.job->resource_name_;
+ *((char**)value) = jcr->dir_impl->res.job->resource_name_;
Dmsg1(debuglevel, "dir-plugin: return bDirVarJob=%s\n",
NPRT(*((char**)value)));
break;
@@ -574,29 +574,30 @@ static bRC bareosGetValue(PluginContext* ctx, brDirVariable var, void* value)
jcr->getJobType());
break;
case bDirVarClient:
- *((char**)value) = jcr->impl->res.client->resource_name_;
+ *((char**)value) = jcr->dir_impl->res.client->resource_name_;
Dmsg1(debuglevel, "dir-plugin: return bDirVarClient=%s\n",
NPRT(*((char**)value)));
break;
case bDirVarNumVols: {
PoolDbRecord pr;
- bstrncpy(pr.Name, jcr->impl->res.pool->resource_name_, sizeof(pr.Name));
+ bstrncpy(pr.Name, jcr->dir_impl->res.pool->resource_name_,
+ sizeof(pr.Name));
if (!jcr->db->GetPoolRecord(jcr, &pr)) { retval = bRC_Error; }
*((int*)value) = pr.NumVols;
Dmsg1(debuglevel, "dir-plugin: return bDirVarNumVols=%d\n", pr.NumVols);
break;
}
case bDirVarPool:
- *((char**)value) = jcr->impl->res.pool->resource_name_;
+ *((char**)value) = jcr->dir_impl->res.pool->resource_name_;
Dmsg1(debuglevel, "dir-plugin: return bDirVarPool=%s\n",
NPRT(*((char**)value)));
break;
case bDirVarStorage:
- if (jcr->impl->res.write_storage) {
- *((char**)value) = jcr->impl->res.write_storage->resource_name_;
- } else if (jcr->impl->res.read_storage) {
- *((char**)value) = jcr->impl->res.read_storage->resource_name_;
+ if (jcr->dir_impl->res.write_storage) {
+ *((char**)value) = jcr->dir_impl->res.write_storage->resource_name_;
+ } else if (jcr->dir_impl->res.read_storage) {
+ *((char**)value) = jcr->dir_impl->res.read_storage->resource_name_;
} else {
*((char**)value) = NULL;
retval = bRC_Error;
@@ -605,8 +606,8 @@ static bRC bareosGetValue(PluginContext* ctx, brDirVariable var, void* value)
NPRT(*((char**)value)));
break;
case bDirVarWriteStorage:
- if (jcr->impl->res.write_storage) {
- *((char**)value) = jcr->impl->res.write_storage->resource_name_;
+ if (jcr->dir_impl->res.write_storage) {
+ *((char**)value) = jcr->dir_impl->res.write_storage->resource_name_;
} else {
*((char**)value) = NULL;
retval = bRC_Error;
@@ -615,8 +616,8 @@ static bRC bareosGetValue(PluginContext* ctx, brDirVariable var, void* value)
NPRT(*((char**)value)));
break;
case bDirVarReadStorage:
- if (jcr->impl->res.read_storage) {
- *((char**)value) = jcr->impl->res.read_storage->resource_name_;
+ if (jcr->dir_impl->res.read_storage) {
+ *((char**)value) = jcr->dir_impl->res.read_storage->resource_name_;
} else {
*((char**)value) = NULL;
retval = bRC_Error;
@@ -625,15 +626,15 @@ static bRC bareosGetValue(PluginContext* ctx, brDirVariable var, void* value)
NPRT(*((char**)value)));
break;
case bDirVarCatalog:
- *((char**)value) = jcr->impl->res.catalog->resource_name_;
+ *((char**)value) = jcr->dir_impl->res.catalog->resource_name_;
Dmsg1(debuglevel, "dir-plugin: return bDirVarCatalog=%s\n",
NPRT(*((char**)value)));
break;
case bDirVarMediaType:
- if (jcr->impl->res.write_storage) {
- *((char**)value) = jcr->impl->res.write_storage->media_type;
- } else if (jcr->impl->res.read_storage) {
- *((char**)value) = jcr->impl->res.read_storage->media_type;
+ if (jcr->dir_impl->res.write_storage) {
+ *((char**)value) = jcr->dir_impl->res.write_storage->media_type;
+ } else if (jcr->dir_impl->res.read_storage) {
+ *((char**)value) = jcr->dir_impl->res.read_storage->media_type;
} else {
*((char**)value) = NULL;
retval = bRC_Error;
@@ -642,9 +643,9 @@ static bRC bareosGetValue(PluginContext* ctx, brDirVariable var, void* value)
NPRT(*((char**)value)));
break;
case bDirVarJobStatus:
- *((int*)value) = jcr->JobStatus;
+ *((int*)value) = jcr->getJobStatus();
Dmsg1(debuglevel, "dir-plugin: return bDirVarJobStatus=%c\n",
- jcr->JobStatus);
+ jcr->getJobStatus());
break;
case bDirVarPriority:
*((int*)value) = jcr->JobPriority;
@@ -670,24 +671,24 @@ static bRC bareosGetValue(PluginContext* ctx, brDirVariable var, void* value)
jcr->JobFiles);
break;
case bDirVarSDJobFiles:
- *((int*)value) = jcr->impl->SDJobFiles;
+ *((int*)value) = jcr->dir_impl->SDJobFiles;
Dmsg1(debuglevel, "dir-plugin: return bDirVarSDFiles=%d\n",
- jcr->impl->SDJobFiles);
+ jcr->dir_impl->SDJobFiles);
break;
case bDirVarSDErrors:
- *((int*)value) = jcr->impl->SDErrors;
+ *((int*)value) = jcr->dir_impl->SDErrors;
Dmsg1(debuglevel, "dir-plugin: return bDirVarSDErrors=%d\n",
- jcr->impl->SDErrors);
+ jcr->dir_impl->SDErrors);
break;
case bDirVarFDJobStatus:
- *((int*)value) = jcr->impl->FDJobStatus;
+ *((int*)value) = jcr->dir_impl->FDJobStatus;
Dmsg1(debuglevel, "dir-plugin: return bDirVarFDJobStatus=%c\n",
- jcr->impl->FDJobStatus);
+ jcr->dir_impl->FDJobStatus.load());
break;
case bDirVarSDJobStatus:
- *((int*)value) = jcr->impl->SDJobStatus;
+ *((int*)value) = jcr->dir_impl->SDJobStatus;
Dmsg1(debuglevel, "dir-plugin: return bDirVarSDJobStatus=%c\n",
- jcr->impl->SDJobStatus);
+ jcr->dir_impl->SDJobStatus.load());
break;
case bDirVarLastRate:
*((int*)value) = jcr->LastRate;
diff --git a/core/src/dird/dird_conf.cc b/core/src/dird/dird_conf.cc
index fb206c5ec..9f7192098 100644
--- a/core/src/dird/dird_conf.cc
+++ b/core/src/dird/dird_conf.cc
@@ -49,7 +49,7 @@
#include "dird.h"
#include "dird/inc_conf.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "include/auth_protocol_types.h"
#include "include/auth_types.h"
#include "include/migration_selection_types.h"
@@ -3139,25 +3139,29 @@ extern "C" char* job_code_callback_director(JobControlRecord* jcr,
switch (param[0]) {
case 'f':
- if (jcr->impl->res.fileset) {
- return jcr->impl->res.fileset->resource_name_;
+ if (jcr->dir_impl->res.fileset) {
+ return jcr->dir_impl->res.fileset->resource_name_;
}
break;
case 'h':
- if (jcr->impl->res.client) { return jcr->impl->res.client->address; }
+ if (jcr->dir_impl->res.client) {
+ return jcr->dir_impl->res.client->address;
+ }
break;
case 'p':
- if (jcr->impl->res.pool) { return jcr->impl->res.pool->resource_name_; }
+ if (jcr->dir_impl->res.pool) {
+ return jcr->dir_impl->res.pool->resource_name_;
+ }
break;
case 'w':
- if (jcr->impl->res.write_storage) {
- return jcr->impl->res.write_storage->resource_name_;
+ if (jcr->dir_impl->res.write_storage) {
+ return jcr->dir_impl->res.write_storage->resource_name_;
}
break;
case 'x':
- return jcr->impl->spool_data ? yes : no;
+ return jcr->dir_impl->spool_data ? yes : no;
case 'C':
- return jcr->impl->cloned ? yes : no;
+ return jcr->dir_impl->cloned ? yes : no;
case 'D':
return my_name;
case 'V':
@@ -3166,7 +3170,7 @@ extern "C" char* job_code_callback_director(JobControlRecord* jcr,
* If this is a migration/copy we need the volume name from the
* mig_jcr.
*/
- if (jcr->impl->mig_jcr) { jcr = jcr->impl->mig_jcr; }
+ if (jcr->dir_impl->mig_jcr) { jcr = jcr->dir_impl->mig_jcr; }
if (jcr->VolumeName) {
return jcr->VolumeName;
diff --git a/core/src/dird/dird_conf.h b/core/src/dird/dird_conf.h
index 71316258c..93d161e12 100644
--- a/core/src/dird/dird_conf.h
+++ b/core/src/dird/dird_conf.h
@@ -210,7 +210,8 @@ class ProfileResource : public BareosResource {
struct UserAcl {
BareosResource* corresponding_resource = nullptr;
alist<const char*>* ACL_lists[Num_ACL] = {0}; /**< Pointers to ACLs */
- alist<const char*>* profiles = nullptr; /**< Pointers to profile resources */
+ alist<ProfileResource*>* profiles
+ = nullptr; /**< Pointers to profile resources */
};
// Console Resource
@@ -340,7 +341,7 @@ class StorageResource
char* media_type = nullptr; /**< Media Type provided by this Storage */
char* ndmp_changer_device = nullptr; /**< If DIR controls storage directly
(NDMP_NATIVE) changer device used */
- alist<const char*>* device
+ alist<DeviceResource*>* device
= nullptr; /**< Alternate devices for this Storage */
int32_t MaxConcurrentJobs = 0; /**< Maximum concurrent jobs */
int32_t MaxConcurrentReadJobs = 0; /**< Maximum concurrent jobs reading */
@@ -475,7 +476,7 @@ class JobResource : public BareosResource {
alist<const char*>* FdPluginOptions = nullptr; /**< Generic FD plugin options used by this Job */
alist<const char*>* SdPluginOptions = nullptr; /**< Generic SD plugin options used by this Job */
alist<const char*>* DirPluginOptions = nullptr; /**< Generic DIR plugin options used by this Job */
- alist<const char*>* base = nullptr; /**< Base jobs */
+ alist<JobResource*>* base = nullptr; /**< Base jobs */
bool allow_mixed_priority = false; /**< Allow jobs with higher priority concurrently with this */
bool where_use_regexp = false; /**< true if RestoreWhere is a BareosRegex */
diff --git a/core/src/dird/jcr_private.h b/core/src/dird/director_jcr_impl.h
index 77511686e..d3f7fe5e5 100644
--- a/core/src/dird/jcr_private.h
+++ b/core/src/dird/director_jcr_impl.h
@@ -21,8 +21,8 @@
02110-1301, USA.
*/
-#ifndef BAREOS_DIRD_JCR_PRIVATE_H_
-#define BAREOS_DIRD_JCR_PRIVATE_H_
+#ifndef BAREOS_DIRD_DIRECTOR_JCR_IMPL_H_
+#define BAREOS_DIRD_DIRECTOR_JCR_IMPL_H_
#include "cats/cats.h"
#include "dird/client_connection_handshake_mode.h"
@@ -45,18 +45,20 @@ namespace storagedaemon {
struct BootStrapRecord;
} // namespace storagedaemon
-#define JobWaiting(jcr) \
- (jcr->job_started \
- && (jcr->JobStatus == JS_WaitFD || jcr->JobStatus == JS_WaitSD \
- || jcr->JobStatus == JS_WaitMedia || jcr->JobStatus == JS_WaitMount \
- || jcr->JobStatus == JS_WaitStoreRes || jcr->JobStatus == JS_WaitJobRes \
- || jcr->JobStatus == JS_WaitClientRes \
- || jcr->JobStatus == JS_WaitMaxJobs \
- || jcr->JobStatus == JS_WaitPriority \
- || jcr->impl->SDJobStatus == JS_WaitMedia \
- || jcr->impl->SDJobStatus == JS_WaitMount \
- || jcr->impl->SDJobStatus == JS_WaitDevice \
- || jcr->impl->SDJobStatus == JS_WaitMaxJobs))
+#define JobWaiting(jcr) \
+ (jcr->job_started \
+ && (jcr->getJobStatus() == JS_WaitFD || jcr->getJobStatus() == JS_WaitSD \
+ || jcr->getJobStatus() == JS_WaitMedia \
+ || jcr->getJobStatus() == JS_WaitMount \
+ || jcr->getJobStatus() == JS_WaitStoreRes \
+ || jcr->getJobStatus() == JS_WaitJobRes \
+ || jcr->getJobStatus() == JS_WaitClientRes \
+ || jcr->getJobStatus() == JS_WaitMaxJobs \
+ || jcr->getJobStatus() == JS_WaitPriority \
+ || jcr->dir_impl->SDJobStatus == JS_WaitMedia \
+ || jcr->dir_impl->SDJobStatus == JS_WaitMount \
+ || jcr->dir_impl->SDJobStatus == JS_WaitDevice \
+ || jcr->dir_impl->SDJobStatus == JS_WaitMaxJobs))
/* clang-format off */
struct Resources {
@@ -94,8 +96,8 @@ struct Resources {
bool run_next_pool_override{}; /**< Next pool override was given on run cmdline */
};
-struct JobControlRecordPrivate {
- JobControlRecordPrivate( std::shared_ptr<ConfigResourcesContainer> configuration_resources_container) : job_config_resources_container_(configuration_resources_container) {
+struct DirectorJcrImpl {
+ DirectorJcrImpl( std::shared_ptr<ConfigResourcesContainer> configuration_resources_container) : job_config_resources_container_(configuration_resources_container) {
RestoreJobId = 0; MigrateJobId = 0; VerifyJobId = 0;
}
std::shared_ptr<ConfigResourcesContainer> job_config_resources_container_;
@@ -111,8 +113,8 @@ struct JobControlRecordPrivate {
uint32_t SDJobFiles{}; /**< Number of files written, this job */
uint64_t SDJobBytes{}; /**< Number of bytes processed this job */
uint32_t SDErrors{}; /**< Number of non-fatal errors */
- volatile int32_t SDJobStatus{}; /**< Storage Job Status */
- volatile int32_t FDJobStatus{}; /**< File daemon Job Status */
+ std::atomic<int32_t> SDJobStatus{}; /**< Storage Job Status */
+ std::atomic<int32_t> FDJobStatus{}; /**< File daemon Job Status */
uint32_t DumpLevel{}; /**< Dump level when doing a NDMP backup */
uint32_t ExpectedFiles{}; /**< Expected restore files */
uint32_t MediaId{}; /**< DB record IDs associated with this job */
@@ -139,7 +141,7 @@ struct JobControlRecordPrivate {
int32_t reschedule_count{}; /**< Number of times rescheduled */
int32_t FDVersion{}; /**< File daemon version number */
int64_t spool_size{}; /**< Spool size for this job */
- volatile bool sd_msg_thread_done{}; /**< Set when Storage message thread done */
+ std::atomic<bool> sd_msg_thread_done{}; /**< Set when Storage message thread done */
bool IgnoreDuplicateJobChecking{}; /**< Set in migration jobs */
bool IgnoreLevelPoolOverrides{}; /**< Set if a cmdline pool was specified */
bool IgnoreClientConcurrency{}; /**< Set in migration jobs */
@@ -167,4 +169,4 @@ struct JobControlRecordPrivate {
};
/* clang-format on */
-#endif // BAREOS_DIRD_JCR_PRIVATE_H_
+#endif // BAREOS_DIRD_DIRECTOR_JCR_IMPL_H_
diff --git a/core/src/dird/expand.cc b/core/src/dird/expand.cc
index a89f3f520..5a4cdea00 100644
--- a/core/src/dird/expand.cc
+++ b/core/src/dird/expand.cc
@@ -30,7 +30,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "lib/parse_conf.h"
#include "lib/util.h"
#include "lib/output_formatter.h"
@@ -92,7 +92,7 @@ static int job_item(JobControlRecord* jcr,
switch (code) {
case 1: /* Job */
- str = jcr->impl->res.job->resource_name_;
+ str = jcr->dir_impl->res.job->resource_name_;
break;
case 2: /* Director's name */
str = my_name;
@@ -108,31 +108,31 @@ static int job_item(JobControlRecord* jcr,
str = buf;
break;
case 6: /* Client */
- str = jcr->impl->res.client->resource_name_;
+ str = jcr->dir_impl->res.client->resource_name_;
if (!str) { str = " "; }
break;
case 7: /* NumVols */
- Bsnprintf(buf, sizeof(buf), "%d", jcr->impl->NumVols);
+ Bsnprintf(buf, sizeof(buf), "%d", jcr->dir_impl->NumVols);
str = buf;
break;
case 8: /* Pool */
- str = jcr->impl->res.pool->resource_name_;
+ str = jcr->dir_impl->res.pool->resource_name_;
break;
case 9: /* Storage */
- if (jcr->impl->res.write_storage) {
- str = jcr->impl->res.write_storage->resource_name_;
+ if (jcr->dir_impl->res.write_storage) {
+ str = jcr->dir_impl->res.write_storage->resource_name_;
} else {
- str = jcr->impl->res.read_storage->resource_name_;
+ str = jcr->dir_impl->res.read_storage->resource_name_;
}
break;
case 10: /* Catalog */
- str = jcr->impl->res.catalog->resource_name_;
+ str = jcr->dir_impl->res.catalog->resource_name_;
break;
case 11: /* MediaType */
- if (jcr->impl->res.write_storage) {
- str = jcr->impl->res.write_storage->media_type;
+ if (jcr->dir_impl->res.write_storage) {
+ str = jcr->dir_impl->res.write_storage->media_type;
} else {
- str = jcr->impl->res.read_storage->media_type;
+ str = jcr->dir_impl->res.read_storage->media_type;
}
break;
case 12: /* JobName */
diff --git a/core/src/dird/fd_cmds.cc b/core/src/dird/fd_cmds.cc
index a8d65cc78..1fc1c9ee4 100644
--- a/core/src/dird/fd_cmds.cc
+++ b/core/src/dird/fd_cmds.cc
@@ -35,12 +35,12 @@
#include "cats/cats.h"
#include "dird.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "findlib/find.h"
#include "dird/authenticate.h"
#include "dird/fd_cmds.h"
#include "dird/getmsg.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/msgchan.h"
#include "dird/run_on_incoming_connect_interval.h"
#include "dird/scheduler.h"
@@ -128,24 +128,24 @@ static bool connect_outbound_to_file_daemon(JobControlRecord* jcr,
if (!IsConnectingToClientAllowed(jcr)) {
Dmsg1(120, "Connection to client \"%s\" is not allowed.\n",
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
return false;
}
fd = new BareosSocketTCP;
- heart_beat = get_heartbeat_interval(jcr->impl->res.client);
+ heart_beat = get_heartbeat_interval(jcr->dir_impl->res.client);
char name[MAX_NAME_LENGTH + 100];
bstrncpy(name, _("Client: "), sizeof(name));
- bstrncat(name, jcr->impl->res.client->resource_name_, sizeof(name));
+ bstrncat(name, jcr->dir_impl->res.client->resource_name_, sizeof(name));
fd->SetSourceAddress(me->DIRsrc_addr);
if (!fd->connect(jcr, retry_interval, max_retry_time, heart_beat, name,
- jcr->impl->res.client->address, NULL,
- jcr->impl->res.client->FDport, verbose)) {
+ jcr->dir_impl->res.client->address, NULL,
+ jcr->dir_impl->res.client->FDport, verbose)) {
delete fd;
fd = NULL;
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
} else {
jcr->file_bsock = fd;
jcr->authenticated = false;
@@ -160,9 +160,9 @@ static void OutputMessageForConnectionTry(JobControlRecord* jcr, UaContext* ua)
{
std::string m;
- if (jcr->impl->res.client->connection_successful_handshake_
+ if (jcr->dir_impl->res.client->connection_successful_handshake_
== ClientConnectionHandshakeMode::kUndefined
- || jcr->impl->res.client->connection_successful_handshake_
+ || jcr->dir_impl->res.client->connection_successful_handshake_
== ClientConnectionHandshakeMode::kFailed) {
m = "Probing client protocol... (result will be saved until config reload)";
} else {
@@ -190,11 +190,11 @@ static void SendInfoChosenCipher(JobControlRecord* jcr, UaContext* ua)
static void SendInfoSuccess(JobControlRecord* jcr, UaContext* ua)
{
std::string m;
- if (jcr->impl->res.client->connection_successful_handshake_
+ if (jcr->dir_impl->res.client->connection_successful_handshake_
== ClientConnectionHandshakeMode::kUndefined) {
- m += "\r\v";
+ m = "\r\v";
}
- switch (jcr->impl->connection_handshake_try_) {
+ switch (jcr->dir_impl->connection_handshake_try_) {
case ClientConnectionHandshakeMode::kTlsFirst:
m += " Handshake: Immediate TLS,";
break;
@@ -227,7 +227,7 @@ bool ConnectToFileDaemon(JobControlRecord* jcr,
{
if (!IsConnectingToClientAllowed(jcr) && !IsConnectFromClientAllowed(jcr)) {
Emsg1(M_WARNING, 0, _("Connecting to %s is not allowed.\n"),
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
return false;
}
bool success = false;
@@ -239,22 +239,22 @@ bool ConnectToFileDaemon(JobControlRecord* jcr,
* in case there is a client that cannot do Tls immediately then
* fall back to cleartext md5-handshake */
OutputMessageForConnectionTry(jcr, ua);
- if (jcr->impl->res.client->connection_successful_handshake_
+ if (jcr->dir_impl->res.client->connection_successful_handshake_
== ClientConnectionHandshakeMode::kUndefined
- || jcr->impl->res.client->connection_successful_handshake_
+ || jcr->dir_impl->res.client->connection_successful_handshake_
== ClientConnectionHandshakeMode::kFailed) {
- if (jcr->impl->res.client->IsTlsConfigured()) {
- jcr->impl->connection_handshake_try_
+ if (jcr->dir_impl->res.client->IsTlsConfigured()) {
+ jcr->dir_impl->connection_handshake_try_
= ClientConnectionHandshakeMode::kTlsFirst;
} else {
- jcr->impl->connection_handshake_try_
+ jcr->dir_impl->connection_handshake_try_
= ClientConnectionHandshakeMode::kCleartextFirst;
}
jcr->is_passive_client_connection_probing = true;
} else {
/* if there is a stored mode from a previous connection then use this */
- jcr->impl->connection_handshake_try_
- = jcr->impl->res.client->connection_successful_handshake_;
+ jcr->dir_impl->connection_handshake_try_
+ = jcr->dir_impl->res.client->connection_successful_handshake_;
jcr->is_passive_client_connection_probing = false;
}
@@ -274,32 +274,32 @@ bool ConnectToFileDaemon(JobControlRecord* jcr,
}
if (jcr->file_bsock) {
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
if (AuthenticateWithFileDaemon(jcr)) {
success = true;
SendInfoSuccess(jcr, ua);
SendInfoChosenCipher(jcr, ua);
jcr->is_passive_client_connection_probing = false;
- jcr->impl->res.client->connection_successful_handshake_
- = jcr->impl->connection_handshake_try_;
+ jcr->dir_impl->res.client->connection_successful_handshake_
+ = jcr->dir_impl->connection_handshake_try_;
} else {
/* authentication failed due to
* - tls mismatch or
* - if an old client cannot do tls- before md5-handshake
* */
- switch (jcr->impl->connection_handshake_try_) {
+ switch (jcr->dir_impl->connection_handshake_try_) {
case ClientConnectionHandshakeMode::kTlsFirst:
if (jcr->file_bsock) {
jcr->file_bsock->close();
delete jcr->file_bsock;
jcr->file_bsock = nullptr;
}
- jcr->resetJobStatus(JS_Running);
- jcr->impl->connection_handshake_try_
+ jcr->setJobStatus(JS_Running);
+ jcr->dir_impl->connection_handshake_try_
= ClientConnectionHandshakeMode::kCleartextFirst;
break;
case ClientConnectionHandshakeMode::kCleartextFirst:
- jcr->impl->connection_handshake_try_
+ jcr->dir_impl->connection_handshake_try_
= ClientConnectionHandshakeMode::kFailed;
break;
case ClientConnectionHandshakeMode::kFailed:
@@ -310,14 +310,14 @@ bool ConnectToFileDaemon(JobControlRecord* jcr,
}
} else {
Jmsg(jcr, M_FATAL, 0, "\nFailed to connect to client \"%s\".\n",
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
}
connect_tries--;
} while (!tcp_connect_failed && connect_tries && !success
- && jcr->impl->connection_handshake_try_
+ && jcr->dir_impl->connection_handshake_try_
!= ClientConnectionHandshakeMode::kFailed);
- if (!success) { jcr->setJobStatus(JS_ErrorTerminated); }
+ if (!success) { jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated); }
return success;
}
@@ -328,7 +328,7 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr)
if (jcr->sd_auth_key == NULL) { jcr->sd_auth_key = strdup("dummy"); }
- if (jcr->impl->res.client->connection_successful_handshake_
+ if (jcr->dir_impl->res.client->connection_successful_handshake_
== ClientConnectionHandshakeMode::kTlsFirst) {
/* client protocol onwards Bareos 18.2 */
TlsPolicy tls_policy = kBnetTlsUnknown;
@@ -341,13 +341,13 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr)
break;
default:
StorageResource* storage = nullptr;
- if (jcr->impl->res.write_storage) {
- storage = jcr->impl->res.write_storage;
- } else if (jcr->impl->res.read_storage) {
- storage = jcr->impl->res.read_storage;
+ if (jcr->dir_impl->res.write_storage) {
+ storage = jcr->dir_impl->res.write_storage;
+ } else if (jcr->dir_impl->res.read_storage) {
+ storage = jcr->dir_impl->res.read_storage;
} else {
Jmsg(jcr, M_FATAL, 0, _("No read or write storage defined\n"));
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return 0;
}
if (storage) {
@@ -360,16 +360,16 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr)
fd->fsend(jobcmdssl, edit_int64(jcr->JobId, ed1), jcr->Job,
jcr->VolSessionId, jcr->VolSessionTime, jcr->sd_auth_key,
tls_policy);
- } else { /* jcr->impl_->res.client->connection_successful_handshake_ !=
+ } else { /* jcr->dir_impl_->res.client->connection_successful_handshake_ !=
ClientConnectionHandshakeMode::kTlsFirst */
/* client protocol before Bareos 18.2 */
char ed1[30];
fd->fsend(jobcmd, edit_int64(jcr->JobId, ed1), jcr->Job, jcr->VolSessionId,
jcr->VolSessionTime, jcr->sd_auth_key);
- } /* if (jcr->impl_->res.client->connection_successful_handshake_ ==
+ } /* if (jcr->dir_impl_->res.client->connection_successful_handshake_ ==
ClientConnectionHandshakeMode::kTlsFirst) */
- if (!jcr->impl->keep_sd_auth_key && !bstrcmp(jcr->sd_auth_key, "dummy")) {
+ if (!jcr->dir_impl->keep_sd_auth_key && !bstrcmp(jcr->sd_auth_key, "dummy")) {
memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key));
}
@@ -378,16 +378,17 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr)
Dmsg1(110, "<filed: %s", fd->msg);
if (!bstrncmp(fd->msg, OKjob, strlen(OKjob))) {
Jmsg(jcr, M_FATAL, 0, _("File daemon \"%s\" rejected Job command: %s\n"),
- jcr->impl->res.client->resource_name_, fd->msg);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->dir_impl->res.client->resource_name_, fd->msg);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return 0;
} else if (jcr->db) {
ClientDbRecord cr;
- bstrncpy(cr.Name, jcr->impl->res.client->resource_name_, sizeof(cr.Name));
- cr.AutoPrune = jcr->impl->res.client->AutoPrune;
- cr.FileRetention = jcr->impl->res.client->FileRetention;
- cr.JobRetention = jcr->impl->res.client->JobRetention;
+ bstrncpy(cr.Name, jcr->dir_impl->res.client->resource_name_,
+ sizeof(cr.Name));
+ cr.AutoPrune = jcr->dir_impl->res.client->AutoPrune;
+ cr.FileRetention = jcr->dir_impl->res.client->FileRetention;
+ cr.JobRetention = jcr->dir_impl->res.client->JobRetention;
bstrncpy(cr.Uname, fd->msg + strlen(OKjob) + 1, sizeof(cr.Uname));
if (!jcr->db->UpdateClientRecord(jcr, &cr)) {
Jmsg(jcr, M_WARNING, 0, _("Error updating Client record. ERR=%s\n"),
@@ -397,7 +398,7 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr)
} else {
Jmsg(jcr, M_FATAL, 0, _("FD gave bad response to JobId command: %s\n"),
BnetStrerror(fd));
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return 0;
}
@@ -412,8 +413,8 @@ bool SendPreviousRestoreObjects(JobControlRecord* jcr)
switch (JobLevel) {
case L_DIFFERENTIAL:
case L_INCREMENTAL:
- if (jcr->impl->previous_jr.JobId > 0) {
- if (!SendRestoreObjects(jcr, jcr->impl->previous_jr.JobId, false)) {
+ if (jcr->dir_impl->previous_jr.JobId > 0) {
+ if (!SendRestoreObjects(jcr, jcr->dir_impl->previous_jr.JobId, false)) {
return false;
}
}
@@ -429,7 +430,7 @@ bool SendBwlimitToFd(JobControlRecord* jcr, const char* Job)
{
BareosSocket* fd = jcr->file_bsock;
- if (jcr->impl->FDVersion >= FD_VERSION_4) {
+ if (jcr->dir_impl->FDVersion >= FD_VERSION_4) {
fd->fsend(bandwidthcmd, jcr->max_bandwidth, Job);
if (!response(jcr, fd, OKBandwidth, "Bandwidth", DISPLAY_ERROR)) {
jcr->max_bandwidth = 0; /* can't set bandwidth limit */
@@ -445,29 +446,29 @@ bool SendSecureEraseReqToFd(JobControlRecord* jcr)
int32_t n;
BareosSocket* fd = jcr->file_bsock;
- if (!jcr->impl->FDSecureEraseCmd) {
- jcr->impl->FDSecureEraseCmd = GetPoolMemory(PM_NAME);
+ if (!jcr->dir_impl->FDSecureEraseCmd) {
+ jcr->dir_impl->FDSecureEraseCmd = GetPoolMemory(PM_NAME);
}
- if (jcr->impl->FDVersion > FD_VERSION_53) {
+ if (jcr->dir_impl->FDVersion > FD_VERSION_53) {
fd->fsend(getSecureEraseCmd);
while ((n = BgetDirmsg(fd)) >= 0) {
- jcr->impl->FDSecureEraseCmd = CheckPoolMemorySize(
- jcr->impl->FDSecureEraseCmd, fd->message_length);
- if (sscanf(fd->msg, OKgetSecureEraseCmd, jcr->impl->FDSecureEraseCmd)
+ jcr->dir_impl->FDSecureEraseCmd = CheckPoolMemorySize(
+ jcr->dir_impl->FDSecureEraseCmd, fd->message_length);
+ if (sscanf(fd->msg, OKgetSecureEraseCmd, jcr->dir_impl->FDSecureEraseCmd)
== 1) {
Dmsg1(400, "Got FD Secure Erase Cmd: %s\n",
- jcr->impl->FDSecureEraseCmd);
+ jcr->dir_impl->FDSecureEraseCmd);
break;
} else {
Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Secure Erase Cmd: %s\n"),
fd->msg);
- PmStrcpy(jcr->impl->FDSecureEraseCmd, "*None*");
+ PmStrcpy(jcr->dir_impl->FDSecureEraseCmd, "*None*");
return false;
}
}
} else {
- PmStrcpy(jcr->impl->FDSecureEraseCmd, "*None*");
+ PmStrcpy(jcr->dir_impl->FDSecureEraseCmd, "*None*");
}
return true;
@@ -481,7 +482,7 @@ static void SendSinceTime(JobControlRecord* jcr)
stime = StrToUtime(jcr->starttime_string);
fd->fsend(levelcmd, "", NT_("since_utime "), edit_uint64(stime, ed1), 0,
- NT_("prev_job="), jcr->impl->PrevJob);
+ NT_("prev_job="), jcr->dir_impl->PrevJob);
while (BgetDirmsg(fd) >= 0) { /* allow him to poll us to sync clocks */
Jmsg(jcr, M_INFO, 0, "%s\n", fd->msg);
@@ -538,9 +539,9 @@ bool SendLevelCommand(JobControlRecord* jcr)
// Send either an Included or an Excluded list to FD
static bool SendFileset(JobControlRecord* jcr)
{
- FilesetResource* fileset = jcr->impl->res.fileset;
+ FilesetResource* fileset = jcr->dir_impl->res.fileset;
BareosSocket* fd = jcr->file_bsock;
- StorageResource* store = jcr->impl->res.write_storage;
+ StorageResource* store = jcr->dir_impl->res.write_storage;
int num;
bool include = true;
@@ -690,7 +691,7 @@ static bool SendFileset(JobControlRecord* jcr)
return true;
bail_out:
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -775,8 +776,9 @@ static bool SendListItem(JobControlRecord* jcr,
bool SendIncludeList(JobControlRecord* jcr)
{
BareosSocket* fd = jcr->file_bsock;
- if (jcr->impl->res.fileset->new_include) {
- fd->fsend(filesetcmd, jcr->impl->res.fileset->enable_vss ? " vss=1" : "");
+ if (jcr->dir_impl->res.fileset->new_include) {
+ fd->fsend(filesetcmd,
+ jcr->dir_impl->res.fileset->enable_vss ? " vss=1" : "");
return SendFileset(jcr);
}
return true;
@@ -820,18 +822,18 @@ int SendRunscriptsCommands(JobControlRecord* jcr)
bool has_before_jobs = false;
// See if there are any runscripts that need to be ran on the client.
- if (!HaveClientRunscripts(jcr->impl->res.job->RunScripts)) { return 1; }
+ if (!HaveClientRunscripts(jcr->dir_impl->res.job->RunScripts)) { return 1; }
Dmsg0(120, "dird: sending runscripts to fd\n");
msg = GetPoolMemory(PM_FNAME);
ehost = GetPoolMemory(PM_FNAME);
- foreach_alist (cmd, jcr->impl->res.job->RunScripts) {
+ foreach_alist (cmd, jcr->dir_impl->res.job->RunScripts) {
if (!cmd->target.empty()) {
ehost = edit_job_codes(jcr, ehost, cmd->target.c_str(), "");
Dmsg2(200, "dird: runscript %s -> %s\n", cmd->target.c_str(), ehost);
- if (bstrcmp(ehost, jcr->impl->res.client->resource_name_)) {
+ if (bstrcmp(ehost, jcr->dir_impl->res.client->resource_name_)) {
PmStrcpy(msg, cmd->command.c_str());
BashSpaces(msg);
@@ -897,15 +899,15 @@ static int RestoreObjectHandler(void* ctx, int, char** row)
if (jcr->IsJobCanceled()) { return 1; }
// Old File Daemon doesn't handle restore objects
- if (jcr->impl->FDVersion < FD_VERSION_3) {
+ if (jcr->dir_impl->FDVersion < FD_VERSION_3) {
Jmsg(jcr, M_WARNING, 0,
_("Client \"%s\" may not be used to restore "
"this job. Please upgrade your client.\n"),
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
return 1;
}
- if (jcr->impl->FDVersion
+ if (jcr->dir_impl->FDVersion
< FD_VERSION_5) { /* Old version without PluginName */
fd->fsend("restoreobject JobId=%s %s,%s,%s,%s,%s,%s\n", row[0], row[1],
row[2], row[3], row[4], row[5], row[6]);
@@ -949,9 +951,9 @@ bool SendPluginOptions(JobControlRecord* jcr)
const char* plugin_options;
POOLMEM* msg;
- if (jcr->impl->plugin_options) {
+ if (jcr->dir_impl->plugin_options) {
msg = GetPoolMemory(PM_FNAME);
- PmStrcpy(msg, jcr->impl->plugin_options);
+ PmStrcpy(msg, jcr->dir_impl->plugin_options);
BashSpaces(msg);
fd->fsend(pluginoptionscmd, msg);
@@ -962,11 +964,11 @@ bool SendPluginOptions(JobControlRecord* jcr)
return false;
}
}
- if (jcr->impl->res.job && jcr->impl->res.job->FdPluginOptions
- && jcr->impl->res.job->FdPluginOptions->size()) {
+ if (jcr->dir_impl->res.job && jcr->dir_impl->res.job->FdPluginOptions
+ && jcr->dir_impl->res.job->FdPluginOptions->size()) {
Dmsg2(200, "dird: sendpluginoptions found FdPluginOptions in res.job\n");
foreach_alist_index (i, plugin_options,
- jcr->impl->res.job->FdPluginOptions) {
+ jcr->dir_impl->res.job->FdPluginOptions) {
PmStrcpy(cur_plugin_options, plugin_options);
BashSpaces(cur_plugin_options.c_str());
@@ -1063,8 +1065,8 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr)
PoolMem digest(PM_MESSAGE);
fd = jcr->file_bsock;
- jcr->impl->jr.FirstIndex = 1;
- jcr->impl->FileIndex = 0;
+ jcr->dir_impl->jr.FirstIndex = 1;
+ jcr->dir_impl->FileIndex = 0;
// Start transaction allocates jcr->attr and jcr->ar if needed
jcr->db->StartTransaction(jcr); /* start transaction if not already open */
@@ -1086,7 +1088,7 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr)
_("<filed: bad attributes, expected 3 fields got %d\n"
"message_length=%d msg=%s\n"),
len, fd->message_length, fd->msg);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return 0;
}
p = fd->msg;
@@ -1111,15 +1113,15 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr)
}
// Any cached attr is flushed so we can reuse jcr->attr and jcr->ar
- fn = jcr->impl->fname
- = CheckPoolMemorySize(jcr->impl->fname, fd->message_length);
+ fn = jcr->dir_impl->fname
+ = CheckPoolMemorySize(jcr->dir_impl->fname, fd->message_length);
while (*p != 0) { *fn++ = *p++; /* copy filename */ }
*fn = *p++; /* term filename and point p to attribs */
PmStrcpy(jcr->attr, p); /* save attributes */
jcr->JobFiles++;
- jcr->impl->FileIndex = file_index;
+ jcr->dir_impl->FileIndex = file_index;
ar->attr = jcr->attr;
- ar->fname = jcr->impl->fname;
+ ar->fname = jcr->dir_impl->fname;
ar->FileIndex = file_index;
ar->Stream = stream;
ar->link = NULL;
@@ -1131,7 +1133,8 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr)
ar->DeltaSeq = 0;
jcr->cached_attribute = true;
- Dmsg2(debuglevel, "dird<filed: stream=%d %s\n", stream, jcr->impl->fname);
+ Dmsg2(debuglevel, "dird<filed: stream=%d %s\n", stream,
+ jcr->dir_impl->fname);
Dmsg1(debuglevel, "dird<filed: attr=%s\n", ar->attr);
jcr->FileId = ar->FileId;
} else if (CryptoDigestStreamType(stream) != CRYPTO_DIGEST_NONE) {
@@ -1143,9 +1146,9 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr)
* it (or not) When we get a new STREAM_UNIX_ATTRIBUTES, we known that we
* can add file to the catalog At the end, we have to add the last file
*/
- if (jcr->impl->FileIndex != (uint32_t)file_index) {
+ if (jcr->dir_impl->FileIndex != (uint32_t)file_index) {
Jmsg3(jcr, M_ERROR, 0, _("%s index %d not same as attributes %d\n"),
- stream_to_ascii(stream), file_index, jcr->impl->FileIndex);
+ stream_to_ascii(stream), file_index, jcr->dir_impl->FileIndex);
continue;
}
@@ -1157,8 +1160,8 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr)
Dmsg4(debuglevel, "stream=%d DigestLen=%d Digest=%s type=%d\n", stream,
strlen(digest.c_str()), digest.c_str(), ar->DigestType);
}
- jcr->impl->jr.JobFiles = jcr->JobFiles = file_index;
- jcr->impl->jr.LastIndex = file_index;
+ jcr->dir_impl->jr.JobFiles = jcr->JobFiles = file_index;
+ jcr->dir_impl->jr.LastIndex = file_index;
}
if (IsBnetError(fd)) {
@@ -1178,7 +1181,7 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr)
jcr->cached_attribute = false;
}
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
return 1;
}
@@ -1188,7 +1191,7 @@ bool CancelFileDaemonJob(UaContext* ua, JobControlRecord* jcr)
{
BareosSocket* fd;
- ua->jcr->impl->res.client = jcr->impl->res.client;
+ ua->jcr->dir_impl->res.client = jcr->dir_impl->res.client;
if (!ConnectToFileDaemon(ua->jcr, 10, me->FDConnectTimeout, true, ua)) {
ua->ErrorMsg(_("\nFailed to connect to File daemon.\n"));
return false;
@@ -1212,7 +1215,7 @@ void DoNativeClientStatus(UaContext* ua, ClientResource* client, char* cmd)
BareosSocket* fd;
// Connect to File daemon
- ua->jcr->impl->res.client = client;
+ ua->jcr->dir_impl->res.client = client;
// Try to connect for 15 seconds
if (!ua->api) {
@@ -1255,7 +1258,7 @@ void DoClientResolve(UaContext* ua, ClientResource* client)
BareosSocket* fd;
// Connect to File daemon
- ua->jcr->impl->res.client = client;
+ ua->jcr->dir_impl->res.client = client;
// Try to connect for 15 seconds
if (!ua->api) {
diff --git a/core/src/dird/get_database_connection.cc b/core/src/dird/get_database_connection.cc
index 3d9cbf42c..2f978d75d 100644
--- a/core/src/dird/get_database_connection.cc
+++ b/core/src/dird/get_database_connection.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
- Copyright (C) 2019-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2019-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -25,7 +25,7 @@
#include "cats/sql_pooling.h"
#include "dird/dird_conf.h"
#include "dird/get_database_connection.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "include/jcr.h"
namespace directordaemon {
@@ -33,15 +33,16 @@ namespace directordaemon {
BareosDb* GetDatabaseConnection(JobControlRecord* jcr)
{
return DbSqlGetPooledConnection(
- jcr, jcr->impl->res.catalog->db_driver, jcr->impl->res.catalog->db_name,
- jcr->impl->res.catalog->db_user,
- jcr->impl->res.catalog->db_password.value,
- jcr->impl->res.catalog->db_address, jcr->impl->res.catalog->db_port,
- jcr->impl->res.catalog->db_socket,
- jcr->impl->res.catalog->mult_db_connections,
- jcr->impl->res.catalog->disable_batch_insert,
- jcr->impl->res.catalog->try_reconnect,
- jcr->impl->res.catalog->exit_on_fatal);
+ jcr, jcr->dir_impl->res.catalog->db_driver,
+ jcr->dir_impl->res.catalog->db_name, jcr->dir_impl->res.catalog->db_user,
+ jcr->dir_impl->res.catalog->db_password.value,
+ jcr->dir_impl->res.catalog->db_address,
+ jcr->dir_impl->res.catalog->db_port,
+ jcr->dir_impl->res.catalog->db_socket,
+ jcr->dir_impl->res.catalog->mult_db_connections,
+ jcr->dir_impl->res.catalog->disable_batch_insert,
+ jcr->dir_impl->res.catalog->try_reconnect,
+ jcr->dir_impl->res.catalog->exit_on_fatal);
}
} // namespace directordaemon
diff --git a/core/src/dird/getmsg.cc b/core/src/dird/getmsg.cc
index f4bfa8f96..0338b33a1 100644
--- a/core/src/dird/getmsg.cc
+++ b/core/src/dird/getmsg.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -43,7 +43,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/catreq.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/msgchan.h"
#include "lib/bnet.h"
#include "lib/edit.h"
@@ -81,15 +81,15 @@ static void SetJcrSdJobStatus(JobControlRecord* jcr, int SDJobStatus)
Dmsg0(800, "Setting wait_time\n");
jcr->wait_time = time(NULL);
}
- jcr->impl->SDJobStatus = SDJobStatus;
+ jcr->dir_impl->SDJobStatus = SDJobStatus;
// Some SD Job status setting are propagated to the controlling Job.
- switch (jcr->impl->SDJobStatus) {
+ switch (jcr->dir_impl->SDJobStatus) {
case JS_Incomplete:
- jcr->setJobStatus(JS_Incomplete);
+ jcr->setJobStatusWithPriorityCheck(JS_Incomplete);
break;
case JS_FatalError:
- jcr->setJobStatus(JS_FatalError);
+ jcr->setJobStatusWithPriorityCheck(JS_FatalError);
break;
default:
break;
diff --git a/core/src/dird/inc_conf.cc b/core/src/dird/inc_conf.cc
index 5a22a2380..e16101333 100644
--- a/core/src/dird/inc_conf.cc
+++ b/core/src/dird/inc_conf.cc
@@ -30,7 +30,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "findlib/match.h"
#include "lib/parse_conf.h"
#include "include/allow_deprecated.h"
@@ -300,9 +300,9 @@ void FindUsedCompressalgos(PoolMem* compressalgos, JobControlRecord* jcr)
FilesetResource* fs;
struct s_fs_opt* fs_opt;
- if (!jcr->impl->res.job || !jcr->impl->res.job->fileset) { return; }
+ if (!jcr->dir_impl->res.job || !jcr->dir_impl->res.job->fileset) { return; }
- fs = jcr->impl->res.job->fileset;
+ fs = jcr->dir_impl->res.job->fileset;
for (std::size_t i = 0; i < fs->include_items.size(); i++) {
inc = fs->include_items[i];
diff --git a/core/src/dird/jcr_util.cc b/core/src/dird/jcr_util.cc
index 53fbc11d0..8653b9e7e 100644
--- a/core/src/dird/jcr_util.cc
+++ b/core/src/dird/jcr_util.cc
@@ -20,7 +20,7 @@
*/
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "lib/parse_bsr.h"
#include "lib/parse_conf.h"
@@ -30,8 +30,7 @@ namespace directordaemon {
JobControlRecord* NewDirectorJcr(JCR_free_HANDLER* DirdFreeJcr)
{
JobControlRecord* jcr = new_jcr(DirdFreeJcr);
- jcr->impl
- = new JobControlRecordPrivate(my_config->config_resources_container_);
+ jcr->dir_impl = new DirectorJcrImpl(my_config->config_resources_container_);
Dmsg1(10, "NewDirectorJcr: configuration_resources_ is at %p %s\n",
my_config->config_resources_container_->configuration_resources_,
my_config->config_resources_container_->TimeStampAsString().c_str());
diff --git a/core/src/dird/jcr_util.h b/core/src/dird/jcr_util.h
index 83921b79f..32ba3ffb4 100644
--- a/core/src/dird/jcr_util.h
+++ b/core/src/dird/jcr_util.h
@@ -22,7 +22,7 @@
#ifndef BAREOS_DIRD_JCR_UTIL_H_
#define BAREOS_DIRD_JCR_UTIL_H_
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
namespace directordaemon {
diff --git a/core/src/dird/job.cc b/core/src/dird/job.cc
index ec9743b1b..43de1fb98 100644
--- a/core/src/dird/job.cc
+++ b/core/src/dird/job.cc
@@ -37,7 +37,7 @@
#include "dird/fd_cmds.h"
#include "dird/get_database_connection.h"
#include "dird/job.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/migration.h"
#include "dird/pthread_detach_if_not_detached.h"
#include "dird/restore.h"
@@ -144,23 +144,23 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output)
// See if we should suppress all output.
if (!suppress_output) {
- InitMsg(jcr, jcr->impl->res.messages, job_code_callback_director);
+ InitMsg(jcr, jcr->dir_impl->res.messages, job_code_callback_director);
} else {
jcr->suppress_output = true;
}
// Initialize termination condition variable
- if ((errstat = pthread_cond_init(&jcr->impl->term_wait, NULL)) != 0) {
+ if ((errstat = pthread_cond_init(&jcr->dir_impl->term_wait, NULL)) != 0) {
BErrNo be;
Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"),
be.bstrerror(errstat));
jcr->unlock();
goto bail_out;
}
- jcr->impl->term_wait_inited = true;
+ jcr->dir_impl->term_wait_inited = true;
// Initialize nextrun ready condition variable
- if ((errstat = pthread_cond_init(&jcr->impl->nextrun_ready, NULL)) != 0) {
+ if ((errstat = pthread_cond_init(&jcr->dir_impl->nextrun_ready, NULL)) != 0) {
BErrNo be;
Jmsg1(jcr, M_FATAL, 0,
_("Unable to init job nextrun cond variable: ERR=%s\n"),
@@ -168,10 +168,10 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output)
jcr->unlock();
goto bail_out;
}
- jcr->impl->nextrun_ready_inited = true;
+ jcr->dir_impl->nextrun_ready_inited = true;
- CreateUniqueJobName(jcr, jcr->impl->res.job->resource_name_);
- jcr->setJobStatus(JS_Created);
+ CreateUniqueJobName(jcr, jcr->dir_impl->res.job->resource_name_);
+ jcr->setJobStatusWithPriorityCheck(JS_Created);
jcr->unlock();
// Open database
@@ -179,44 +179,45 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output)
jcr->db = GetDatabaseConnection(jcr);
if (jcr->db == NULL) {
Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"),
- jcr->impl->res.catalog->db_name);
+ jcr->dir_impl->res.catalog->db_name);
goto bail_out;
}
Dmsg0(150, "DB opened\n");
- if (!jcr->impl->fname) { jcr->impl->fname = GetPoolMemory(PM_FNAME); }
+ if (!jcr->dir_impl->fname) { jcr->dir_impl->fname = GetPoolMemory(PM_FNAME); }
- if (!jcr->impl->res.pool_source) {
- jcr->impl->res.pool_source = GetPoolMemory(PM_MESSAGE);
- PmStrcpy(jcr->impl->res.pool_source, _("unknown source"));
+ if (!jcr->dir_impl->res.pool_source) {
+ jcr->dir_impl->res.pool_source = GetPoolMemory(PM_MESSAGE);
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("unknown source"));
}
- if (!jcr->impl->res.npool_source) {
- jcr->impl->res.npool_source = GetPoolMemory(PM_MESSAGE);
- PmStrcpy(jcr->impl->res.npool_source, _("unknown source"));
+ if (!jcr->dir_impl->res.npool_source) {
+ jcr->dir_impl->res.npool_source = GetPoolMemory(PM_MESSAGE);
+ PmStrcpy(jcr->dir_impl->res.npool_source, _("unknown source"));
}
if (jcr->JobReads()) {
- if (!jcr->impl->res.rpool_source) {
- jcr->impl->res.rpool_source = GetPoolMemory(PM_MESSAGE);
- PmStrcpy(jcr->impl->res.rpool_source, _("unknown source"));
+ if (!jcr->dir_impl->res.rpool_source) {
+ jcr->dir_impl->res.rpool_source = GetPoolMemory(PM_MESSAGE);
+ PmStrcpy(jcr->dir_impl->res.rpool_source, _("unknown source"));
}
}
// Create Job record
InitJcrJobRecord(jcr);
- if (jcr->impl->res.client) {
+ if (jcr->dir_impl->res.client) {
if (!GetOrCreateClientRecord(jcr)) { goto bail_out; }
}
- if (!jcr->db->CreateJobRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->CreateJobRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
goto bail_out;
}
- jcr->JobId = jcr->impl->jr.JobId;
+ jcr->JobId = jcr->dir_impl->jr.JobId;
Dmsg4(100, "Created job record JobId=%d Name=%s Type=%c Level=%c\n",
- jcr->JobId, jcr->Job, jcr->impl->jr.JobType, jcr->impl->jr.JobLevel);
+ jcr->JobId, jcr->Job, jcr->dir_impl->jr.JobType,
+ jcr->dir_impl->jr.JobLevel);
NewPlugins(jcr); /* instantiate plugins for this jcr */
DispatchNewPluginOptions(jcr);
@@ -224,11 +225,12 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output)
if (JobCanceled(jcr)) { goto bail_out; }
- if (jcr->JobReads() && !jcr->impl->res.read_storage_list) {
- if (jcr->impl->res.job->storage) {
- CopyRwstorage(jcr, jcr->impl->res.job->storage, _("Job resource"));
+ if (jcr->JobReads() && !jcr->dir_impl->res.read_storage_list) {
+ if (jcr->dir_impl->res.job->storage) {
+ CopyRwstorage(jcr, jcr->dir_impl->res.job->storage, _("Job resource"));
} else {
- CopyRwstorage(jcr, jcr->impl->res.job->pool->storage, _("Pool resource"));
+ CopyRwstorage(jcr, jcr->dir_impl->res.job->pool->storage,
+ _("Pool resource"));
}
}
@@ -308,9 +310,9 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output)
* Any non NDMP restore is not interested at the items
* that were selected for restore so drop them now.
*/
- if (jcr->impl->restore_tree_root) {
- FreeTree(jcr->impl->restore_tree_root);
- jcr->impl->restore_tree_root = NULL;
+ if (jcr->dir_impl->restore_tree_root) {
+ FreeTree(jcr->dir_impl->restore_tree_root);
+ jcr->dir_impl->restore_tree_root = NULL;
}
if (!DoNativeRestoreInit(jcr)) {
NativeRestoreCleanup(jcr, JS_ErrorTerminated);
@@ -364,7 +366,7 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output)
break;
default:
Pmsg1(0, _("Unimplemented job type: %d\n"), jcr->getJobType());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
goto bail_out;
}
@@ -382,7 +384,7 @@ bool IsConnectingToClientAllowed(ClientResource* res)
bool IsConnectingToClientAllowed(JobControlRecord* jcr)
{
- return IsConnectingToClientAllowed(jcr->impl->res.client);
+ return IsConnectingToClientAllowed(jcr->dir_impl->res.client);
}
bool IsConnectFromClientAllowed(ClientResource* res)
@@ -392,7 +394,7 @@ bool IsConnectFromClientAllowed(ClientResource* res)
bool IsConnectFromClientAllowed(JobControlRecord* jcr)
{
- return IsConnectFromClientAllowed(jcr->impl->res.client);
+ return IsConnectFromClientAllowed(jcr->dir_impl->res.client);
}
bool UseWaitingClient(JobControlRecord* jcr, int timeout)
@@ -403,17 +405,17 @@ bool UseWaitingClient(JobControlRecord* jcr, int timeout)
if (!IsConnectFromClientAllowed(jcr)) {
Dmsg1(120, "Connection from client \"%s\" to director is not allowed.\n",
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
} else {
- connection
- = connections->remove(jcr->impl->res.client->resource_name_, timeout);
+ connection = connections->remove(jcr->dir_impl->res.client->resource_name_,
+ timeout);
if (connection) {
jcr->file_bsock = connection->bsock();
- jcr->impl->FDVersion = connection->protocol_version();
+ jcr->dir_impl->FDVersion = connection->protocol_version();
jcr->authenticated = connection->authenticated();
delete (connection);
Jmsg(jcr, M_INFO, 0, _("Using Client Initiated Connection (%s).\n"),
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
result = true;
}
}
@@ -424,7 +426,7 @@ bool UseWaitingClient(JobControlRecord* jcr, int timeout)
void UpdateJobEnd(JobControlRecord* jcr, int TermCode)
{
DequeueMessages(jcr); /* display any queued messages */
- jcr->setJobStatus(TermCode);
+ jcr->setJobStatusWithPriorityCheck(TermCode);
UpdateJobEndRecord(jcr);
}
@@ -442,40 +444,41 @@ static void* job_thread(void* arg)
DetachIfNotDetached(pthread_self());
Dmsg0(200, "=====Start Job=========\n");
- jcr->setJobStatus(JS_Running); /* this will be set only if no error */
- jcr->start_time = time(NULL); /* set the real start time */
- jcr->impl->jr.StartTime = jcr->start_time;
+ jcr->setJobStatusWithPriorityCheck(
+ JS_Running); /* this will be set only if no error */
+ jcr->start_time = time(NULL); /* set the real start time */
+ jcr->dir_impl->jr.StartTime = jcr->start_time;
// Let the statistics subsystem know a new Job was started.
stats_job_started();
- if (jcr->impl->res.job->MaxStartDelay != 0
- && jcr->impl->res.job->MaxStartDelay
+ if (jcr->dir_impl->res.job->MaxStartDelay != 0
+ && jcr->dir_impl->res.job->MaxStartDelay
< (utime_t)(jcr->start_time - jcr->sched_time)) {
- jcr->setJobStatus(JS_Canceled);
+ jcr->setJobStatusWithPriorityCheck(JS_Canceled);
Jmsg(jcr, M_FATAL, 0,
_("Job canceled because max start delay time exceeded.\n"));
}
if (JobCheckMaxrunschedtime(jcr)) {
- jcr->setJobStatus(JS_Canceled);
+ jcr->setJobStatusWithPriorityCheck(JS_Canceled);
Jmsg(jcr, M_FATAL, 0,
_("Job canceled because max run sched time exceeded.\n"));
}
// TODO : check if it is used somewhere
- if (jcr->impl->res.job->RunScripts == NULL) {
+ if (jcr->dir_impl->res.job->RunScripts == NULL) {
Dmsg0(200, "Warning, job->RunScripts is empty\n");
- jcr->impl->res.job->RunScripts
+ jcr->dir_impl->res.job->RunScripts
= new alist<RunScript*>(10, not_owned_by_alist);
}
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
}
// Run any script BeforeJob on dird
- RunScripts(jcr, jcr->impl->res.job->RunScripts, "BeforeJob");
+ RunScripts(jcr, jcr->dir_impl->res.job->RunScripts, "BeforeJob");
/*
* We re-update the job start record so that the start time is set after the
@@ -487,8 +490,8 @@ static void* job_thread(void* arg)
* because in that case, their date is after the start of this run.
*/
jcr->start_time = time(NULL);
- jcr->impl->jr.StartTime = jcr->start_time;
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->dir_impl->jr.StartTime = jcr->start_time;
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
}
@@ -642,13 +645,13 @@ static void* job_thread(void* arg)
break;
}
- RunScripts(jcr, jcr->impl->res.job->RunScripts, "AfterJob");
+ RunScripts(jcr, jcr->dir_impl->res.job->RunScripts, "AfterJob");
// Send off any queued messages
if (jcr->msg_queue && jcr->msg_queue->size() > 0) { DequeueMessages(jcr); }
GeneratePluginEvent(jcr, bDirEventJobEnd);
- Dmsg1(50, "======== End Job stat=%c ==========\n", jcr->JobStatus);
+ Dmsg1(50, "======== End Job stat=%c ==========\n", jcr->getJobStatus());
return NULL;
}
@@ -656,10 +659,10 @@ static void* job_thread(void* arg)
void SdMsgThreadSendSignal(JobControlRecord* jcr, int sig)
{
jcr->lock();
- if (!jcr->impl->sd_msg_thread_done && jcr->impl->SD_msg_chan_started
- && !pthread_equal(jcr->impl->SD_msg_chan, pthread_self())) {
+ if (!jcr->dir_impl->sd_msg_thread_done && jcr->dir_impl->SD_msg_chan_started
+ && !pthread_equal(jcr->dir_impl->SD_msg_chan, pthread_self())) {
Dmsg1(800, "Send kill to SD msg chan jid=%d\n", jcr->JobId);
- pthread_kill(jcr->impl->SD_msg_chan, sig);
+ pthread_kill(jcr->dir_impl->SD_msg_chan, sig);
}
jcr->unlock();
}
@@ -674,9 +677,9 @@ void SdMsgThreadSendSignal(JobControlRecord* jcr, int sig)
bool CancelJob(UaContext* ua, JobControlRecord* jcr)
{
char ed1[50];
- int32_t old_status = jcr->JobStatus;
+ int32_t old_status = jcr->getJobStatus();
- jcr->setJobStatus(JS_Canceled);
+ jcr->setJobStatusWithPriorityCheck(JS_Canceled);
switch (old_status) {
case JS_Created:
@@ -703,14 +706,16 @@ bool CancelJob(UaContext* ua, JobControlRecord* jcr)
}
// Cancel second Storage daemon for SD-SD replication.
- if (jcr->impl->mig_jcr && jcr->impl->mig_jcr->store_bsock) {
- if (!CancelStorageDaemonJob(ua, jcr->impl->mig_jcr)) { return false; }
+ if (jcr->dir_impl->mig_jcr && jcr->dir_impl->mig_jcr->store_bsock) {
+ if (!CancelStorageDaemonJob(ua, jcr->dir_impl->mig_jcr)) {
+ return false;
+ }
}
break;
}
- RunScripts(jcr, jcr->impl->res.job->RunScripts, "AfterJob");
+ RunScripts(jcr, jcr->dir_impl->res.job->RunScripts, "AfterJob");
return true;
}
@@ -733,24 +738,24 @@ static void JobMonitorWatchdog(watchdog_t* self)
foreach_jcr (jcr) {
bool cancel = false;
- if (jcr->JobId == 0 || JobCanceled(jcr) || jcr->impl->no_maxtime) {
+ if (jcr->JobId == 0 || JobCanceled(jcr) || jcr->dir_impl->no_maxtime) {
Dmsg2(800, "Skipping JobControlRecord=%p Job=%s\n", jcr, jcr->Job);
continue;
}
/* check MaxWaitTime */
if (JobCheckMaxwaittime(jcr)) {
- jcr->setJobStatus(JS_Canceled);
+ jcr->setJobStatusWithPriorityCheck(JS_Canceled);
Qmsg(jcr, M_FATAL, 0, _("Max wait time exceeded. Job canceled.\n"));
cancel = true;
/* check MaxRunTime */
} else if (JobCheckMaxruntime(jcr)) {
- jcr->setJobStatus(JS_Canceled);
+ jcr->setJobStatusWithPriorityCheck(JS_Canceled);
Qmsg(jcr, M_FATAL, 0, _("Max run time exceeded. Job canceled.\n"));
cancel = true;
/* check MaxRunSchedTime */
} else if (JobCheckMaxrunschedtime(jcr)) {
- jcr->setJobStatus(JS_Canceled);
+ jcr->setJobStatusWithPriorityCheck(JS_Canceled);
Qmsg(jcr, M_FATAL, 0, _("Max run sched time exceeded. Job canceled.\n"));
cancel = true;
}
@@ -777,7 +782,7 @@ static void JobMonitorWatchdog(watchdog_t* self)
static bool JobCheckMaxwaittime(JobControlRecord* jcr)
{
bool cancel = false;
- JobResource* job = jcr->impl->res.job;
+ JobResource* job = jcr->dir_impl->res.job;
utime_t current = 0;
if (!JobWaiting(jcr)) { return false; }
@@ -801,7 +806,7 @@ static bool JobCheckMaxwaittime(JobControlRecord* jcr)
static bool JobCheckMaxruntime(JobControlRecord* jcr)
{
bool cancel = false;
- JobResource* job = jcr->impl->res.job;
+ JobResource* job = jcr->dir_impl->res.job;
utime_t run_time;
if (JobCanceled(jcr) || !jcr->job_started) { return false; }
@@ -840,10 +845,11 @@ static bool JobCheckMaxruntime(JobControlRecord* jcr)
*/
static bool JobCheckMaxrunschedtime(JobControlRecord* jcr)
{
- if (jcr->impl->MaxRunSchedTime == 0 || JobCanceled(jcr)) { return false; }
- if ((watchdog_time - jcr->initial_sched_time) < jcr->impl->MaxRunSchedTime) {
+ if (jcr->dir_impl->MaxRunSchedTime == 0 || JobCanceled(jcr)) { return false; }
+ if ((watchdog_time - jcr->initial_sched_time)
+ < jcr->dir_impl->MaxRunSchedTime) {
Dmsg3(200, "Job %p (%s) with MaxRunSchedTime %d not expired\n", jcr,
- jcr->Job, jcr->impl->MaxRunSchedTime);
+ jcr->Job, jcr->dir_impl->MaxRunSchedTime);
return false;
}
@@ -864,7 +870,7 @@ DBId_t GetOrCreatePoolRecord(JobControlRecord* jcr, char* pool_name)
while (!jcr->db->GetPoolRecord(jcr, &pr)) { /* get by Name */
/* Try to create the pool */
- if (CreatePool(jcr, jcr->db, jcr->impl->res.pool, POOL_OP_CREATE) < 0) {
+ if (CreatePool(jcr, jcr->db, jcr->dir_impl->res.pool, POOL_OP_CREATE) < 0) {
Jmsg(jcr, M_FATAL, 0, _("Pool \"%s\" not in database. ERR=%s"), pr.Name,
jcr->db->strerror());
return 0;
@@ -884,7 +890,7 @@ DBId_t GetOrCreatePoolRecord(JobControlRecord* jcr, char* pool_name)
bool AllowDuplicateJob(JobControlRecord* jcr)
{
JobControlRecord* djcr; /* possible duplicate job */
- JobResource* job = jcr->impl->res.job;
+ JobResource* job = jcr->dir_impl->res.job;
bool cancel_dup = false;
bool cancel_me = false;
@@ -892,7 +898,7 @@ bool AllowDuplicateJob(JobControlRecord* jcr)
* See if AllowDuplicateJobs is set or
* if duplicate checking is disabled for this job.
*/
- if (job->AllowDuplicateJobs || jcr->impl->IgnoreDuplicateJobChecking) {
+ if (job->AllowDuplicateJobs || jcr->dir_impl->IgnoreDuplicateJobChecking) {
return true;
}
@@ -912,9 +918,9 @@ bool AllowDuplicateJob(JobControlRecord* jcr)
* See if this Job has the IgnoreDuplicateJobChecking flag set, ignore it
* for any checking against other jobs.
*/
- if (djcr->impl->IgnoreDuplicateJobChecking) { continue; }
+ if (djcr->dir_impl->IgnoreDuplicateJobChecking) { continue; }
- if (bstrcmp(job->resource_name_, djcr->impl->res.job->resource_name_)) {
+ if (bstrcmp(job->resource_name_, djcr->dir_impl->res.job->resource_name_)) {
if (job->DuplicateJobProximity > 0) {
utime_t now = (utime_t)time(NULL);
if ((now - djcr->start_time) > job->DuplicateJobProximity) {
@@ -943,7 +949,7 @@ bool AllowDuplicateJob(JobControlRecord* jcr)
// cancel_dup will be done below
if (cancel_me) {
/* Zap current job */
- jcr->setJobStatus(JS_Canceled);
+ jcr->setJobStatusWithPriorityCheck(JS_Canceled);
Jmsg(jcr, M_FATAL, 0,
_("JobId %d already running. Duplicate job not allowed.\n"),
djcr->JobId);
@@ -956,7 +962,7 @@ bool AllowDuplicateJob(JobControlRecord* jcr)
* If CancelQueuedDuplicates is set do so only if job is queued.
*/
if (job->CancelQueuedDuplicates) {
- switch (djcr->JobStatus) {
+ switch (djcr->getJobStatus()) {
case JS_Created:
case JS_WaitJobRes:
case JS_WaitClientRes:
@@ -978,13 +984,13 @@ bool AllowDuplicateJob(JobControlRecord* jcr)
djcr->JobId);
CancelJob(ua, djcr);
Bmicrosleep(0, 500000);
- djcr->setJobStatus(JS_Canceled);
+ djcr->setJobStatusWithPriorityCheck(JS_Canceled);
CancelJob(ua, djcr);
FreeUaContext(ua);
Dmsg2(800, "Cancel dup %p JobId=%d\n", djcr, djcr->JobId);
} else {
// Zap current job
- jcr->setJobStatus(JS_Canceled);
+ jcr->setJobStatusWithPriorityCheck(JS_Canceled);
Jmsg(jcr, M_FATAL, 0,
_("JobId %d already running. Duplicate job not allowed.\n"),
djcr->JobId);
@@ -1020,14 +1026,15 @@ bool GetLevelSinceTime(JobControlRecord* jcr)
utime_t last_diff_time;
char prev_job[MAX_NAME_LENGTH];
- jcr->impl->since[0] = 0;
+ jcr->dir_impl->since[0] = 0;
// If since time was given on command line use it
if (jcr->starttime_string && jcr->starttime_string[0]) {
- bstrncpy(jcr->impl->since, _(", since="), sizeof(jcr->impl->since));
- bstrncat(jcr->impl->since, jcr->starttime_string, sizeof(jcr->impl->since));
+ bstrncpy(jcr->dir_impl->since, _(", since="), sizeof(jcr->dir_impl->since));
+ bstrncat(jcr->dir_impl->since, jcr->starttime_string,
+ sizeof(jcr->dir_impl->since));
Jmsg(jcr, M_INFO, 0, "Using since time from command line %s (%s)",
- jcr->starttime_string, jcr->impl->since);
+ jcr->starttime_string, jcr->dir_impl->since);
return pool_updated;
}
@@ -1037,7 +1044,7 @@ bool GetLevelSinceTime(JobControlRecord* jcr)
jcr->starttime_string = GetPoolMemory(PM_MESSAGE);
jcr->starttime_string[0] = 0;
}
- jcr->impl->PrevJob[0] = 0;
+ jcr->dir_impl->PrevJob[0] = 0;
/*
* Lookup the last FULL backup job to get the time/date for a
@@ -1051,19 +1058,20 @@ bool GetLevelSinceTime(JobControlRecord* jcr)
// Look up start time of last Full job
now = (utime_t)time(NULL);
- jcr->impl->jr.JobId = 0; /* flag to return since time */
+ jcr->dir_impl->jr.JobId = 0; /* flag to return since time */
/*
* This is probably redundant, but some of the code below
* uses jcr->starttime_string, so don't remove unless you are sure.
*/
- if (!jcr->db->FindJobStartTime(jcr, &jcr->impl->jr, jcr->starttime_string,
- jcr->impl->PrevJob)) {
+ if (!jcr->db->FindJobStartTime(jcr, &jcr->dir_impl->jr,
+ jcr->starttime_string,
+ jcr->dir_impl->PrevJob)) {
do_full = true;
}
- have_full = jcr->db->FindLastJobStartTime(jcr, &jcr->impl->jr, start_time,
- prev_job, L_FULL);
+ have_full = jcr->db->FindLastJobStartTime(jcr, &jcr->dir_impl->jr,
+ start_time, prev_job, L_FULL);
if (have_full) {
last_full_time = StrToUtime(start_time);
} else {
@@ -1075,9 +1083,9 @@ bool GetLevelSinceTime(JobControlRecord* jcr)
// Make sure the last diff is recent enough
if (have_full && JobLevel == L_INCREMENTAL
- && jcr->impl->res.job->MaxDiffInterval > 0) {
+ && jcr->dir_impl->res.job->MaxDiffInterval > 0) {
// Lookup last diff job
- if (jcr->db->FindLastJobStartTime(jcr, &jcr->impl->jr, start_time,
+ if (jcr->db->FindLastJobStartTime(jcr, &jcr->dir_impl->jr, start_time,
prev_job, L_DIFFERENTIAL)) {
last_diff_time = StrToUtime(start_time);
// If no Diff since Full, use Full time
@@ -1092,19 +1100,19 @@ bool GetLevelSinceTime(JobControlRecord* jcr)
Dmsg1(50, "No last_diff_time setting to full_time=%lld\n",
last_full_time);
}
- do_diff
- = ((now - last_diff_time) >= jcr->impl->res.job->MaxDiffInterval);
+ do_diff = ((now - last_diff_time)
+ >= jcr->dir_impl->res.job->MaxDiffInterval);
Dmsg2(50, "do_diff=%d diffInter=%lld\n", do_diff,
- jcr->impl->res.job->MaxDiffInterval);
+ jcr->dir_impl->res.job->MaxDiffInterval);
}
// Note, do_full takes precedence over do_vfull and do_diff
- if (have_full && jcr->impl->res.job->MaxFullInterval > 0) {
- do_full
- = ((now - last_full_time) >= jcr->impl->res.job->MaxFullInterval);
- } else if (have_full && jcr->impl->res.job->MaxVFullInterval > 0) {
- do_vfull
- = ((now - last_full_time) >= jcr->impl->res.job->MaxVFullInterval);
+ if (have_full && jcr->dir_impl->res.job->MaxFullInterval > 0) {
+ do_full = ((now - last_full_time)
+ >= jcr->dir_impl->res.job->MaxFullInterval);
+ } else if (have_full && jcr->dir_impl->res.job->MaxVFullInterval > 0) {
+ do_vfull = ((now - last_full_time)
+ >= jcr->dir_impl->res.job->MaxVFullInterval);
}
FreePoolMemory(start_time);
@@ -1114,9 +1122,9 @@ bool GetLevelSinceTime(JobControlRecord* jcr)
Jmsg(jcr, M_INFO, 0,
_("No prior or suitable Full backup found in catalog. Doing FULL "
"backup.\n"));
- Bsnprintf(jcr->impl->since, sizeof(jcr->impl->since),
+ Bsnprintf(jcr->dir_impl->since, sizeof(jcr->dir_impl->since),
_(" (upgraded from %s)"), JobLevelToString(JobLevel));
- jcr->setJobLevel(jcr->impl->jr.JobLevel = L_FULL);
+ jcr->setJobLevel(jcr->dir_impl->jr.JobLevel = L_FULL);
pool_updated = true;
} else if (do_vfull) {
/*
@@ -1127,59 +1135,60 @@ bool GetLevelSinceTime(JobControlRecord* jcr)
Jmsg(jcr, M_INFO, 0,
_("No prior or suitable Full backup found in catalog. Doing "
"Virtual FULL backup.\n"));
- Bsnprintf(jcr->impl->since, sizeof(jcr->impl->since),
+ Bsnprintf(jcr->dir_impl->since, sizeof(jcr->dir_impl->since),
_(" (upgraded from %s)"),
JobLevelToString(jcr->getJobLevel()));
- jcr->setJobLevel(jcr->impl->jr.JobLevel = L_VIRTUAL_FULL);
+ jcr->setJobLevel(jcr->dir_impl->jr.JobLevel = L_VIRTUAL_FULL);
pool_updated = true;
/*
* If we get upgraded to a Virtual Full we will be using a read pool so
* make sure we have a rpool_source.
*/
- if (!jcr->impl->res.rpool_source) {
- jcr->impl->res.rpool_source = GetPoolMemory(PM_MESSAGE);
- PmStrcpy(jcr->impl->res.rpool_source, _("unknown source"));
+ if (!jcr->dir_impl->res.rpool_source) {
+ jcr->dir_impl->res.rpool_source = GetPoolMemory(PM_MESSAGE);
+ PmStrcpy(jcr->dir_impl->res.rpool_source, _("unknown source"));
}
} else if (do_diff) {
// No recent diff job found, so upgrade this one to Diff
Jmsg(jcr, M_INFO, 0,
_("No prior or suitable Differential backup found in catalog. "
"Doing Differential backup.\n"));
- Bsnprintf(jcr->impl->since, sizeof(jcr->impl->since),
+ Bsnprintf(jcr->dir_impl->since, sizeof(jcr->dir_impl->since),
_(" (upgraded from %s)"), JobLevelToString(JobLevel));
- jcr->setJobLevel(jcr->impl->jr.JobLevel = L_DIFFERENTIAL);
+ jcr->setJobLevel(jcr->dir_impl->jr.JobLevel = L_DIFFERENTIAL);
pool_updated = true;
} else {
- if (jcr->impl->res.job->rerun_failed_levels) {
- if (jcr->db->FindFailedJobSince(jcr, &jcr->impl->jr,
+ if (jcr->dir_impl->res.job->rerun_failed_levels) {
+ if (jcr->db->FindFailedJobSince(jcr, &jcr->dir_impl->jr,
jcr->starttime_string, JobLevel)) {
Jmsg(jcr, M_INFO, 0,
_("Prior failed job found in catalog. Upgrading to %s.\n"),
JobLevelToString(JobLevel));
- Bsnprintf(jcr->impl->since, sizeof(jcr->impl->since),
+ Bsnprintf(jcr->dir_impl->since, sizeof(jcr->dir_impl->since),
_(" (upgraded from %s)"), JobLevelToString(JobLevel));
- jcr->setJobLevel(jcr->impl->jr.JobLevel = JobLevel);
- jcr->impl->jr.JobId = jcr->JobId;
+ jcr->setJobLevel(jcr->dir_impl->jr.JobLevel = JobLevel);
+ jcr->dir_impl->jr.JobId = jcr->JobId;
pool_updated = true;
break;
}
}
- bstrncpy(jcr->impl->since, _(", since="), sizeof(jcr->impl->since));
- bstrncat(jcr->impl->since, jcr->starttime_string,
- sizeof(jcr->impl->since));
+ bstrncpy(jcr->dir_impl->since, _(", since="),
+ sizeof(jcr->dir_impl->since));
+ bstrncat(jcr->dir_impl->since, jcr->starttime_string,
+ sizeof(jcr->dir_impl->since));
}
- jcr->impl->jr.JobId = jcr->JobId;
+ jcr->dir_impl->jr.JobId = jcr->JobId;
/*
* Lookup the Job record of the previous Job and store it in
- * jcr->impl_->previous_jr.
+ * jcr->dir_impl_->previous_jr.
*/
- if (jcr->impl->PrevJob[0]) {
- bstrncpy(jcr->impl->previous_jr.Job, jcr->impl->PrevJob,
- sizeof(jcr->impl->previous_jr.Job));
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) {
+ if (jcr->dir_impl->PrevJob[0]) {
+ bstrncpy(jcr->dir_impl->previous_jr.Job, jcr->dir_impl->PrevJob,
+ sizeof(jcr->dir_impl->previous_jr.Job));
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->previous_jr)) {
Jmsg(jcr, M_FATAL, 0,
_("Could not get job record for previous Job. ERR=%s\n"),
jcr->db->strerror());
@@ -1190,7 +1199,7 @@ bool GetLevelSinceTime(JobControlRecord* jcr)
}
Dmsg3(100, "Level=%c last start time=%s job=%s\n", JobLevel,
- jcr->starttime_string, jcr->impl->PrevJob);
+ jcr->starttime_string, jcr->dir_impl->PrevJob);
return pool_updated;
}
@@ -1204,86 +1213,93 @@ void ApplyPoolOverrides(JobControlRecord* jcr, bool force)
* If a cmdline pool override is given ignore any level pool overrides.
* Unless a force is given then we always apply any overrides.
*/
- if (!force && jcr->impl->IgnoreLevelPoolOverrides) { return; }
+ if (!force && jcr->dir_impl->IgnoreLevelPoolOverrides) { return; }
/*
* If only a pool override and no level overrides are given in run entry
* choose this pool
*/
- if (jcr->impl->res.run_pool_override && !jcr->impl->res.run_full_pool_override
- && !jcr->impl->res.run_vfull_pool_override
- && !jcr->impl->res.run_inc_pool_override
- && !jcr->impl->res.run_diff_pool_override) {
- PmStrcpy(jcr->impl->res.pool_source, _("Run Pool override"));
+ if (jcr->dir_impl->res.run_pool_override
+ && !jcr->dir_impl->res.run_full_pool_override
+ && !jcr->dir_impl->res.run_vfull_pool_override
+ && !jcr->dir_impl->res.run_inc_pool_override
+ && !jcr->dir_impl->res.run_diff_pool_override) {
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("Run Pool override"));
Dmsg2(100, "Pool set to '%s' because of %s",
- jcr->impl->res.pool->resource_name_, _("Run Pool override\n"));
+ jcr->dir_impl->res.pool->resource_name_, _("Run Pool override\n"));
} else {
// Apply any level related Pool selections
switch (jcr->getJobLevel()) {
case L_FULL:
- if (jcr->impl->res.full_pool) {
- jcr->impl->res.pool = jcr->impl->res.full_pool;
+ if (jcr->dir_impl->res.full_pool) {
+ jcr->dir_impl->res.pool = jcr->dir_impl->res.full_pool;
pool_override = true;
- if (jcr->impl->res.run_full_pool_override) {
- PmStrcpy(jcr->impl->res.pool_source, _("Run FullPool override"));
+ if (jcr->dir_impl->res.run_full_pool_override) {
+ PmStrcpy(jcr->dir_impl->res.pool_source,
+ _("Run FullPool override"));
Dmsg2(100, "Pool set to '%s' because of %s",
- jcr->impl->res.full_pool->resource_name_,
+ jcr->dir_impl->res.full_pool->resource_name_,
"Run FullPool override\n");
} else {
- PmStrcpy(jcr->impl->res.pool_source, _("Job FullPool override"));
+ PmStrcpy(jcr->dir_impl->res.pool_source,
+ _("Job FullPool override"));
Dmsg2(100, "Pool set to '%s' because of %s",
- jcr->impl->res.full_pool->resource_name_,
+ jcr->dir_impl->res.full_pool->resource_name_,
"Job FullPool override\n");
}
}
break;
case L_VIRTUAL_FULL:
- if (jcr->impl->res.vfull_pool) {
- jcr->impl->res.pool = jcr->impl->res.vfull_pool;
+ if (jcr->dir_impl->res.vfull_pool) {
+ jcr->dir_impl->res.pool = jcr->dir_impl->res.vfull_pool;
pool_override = true;
- if (jcr->impl->res.run_vfull_pool_override) {
- PmStrcpy(jcr->impl->res.pool_source, _("Run VFullPool override"));
+ if (jcr->dir_impl->res.run_vfull_pool_override) {
+ PmStrcpy(jcr->dir_impl->res.pool_source,
+ _("Run VFullPool override"));
Dmsg2(100, "Pool set to '%s' because of %s",
- jcr->impl->res.vfull_pool->resource_name_,
+ jcr->dir_impl->res.vfull_pool->resource_name_,
"Run VFullPool override\n");
} else {
- PmStrcpy(jcr->impl->res.pool_source, _("Job VFullPool override"));
+ PmStrcpy(jcr->dir_impl->res.pool_source,
+ _("Job VFullPool override"));
Dmsg2(100, "Pool set to '%s' because of %s",
- jcr->impl->res.vfull_pool->resource_name_,
+ jcr->dir_impl->res.vfull_pool->resource_name_,
"Job VFullPool override\n");
}
}
break;
case L_INCREMENTAL:
- if (jcr->impl->res.inc_pool) {
- jcr->impl->res.pool = jcr->impl->res.inc_pool;
+ if (jcr->dir_impl->res.inc_pool) {
+ jcr->dir_impl->res.pool = jcr->dir_impl->res.inc_pool;
pool_override = true;
- if (jcr->impl->res.run_inc_pool_override) {
- PmStrcpy(jcr->impl->res.pool_source, _("Run IncPool override"));
+ if (jcr->dir_impl->res.run_inc_pool_override) {
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("Run IncPool override"));
Dmsg2(100, "Pool set to '%s' because of %s",
- jcr->impl->res.inc_pool->resource_name_,
+ jcr->dir_impl->res.inc_pool->resource_name_,
"Run IncPool override\n");
} else {
- PmStrcpy(jcr->impl->res.pool_source, _("Job IncPool override"));
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("Job IncPool override"));
Dmsg2(100, "Pool set to '%s' because of %s",
- jcr->impl->res.inc_pool->resource_name_,
+ jcr->dir_impl->res.inc_pool->resource_name_,
"Job IncPool override\n");
}
}
break;
case L_DIFFERENTIAL:
- if (jcr->impl->res.diff_pool) {
- jcr->impl->res.pool = jcr->impl->res.diff_pool;
+ if (jcr->dir_impl->res.diff_pool) {
+ jcr->dir_impl->res.pool = jcr->dir_impl->res.diff_pool;
pool_override = true;
- if (jcr->impl->res.run_diff_pool_override) {
- PmStrcpy(jcr->impl->res.pool_source, _("Run DiffPool override"));
+ if (jcr->dir_impl->res.run_diff_pool_override) {
+ PmStrcpy(jcr->dir_impl->res.pool_source,
+ _("Run DiffPool override"));
Dmsg2(100, "Pool set to '%s' because of %s",
- jcr->impl->res.diff_pool->resource_name_,
+ jcr->dir_impl->res.diff_pool->resource_name_,
"Run DiffPool override\n");
} else {
- PmStrcpy(jcr->impl->res.pool_source, _("Job DiffPool override"));
+ PmStrcpy(jcr->dir_impl->res.pool_source,
+ _("Job DiffPool override"));
Dmsg2(100, "Pool set to '%s' because of %s",
- jcr->impl->res.diff_pool->resource_name_,
+ jcr->dir_impl->res.diff_pool->resource_name_,
"Job DiffPool override\n");
}
}
@@ -1292,9 +1308,9 @@ void ApplyPoolOverrides(JobControlRecord* jcr, bool force)
}
// Update catalog if pool overridden
- if (pool_override && jcr->impl->res.pool->catalog) {
- jcr->impl->res.catalog = jcr->impl->res.pool->catalog;
- PmStrcpy(jcr->impl->res.catalog_source, _("Pool resource"));
+ if (pool_override && jcr->dir_impl->res.pool->catalog) {
+ jcr->dir_impl->res.catalog = jcr->dir_impl->res.pool->catalog;
+ PmStrcpy(jcr->dir_impl->res.catalog_source, _("Pool resource"));
}
}
@@ -1303,40 +1319,40 @@ bool GetOrCreateClientRecord(JobControlRecord* jcr)
{
ClientDbRecord cr;
- bstrncpy(cr.Name, jcr->impl->res.client->resource_name_, sizeof(cr.Name));
- cr.AutoPrune = jcr->impl->res.client->AutoPrune;
- cr.FileRetention = jcr->impl->res.client->FileRetention;
- cr.JobRetention = jcr->impl->res.client->JobRetention;
+ bstrncpy(cr.Name, jcr->dir_impl->res.client->resource_name_, sizeof(cr.Name));
+ cr.AutoPrune = jcr->dir_impl->res.client->AutoPrune;
+ cr.FileRetention = jcr->dir_impl->res.client->FileRetention;
+ cr.JobRetention = jcr->dir_impl->res.client->JobRetention;
if (!jcr->client_name) { jcr->client_name = GetPoolMemory(PM_NAME); }
- PmStrcpy(jcr->client_name, jcr->impl->res.client->resource_name_);
+ PmStrcpy(jcr->client_name, jcr->dir_impl->res.client->resource_name_);
if (!jcr->db->CreateClientRecord(jcr, &cr)) {
Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s\n"),
jcr->db->strerror());
return false;
}
// Only initialize quota when a Soft or Hard Limit is set.
- if (jcr->impl->res.client->HardQuota != 0
- || jcr->impl->res.client->SoftQuota != 0) {
+ if (jcr->dir_impl->res.client->HardQuota != 0
+ || jcr->dir_impl->res.client->SoftQuota != 0) {
if (!jcr->db->GetQuotaRecord(jcr, &cr)) {
if (!jcr->db->CreateQuotaRecord(jcr, &cr)) {
Jmsg(jcr, M_FATAL, 0, _("Could not create Quota record. ERR=%s\n"),
jcr->db->strerror());
}
- jcr->impl->res.client->QuotaLimit = 0;
- jcr->impl->res.client->GraceTime = 0;
+ jcr->dir_impl->res.client->QuotaLimit = 0;
+ jcr->dir_impl->res.client->GraceTime = 0;
}
}
- jcr->impl->jr.ClientId = cr.ClientId;
- jcr->impl->res.client->QuotaLimit = cr.QuotaLimit;
- jcr->impl->res.client->GraceTime = cr.GraceTime;
+ jcr->dir_impl->jr.ClientId = cr.ClientId;
+ jcr->dir_impl->res.client->QuotaLimit = cr.QuotaLimit;
+ jcr->dir_impl->res.client->GraceTime = cr.GraceTime;
if (cr.Uname[0]) {
- if (!jcr->impl->client_uname) {
- jcr->impl->client_uname = GetPoolMemory(PM_NAME);
+ if (!jcr->dir_impl->client_uname) {
+ jcr->dir_impl->client_uname = GetPoolMemory(PM_NAME);
}
- PmStrcpy(jcr->impl->client_uname, cr.Uname);
+ PmStrcpy(jcr->dir_impl->client_uname, cr.Uname);
}
Dmsg2(100, "Created Client %s record %d\n",
- jcr->impl->res.client->resource_name_, jcr->impl->jr.ClientId);
+ jcr->dir_impl->res.client->resource_name_, jcr->dir_impl->jr.ClientId);
return true;
}
@@ -1345,24 +1361,22 @@ bool GetOrCreateFilesetRecord(JobControlRecord* jcr)
FileSetDbRecord fsr;
// Get or Create FileSet record
- bstrncpy(fsr.FileSet, jcr->impl->res.fileset->resource_name_,
+ bstrncpy(fsr.FileSet, jcr->dir_impl->res.fileset->resource_name_,
sizeof(fsr.FileSet));
- if (jcr->impl->res.fileset->have_MD5) {
+ if (jcr->dir_impl->res.fileset->have_MD5) {
MD5_CTX md5c;
unsigned char digest[16]; /* MD5 digest length */
- memcpy(&md5c, &jcr->impl->res.fileset->md5c, sizeof(md5c));
+ memcpy(&md5c, &jcr->dir_impl->res.fileset->md5c, sizeof(md5c));
ALLOW_DEPRECATED(MD5_Final(digest, &md5c));
- /*
- * Keep the flag (last arg) set to false otherwise old FileSets will
- * get new MD5 sums and the user will get Full backups on everything
- */
+ /* Keep the flag (last arg) set to false otherwise old FileSets will
+ * get new MD5 sums and the user will get Full backups on everything */
BinToBase64(fsr.MD5, sizeof(fsr.MD5), (char*)digest, sizeof(digest), false);
- bstrncpy(jcr->impl->res.fileset->MD5, fsr.MD5,
- sizeof(jcr->impl->res.fileset->MD5));
+ bstrncpy(jcr->dir_impl->res.fileset->MD5, fsr.MD5,
+ sizeof(jcr->dir_impl->res.fileset->MD5));
} else {
Jmsg(jcr, M_WARNING, 0, _("FileSet MD5 digest not found.\n"));
}
- if (!jcr->impl->res.fileset->ignore_fs_changes
+ if (!jcr->dir_impl->res.fileset->ignore_fs_changes
|| !jcr->db->GetFilesetRecord(jcr, &fsr)) {
PoolMem FileSetText(PM_MESSAGE);
OutputFormatter output_formatter
@@ -1370,8 +1384,8 @@ bool GetOrCreateFilesetRecord(JobControlRecord* jcr)
OutputFormatterResource output_formatter_resource
= OutputFormatterResource(&output_formatter);
- jcr->impl->res.fileset->PrintConfig(output_formatter_resource, *my_config,
- false, false);
+ jcr->dir_impl->res.fileset->PrintConfig(output_formatter_resource,
+ *my_config, false, false);
fsr.FileSetText = FileSetText.c_str();
@@ -1383,46 +1397,47 @@ bool GetOrCreateFilesetRecord(JobControlRecord* jcr)
}
}
- jcr->impl->jr.FileSetId = fsr.FileSetId;
- bstrncpy(jcr->impl->FSCreateTime, fsr.cCreateTime,
- sizeof(jcr->impl->FSCreateTime));
+ jcr->dir_impl->jr.FileSetId = fsr.FileSetId;
+ bstrncpy(jcr->dir_impl->FSCreateTime, fsr.cCreateTime,
+ sizeof(jcr->dir_impl->FSCreateTime));
Dmsg2(119, "Created FileSet %s record %u\n",
- jcr->impl->res.fileset->resource_name_, jcr->impl->jr.FileSetId);
+ jcr->dir_impl->res.fileset->resource_name_,
+ jcr->dir_impl->jr.FileSetId);
return true;
}
void InitJcrJobRecord(JobControlRecord* jcr)
{
- jcr->impl->jr.SchedTime = jcr->sched_time;
- jcr->impl->jr.StartTime = jcr->start_time;
- jcr->impl->jr.EndTime = 0; /* perhaps rescheduled, clear it */
- jcr->impl->jr.JobType = jcr->getJobType();
- jcr->impl->jr.JobLevel = jcr->getJobLevel();
- jcr->impl->jr.JobStatus = jcr->JobStatus;
- jcr->impl->jr.JobId = jcr->JobId;
- jcr->impl->jr.JobSumTotalBytes = 18446744073709551615LLU;
- bstrncpy(jcr->impl->jr.Name, jcr->impl->res.job->resource_name_,
- sizeof(jcr->impl->jr.Name));
- bstrncpy(jcr->impl->jr.Job, jcr->Job, sizeof(jcr->impl->jr.Job));
+ jcr->dir_impl->jr.SchedTime = jcr->sched_time;
+ jcr->dir_impl->jr.StartTime = jcr->start_time;
+ jcr->dir_impl->jr.EndTime = 0; /* perhaps rescheduled, clear it */
+ jcr->dir_impl->jr.JobType = jcr->getJobType();
+ jcr->dir_impl->jr.JobLevel = jcr->getJobLevel();
+ jcr->dir_impl->jr.JobStatus = jcr->getJobStatus();
+ jcr->dir_impl->jr.JobId = jcr->JobId;
+ jcr->dir_impl->jr.JobSumTotalBytes = 18446744073709551615LLU;
+ bstrncpy(jcr->dir_impl->jr.Name, jcr->dir_impl->res.job->resource_name_,
+ sizeof(jcr->dir_impl->jr.Name));
+ bstrncpy(jcr->dir_impl->jr.Job, jcr->Job, sizeof(jcr->dir_impl->jr.Job));
}
// Write status and such in DB
void UpdateJobEndRecord(JobControlRecord* jcr)
{
- jcr->impl->jr.EndTime = time(NULL);
- jcr->end_time = jcr->impl->jr.EndTime;
- jcr->impl->jr.JobId = jcr->JobId;
- jcr->impl->jr.JobStatus = jcr->JobStatus;
- jcr->impl->jr.JobFiles = jcr->JobFiles;
- jcr->impl->jr.JobBytes = jcr->JobBytes;
- jcr->impl->jr.ReadBytes = jcr->ReadBytes;
- jcr->impl->jr.VolSessionId = jcr->VolSessionId;
- jcr->impl->jr.VolSessionTime = jcr->VolSessionTime;
- jcr->impl->jr.JobErrors = jcr->JobErrors;
- jcr->impl->jr.HasBase = jcr->HasBase;
- if (!jcr->db->UpdateJobEndRecord(jcr, &jcr->impl->jr)) {
+ jcr->dir_impl->jr.EndTime = time(NULL);
+ jcr->end_time = jcr->dir_impl->jr.EndTime;
+ jcr->dir_impl->jr.JobId = jcr->JobId;
+ jcr->dir_impl->jr.JobStatus = jcr->getJobStatus();
+ jcr->dir_impl->jr.JobFiles = jcr->JobFiles;
+ jcr->dir_impl->jr.JobBytes = jcr->JobBytes;
+ jcr->dir_impl->jr.ReadBytes = jcr->ReadBytes;
+ jcr->dir_impl->jr.VolSessionId = jcr->VolSessionId;
+ jcr->dir_impl->jr.VolSessionTime = jcr->VolSessionTime;
+ jcr->dir_impl->jr.JobErrors = jcr->JobErrors;
+ jcr->dir_impl->jr.HasBase = jcr->HasBase;
+ if (!jcr->db->UpdateJobEndRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0, _("Error updating job record. %s\n"),
jcr->db->strerror());
}
@@ -1510,14 +1525,14 @@ void DirdFreeJcrPointers(JobControlRecord* jcr)
BfreeAndNull(jcr->sd_auth_key);
BfreeAndNull(jcr->where);
- BfreeAndNull(jcr->impl->backup_format);
+ BfreeAndNull(jcr->dir_impl->backup_format);
BfreeAndNull(jcr->RestoreBootstrap);
BfreeAndNull(jcr->ar);
FreeAndNullPoolMemory(jcr->JobIds);
- FreeAndNullPoolMemory(jcr->impl->client_uname);
+ FreeAndNullPoolMemory(jcr->dir_impl->client_uname);
FreeAndNullPoolMemory(jcr->attr);
- FreeAndNullPoolMemory(jcr->impl->fname);
+ FreeAndNullPoolMemory(jcr->dir_impl->fname);
}
/**
@@ -1529,21 +1544,21 @@ void DirdFreeJcr(JobControlRecord* jcr)
{
Dmsg0(200, "Start dird FreeJcr\n");
- if (jcr->impl->mig_jcr) {
- FreeJcr(jcr->impl->mig_jcr);
- jcr->impl->mig_jcr = NULL;
+ if (jcr->dir_impl->mig_jcr) {
+ FreeJcr(jcr->dir_impl->mig_jcr);
+ jcr->dir_impl->mig_jcr = NULL;
}
DirdFreeJcrPointers(jcr);
- if (jcr->impl->term_wait_inited) {
- pthread_cond_destroy(&jcr->impl->term_wait);
- jcr->impl->term_wait_inited = false;
+ if (jcr->dir_impl->term_wait_inited) {
+ pthread_cond_destroy(&jcr->dir_impl->term_wait);
+ jcr->dir_impl->term_wait_inited = false;
}
- if (jcr->impl->nextrun_ready_inited) {
- pthread_cond_destroy(&jcr->impl->nextrun_ready);
- jcr->impl->nextrun_ready_inited = false;
+ if (jcr->dir_impl->nextrun_ready_inited) {
+ pthread_cond_destroy(&jcr->dir_impl->nextrun_ready);
+ jcr->dir_impl->nextrun_ready_inited = false;
}
if (jcr->db_batch) {
@@ -1557,24 +1572,26 @@ void DirdFreeJcr(JobControlRecord* jcr)
jcr->db = NULL;
}
- if (jcr->impl->restore_tree_root) { FreeTree(jcr->impl->restore_tree_root); }
+ if (jcr->dir_impl->restore_tree_root) {
+ FreeTree(jcr->dir_impl->restore_tree_root);
+ }
- if (jcr->impl->bsr) {
- libbareos::FreeBsr(jcr->impl->bsr);
- jcr->impl->bsr = NULL;
+ if (jcr->dir_impl->bsr) {
+ libbareos::FreeBsr(jcr->dir_impl->bsr);
+ jcr->dir_impl->bsr = NULL;
}
FreeAndNullPoolMemory(jcr->starttime_string);
- FreeAndNullPoolMemory(jcr->impl->fname);
- FreeAndNullPoolMemory(jcr->impl->res.pool_source);
- FreeAndNullPoolMemory(jcr->impl->res.npool_source);
- FreeAndNullPoolMemory(jcr->impl->res.rpool_source);
- FreeAndNullPoolMemory(jcr->impl->res.wstore_source);
- FreeAndNullPoolMemory(jcr->impl->res.rstore_source);
- FreeAndNullPoolMemory(jcr->impl->res.catalog_source);
- FreeAndNullPoolMemory(jcr->impl->FDSecureEraseCmd);
- FreeAndNullPoolMemory(jcr->impl->SDSecureEraseCmd);
- FreeAndNullPoolMemory(jcr->impl->vf_jobids);
+ FreeAndNullPoolMemory(jcr->dir_impl->fname);
+ FreeAndNullPoolMemory(jcr->dir_impl->res.pool_source);
+ FreeAndNullPoolMemory(jcr->dir_impl->res.npool_source);
+ FreeAndNullPoolMemory(jcr->dir_impl->res.rpool_source);
+ FreeAndNullPoolMemory(jcr->dir_impl->res.wstore_source);
+ FreeAndNullPoolMemory(jcr->dir_impl->res.rstore_source);
+ FreeAndNullPoolMemory(jcr->dir_impl->res.catalog_source);
+ FreeAndNullPoolMemory(jcr->dir_impl->FDSecureEraseCmd);
+ FreeAndNullPoolMemory(jcr->dir_impl->SDSecureEraseCmd);
+ FreeAndNullPoolMemory(jcr->dir_impl->vf_jobids);
// Delete lists setup to hold storage pointers
FreeRwstorage(jcr);
@@ -1588,9 +1605,9 @@ void DirdFreeJcr(JobControlRecord* jcr)
FreePlugins(jcr); /* release instantiated plugins */
- if (jcr->impl) {
- delete jcr->impl;
- jcr->impl = nullptr;
+ if (jcr->dir_impl) {
+ delete jcr->dir_impl;
+ jcr->dir_impl = nullptr;
}
Dmsg0(200, "End dird FreeJcr\n");
@@ -1634,10 +1651,10 @@ void GetJobStorage(UnifiedStorageResource* store,
*/
void SetJcrDefaults(JobControlRecord* jcr, JobResource* job)
{
- jcr->impl->res.job = job;
+ jcr->dir_impl->res.job = job;
jcr->setJobType(job->JobType);
jcr->setJobProtocol(job->Protocol);
- jcr->JobStatus = JS_Created;
+ jcr->setJobStatus(JS_Created);
switch (jcr->getJobType()) {
case JT_ADMIN:
@@ -1651,18 +1668,18 @@ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job)
break;
}
- if (!jcr->impl->fname) { jcr->impl->fname = GetPoolMemory(PM_FNAME); }
- if (!jcr->impl->res.pool_source) {
- jcr->impl->res.pool_source = GetPoolMemory(PM_MESSAGE);
- PmStrcpy(jcr->impl->res.pool_source, _("unknown source"));
+ if (!jcr->dir_impl->fname) { jcr->dir_impl->fname = GetPoolMemory(PM_FNAME); }
+ if (!jcr->dir_impl->res.pool_source) {
+ jcr->dir_impl->res.pool_source = GetPoolMemory(PM_MESSAGE);
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("unknown source"));
}
- if (!jcr->impl->res.npool_source) {
- jcr->impl->res.npool_source = GetPoolMemory(PM_MESSAGE);
- PmStrcpy(jcr->impl->res.npool_source, _("unknown source"));
+ if (!jcr->dir_impl->res.npool_source) {
+ jcr->dir_impl->res.npool_source = GetPoolMemory(PM_MESSAGE);
+ PmStrcpy(jcr->dir_impl->res.npool_source, _("unknown source"));
}
- if (!jcr->impl->res.catalog_source) {
- jcr->impl->res.catalog_source = GetPoolMemory(PM_MESSAGE);
- PmStrcpy(jcr->impl->res.catalog_source, _("unknown source"));
+ if (!jcr->dir_impl->res.catalog_source) {
+ jcr->dir_impl->res.catalog_source = GetPoolMemory(PM_MESSAGE);
+ PmStrcpy(jcr->dir_impl->res.catalog_source, _("unknown source"));
}
jcr->JobPriority = job->Priority;
@@ -1673,48 +1690,48 @@ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job)
} else if (job->pool) {
CopyRwstorage(jcr, job->pool->storage, _("Pool resource"));
}
- jcr->impl->res.client = job->client;
+ jcr->dir_impl->res.client = job->client;
- if (jcr->impl->res.client) {
+ if (jcr->dir_impl->res.client) {
if (!jcr->client_name) { jcr->client_name = GetPoolMemory(PM_NAME); }
- PmStrcpy(jcr->client_name, jcr->impl->res.client->resource_name_);
+ PmStrcpy(jcr->client_name, jcr->dir_impl->res.client->resource_name_);
}
- PmStrcpy(jcr->impl->res.pool_source, _("Job resource"));
- jcr->impl->res.pool = job->pool;
- jcr->impl->res.full_pool = job->full_pool;
- jcr->impl->res.inc_pool = job->inc_pool;
- jcr->impl->res.diff_pool = job->diff_pool;
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("Job resource"));
+ jcr->dir_impl->res.pool = job->pool;
+ jcr->dir_impl->res.full_pool = job->full_pool;
+ jcr->dir_impl->res.inc_pool = job->inc_pool;
+ jcr->dir_impl->res.diff_pool = job->diff_pool;
if (job->pool && job->pool->catalog) {
- jcr->impl->res.catalog = job->pool->catalog;
- PmStrcpy(jcr->impl->res.catalog_source, _("Pool resource"));
+ jcr->dir_impl->res.catalog = job->pool->catalog;
+ PmStrcpy(jcr->dir_impl->res.catalog_source, _("Pool resource"));
} else {
if (job->catalog) {
- jcr->impl->res.catalog = job->catalog;
- PmStrcpy(jcr->impl->res.catalog_source, _("Job resource"));
+ jcr->dir_impl->res.catalog = job->catalog;
+ PmStrcpy(jcr->dir_impl->res.catalog_source, _("Job resource"));
} else {
if (job->client) {
- jcr->impl->res.catalog = job->client->catalog;
- PmStrcpy(jcr->impl->res.catalog_source, _("Client resource"));
+ jcr->dir_impl->res.catalog = job->client->catalog;
+ PmStrcpy(jcr->dir_impl->res.catalog_source, _("Client resource"));
} else {
- jcr->impl->res.catalog
+ jcr->dir_impl->res.catalog
= (CatalogResource*)my_config->GetNextRes(R_CATALOG, NULL);
- PmStrcpy(jcr->impl->res.catalog_source, _("Default catalog"));
+ PmStrcpy(jcr->dir_impl->res.catalog_source, _("Default catalog"));
}
}
}
- jcr->impl->res.fileset = job->fileset;
+ jcr->dir_impl->res.fileset = job->fileset;
jcr->accurate = job->accurate;
- jcr->impl->res.messages = job->messages;
- jcr->impl->spool_data = job->spool_data;
- jcr->impl->spool_size = job->spool_size;
- jcr->impl->IgnoreDuplicateJobChecking = job->IgnoreDuplicateJobChecking;
- jcr->impl->MaxRunSchedTime = job->MaxRunSchedTime;
+ jcr->dir_impl->res.messages = job->messages;
+ jcr->dir_impl->spool_data = job->spool_data;
+ jcr->dir_impl->spool_size = job->spool_size;
+ jcr->dir_impl->IgnoreDuplicateJobChecking = job->IgnoreDuplicateJobChecking;
+ jcr->dir_impl->MaxRunSchedTime = job->MaxRunSchedTime;
- if (jcr->impl->backup_format) { free(jcr->impl->backup_format); }
- jcr->impl->backup_format = strdup(job->backup_format);
+ if (jcr->dir_impl->backup_format) { free(jcr->dir_impl->backup_format); }
+ jcr->dir_impl->backup_format = strdup(job->backup_format);
if (jcr->RestoreBootstrap) {
free(jcr->RestoreBootstrap);
@@ -1727,7 +1744,7 @@ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job)
}
// This can be overridden by Console program
- jcr->impl->res.verify_job = job->verify_job;
+ jcr->dir_impl->res.verify_job = job->verify_job;
// If no default level given, set one
if (jcr->getJobLevel() == 0) {
@@ -1752,12 +1769,12 @@ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job)
void CreateClones(JobControlRecord* jcr)
{
// Fire off any clone jobs (run directives)
- Dmsg2(900, "cloned=%d run_cmds=%p\n", jcr->impl->cloned,
- jcr->impl->res.job->run_cmds);
- if (!jcr->impl->cloned && jcr->impl->res.job->run_cmds) {
- char* runcmd = nullptr;
+ Dmsg2(900, "cloned=%d run_cmds=%p\n", jcr->dir_impl->cloned,
+ jcr->dir_impl->res.job->run_cmds);
+ if (!jcr->dir_impl->cloned && jcr->dir_impl->res.job->run_cmds) {
+ const char* runcmd = nullptr;
JobId_t jobid;
- JobResource* job = jcr->impl->res.job;
+ JobResource* job = jcr->dir_impl->res.job;
POOLMEM* cmd = GetPoolMemory(PM_FNAME);
UaContext* ua = new_ua_context(jcr);
@@ -1782,7 +1799,7 @@ void CreateClones(JobControlRecord* jcr)
}
/**
- * Given: a JobId in jcr->impl_->previous_jr.JobId,
+ * Given: a JobId in jcr->dir_impl_->previous_jr.JobId,
* this subroutine writes a bsr file to restore that job.
* Returns: -1 on error
* number of files if OK
@@ -1795,24 +1812,24 @@ int CreateRestoreBootstrapFile(JobControlRecord* jcr)
rx.bsr = std::make_unique<RestoreBootstrapRecord>();
rx.JobIds = (char*)"";
- rx.bsr->JobId = jcr->impl->previous_jr.JobId;
+ rx.bsr->JobId = jcr->dir_impl->previous_jr.JobId;
ua = new_ua_context(jcr);
if (!AddVolumeInformationToBsr(ua, rx.bsr.get())) {
files = -1;
goto bail_out;
}
- for (uint32_t fi = 1; fi <= jcr->impl->previous_jr.JobFiles; fi++) {
+ for (uint32_t fi = 1; fi <= jcr->dir_impl->previous_jr.JobFiles; fi++) {
rx.bsr->fi->Add(fi);
}
- jcr->impl->ExpectedFiles = WriteBsrFile(ua, rx);
- if (jcr->impl->ExpectedFiles == 0) {
+ jcr->dir_impl->ExpectedFiles = WriteBsrFile(ua, rx);
+ if (jcr->dir_impl->ExpectedFiles == 0) {
files = 0;
goto bail_out;
}
FreeUaContext(ua);
rx.bsr.reset(nullptr);
- jcr->impl->needs_sd = true;
- return jcr->impl->ExpectedFiles;
+ jcr->dir_impl->needs_sd = true;
+ return jcr->dir_impl->ExpectedFiles;
bail_out:
FreeUaContext(ua);
diff --git a/core/src/dird/jobq.cc b/core/src/dird/jobq.cc
index 5d1bd8c17..0dd832e94 100644
--- a/core/src/dird/jobq.cc
+++ b/core/src/dird/jobq.cc
@@ -33,7 +33,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/jobq.h"
#include "dird/storage.h"
@@ -167,7 +167,7 @@ extern "C" void* sched_wait(void* arg)
Dmsg0(2300, "Enter sched_wait.\n");
free(arg);
time_t wtime = jcr->sched_time - time(NULL);
- jcr->setJobStatus(JS_WaitStartTime);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitStartTime);
// Wait until scheduled time arrives
if (wtime > 0) {
@@ -206,15 +206,15 @@ int JobqAdd(jobq_t* jq, JobControlRecord* jcr)
pthread_t id;
wait_pkt* sched_pkt;
- if (!jcr->impl->term_wait_inited) {
+ if (!jcr->dir_impl->term_wait_inited) {
// Initialize termination condition variable
- if ((status = pthread_cond_init(&jcr->impl->term_wait, NULL)) != 0) {
+ if ((status = pthread_cond_init(&jcr->dir_impl->term_wait, NULL)) != 0) {
BErrNo be;
Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"),
be.bstrerror(status));
return status;
}
- jcr->impl->term_wait_inited = true;
+ jcr->dir_impl->term_wait_inited = true;
}
Dmsg3(2300, "JobqAdd jobid=%d jcr=0x%x UseCount=%d\n", jcr->JobId, jcr,
@@ -421,7 +421,7 @@ extern "C" void* jobq_server(void* arg)
// Call user's routine here
Dmsg3(2300, "Calling user engine for jobid=%d use=%d stat=%c\n",
- jcr->JobId, jcr->UseCount(), jcr->JobStatus);
+ jcr->JobId, jcr->UseCount(), jcr->getJobStatus());
jq->engine(je->jcr);
// Job finished detach from thread
@@ -441,12 +441,12 @@ extern "C" void* jobq_server(void* arg)
* been acquired for jobs canceled before they were put into the ready
* queue.
*/
- if (jcr->impl->acquired_resource_locks) {
+ if (jcr->dir_impl->acquired_resource_locks) {
DecReadStore(jcr);
DecWriteStore(jcr);
DecClientConcurrency(jcr);
DecJobConcurrency(jcr);
- jcr->impl->acquired_resource_locks = false;
+ jcr->dir_impl->acquired_resource_locks = false;
}
if (RescheduleJob(jcr, jq, je)) { continue; /* go look for more work */ }
@@ -454,7 +454,7 @@ extern "C" void* jobq_server(void* arg)
// Clean up and release old jcr
Dmsg2(2300, "====== Termination job=%d use_cnt=%d\n", jcr->JobId,
jcr->UseCount());
- jcr->impl->SDJobStatus = 0;
+ jcr->dir_impl->SDJobStatus = 0;
unlock_mutex(jq->mutex); /* release internal lock */
FreeJcr(jcr);
free(je); /* release job entry */
@@ -475,10 +475,10 @@ extern "C" void* jobq_server(void* arg)
running_allow_mix = true;
for (; re;) {
- Dmsg2(
- 2300, "JobId %d is also running with %s\n", re->jcr->JobId,
- re->jcr->impl->res.job->allow_mixed_priority ? "mix" : "no mix");
- if (!re->jcr->impl->res.job->allow_mixed_priority) {
+ Dmsg2(2300, "JobId %d is also running with %s\n", re->jcr->JobId,
+ re->jcr->dir_impl->res.job->allow_mixed_priority ? "mix"
+ : "no mix");
+ if (!re->jcr->dir_impl->res.job->allow_mixed_priority) {
running_allow_mix = false;
break;
}
@@ -502,14 +502,14 @@ extern "C" void* jobq_server(void* arg)
Dmsg4(2300, "Examining Job=%d JobPri=%d want Pri=%d (%s)\n", jcr->JobId,
jcr->JobPriority, Priority,
- jcr->impl->res.job->allow_mixed_priority ? "mix" : "no mix");
+ jcr->dir_impl->res.job->allow_mixed_priority ? "mix" : "no mix");
// Take only jobs of correct Priority
if (!(jcr->JobPriority == Priority
|| (jcr->JobPriority < Priority
- && jcr->impl->res.job->allow_mixed_priority
+ && jcr->dir_impl->res.job->allow_mixed_priority
&& running_allow_mix))) {
- jcr->setJobStatus(JS_WaitPriority);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitPriority);
break;
}
@@ -593,15 +593,16 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je)
// Reschedule the job if requested and possible
// Basic condition is that more reschedule times remain
- if (jcr->impl->res.job->RescheduleTimes == 0
- || jcr->impl->reschedule_count < jcr->impl->res.job->RescheduleTimes) {
+ if (jcr->dir_impl->res.job->RescheduleTimes == 0
+ || jcr->dir_impl->reschedule_count
+ < jcr->dir_impl->res.job->RescheduleTimes) {
resched =
// Check for incomplete jobs
- (jcr->impl->res.job->RescheduleIncompleteJobs && jcr->IsIncomplete()
+ (jcr->dir_impl->res.job->RescheduleIncompleteJobs && jcr->IsIncomplete()
&& jcr->is_JobType(JT_BACKUP) && !jcr->is_JobLevel(L_BASE))
||
// Check for failed jobs
- (jcr->impl->res.job->RescheduleOnError && !jcr->IsTerminatedOk()
+ (jcr->dir_impl->res.job->RescheduleOnError && !jcr->IsTerminatedOk()
&& !jcr->is_JobStatus(JS_Canceled) && jcr->is_JobType(JT_BACKUP));
}
@@ -614,19 +615,19 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je)
* possible.
*/
now = time(NULL);
- jcr->impl->reschedule_count++;
- jcr->sched_time = now + jcr->impl->res.job->RescheduleInterval;
+ jcr->dir_impl->reschedule_count++;
+ jcr->sched_time = now + jcr->dir_impl->res.job->RescheduleInterval;
bstrftime(dt, sizeof(dt), now);
bstrftime(dt2, sizeof(dt2), jcr->sched_time);
Dmsg4(2300, "Rescheduled Job %s to re-run in %d seconds.(now=%u,then=%u)\n",
- jcr->Job, (int)jcr->impl->res.job->RescheduleInterval, now,
+ jcr->Job, (int)jcr->dir_impl->res.job->RescheduleInterval, now,
jcr->sched_time);
Jmsg(jcr, M_INFO, 0,
_("Rescheduled Job %s at %s to re-run in %d seconds (%s).\n"),
- jcr->Job, dt, (int)jcr->impl->res.job->RescheduleInterval, dt2);
+ jcr->Job, dt, (int)jcr->dir_impl->res.job->RescheduleInterval, dt2);
DirdFreeJcrPointers(jcr); /* partial cleanup old stuff */
- jcr->JobStatus = -1;
- jcr->impl->SDJobStatus = 0;
+ jcr->setJobStatus(-1);
+ jcr->dir_impl->SDJobStatus = 0;
jcr->JobErrors = 0;
if (!AllowDuplicateJob(jcr)) { return false; }
@@ -638,7 +639,7 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je)
UpdateJobEnd(jcr, JS_WaitStartTime);
Dmsg2(2300, "Requeue job=%d use=%d\n", jcr->JobId, jcr->UseCount());
unlock_mutex(jq->mutex);
- jcr->impl->jr.RealEndTime = 0;
+ jcr->dir_impl->jr.RealEndTime = 0;
JobqAdd(jq, jcr); /* queue the job to run again */
lock_mutex(jq->mutex);
FreeJcr(jcr); /* release jcr */
@@ -653,43 +654,45 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je)
* conflicts. We now create a new job, copying the
* appropriate fields.
*/
- jcr->setJobStatus(JS_WaitStartTime);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitStartTime);
njcr = NewDirectorJcr(DirdFreeJcr);
- SetJcrDefaults(njcr, jcr->impl->res.job);
- njcr->impl->reschedule_count = jcr->impl->reschedule_count;
+ SetJcrDefaults(njcr, jcr->dir_impl->res.job);
+ njcr->dir_impl->reschedule_count = jcr->dir_impl->reschedule_count;
njcr->sched_time = jcr->sched_time;
njcr->initial_sched_time = jcr->initial_sched_time;
njcr->setJobLevel(jcr->getJobLevel());
- njcr->impl->res.pool = jcr->impl->res.pool;
- njcr->impl->res.run_pool_override = jcr->impl->res.run_pool_override;
- njcr->impl->res.full_pool = jcr->impl->res.full_pool;
- njcr->impl->res.run_full_pool_override
- = jcr->impl->res.run_full_pool_override;
- njcr->impl->res.inc_pool = jcr->impl->res.inc_pool;
- njcr->impl->res.run_inc_pool_override
- = jcr->impl->res.run_inc_pool_override;
- njcr->impl->res.diff_pool = jcr->impl->res.diff_pool;
- njcr->impl->res.run_diff_pool_override
- = jcr->impl->res.run_diff_pool_override;
- njcr->impl->res.next_pool = jcr->impl->res.next_pool;
- njcr->impl->res.run_next_pool_override
- = jcr->impl->res.run_next_pool_override;
- njcr->JobStatus = -1;
- njcr->setJobStatus(jcr->JobStatus);
- if (jcr->impl->res.read_storage) {
- CopyRstorage(njcr, jcr->impl->res.read_storage_list, _("previous Job"));
+ njcr->dir_impl->res.pool = jcr->dir_impl->res.pool;
+ njcr->dir_impl->res.run_pool_override
+ = jcr->dir_impl->res.run_pool_override;
+ njcr->dir_impl->res.full_pool = jcr->dir_impl->res.full_pool;
+ njcr->dir_impl->res.run_full_pool_override
+ = jcr->dir_impl->res.run_full_pool_override;
+ njcr->dir_impl->res.inc_pool = jcr->dir_impl->res.inc_pool;
+ njcr->dir_impl->res.run_inc_pool_override
+ = jcr->dir_impl->res.run_inc_pool_override;
+ njcr->dir_impl->res.diff_pool = jcr->dir_impl->res.diff_pool;
+ njcr->dir_impl->res.run_diff_pool_override
+ = jcr->dir_impl->res.run_diff_pool_override;
+ njcr->dir_impl->res.next_pool = jcr->dir_impl->res.next_pool;
+ njcr->dir_impl->res.run_next_pool_override
+ = jcr->dir_impl->res.run_next_pool_override;
+ njcr->setJobStatus(-1);
+ njcr->setJobStatusWithPriorityCheck(jcr->getJobStatus());
+ if (jcr->dir_impl->res.read_storage) {
+ CopyRstorage(njcr, jcr->dir_impl->res.read_storage_list,
+ _("previous Job"));
} else {
FreeRstorage(njcr);
}
- if (jcr->impl->res.write_storage) {
- CopyWstorage(njcr, jcr->impl->res.write_storage_list,
+ if (jcr->dir_impl->res.write_storage) {
+ CopyWstorage(njcr, jcr->dir_impl->res.write_storage_list,
_("previous Job"));
} else {
FreeWstorage(njcr);
}
- njcr->impl->res.messages = jcr->impl->res.messages;
- njcr->impl->spool_data = jcr->impl->spool_data;
+ njcr->dir_impl->res.messages = jcr->dir_impl->res.messages;
+ njcr->dir_impl->spool_data = jcr->dir_impl->spool_data;
Dmsg0(2300, "Call to run new job\n");
unlock_mutex(jq->mutex);
RunJob(njcr); /* This creates a "new" job */
@@ -712,7 +715,7 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je)
static bool AcquireResources(JobControlRecord* jcr)
{
// Set that we didn't acquire any resourse locks yet.
- jcr->impl->acquired_resource_locks = false;
+ jcr->dir_impl->acquired_resource_locks = false;
/*
* Some Job Types are excluded from the client and storage concurrency
@@ -726,11 +729,11 @@ static bool AcquireResources(JobControlRecord* jcr)
* Migration/Copy and Consolidation jobs are not counted for client
* concurrency as they do not touch the client at all
*/
- jcr->impl->IgnoreClientConcurrency = true;
+ jcr->dir_impl->IgnoreClientConcurrency = true;
Dmsg1(200, "Skipping migrate/copy Job %s for client concurrency\n",
jcr->Job);
- if (jcr->impl->MigrateJobId == 0) {
+ if (jcr->dir_impl->MigrateJobId == 0) {
/*
* Migration/Copy control jobs are not counted for storage concurrency
* as they do not touch the storage at all
@@ -738,25 +741,25 @@ static bool AcquireResources(JobControlRecord* jcr)
Dmsg1(200,
"Skipping migrate/copy Control Job %s for storage concurrency\n",
jcr->Job);
- jcr->impl->IgnoreStorageConcurrency = true;
+ jcr->dir_impl->IgnoreStorageConcurrency = true;
}
break;
default:
break;
}
- if (jcr->impl->res.read_storage) {
+ if (jcr->dir_impl->res.read_storage) {
if (!IncReadStore(jcr)) {
- jcr->setJobStatus(JS_WaitStoreRes);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitStoreRes);
return false;
}
}
- if (jcr->impl->res.write_storage) {
+ if (jcr->dir_impl->res.write_storage) {
if (!IncWriteStore(jcr)) {
DecReadStore(jcr);
- jcr->setJobStatus(JS_WaitStoreRes);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitStoreRes);
return false;
}
@@ -766,7 +769,7 @@ static bool AcquireResources(JobControlRecord* jcr)
// Back out previous locks
DecWriteStore(jcr);
DecReadStore(jcr);
- jcr->setJobStatus(JS_WaitClientRes);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitClientRes);
return false;
}
@@ -776,28 +779,29 @@ static bool AcquireResources(JobControlRecord* jcr)
DecWriteStore(jcr);
DecReadStore(jcr);
DecClientConcurrency(jcr);
- jcr->setJobStatus(JS_WaitJobRes);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitJobRes);
return false;
}
- jcr->impl->acquired_resource_locks = true;
+ jcr->dir_impl->acquired_resource_locks = true;
return true;
}
static bool IncClientConcurrency(JobControlRecord* jcr)
{
- if (!jcr->impl->res.client || jcr->impl->IgnoreClientConcurrency) {
+ if (!jcr->dir_impl->res.client || jcr->dir_impl->IgnoreClientConcurrency) {
return true;
}
lock_mutex(mutex);
- if (jcr->impl->res.client->rcs->NumConcurrentJobs
- < jcr->impl->res.client->MaxConcurrentJobs) {
- jcr->impl->res.client->rcs->NumConcurrentJobs++;
- Dmsg2(50, "Inc Client=%s rncj=%d\n", jcr->impl->res.client->resource_name_,
- jcr->impl->res.client->rcs->NumConcurrentJobs);
+ if (jcr->dir_impl->res.client->rcs->NumConcurrentJobs
+ < jcr->dir_impl->res.client->MaxConcurrentJobs) {
+ jcr->dir_impl->res.client->rcs->NumConcurrentJobs++;
+ Dmsg2(50, "Inc Client=%s rncj=%d\n",
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->res.client->rcs->NumConcurrentJobs);
unlock_mutex(mutex);
return true;
@@ -810,13 +814,14 @@ static bool IncClientConcurrency(JobControlRecord* jcr)
static void DecClientConcurrency(JobControlRecord* jcr)
{
- if (jcr->impl->IgnoreClientConcurrency) { return; }
+ if (jcr->dir_impl->IgnoreClientConcurrency) { return; }
lock_mutex(mutex);
- if (jcr->impl->res.client) {
- jcr->impl->res.client->rcs->NumConcurrentJobs--;
- Dmsg2(50, "Dec Client=%s rncj=%d\n", jcr->impl->res.client->resource_name_,
- jcr->impl->res.client->rcs->NumConcurrentJobs);
+ if (jcr->dir_impl->res.client) {
+ jcr->dir_impl->res.client->rcs->NumConcurrentJobs--;
+ Dmsg2(50, "Dec Client=%s rncj=%d\n",
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->res.client->rcs->NumConcurrentJobs);
}
unlock_mutex(mutex);
}
@@ -824,11 +829,11 @@ static void DecClientConcurrency(JobControlRecord* jcr)
static bool IncJobConcurrency(JobControlRecord* jcr)
{
lock_mutex(mutex);
- if (jcr->impl->res.job->rjs->NumConcurrentJobs
- < jcr->impl->res.job->MaxConcurrentJobs) {
- jcr->impl->res.job->rjs->NumConcurrentJobs++;
- Dmsg2(50, "Inc Job=%s rncj=%d\n", jcr->impl->res.job->resource_name_,
- jcr->impl->res.job->rjs->NumConcurrentJobs);
+ if (jcr->dir_impl->res.job->rjs->NumConcurrentJobs
+ < jcr->dir_impl->res.job->MaxConcurrentJobs) {
+ jcr->dir_impl->res.job->rjs->NumConcurrentJobs++;
+ Dmsg2(50, "Inc Job=%s rncj=%d\n", jcr->dir_impl->res.job->resource_name_,
+ jcr->dir_impl->res.job->rjs->NumConcurrentJobs);
unlock_mutex(mutex);
return true;
@@ -842,9 +847,9 @@ static bool IncJobConcurrency(JobControlRecord* jcr)
static void DecJobConcurrency(JobControlRecord* jcr)
{
lock_mutex(mutex);
- jcr->impl->res.job->rjs->NumConcurrentJobs--;
- Dmsg2(50, "Dec Job=%s rncj=%d\n", jcr->impl->res.job->resource_name_,
- jcr->impl->res.job->rjs->NumConcurrentJobs);
+ jcr->dir_impl->res.job->rjs->NumConcurrentJobs--;
+ Dmsg2(50, "Dec Job=%s rncj=%d\n", jcr->dir_impl->res.job->resource_name_,
+ jcr->dir_impl->res.job->rjs->NumConcurrentJobs);
unlock_mutex(mutex);
}
@@ -854,18 +859,19 @@ static void DecJobConcurrency(JobControlRecord* jcr)
*/
bool IncReadStore(JobControlRecord* jcr)
{
- if (jcr->impl->IgnoreStorageConcurrency) { return true; }
+ if (jcr->dir_impl->IgnoreStorageConcurrency) { return true; }
lock_mutex(mutex);
- if (jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs
- < jcr->impl->res.read_storage->MaxConcurrentJobs) {
- jcr->impl->res.read_storage->runtime_storage_status
+ if (jcr->dir_impl->res.read_storage->runtime_storage_status->NumConcurrentJobs
+ < jcr->dir_impl->res.read_storage->MaxConcurrentJobs) {
+ jcr->dir_impl->res.read_storage->runtime_storage_status
->NumConcurrentReadJobs++;
- jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs++;
- Dmsg2(
- 50, "Inc Rstore=%s rncj=%d\n",
- jcr->impl->res.read_storage->resource_name_,
- jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs);
+ jcr->dir_impl->res.read_storage->runtime_storage_status
+ ->NumConcurrentJobs++;
+ Dmsg2(50, "Inc Rstore=%s rncj=%d\n",
+ jcr->dir_impl->res.read_storage->resource_name_,
+ jcr->dir_impl->res.read_storage->runtime_storage_status
+ ->NumConcurrentJobs);
unlock_mutex(mutex);
return true;
@@ -873,38 +879,42 @@ bool IncReadStore(JobControlRecord* jcr)
unlock_mutex(mutex);
Dmsg2(50, "Fail to acquire Rstore=%s rncj=%d\n",
- jcr->impl->res.read_storage->resource_name_,
- jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs);
+ jcr->dir_impl->res.read_storage->resource_name_,
+ jcr->dir_impl->res.read_storage->runtime_storage_status
+ ->NumConcurrentJobs);
return false;
}
void DecReadStore(JobControlRecord* jcr)
{
- if (jcr->impl->res.read_storage && !jcr->impl->IgnoreStorageConcurrency) {
+ if (jcr->dir_impl->res.read_storage
+ && !jcr->dir_impl->IgnoreStorageConcurrency) {
lock_mutex(mutex);
- jcr->impl->res.read_storage->runtime_storage_status
+ jcr->dir_impl->res.read_storage->runtime_storage_status
->NumConcurrentReadJobs--;
- jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs--;
- Dmsg2(
- 50, "Dec Rstore=%s rncj=%d\n",
- jcr->impl->res.read_storage->resource_name_,
- jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs);
+ jcr->dir_impl->res.read_storage->runtime_storage_status
+ ->NumConcurrentJobs--;
+ Dmsg2(50, "Dec Rstore=%s rncj=%d\n",
+ jcr->dir_impl->res.read_storage->resource_name_,
+ jcr->dir_impl->res.read_storage->runtime_storage_status
+ ->NumConcurrentJobs);
- if (jcr->impl->res.read_storage->runtime_storage_status
+ if (jcr->dir_impl->res.read_storage->runtime_storage_status
->NumConcurrentReadJobs
< 0) {
Jmsg(jcr, M_FATAL, 0, _("NumConcurrentReadJobs Dec Rstore=%s rncj=%d\n"),
- jcr->impl->res.read_storage->resource_name_,
- jcr->impl->res.read_storage->runtime_storage_status
+ jcr->dir_impl->res.read_storage->resource_name_,
+ jcr->dir_impl->res.read_storage->runtime_storage_status
->NumConcurrentReadJobs);
}
- if (jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs
+ if (jcr->dir_impl->res.read_storage->runtime_storage_status
+ ->NumConcurrentJobs
< 0) {
Jmsg(jcr, M_FATAL, 0, _("NumConcurrentJobs Dec Rstore=%s rncj=%d\n"),
- jcr->impl->res.read_storage->resource_name_,
- jcr->impl->res.read_storage->runtime_storage_status
+ jcr->dir_impl->res.read_storage->resource_name_,
+ jcr->dir_impl->res.read_storage->runtime_storage_status
->NumConcurrentJobs);
}
unlock_mutex(mutex);
@@ -913,15 +923,17 @@ void DecReadStore(JobControlRecord* jcr)
static bool IncWriteStore(JobControlRecord* jcr)
{
- if (jcr->impl->IgnoreStorageConcurrency) { return true; }
+ if (jcr->dir_impl->IgnoreStorageConcurrency) { return true; }
lock_mutex(mutex);
- if (jcr->impl->res.write_storage->runtime_storage_status->NumConcurrentJobs
- < jcr->impl->res.write_storage->MaxConcurrentJobs) {
- jcr->impl->res.write_storage->runtime_storage_status->NumConcurrentJobs++;
+ if (jcr->dir_impl->res.write_storage->runtime_storage_status
+ ->NumConcurrentJobs
+ < jcr->dir_impl->res.write_storage->MaxConcurrentJobs) {
+ jcr->dir_impl->res.write_storage->runtime_storage_status
+ ->NumConcurrentJobs++;
Dmsg2(50, "Inc Wstore=%s wncj=%d\n",
- jcr->impl->res.write_storage->resource_name_,
- jcr->impl->res.write_storage->runtime_storage_status
+ jcr->dir_impl->res.write_storage->resource_name_,
+ jcr->dir_impl->res.write_storage->runtime_storage_status
->NumConcurrentJobs);
unlock_mutex(mutex);
@@ -929,29 +941,32 @@ static bool IncWriteStore(JobControlRecord* jcr)
}
unlock_mutex(mutex);
- Dmsg2(
- 50, "Fail to acquire Wstore=%s wncj=%d\n",
- jcr->impl->res.write_storage->resource_name_,
- jcr->impl->res.write_storage->runtime_storage_status->NumConcurrentJobs);
+ Dmsg2(50, "Fail to acquire Wstore=%s wncj=%d\n",
+ jcr->dir_impl->res.write_storage->resource_name_,
+ jcr->dir_impl->res.write_storage->runtime_storage_status
+ ->NumConcurrentJobs);
return false;
}
static void DecWriteStore(JobControlRecord* jcr)
{
- if (jcr->impl->res.write_storage && !jcr->impl->IgnoreStorageConcurrency) {
+ if (jcr->dir_impl->res.write_storage
+ && !jcr->dir_impl->IgnoreStorageConcurrency) {
lock_mutex(mutex);
- jcr->impl->res.write_storage->runtime_storage_status->NumConcurrentJobs--;
+ jcr->dir_impl->res.write_storage->runtime_storage_status
+ ->NumConcurrentJobs--;
Dmsg2(50, "Dec Wstore=%s wncj=%d\n",
- jcr->impl->res.write_storage->resource_name_,
- jcr->impl->res.write_storage->runtime_storage_status
+ jcr->dir_impl->res.write_storage->resource_name_,
+ jcr->dir_impl->res.write_storage->runtime_storage_status
->NumConcurrentJobs);
- if (jcr->impl->res.write_storage->runtime_storage_status->NumConcurrentJobs
+ if (jcr->dir_impl->res.write_storage->runtime_storage_status
+ ->NumConcurrentJobs
< 0) {
Jmsg(jcr, M_FATAL, 0, _("NumConcurrentJobs Dec Wstore=%s wncj=%d\n"),
- jcr->impl->res.write_storage->resource_name_,
- jcr->impl->res.write_storage->runtime_storage_status
+ jcr->dir_impl->res.write_storage->resource_name_,
+ jcr->dir_impl->res.write_storage->runtime_storage_status
->NumConcurrentJobs);
}
unlock_mutex(mutex);
diff --git a/core/src/dird/migrate.cc b/core/src/dird/migrate.cc
index 1b52f183f..22fe386e4 100644
--- a/core/src/dird/migrate.cc
+++ b/core/src/dird/migrate.cc
@@ -42,7 +42,7 @@
#include "dird.h"
#include "dird/dird_globals.h"
#include "dird/backup.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/migration.h"
#include "dird/msgchan.h"
@@ -250,7 +250,7 @@ static inline bool SetMigrationNextPool(JobControlRecord* jcr,
* Get the PoolId used with the original job. Then
* find the pool name from the database record.
*/
- pr.PoolId = jcr->impl->jr.PoolId;
+ pr.PoolId = jcr->dir_impl->jr.PoolId;
if (!jcr->db->GetPoolRecord(jcr, &pr)) {
Jmsg(jcr, M_FATAL, 0, _("Pool for JobId %s not in database. ERR=%s\n"),
edit_int64(pr.PoolId, ed1), jcr->db->strerror());
@@ -266,22 +266,24 @@ static inline bool SetMigrationNextPool(JobControlRecord* jcr,
}
// See if there is a next pool override.
- if (jcr->impl->res.run_next_pool_override) {
- PmStrcpy(jcr->impl->res.npool_source, _("Run NextPool override"));
- PmStrcpy(jcr->impl->res.pool_source, _("Run NextPool override"));
+ if (jcr->dir_impl->res.run_next_pool_override) {
+ PmStrcpy(jcr->dir_impl->res.npool_source, _("Run NextPool override"));
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("Run NextPool override"));
storage_source = _("Storage from Run NextPool override");
} else {
// See if there is a next pool override in the Job definition.
- if (jcr->impl->res.job->next_pool) {
- jcr->impl->res.next_pool = jcr->impl->res.job->next_pool;
- PmStrcpy(jcr->impl->res.npool_source, _("Job's NextPool resource"));
- PmStrcpy(jcr->impl->res.pool_source, _("Job's NextPool resource"));
+ if (jcr->dir_impl->res.job->next_pool) {
+ jcr->dir_impl->res.next_pool = jcr->dir_impl->res.job->next_pool;
+ PmStrcpy(jcr->dir_impl->res.npool_source, _("Job's NextPool resource"));
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("Job's NextPool resource"));
storage_source = _("Storage from Job's NextPool resource");
} else {
// Fall back to the pool's NextPool definition.
- jcr->impl->res.next_pool = pool->NextPool;
- PmStrcpy(jcr->impl->res.npool_source, _("Job Pool's NextPool resource"));
- PmStrcpy(jcr->impl->res.pool_source, _("Job Pool's NextPool resource"));
+ jcr->dir_impl->res.next_pool = pool->NextPool;
+ PmStrcpy(jcr->dir_impl->res.npool_source,
+ _("Job Pool's NextPool resource"));
+ PmStrcpy(jcr->dir_impl->res.pool_source,
+ _("Job Pool's NextPool resource"));
storage_source = _("Storage from Pool's NextPool resource");
}
}
@@ -291,21 +293,21 @@ static inline bool SetMigrationNextPool(JobControlRecord* jcr,
* record exists in the database. Note, in this case, we
* will be migrating from pool to pool->NextPool.
*/
- if (jcr->impl->res.next_pool) {
- jcr->impl->jr.PoolId
- = GetOrCreatePoolRecord(jcr, jcr->impl->res.next_pool->resource_name_);
- if (jcr->impl->jr.PoolId == 0) { return false; }
+ if (jcr->dir_impl->res.next_pool) {
+ jcr->dir_impl->jr.PoolId = GetOrCreatePoolRecord(
+ jcr, jcr->dir_impl->res.next_pool->resource_name_);
+ if (jcr->dir_impl->jr.PoolId == 0) { return false; }
}
- if (!SetMigrationWstorage(jcr, pool, jcr->impl->res.next_pool,
+ if (!SetMigrationWstorage(jcr, pool, jcr->dir_impl->res.next_pool,
storage_source)) {
return false;
}
- jcr->impl->res.pool = jcr->impl->res.next_pool;
+ jcr->dir_impl->res.pool = jcr->dir_impl->res.next_pool;
Dmsg2(dbglevel, "Write pool=%s read rpool=%s\n",
- jcr->impl->res.pool->resource_name_,
- jcr->impl->res.rpool->resource_name_);
+ jcr->dir_impl->res.pool->resource_name_,
+ jcr->dir_impl->res.rpool->resource_name_);
return true;
}
@@ -315,8 +317,9 @@ static inline bool SameStorage(JobControlRecord* jcr)
{
StorageResource *read_store, *write_store;
- read_store = (StorageResource*)jcr->impl->res.read_storage_list->first();
- write_store = (StorageResource*)jcr->impl->res.write_storage_list->first();
+ read_store = (StorageResource*)jcr->dir_impl->res.read_storage_list->first();
+ write_store
+ = (StorageResource*)jcr->dir_impl->res.write_storage_list->first();
if (!read_store->autochanger && !write_store->autochanger
&& bstrcmp(read_store->resource_name_, write_store->resource_name_)) {
@@ -336,21 +339,22 @@ static inline void StartNewMigrationJob(JobControlRecord* jcr)
ua = new_ua_context(jcr);
ua->batch = true;
Mmsg(ua->cmd, "run job=\"%s\" jobid=%s ignoreduplicatecheck=yes",
- jcr->impl->res.job->resource_name_,
- edit_uint64(jcr->impl->MigrateJobId, ed1));
+ jcr->dir_impl->res.job->resource_name_,
+ edit_uint64(jcr->dir_impl->MigrateJobId, ed1));
// Make sure we have something to compare against.
- if (jcr->impl->res.pool) {
+ if (jcr->dir_impl->res.pool) {
// See if there was actually a pool override.
- if (jcr->impl->res.pool != jcr->impl->res.job->pool) {
- Mmsg(cmd, " pool=\"%s\"", jcr->impl->res.pool->resource_name_);
+ if (jcr->dir_impl->res.pool != jcr->dir_impl->res.job->pool) {
+ Mmsg(cmd, " pool=\"%s\"", jcr->dir_impl->res.pool->resource_name_);
PmStrcat(ua->cmd, cmd.c_str());
}
// See if there was actually a next pool override.
- if (jcr->impl->res.next_pool
- && jcr->impl->res.next_pool != jcr->impl->res.pool->NextPool) {
- Mmsg(cmd, " nextpool=\"%s\"", jcr->impl->res.next_pool->resource_name_);
+ if (jcr->dir_impl->res.next_pool
+ && jcr->dir_impl->res.next_pool != jcr->dir_impl->res.pool->NextPool) {
+ Mmsg(cmd, " nextpool=\"%s\"",
+ jcr->dir_impl->res.next_pool->resource_name_);
PmStrcat(ua->cmd, cmd.c_str());
}
}
@@ -532,7 +536,7 @@ static bool find_mediaid_then_jobids(JobControlRecord* jcr,
ids->count = 0;
// Basic query for MediaId
- Mmsg(query, query1, jcr->impl->res.rpool->resource_name_);
+ Mmsg(query, query1, jcr->dir_impl->res.rpool->resource_name_);
if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)ids)) {
Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror());
return false;
@@ -572,9 +576,9 @@ static inline bool FindJobidsOfPoolUncopiedJobs(JobControlRecord* jcr,
}
Dmsg1(dbglevel, "copy selection pattern=%s\n",
- jcr->impl->res.rpool->resource_name_);
+ jcr->dir_impl->res.rpool->resource_name_);
Mmsg(query, sql_jobids_of_pool_uncopied_jobs,
- jcr->impl->res.rpool->resource_name_);
+ jcr->dir_impl->res.rpool->resource_name_);
Dmsg1(dbglevel, "get uncopied jobs query=%s\n", query.c_str());
if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)ids)) {
Jmsg(jcr, M_FATAL, 0, _("SQL to get uncopied jobs failed. ERR=%s\n"),
@@ -601,16 +605,16 @@ static bool regex_find_jobids(JobControlRecord* jcr,
PoolMem query(PM_MESSAGE);
item_chain = new dlist<uitem>();
- if (!jcr->impl->res.job->selection_pattern) {
+ if (!jcr->dir_impl->res.job->selection_pattern) {
Jmsg(jcr, M_FATAL, 0, _("No %s %s selection pattern specified.\n"),
jcr->get_OperationName(), type);
goto bail_out;
}
Dmsg1(dbglevel, "regex-sel-pattern=%s\n",
- jcr->impl->res.job->selection_pattern);
+ jcr->dir_impl->res.job->selection_pattern);
// Basic query for names
- Mmsg(query, query1, jcr->impl->res.rpool->resource_name_);
+ Mmsg(query, query1, jcr->dir_impl->res.rpool->resource_name_);
Dmsg1(dbglevel, "get name query1=%s\n", query.c_str());
if (!jcr->db->SqlQuery(query.c_str(), UniqueNameHandler, (void*)item_chain)) {
Jmsg(jcr, M_FATAL, 0, _("SQL to get %s failed. ERR=%s\n"), type,
@@ -620,17 +624,18 @@ static bool regex_find_jobids(JobControlRecord* jcr,
Dmsg1(dbglevel, "query1 returned %d names\n", item_chain->size());
if (item_chain->size() == 0) {
Jmsg(jcr, M_INFO, 0, _("Query of Pool \"%s\" returned no Jobs to %s.\n"),
- jcr->impl->res.rpool->resource_name_, jcr->get_ActionName());
+ jcr->dir_impl->res.rpool->resource_name_, jcr->get_ActionName());
ok = true;
goto bail_out; /* skip regex match */
} else {
// Compile regex expression
- rc = regcomp(&preg, jcr->impl->res.job->selection_pattern, REG_EXTENDED);
+ rc = regcomp(&preg, jcr->dir_impl->res.job->selection_pattern,
+ REG_EXTENDED);
if (rc != 0) {
regerror(rc, &preg, prbuf, sizeof(prbuf));
Jmsg(jcr, M_FATAL, 0,
_("Could not compile regex pattern \"%s\" ERR=%s\n"),
- jcr->impl->res.job->selection_pattern, prbuf);
+ jcr->dir_impl->res.job->selection_pattern, prbuf);
goto bail_out;
}
@@ -674,7 +679,7 @@ static bool regex_find_jobids(JobControlRecord* jcr,
ids->count = 0;
foreach_dlist (item, item_chain) {
Dmsg2(dbglevel, "Got %s: %s\n", type, item->item);
- Mmsg(query, query2, item->item, jcr->impl->res.rpool->resource_name_);
+ Mmsg(query, query2, item->item, jcr->dir_impl->res.rpool->resource_name_);
Dmsg1(dbglevel, "get id from name query2=%s\n", query.c_str());
if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)ids)) {
Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror());
@@ -729,7 +734,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr)
mid.list = NULL;
jids.list = NULL;
- switch (jcr->impl->res.job->selection_type) {
+ switch (jcr->dir_impl->res.job->selection_type) {
case MT_JOB:
if (!regex_find_jobids(jcr, &ids, sql_job, sql_jobids_from_job, "Job")) {
goto bail_out;
@@ -748,13 +753,13 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr)
}
break;
case MT_SQLQUERY:
- if (!jcr->impl->res.job->selection_pattern) {
+ if (!jcr->dir_impl->res.job->selection_pattern) {
Jmsg(jcr, M_FATAL, 0, _("No %s SQL selection pattern specified.\n"),
jcr->get_OperationName());
goto bail_out;
}
- Dmsg1(dbglevel, "SQL=%s\n", jcr->impl->res.job->selection_pattern);
- if (!jcr->db->SqlQuery(jcr->impl->res.job->selection_pattern,
+ Dmsg1(dbglevel, "SQL=%s\n", jcr->dir_impl->res.job->selection_pattern);
+ if (!jcr->db->SqlQuery(jcr->dir_impl->res.job->selection_pattern,
UniqueDbidHandler, (void*)&ids)) {
Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror());
goto bail_out;
@@ -785,7 +790,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr)
ctx.count = 0;
// Find count of bytes in pool
- Mmsg(query, sql_pool_bytes, jcr->impl->res.rpool->resource_name_);
+ Mmsg(query, sql_pool_bytes, jcr->dir_impl->res.rpool->resource_name_);
if (!jcr->db->SqlQuery(query.c_str(), db_int64_handler, (void*)&ctx)) {
Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror());
@@ -801,9 +806,9 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr)
pool_bytes = ctx.value;
Dmsg2(dbglevel, "highbytes=%lld pool=%lld\n",
- jcr->impl->res.rpool->MigrationHighBytes, pool_bytes);
+ jcr->dir_impl->res.rpool->MigrationHighBytes, pool_bytes);
- if (pool_bytes < (int64_t)jcr->impl->res.rpool->MigrationHighBytes) {
+ if (pool_bytes < (int64_t)jcr->dir_impl->res.rpool->MigrationHighBytes) {
Jmsg(jcr, M_INFO, 0, _("No Volumes found to %s.\n"),
jcr->get_ActionName());
retval = true;
@@ -814,7 +819,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr)
ids.count = 0;
// Find a list of MediaIds that could be migrated
- Mmsg(query, sql_mediaids, jcr->impl->res.rpool->resource_name_);
+ Mmsg(query, sql_mediaids, jcr->dir_impl->res.rpool->resource_name_);
Dmsg1(dbglevel, "query=%s\n", query.c_str());
if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)&ids)) {
@@ -864,10 +869,11 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr)
Dmsg2(dbglevel, "Total %s Job bytes=%s\n", jcr->get_ActionName(),
edit_int64_with_commas(ctx.value, ed1));
Dmsg2(dbglevel, "lowbytes=%s poolafter=%s\n",
- edit_int64_with_commas(jcr->impl->res.rpool->MigrationLowBytes,
- ed1),
+ edit_int64_with_commas(
+ jcr->dir_impl->res.rpool->MigrationLowBytes, ed1),
edit_int64_with_commas(pool_bytes, ed2));
- if (pool_bytes <= (int64_t)jcr->impl->res.rpool->MigrationLowBytes) {
+ if (pool_bytes
+ <= (int64_t)jcr->dir_impl->res.rpool->MigrationLowBytes) {
Dmsg0(dbglevel, "We should be done.\n");
break;
}
@@ -883,11 +889,11 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr)
time_t ttime;
char dt[MAX_TIME_LENGTH];
- ttime = time(NULL) - (time_t)jcr->impl->res.rpool->MigrationTime;
+ ttime = time(NULL) - (time_t)jcr->dir_impl->res.rpool->MigrationTime;
bstrutime(dt, sizeof(dt), ttime);
ids.count = 0;
- Mmsg(query, sql_pool_time, jcr->impl->res.rpool->resource_name_, dt);
+ Mmsg(query, sql_pool_time, jcr->dir_impl->res.rpool->resource_name_, dt);
Dmsg1(dbglevel, "query=%s\n", query.c_str());
if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)&ids)) {
@@ -927,8 +933,8 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr)
Dmsg2(dbglevel, "Before loop count=%d ids=%s\n", ids.count, ids.list);
// Note: to not over load the system, limit the number of new jobs started.
- if (jcr->impl->res.job->MaxConcurrentCopies) {
- limit = jcr->impl->res.job->MaxConcurrentCopies;
+ if (jcr->dir_impl->res.job->MaxConcurrentCopies) {
+ limit = jcr->dir_impl->res.job->MaxConcurrentCopies;
apply_limit = true;
}
@@ -946,7 +952,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr)
retval = true;
goto bail_out;
}
- jcr->impl->MigrateJobId = JobId;
+ jcr->dir_impl->MigrateJobId = JobId;
if (apply_limit) {
// Don't start any more when limit reaches zero
@@ -958,7 +964,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr)
Dmsg0(dbglevel, "Back from StartNewMigrationJob\n");
}
- jcr->impl->HasSelectedJobs = true;
+ jcr->dir_impl->HasSelectedJobs = true;
retval = true;
bail_out:
@@ -992,9 +998,9 @@ bool DoMigrationInit(JobControlRecord* jcr)
if (!AllowDuplicateJob(jcr)) { return false; }
- jcr->impl->jr.PoolId
- = GetOrCreatePoolRecord(jcr, jcr->impl->res.pool->resource_name_);
- if (jcr->impl->jr.PoolId == 0) {
+ jcr->dir_impl->jr.PoolId
+ = GetOrCreatePoolRecord(jcr, jcr->dir_impl->res.pool->resource_name_);
+ if (jcr->dir_impl->jr.PoolId == 0) {
Dmsg1(dbglevel, "JobId=%d no PoolId\n", (int)jcr->JobId);
Jmsg(jcr, M_FATAL, 0, _("Could not get or create a Pool record.\n"));
return false;
@@ -1006,50 +1012,53 @@ bool DoMigrationInit(JobControlRecord* jcr)
* pool will be changed to point to the write pool,
* which comes from pool->NextPool.
*/
- jcr->impl->res.rpool = jcr->impl->res.pool; /* save read pool */
- PmStrcpy(jcr->impl->res.rpool_source, jcr->impl->res.pool_source);
+ jcr->dir_impl->res.rpool = jcr->dir_impl->res.pool; /* save read pool */
+ PmStrcpy(jcr->dir_impl->res.rpool_source, jcr->dir_impl->res.pool_source);
Dmsg2(dbglevel, "Read pool=%s (From %s)\n",
- jcr->impl->res.rpool->resource_name_, jcr->impl->res.rpool_source);
+ jcr->dir_impl->res.rpool->resource_name_,
+ jcr->dir_impl->res.rpool_source);
/*
* See if this is a control job e.g. the one that selects the Jobs to Migrate
* or Copy or one of the worker Jobs that do the actual Migration or Copy. If
- * jcr->impl_->MigrateJobId is set we know that its an actual Migration or
+ * jcr->dir_impl_->MigrateJobId is set we know that its an actual Migration or
* Copy Job.
*/
- if (jcr->impl->MigrateJobId != 0) {
+ if (jcr->dir_impl->MigrateJobId != 0) {
Dmsg1(dbglevel, "At Job start previous jobid=%u\n",
- jcr->impl->MigrateJobId);
+ jcr->dir_impl->MigrateJobId);
- jcr->impl->previous_jr.JobId = jcr->impl->MigrateJobId;
- Dmsg1(dbglevel, "Previous jobid=%d\n", (int)jcr->impl->previous_jr.JobId);
+ jcr->dir_impl->previous_jr.JobId = jcr->dir_impl->MigrateJobId;
+ Dmsg1(dbglevel, "Previous jobid=%d\n",
+ (int)jcr->dir_impl->previous_jr.JobId);
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) {
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->previous_jr)) {
Jmsg(jcr, M_FATAL, 0,
_("Could not get job record for JobId %s to %s. ERR=%s\n"),
- edit_int64(jcr->impl->previous_jr.JobId, ed1), jcr->get_ActionName(),
- jcr->db->strerror());
+ edit_int64(jcr->dir_impl->previous_jr.JobId, ed1),
+ jcr->get_ActionName(), jcr->db->strerror());
return false;
}
Jmsg(jcr, M_INFO, 0, _("%s using JobId=%s Job=%s\n"),
jcr->get_OperationName(),
- edit_int64(jcr->impl->previous_jr.JobId, ed1),
- jcr->impl->previous_jr.Job);
+ edit_int64(jcr->dir_impl->previous_jr.JobId, ed1),
+ jcr->dir_impl->previous_jr.Job);
Dmsg4(dbglevel, "%s JobId=%d using JobId=%s Job=%s\n",
jcr->get_OperationName(), jcr->JobId,
- edit_int64(jcr->impl->previous_jr.JobId, ed1),
- jcr->impl->previous_jr.Job);
+ edit_int64(jcr->dir_impl->previous_jr.JobId, ed1),
+ jcr->dir_impl->previous_jr.Job);
if (CreateRestoreBootstrapFile(jcr) < 0) {
Jmsg(jcr, M_FATAL, 0, _("Create bootstrap file failed.\n"));
return false;
}
- if (jcr->impl->previous_jr.JobId == 0 || jcr->impl->ExpectedFiles == 0) {
- jcr->setJobStatus(JS_Terminated);
+ if (jcr->dir_impl->previous_jr.JobId == 0
+ || jcr->dir_impl->ExpectedFiles == 0) {
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
Dmsg1(dbglevel, "JobId=%d expected files == 0\n", (int)jcr->JobId);
- if (jcr->impl->previous_jr.JobId == 0) {
+ if (jcr->dir_impl->previous_jr.JobId == 0) {
Jmsg(jcr, M_INFO, 0, _("No previous Job found to %s.\n"),
jcr->get_ActionName());
} else {
@@ -1061,22 +1070,23 @@ bool DoMigrationInit(JobControlRecord* jcr)
}
Dmsg5(dbglevel, "JobId=%d: Current: Name=%s JobId=%d Type=%c Level=%c\n",
- (int)jcr->JobId, jcr->impl->jr.Name, (int)jcr->impl->jr.JobId,
- jcr->impl->jr.JobType, jcr->impl->jr.JobLevel);
+ (int)jcr->JobId, jcr->dir_impl->jr.Name, (int)jcr->dir_impl->jr.JobId,
+ jcr->dir_impl->jr.JobType, jcr->dir_impl->jr.JobLevel);
- job = (JobResource*)my_config->GetResWithName(R_JOB, jcr->impl->jr.Name);
+ job = (JobResource*)my_config->GetResWithName(R_JOB,
+ jcr->dir_impl->jr.Name);
prev_job = (JobResource*)my_config->GetResWithName(
- R_JOB, jcr->impl->previous_jr.Name);
+ R_JOB, jcr->dir_impl->previous_jr.Name);
if (!job) {
Jmsg(jcr, M_FATAL, 0, _("Job resource not found for \"%s\".\n"),
- jcr->impl->jr.Name);
+ jcr->dir_impl->jr.Name);
return false;
}
if (!prev_job) {
Jmsg(jcr, M_FATAL, 0, _("Previous Job resource not found for \"%s\".\n"),
- jcr->impl->previous_jr.Name);
+ jcr->dir_impl->previous_jr.Name);
return false;
}
@@ -1091,29 +1101,33 @@ bool DoMigrationInit(JobControlRecord* jcr)
* If the current Job has no explicit client set use the client setting of
* the previous Job.
*/
- if (!jcr->impl->res.client && prev_job->client) {
- jcr->impl->res.client = prev_job->client;
+ if (!jcr->dir_impl->res.client && prev_job->client) {
+ jcr->dir_impl->res.client = prev_job->client;
if (!jcr->client_name) { jcr->client_name = GetPoolMemory(PM_NAME); }
- PmStrcpy(jcr->client_name, jcr->impl->res.client->resource_name_);
+ PmStrcpy(jcr->client_name, jcr->dir_impl->res.client->resource_name_);
}
/*
* If the current Job has no explicit fileset set use the client setting of
* the previous Job.
*/
- if (!jcr->impl->res.fileset) { jcr->impl->res.fileset = prev_job->fileset; }
+ if (!jcr->dir_impl->res.fileset) {
+ jcr->dir_impl->res.fileset = prev_job->fileset;
+ }
/*
* See if spooling data is not enabled yet. If so turn on spooling if
* requested in job
*/
- if (!jcr->impl->spool_data) { jcr->impl->spool_data = job->spool_data; }
+ if (!jcr->dir_impl->spool_data) {
+ jcr->dir_impl->spool_data = job->spool_data;
+ }
// Create a migration jcr
mig_jcr = NewDirectorJcr(DirdFreeJcr);
- jcr->impl->mig_jcr = mig_jcr;
- memcpy(&mig_jcr->impl->previous_jr, &jcr->impl->previous_jr,
- sizeof(mig_jcr->impl->previous_jr));
+ jcr->dir_impl->mig_jcr = mig_jcr;
+ memcpy(&mig_jcr->dir_impl->previous_jr, &jcr->dir_impl->previous_jr,
+ sizeof(mig_jcr->dir_impl->previous_jr));
/*
* Turn the mig_jcr into a "real" job that takes on the aspects of
@@ -1129,17 +1143,17 @@ bool DoMigrationInit(JobControlRecord* jcr)
SetJcrDefaults(mig_jcr, prev_job);
// Time value on this Job
- mig_jcr->impl->no_maxtime = true;
+ mig_jcr->dir_impl->no_maxtime = true;
// Don't check for duplicates on migration and copy jobs
- mig_jcr->impl->IgnoreDuplicateJobChecking = true;
+ mig_jcr->dir_impl->IgnoreDuplicateJobChecking = true;
/*
* Copy some overwrites back from the Control Job to the migration and copy
* job.
*/
- mig_jcr->impl->spool_data = jcr->impl->spool_data;
- mig_jcr->impl->spool_size = jcr->impl->spool_size;
+ mig_jcr->dir_impl->spool_data = jcr->dir_impl->spool_data;
+ mig_jcr->dir_impl->spool_size = jcr->dir_impl->spool_size;
if (!SetupJob(mig_jcr, true)) {
@@ -1151,21 +1165,21 @@ bool DoMigrationInit(JobControlRecord* jcr)
mig_jcr->cjcr = jcr;
// Now reset the job record from the previous job
- memcpy(&mig_jcr->impl->jr, &jcr->impl->previous_jr,
- sizeof(mig_jcr->impl->jr));
+ memcpy(&mig_jcr->dir_impl->jr, &jcr->dir_impl->previous_jr,
+ sizeof(mig_jcr->dir_impl->jr));
// Update the jr to reflect the new values of PoolId and JobId.
- mig_jcr->impl->jr.PoolId = jcr->impl->jr.PoolId;
- mig_jcr->impl->jr.JobId = mig_jcr->JobId;
+ mig_jcr->dir_impl->jr.PoolId = jcr->dir_impl->jr.PoolId;
+ mig_jcr->dir_impl->jr.JobId = mig_jcr->JobId;
if (SetMigrationNextPool(jcr, &pool)) {
// If pool storage specified, use it as source
CopyRstorage(mig_jcr, pool->storage, _("Pool resource"));
CopyRstorage(jcr, pool->storage, _("Pool resource"));
- mig_jcr->impl->res.pool = jcr->impl->res.pool;
- mig_jcr->impl->res.next_pool = jcr->impl->res.next_pool;
- mig_jcr->impl->jr.PoolId = jcr->impl->jr.PoolId;
+ mig_jcr->dir_impl->res.pool = jcr->dir_impl->res.pool;
+ mig_jcr->dir_impl->res.next_pool = jcr->dir_impl->res.next_pool;
+ mig_jcr->dir_impl->jr.PoolId = jcr->dir_impl->jr.PoolId;
}
/*
@@ -1173,7 +1187,7 @@ bool DoMigrationInit(JobControlRecord* jcr)
* This only happens when the original pool used doesn't have an explicit
* storage.
*/
- if (!jcr->impl->res.read_storage_list) {
+ if (!jcr->dir_impl->res.read_storage_list) {
CopyRstorage(jcr, prev_job->storage, _("previous Job"));
}
@@ -1183,16 +1197,16 @@ bool DoMigrationInit(JobControlRecord* jcr)
* otherwise we open a connection to the reading SD and a second
* one to the writing SD.
*/
- jcr->impl->remote_replicate = !IsSameStorageDaemon(
- jcr->impl->res.read_storage, jcr->impl->res.write_storage);
+ jcr->dir_impl->remote_replicate = !IsSameStorageDaemon(
+ jcr->dir_impl->res.read_storage, jcr->dir_impl->res.write_storage);
// set the JobLevel to what the original job was
- mig_jcr->setJobLevel(mig_jcr->impl->previous_jr.JobLevel);
+ mig_jcr->setJobLevel(mig_jcr->dir_impl->previous_jr.JobLevel);
Dmsg4(dbglevel, "mig_jcr: Name=%s JobId=%d Type=%c Level=%c\n",
- mig_jcr->impl->jr.Name, (int)mig_jcr->impl->jr.JobId,
- mig_jcr->impl->jr.JobType, mig_jcr->impl->jr.JobLevel);
+ mig_jcr->dir_impl->jr.Name, (int)mig_jcr->dir_impl->jr.JobId,
+ mig_jcr->dir_impl->jr.JobType, mig_jcr->dir_impl->jr.JobLevel);
}
return true;
@@ -1230,30 +1244,30 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
{
char ed1[100];
bool retval = false;
- JobControlRecord* mig_jcr = jcr->impl->mig_jcr;
+ JobControlRecord* mig_jcr = jcr->dir_impl->mig_jcr;
ASSERT(mig_jcr);
// Make sure this job was not already migrated
- if (jcr->impl->previous_jr.JobType != JT_BACKUP
- && jcr->impl->previous_jr.JobType != JT_JOB_COPY
- && jcr->impl->previous_jr.JobType != JT_ARCHIVE) {
+ if (jcr->dir_impl->previous_jr.JobType != JT_BACKUP
+ && jcr->dir_impl->previous_jr.JobType != JT_JOB_COPY
+ && jcr->dir_impl->previous_jr.JobType != JT_ARCHIVE) {
Jmsg(jcr, M_INFO, 0,
_("JobId %s already %s probably by another Job. %s stopped.\n"),
- edit_int64(jcr->impl->previous_jr.JobId, ed1),
+ edit_int64(jcr->dir_impl->previous_jr.JobId, ed1),
jcr->get_ActionName(true), jcr->get_OperationName());
- jcr->setJobStatus(JS_Terminated);
- MigrationCleanup(jcr, jcr->JobStatus);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
+ MigrationCleanup(jcr, jcr->getJobStatus());
return true;
}
if (SameStorage(jcr)) {
Jmsg(jcr, M_FATAL, 0,
_("JobId %s cannot %s using the same read and write storage.\n"),
- edit_int64(jcr->impl->previous_jr.JobId, ed1),
+ edit_int64(jcr->dir_impl->previous_jr.JobId, ed1),
jcr->get_OperationName());
- jcr->setJobStatus(JS_Terminated);
- MigrationCleanup(jcr, jcr->JobStatus);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
+ MigrationCleanup(jcr, jcr->getJobStatus());
return true;
}
@@ -1268,12 +1282,12 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
if (HasPairedStorage(jcr)) { SetPairedStorage(jcr); }
Dmsg2(dbglevel, "Read store=%s, write store=%s\n",
- ((StorageResource*)jcr->impl->res.read_storage_list->first())
+ ((StorageResource*)jcr->dir_impl->res.read_storage_list->first())
->resource_name_,
- ((StorageResource*)jcr->impl->res.write_storage_list->first())
+ ((StorageResource*)jcr->dir_impl->res.write_storage_list->first())
->resource_name_);
- if (jcr->impl->remote_replicate) {
+ if (jcr->dir_impl->remote_replicate) {
alist<StorageResource*>* write_storage_list;
/*
@@ -1283,12 +1297,12 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
* - Writing Storage Daemon bandwidth limiting
* - Reading Storage Daemon bandwidth limiting
*/
- if (jcr->impl->res.job->max_bandwidth > 0) {
- jcr->max_bandwidth = jcr->impl->res.job->max_bandwidth;
- } else if (jcr->impl->res.write_storage->max_bandwidth > 0) {
- jcr->max_bandwidth = jcr->impl->res.write_storage->max_bandwidth;
- } else if (jcr->impl->res.read_storage->max_bandwidth > 0) {
- jcr->max_bandwidth = jcr->impl->res.read_storage->max_bandwidth;
+ if (jcr->dir_impl->res.job->max_bandwidth > 0) {
+ jcr->max_bandwidth = jcr->dir_impl->res.job->max_bandwidth;
+ } else if (jcr->dir_impl->res.write_storage->max_bandwidth > 0) {
+ jcr->max_bandwidth = jcr->dir_impl->res.write_storage->max_bandwidth;
+ } else if (jcr->dir_impl->res.read_storage->max_bandwidth > 0) {
+ jcr->max_bandwidth = jcr->dir_impl->res.read_storage->max_bandwidth;
}
// Open a message channel connection to the Reading Storage daemon.
@@ -1299,16 +1313,17 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
* the jcr is connected to the reading storage daemon and the
* mig_jcr to the writing storage daemon.
*/
- mig_jcr->impl->res.write_storage = jcr->impl->res.write_storage;
- jcr->impl->res.write_storage = NULL;
+ mig_jcr->dir_impl->res.write_storage = jcr->dir_impl->res.write_storage;
+ jcr->dir_impl->res.write_storage = NULL;
// Swap the write_storage_list between the jcr and the mig_jcr.
- write_storage_list = mig_jcr->impl->res.write_storage_list;
- mig_jcr->impl->res.write_storage_list = jcr->impl->res.write_storage_list;
- jcr->impl->res.write_storage_list = write_storage_list;
+ write_storage_list = mig_jcr->dir_impl->res.write_storage_list;
+ mig_jcr->dir_impl->res.write_storage_list
+ = jcr->dir_impl->res.write_storage_list;
+ jcr->dir_impl->res.write_storage_list = write_storage_list;
// Start conversation with Reading Storage daemon
- jcr->setJobStatus(JS_WaitSD);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitSD);
if (!ConnectToStorageDaemon(jcr, 10, me->SDConnectTimeout, true)) {
goto bail_out;
}
@@ -1317,13 +1332,13 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
Dmsg0(110, "Open connection with writing storage daemon\n");
// Start conversation with Writing Storage daemon
- mig_jcr->setJobStatus(JS_WaitSD);
+ mig_jcr->setJobStatusWithPriorityCheck(JS_WaitSD);
if (!ConnectToStorageDaemon(mig_jcr, 10, me->SDConnectTimeout, true)) {
goto bail_out;
}
// Now start a job with the Reading Storage daemon
- if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list, NULL,
+ if (!StartStorageDaemonJob(jcr, jcr->dir_impl->res.read_storage_list, NULL,
/* send_bsr */ true)) {
goto bail_out;
}
@@ -1333,7 +1348,7 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
// Now start a job with the Writing Storage daemon
if (!StartStorageDaemonJob(mig_jcr, NULL,
- mig_jcr->impl->res.write_storage_list,
+ mig_jcr->dir_impl->res.write_storage_list,
/* send_bsr */ false)) {
goto bail_out;
}
@@ -1344,8 +1359,8 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
// Open a message channel connection with the Storage daemon.
Dmsg0(110, "Open connection with storage daemon\n");
- jcr->setJobStatus(JS_WaitSD);
- mig_jcr->setJobStatus(JS_WaitSD);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitSD);
+ mig_jcr->setJobStatusWithPriorityCheck(JS_WaitSD);
// Start conversation with Storage daemon
if (!ConnectToStorageDaemon(jcr, 10, me->SDConnectTimeout, true)) {
@@ -1354,8 +1369,8 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
}
// Now start a job with the Storage daemon
- if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list,
- jcr->impl->res.write_storage_list,
+ if (!StartStorageDaemonJob(jcr, jcr->dir_impl->res.read_storage_list,
+ jcr->dir_impl->res.write_storage_list,
/* send_bsr */ true)) {
FreePairedStorage(jcr);
return false;
@@ -1375,12 +1390,12 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
* is after the start of this run.
*/
jcr->start_time = time(NULL);
- jcr->impl->jr.StartTime = jcr->start_time;
- jcr->impl->jr.JobTDate = jcr->start_time;
- jcr->setJobStatus(JS_Running);
+ jcr->dir_impl->jr.StartTime = jcr->start_time;
+ jcr->dir_impl->jr.JobTDate = jcr->start_time;
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
// Update job start record for this migration control job
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
goto bail_out;
}
@@ -1389,28 +1404,28 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
jcr->setJobStarted();
mig_jcr->start_time = time(NULL);
- mig_jcr->impl->jr.StartTime = mig_jcr->start_time;
- mig_jcr->impl->jr.JobTDate = mig_jcr->start_time;
- mig_jcr->setJobStatus(JS_Running);
+ mig_jcr->dir_impl->jr.StartTime = mig_jcr->start_time;
+ mig_jcr->dir_impl->jr.JobTDate = mig_jcr->start_time;
+ mig_jcr->setJobStatusWithPriorityCheck(JS_Running);
// Update job start record for the real migration backup job
- if (!mig_jcr->db->UpdateJobStartRecord(mig_jcr, &mig_jcr->impl->jr)) {
+ if (!mig_jcr->db->UpdateJobStartRecord(mig_jcr, &mig_jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", mig_jcr->db->strerror());
goto bail_out;
}
Dmsg4(dbglevel, "mig_jcr: Name=%s JobId=%d Type=%c Level=%c\n",
- mig_jcr->impl->jr.Name, (int)mig_jcr->impl->jr.JobId,
- mig_jcr->impl->jr.JobType, mig_jcr->impl->jr.JobLevel);
+ mig_jcr->dir_impl->jr.Name, (int)mig_jcr->dir_impl->jr.JobId,
+ mig_jcr->dir_impl->jr.JobType, mig_jcr->dir_impl->jr.JobLevel);
/*
* If we are connected to two different SDs tell the writing one
* to be ready to receive the data and tell the reading one
* to replicate to the other.
*/
- if (jcr->impl->remote_replicate) {
- StorageResource* write_storage = mig_jcr->impl->res.write_storage;
- StorageResource* read_storage = jcr->impl->res.read_storage;
+ if (jcr->dir_impl->remote_replicate) {
+ StorageResource* write_storage = mig_jcr->dir_impl->res.write_storage;
+ StorageResource* read_storage = jcr->dir_impl->res.read_storage;
PoolMem command(PM_MESSAGE);
uint32_t tls_need = 0;
@@ -1455,8 +1470,8 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
// Now start a Storage daemon message thread
if (!StartStorageDaemonMessageThread(jcr)) { goto bail_out; }
- jcr->setJobStatus(JS_Running);
- mig_jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
+ mig_jcr->setJobStatusWithPriorityCheck(JS_Running);
/*
* Pickup Job termination data
@@ -1464,27 +1479,28 @@ static inline bool DoActualMigration(JobControlRecord* jcr)
* mig_jcr->JobFiles/ReadBytes/JobBytes/JobErrors when replicating to
* a remote storage daemon.
*/
- if (jcr->impl->remote_replicate) {
+ if (jcr->dir_impl->remote_replicate) {
WaitForStorageDaemonTermination(jcr);
WaitForStorageDaemonTermination(mig_jcr);
- jcr->setJobStatus(jcr->impl->SDJobStatus);
+ jcr->setJobStatusWithPriorityCheck(jcr->dir_impl->SDJobStatus);
if (mig_jcr->batch_started) {
mig_jcr->db_batch->WriteBatchFileRecords(mig_jcr);
}
} else {
WaitForStorageDaemonTermination(jcr);
- jcr->setJobStatus(jcr->impl->SDJobStatus);
+ jcr->setJobStatusWithPriorityCheck(jcr->dir_impl->SDJobStatus);
if (jcr->batch_started) { jcr->db_batch->WriteBatchFileRecords(jcr); }
}
bail_out:
- if (jcr->impl->remote_replicate && mig_jcr) {
+ if (jcr->dir_impl->remote_replicate && mig_jcr) {
alist<StorageResource*>* write_storage_list;
// Swap the write_storage_list between the jcr and the mig_jcr.
- write_storage_list = mig_jcr->impl->res.write_storage_list;
- mig_jcr->impl->res.write_storage_list = jcr->impl->res.write_storage_list;
- jcr->impl->res.write_storage_list = write_storage_list;
+ write_storage_list = mig_jcr->dir_impl->res.write_storage_list;
+ mig_jcr->dir_impl->res.write_storage_list
+ = jcr->dir_impl->res.write_storage_list;
+ jcr->dir_impl->res.write_storage_list = write_storage_list;
/*
* Undo the clear of the write_storage in the jcr and assign the mig_jcr
@@ -1494,14 +1510,14 @@ bail_out:
* the ConnectToStorageDaemon function will do the right thing e.g. connect
* the jcrs in the way we want them to.
*/
- jcr->impl->res.write_storage = mig_jcr->impl->res.write_storage;
- mig_jcr->impl->res.write_storage = NULL;
+ jcr->dir_impl->res.write_storage = mig_jcr->dir_impl->res.write_storage;
+ mig_jcr->dir_impl->res.write_storage = NULL;
}
FreePairedStorage(jcr);
if (jcr->is_JobStatus(JS_Terminated)) {
- MigrationCleanup(jcr, jcr->JobStatus);
+ MigrationCleanup(jcr, jcr->getJobStatus());
retval = true;
}
@@ -1515,10 +1531,10 @@ static inline bool DoMigrationSelection(JobControlRecord* jcr)
retval = getJobs_to_migrate(jcr);
if (retval) {
- jcr->setJobStatus(JS_Terminated);
- MigrationCleanup(jcr, jcr->JobStatus);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
+ MigrationCleanup(jcr, jcr->getJobStatus());
} else {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
return retval;
@@ -1529,9 +1545,9 @@ bool DoMigration(JobControlRecord* jcr)
/*
* See if this is a control job e.g. the one that selects the Jobs to Migrate
* or Copy or one of the worker Jobs that do the actual Migration or Copy. If
- * jcr->impl_->MigrateJobId is unset we know that its the control job.
+ * jcr->dir_impl_->MigrateJobId is unset we know that its the control job.
*/
- if (jcr->impl->MigrateJobId == 0) {
+ if (jcr->dir_impl->MigrateJobId == 0) {
return DoMigrationSelection(jcr);
} else {
return DoActualMigration(jcr);
@@ -1545,7 +1561,7 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr,
{
double kbps;
utime_t RunTime;
- JobControlRecord* mig_jcr = jcr->impl->mig_jcr;
+ JobControlRecord* mig_jcr = jcr->dir_impl->mig_jcr;
char term_code[100], sd_term_msg[100];
char sdt[MAX_TIME_LENGTH], edt[MAX_TIME_LENGTH];
char ec1[30], ec2[30], ec3[30], ec4[30], ec5[30], elapsed[50];
@@ -1553,17 +1569,18 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr,
Bsnprintf(term_code, sizeof(term_code), TermMsg, jcr->get_OperationName(),
jcr->get_ActionName());
- bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime);
- bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime);
- RunTime = jcr->impl->jr.EndTime - jcr->impl->jr.StartTime;
+ bstrftimes(sdt, sizeof(sdt), jcr->dir_impl->jr.StartTime);
+ bstrftimes(edt, sizeof(edt), jcr->dir_impl->jr.EndTime);
+ RunTime = jcr->dir_impl->jr.EndTime - jcr->dir_impl->jr.StartTime;
- JobstatusToAscii(jcr->impl->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
- if (jcr->impl->previous_jr.JobId != 0) {
+ JobstatusToAscii(jcr->dir_impl->SDJobStatus, sd_term_msg,
+ sizeof(sd_term_msg));
+ if (jcr->dir_impl->previous_jr.JobId != 0) {
// Copy/Migrate worker Job.
if (RunTime <= 0) {
kbps = 0;
} else {
- kbps = (double)jcr->impl->SDJobBytes / (1000 * RunTime);
+ kbps = (double)jcr->dir_impl->SDJobBytes / (1000 * RunTime);
}
Jmsg(jcr, msg_type, 0,
@@ -1601,38 +1618,42 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr,
" Termination: %s\n\n"),
BAREOS, my_name, kBareosVersionStrings.Full,
kBareosVersionStrings.ShortDate, kBareosVersionStrings.GetOsInfo(),
- edit_uint64(jcr->impl->previous_jr.JobId, ec6),
- jcr->impl->previous_jr.Job,
- mig_jcr ? edit_uint64(mig_jcr->impl->jr.JobId, ec7) : _("*None*"),
- edit_uint64(jcr->impl->jr.JobId, ec8), jcr->impl->jr.Job,
+ edit_uint64(jcr->dir_impl->previous_jr.JobId, ec6),
+ jcr->dir_impl->previous_jr.Job,
+ mig_jcr ? edit_uint64(mig_jcr->dir_impl->jr.JobId, ec7) : _("*None*"),
+ edit_uint64(jcr->dir_impl->jr.JobId, ec8), jcr->dir_impl->jr.Job,
JobLevelToString(jcr->getJobLevel()),
- jcr->impl->res.client ? jcr->impl->res.client->resource_name_
- : _("*None*"),
- jcr->impl->res.fileset ? jcr->impl->res.fileset->resource_name_
- : _("*None*"),
- jcr->impl->res.rpool->resource_name_, jcr->impl->res.rpool_source,
- jcr->impl->res.read_storage
- ? jcr->impl->res.read_storage->resource_name_
+ jcr->dir_impl->res.client ? jcr->dir_impl->res.client->resource_name_
+ : _("*None*"),
+ jcr->dir_impl->res.fileset ? jcr->dir_impl->res.fileset->resource_name_
+ : _("*None*"),
+ jcr->dir_impl->res.rpool->resource_name_,
+ jcr->dir_impl->res.rpool_source,
+ jcr->dir_impl->res.read_storage
+ ? jcr->dir_impl->res.read_storage->resource_name_
+ : _("*None*"),
+ NPRT(jcr->dir_impl->res.rstore_source),
+ jcr->dir_impl->res.pool->resource_name_,
+ jcr->dir_impl->res.pool_source,
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
: _("*None*"),
- NPRT(jcr->impl->res.rstore_source),
- jcr->impl->res.pool->resource_name_, jcr->impl->res.pool_source,
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
+ NPRT(jcr->dir_impl->res.wstore_source),
+ jcr->dir_impl->res.next_pool
+ ? jcr->dir_impl->res.next_pool->resource_name_
: _("*None*"),
- NPRT(jcr->impl->res.wstore_source),
- jcr->impl->res.next_pool ? jcr->impl->res.next_pool->resource_name_
- : _("*None*"),
- NPRT(jcr->impl->res.npool_source),
- jcr->impl->res.catalog->resource_name_, jcr->impl->res.catalog_source,
- sdt, edt, edit_utime(RunTime, elapsed, sizeof(elapsed)),
- jcr->JobPriority, edit_uint64_with_commas(jcr->impl->SDJobFiles, ec1),
- edit_uint64_with_commas(jcr->impl->SDJobBytes, ec2),
- edit_uint64_with_suffix(jcr->impl->SDJobBytes, ec3), (float)kbps,
+ NPRT(jcr->dir_impl->res.npool_source),
+ jcr->dir_impl->res.catalog->resource_name_,
+ jcr->dir_impl->res.catalog_source, sdt, edt,
+ edit_utime(RunTime, elapsed, sizeof(elapsed)), jcr->JobPriority,
+ edit_uint64_with_commas(jcr->dir_impl->SDJobFiles, ec1),
+ edit_uint64_with_commas(jcr->dir_impl->SDJobBytes, ec2),
+ edit_uint64_with_suffix(jcr->dir_impl->SDJobBytes, ec3), (float)kbps,
mig_jcr ? mig_jcr->VolumeName : _("*None*"), jcr->VolSessionId,
jcr->VolSessionTime, edit_uint64_with_commas(mr->VolBytes, ec4),
- edit_uint64_with_suffix(mr->VolBytes, ec5), jcr->impl->SDErrors,
+ edit_uint64_with_suffix(mr->VolBytes, ec5), jcr->dir_impl->SDErrors,
sd_term_msg, kBareosVersionStrings.JoblogMessage,
- JobTriggerToString(jcr->impl->job_trigger).c_str(), term_code);
+ JobTriggerToString(jcr->dir_impl->job_trigger).c_str(), term_code);
} else {
// Copy/Migrate selection only Job.
Jmsg(jcr, msg_type, 0,
@@ -1650,11 +1671,12 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr,
" Termination: %s\n\n"),
BAREOS, my_name, kBareosVersionStrings.Full,
kBareosVersionStrings.ShortDate, kBareosVersionStrings.GetOsInfo(),
- edit_uint64(jcr->impl->jr.JobId, ec8), jcr->impl->jr.Job,
- jcr->impl->res.catalog->resource_name_, jcr->impl->res.catalog_source,
- sdt, edt, edit_utime(RunTime, elapsed, sizeof(elapsed)),
- jcr->JobPriority, kBareosVersionStrings.JoblogMessage,
- JobTriggerToString(jcr->impl->job_trigger).c_str(), term_code);
+ edit_uint64(jcr->dir_impl->jr.JobId, ec8), jcr->dir_impl->jr.Job,
+ jcr->dir_impl->res.catalog->resource_name_,
+ jcr->dir_impl->res.catalog_source, sdt, edt,
+ edit_utime(RunTime, elapsed, sizeof(elapsed)), jcr->JobPriority,
+ kBareosVersionStrings.JoblogMessage,
+ JobTriggerToString(jcr->dir_impl->job_trigger).c_str(), term_code);
}
}
@@ -1665,7 +1687,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
const char* TermMsg;
int msg_type = M_INFO;
MediaDbRecord mr;
- JobControlRecord* mig_jcr = jcr->impl->mig_jcr;
+ JobControlRecord* mig_jcr = jcr->dir_impl->mig_jcr;
PoolMem query(PM_MESSAGE);
Dmsg2(100, "Enter migrate_cleanup %d %c\n", TermCode, TermCode);
@@ -1680,8 +1702,8 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
char old_jobid[50], new_jobid[50];
- edit_uint64(jcr->impl->previous_jr.JobId, old_jobid);
- edit_uint64(mig_jcr->impl->jr.JobId, new_jobid);
+ edit_uint64(jcr->dir_impl->previous_jr.JobId, old_jobid);
+ edit_uint64(mig_jcr->dir_impl->jr.JobId, new_jobid);
// use the PriorJobId field to store the migrated jobid in order to keep
// track of it
@@ -1694,20 +1716,20 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
* the jobfiles and jobbytes and the new volsessionid
* and volsessiontime as the writing SD generates this info.
*/
- if (jcr->impl->remote_replicate) {
- mig_jcr->JobFiles = jcr->JobFiles = mig_jcr->impl->SDJobFiles;
- mig_jcr->JobBytes = jcr->JobBytes = mig_jcr->impl->SDJobBytes;
+ if (jcr->dir_impl->remote_replicate) {
+ mig_jcr->JobFiles = jcr->JobFiles = mig_jcr->dir_impl->SDJobFiles;
+ mig_jcr->JobBytes = jcr->JobBytes = mig_jcr->dir_impl->SDJobBytes;
} else {
- mig_jcr->JobFiles = jcr->JobFiles = jcr->impl->SDJobFiles;
- mig_jcr->JobBytes = jcr->JobBytes = jcr->impl->SDJobBytes;
+ mig_jcr->JobFiles = jcr->JobFiles = jcr->dir_impl->SDJobFiles;
+ mig_jcr->JobBytes = jcr->JobBytes = jcr->dir_impl->SDJobBytes;
mig_jcr->VolSessionId = jcr->VolSessionId;
mig_jcr->VolSessionTime = jcr->VolSessionTime;
}
- mig_jcr->impl->jr.RealEndTime = 0;
- mig_jcr->impl->jr.PriorJobId = jcr->impl->previous_jr.JobId;
+ mig_jcr->dir_impl->jr.RealEndTime = 0;
+ mig_jcr->dir_impl->jr.PriorJobId = jcr->dir_impl->previous_jr.JobId;
if (jcr->is_JobStatus(JS_Terminated)
- && (jcr->JobErrors || jcr->impl->SDErrors)) {
+ && (jcr->JobErrors || jcr->dir_impl->SDErrors)) {
TermCode = JS_Warnings;
}
@@ -1717,8 +1739,9 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
Mmsg(query,
"UPDATE Job SET StartTime='%s',EndTime='%s',"
"JobTDate=%s WHERE JobId=%s",
- jcr->impl->previous_jr.cStartTime, jcr->impl->previous_jr.cEndTime,
- edit_uint64(jcr->impl->previous_jr.JobTDate, ec1), new_jobid);
+ jcr->dir_impl->previous_jr.cStartTime,
+ jcr->dir_impl->previous_jr.cEndTime,
+ edit_uint64(jcr->dir_impl->previous_jr.JobTDate, ec1), new_jobid);
jcr->db->SqlQuery(query.c_str());
if (jcr->IsTerminatedOk()) {
@@ -1749,7 +1772,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
* storage daemon we need to add data normally send to the director
* via the FHDB interface here.
*/
- switch (jcr->impl->res.client->Protocol) {
+ switch (jcr->dir_impl->res.client->Protocol) {
case APT_NDMPV2:
case APT_NDMPV3:
case APT_NDMPV4:
@@ -1762,7 +1785,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
}
ua = new_ua_context(jcr);
- if (jcr->impl->res.job->PurgeMigrateJob) {
+ if (jcr->dir_impl->res.job->PurgeMigrateJob) {
// Purge old Job record
PurgeJobsFromCatalog(ua, old_jobid);
} else {
@@ -1792,7 +1815,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
* storage daemon we need to add data normally send to the director
* via the FHDB interface here.
*/
- switch (jcr->impl->res.client->Protocol) {
+ switch (jcr->dir_impl->res.client->Protocol) {
case APT_NDMPV2:
case APT_NDMPV3:
case APT_NDMPV4:
@@ -1813,16 +1836,16 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
}
}
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error getting Job record for Job report: ERR=%s\n"),
jcr->db->strerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
UpdateBootstrapFile(mig_jcr);
- if (!mig_jcr->db->GetJobVolumeNames(mig_jcr, mig_jcr->impl->jr.JobId,
+ if (!mig_jcr->db->GetJobVolumeNames(mig_jcr, mig_jcr->dir_impl->jr.JobId,
mig_jcr->VolumeName)) {
/*
* Note, if the job has failed, most likely it did not write any
@@ -1830,7 +1853,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
* it is normal. Or look at it the other way, only for a
* normal exit should we complain about this error.
*/
- if (jcr->IsTerminatedOk() && jcr->impl->jr.JobBytes) {
+ if (jcr->IsTerminatedOk() && jcr->dir_impl->jr.JobBytes) {
Jmsg(jcr, M_ERROR, 0, "%s", mig_jcr->db->strerror());
}
mig_jcr->VolumeName[0] = 0; /* none */
@@ -1852,7 +1875,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
}
}
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
TermMsg = _("%s OK");
break;
@@ -1868,7 +1891,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
* can be different so that is why we do a second switch inside the
* switch on the JobStatus.
*/
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Canceled:
TermMsg = _("%s Canceled");
break;
@@ -1881,16 +1904,16 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
// Close connection to Reading SD.
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
// Close connection to Writing SD (if SD-SD replication)
if (mig_jcr->store_bsock) {
mig_jcr->store_bsock->signal(BNET_TERMINATE);
- if (mig_jcr->impl->SD_msg_chan_started) {
- pthread_cancel(mig_jcr->impl->SD_msg_chan);
+ if (mig_jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(mig_jcr->dir_impl->SD_msg_chan);
}
}
break;
@@ -1898,11 +1921,11 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode)
TermMsg = _("Inappropriate %s term code");
break;
}
- } else if (jcr->impl->HasSelectedJobs) {
+ } else if (jcr->dir_impl->HasSelectedJobs) {
Mmsg(query, "DELETE FROM job WHERE JobId=%d", jcr->JobId);
jcr->db->SqlQuery(query.c_str());
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
TermMsg = _("%s OK");
break;
diff --git a/core/src/dird/msgchan.cc b/core/src/dird/msgchan.cc
index 0473466b4..e062f3ccf 100644
--- a/core/src/dird/msgchan.cc
+++ b/core/src/dird/msgchan.cc
@@ -37,7 +37,7 @@
#include "dird.h"
#include "dird/getmsg.h"
#include "dird/job.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/msgchan.h"
#include "dird/quota.h"
#include "dird/sd_cmds.h"
@@ -103,16 +103,16 @@ static inline bool SendBootstrapFileToSd(JobControlRecord* jcr,
BErrNo be;
Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"),
jcr->RestoreBootstrap, be.bstrerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
sd->fsend(bootstrap);
while (fgets(buf, sizeof(buf), bs)) { sd->fsend("%s", buf); }
sd->signal(BNET_EOD);
fclose(bs);
- if (jcr->impl->unlink_bsr) {
+ if (jcr->dir_impl->unlink_bsr) {
SecureErase(jcr, jcr->RestoreBootstrap);
- jcr->impl->unlink_bsr = false;
+ jcr->dir_impl->unlink_bsr = false;
}
return true;
}
@@ -148,32 +148,32 @@ bool StartStorageDaemonJob(JobControlRecord* jcr,
}
// Now send JobId and permissions, and get back the authorization key.
- PmStrcpy(job_name, jcr->impl->res.job->resource_name_);
+ PmStrcpy(job_name, jcr->dir_impl->res.job->resource_name_);
BashSpaces(job_name);
- if (jcr->impl->res.client) {
- PmStrcpy(client_name, jcr->impl->res.client->resource_name_);
+ if (jcr->dir_impl->res.client) {
+ PmStrcpy(client_name, jcr->dir_impl->res.client->resource_name_);
} else {
PmStrcpy(client_name, "**None**");
}
BashSpaces(client_name);
- if (jcr->impl->res.fileset) {
- PmStrcpy(fileset_name, jcr->impl->res.fileset->resource_name_);
+ if (jcr->dir_impl->res.fileset) {
+ PmStrcpy(fileset_name, jcr->dir_impl->res.fileset->resource_name_);
} else {
PmStrcpy(fileset_name, "**None**");
}
BashSpaces(fileset_name);
- PmStrcpy(backup_format, jcr->impl->backup_format);
+ PmStrcpy(backup_format, jcr->dir_impl->backup_format);
BashSpaces(backup_format);
- if (jcr->impl->res.fileset && jcr->impl->res.fileset->MD5[0] == 0) {
- bstrncpy(jcr->impl->res.fileset->MD5, "**Dummy**",
- sizeof(jcr->impl->res.fileset->MD5));
- fileset_md5 = jcr->impl->res.fileset->MD5;
- } else if (jcr->impl->res.fileset) {
- fileset_md5 = jcr->impl->res.fileset->MD5;
+ if (jcr->dir_impl->res.fileset && jcr->dir_impl->res.fileset->MD5[0] == 0) {
+ bstrncpy(jcr->dir_impl->res.fileset->MD5, "**Dummy**",
+ sizeof(jcr->dir_impl->res.fileset->MD5));
+ fileset_md5 = jcr->dir_impl->res.fileset->MD5;
+ } else if (jcr->dir_impl->res.fileset) {
+ fileset_md5 = jcr->dir_impl->res.fileset->MD5;
} else {
fileset_md5 = "**Dummy**";
}
@@ -184,7 +184,7 @@ bool StartStorageDaemonJob(JobControlRecord* jcr,
* If we do not cancel it the SD will not accept a new connection
* for the same jobid.
*/
- if (jcr->impl->reschedule_count) {
+ if (jcr->dir_impl->reschedule_count) {
sd->fsend("cancel Job=%s\n", jcr->Job);
while (sd->recv() >= 0) { continue; }
}
@@ -195,10 +195,11 @@ bool StartStorageDaemonJob(JobControlRecord* jcr,
sd->fsend(jobcmd, edit_int64(jcr->JobId, ed1), jcr->Job, job_name.c_str(),
client_name.c_str(), jcr->getJobType(), jcr->getJobLevel(),
- fileset_name.c_str(), !jcr->impl->res.pool->catalog_files,
- jcr->impl->res.job->SpoolAttributes, fileset_md5,
- jcr->impl->spool_data, jcr->impl->res.job->PreferMountedVolumes,
- edit_int64(jcr->impl->spool_size, ed2), jcr->rerunning,
+ fileset_name.c_str(), !jcr->dir_impl->res.pool->catalog_files,
+ jcr->dir_impl->res.job->SpoolAttributes, fileset_md5,
+ jcr->dir_impl->spool_data,
+ jcr->dir_impl->res.job->PreferMountedVolumes,
+ edit_int64(jcr->dir_impl->spool_size, ed2), jcr->rerunning,
jcr->VolSessionId, jcr->VolSessionTime, remainingquota,
jcr->getJobProtocol(), backup_format.c_str());
@@ -251,11 +252,11 @@ bool StartStorageDaemonJob(JobControlRecord* jcr,
/* For the moment, only migrate, copy and vbackup have rpool */
if (jcr->is_JobType(JT_MIGRATE) || jcr->is_JobType(JT_COPY)
|| (jcr->is_JobType(JT_BACKUP) && jcr->is_JobLevel(L_VIRTUAL_FULL))) {
- PmStrcpy(pool_type, jcr->impl->res.rpool->pool_type);
- PmStrcpy(pool_name, jcr->impl->res.rpool->resource_name_);
+ PmStrcpy(pool_type, jcr->dir_impl->res.rpool->pool_type);
+ PmStrcpy(pool_name, jcr->dir_impl->res.rpool->resource_name_);
} else {
- PmStrcpy(pool_type, jcr->impl->res.pool->pool_type);
- PmStrcpy(pool_name, jcr->impl->res.pool->resource_name_);
+ PmStrcpy(pool_type, jcr->dir_impl->res.pool->pool_type);
+ PmStrcpy(pool_name, jcr->dir_impl->res.pool->resource_name_);
}
BashSpaces(pool_type);
BashSpaces(pool_name);
@@ -294,8 +295,8 @@ bool StartStorageDaemonJob(JobControlRecord* jcr,
/* Do write side of storage daemon */
if (ok && write_storage) {
- PmStrcpy(pool_type, jcr->impl->res.pool->pool_type);
- PmStrcpy(pool_name, jcr->impl->res.pool->resource_name_);
+ PmStrcpy(pool_type, jcr->dir_impl->res.pool->pool_type);
+ PmStrcpy(pool_name, jcr->dir_impl->res.pool->resource_name_);
BashSpaces(pool_type);
BashSpaces(pool_name);
foreach_alist (storage, write_storage) {
@@ -358,8 +359,8 @@ bool StartStorageDaemonMessageThread(JobControlRecord* jcr)
pthread_t thid;
jcr->IncUseCount(); /* mark in use by msg thread */
- jcr->impl->sd_msg_thread_done = false;
- jcr->impl->SD_msg_chan_started = false;
+ jcr->dir_impl->sd_msg_thread_done = false;
+ jcr->dir_impl->SD_msg_chan_started = false;
Dmsg0(100, "Start SD msg_thread.\n");
if ((status = pthread_create(&thid, NULL, msg_thread, (void*)jcr)) != 0) {
BErrNo be;
@@ -367,9 +368,9 @@ bool StartStorageDaemonMessageThread(JobControlRecord* jcr)
be.bstrerror(status));
}
/* Wait for thread to start */
- while (!jcr->impl->SD_msg_chan_started) {
+ while (!jcr->dir_impl->SD_msg_chan_started) {
Bmicrosleep(0, 50);
- if (JobCanceled(jcr) || jcr->impl->sd_msg_thread_done) { return false; }
+ if (JobCanceled(jcr) || jcr->dir_impl->sd_msg_thread_done) { return false; }
}
Dmsg1(100, "SD msg_thread started. use=%d\n", jcr->UseCount());
return true;
@@ -381,13 +382,13 @@ extern "C" void MsgThreadCleanup(void* arg)
jcr->db->EndTransaction(jcr); /* Terminate any open transaction */
jcr->lock();
- jcr->impl->sd_msg_thread_done = true;
- jcr->impl->SD_msg_chan_started = false;
+ jcr->dir_impl->sd_msg_thread_done = true;
+ jcr->dir_impl->SD_msg_chan_started = false;
jcr->unlock();
pthread_cond_broadcast(
- &jcr->impl->nextrun_ready); /* wakeup any waiting threads */
+ &jcr->dir_impl->nextrun_ready); /* wakeup any waiting threads */
pthread_cond_broadcast(
- &jcr->impl->term_wait); /* wakeup any waiting threads */
+ &jcr->dir_impl->term_wait); /* wakeup any waiting threads */
Dmsg2(100, "=== End msg_thread. JobId=%d usecnt=%d\n", jcr->JobId,
jcr->UseCount());
jcr->db->ThreadCleanup(); /* remove thread specific data */
@@ -411,8 +412,8 @@ extern "C" void* msg_thread(void* arg)
pthread_detach(pthread_self());
SetJcrInThreadSpecificData(jcr);
- jcr->impl->SD_msg_chan = pthread_self();
- jcr->impl->SD_msg_chan_started = true;
+ jcr->dir_impl->SD_msg_chan = pthread_self();
+ jcr->dir_impl->SD_msg_chan_started = true;
pthread_cleanup_push(MsgThreadCleanup, arg);
sd = jcr->store_bsock;
@@ -429,7 +430,7 @@ extern "C" void* msg_thread(void* arg)
if (jcr->sd_auth_key) { free(jcr->sd_auth_key); }
jcr->sd_auth_key = strdup(auth_key);
pthread_cond_broadcast(
- &jcr->impl->nextrun_ready); /* wakeup any waiting threads */
+ &jcr->dir_impl->nextrun_ready); /* wakeup any waiting threads */
continue;
}
@@ -443,10 +444,10 @@ extern "C" void* msg_thread(void* arg)
if (sscanf(sd->msg, Job_end, Job, &JobStatus, &JobFiles, &JobBytes,
&JobErrors)
== 5) {
- jcr->impl->SDJobStatus = JobStatus; /* termination status */
- jcr->impl->SDJobFiles = JobFiles;
- jcr->impl->SDJobBytes = JobBytes;
- jcr->impl->SDErrors = JobErrors;
+ jcr->dir_impl->SDJobStatus = JobStatus; /* termination status */
+ jcr->dir_impl->SDJobFiles = JobFiles;
+ jcr->dir_impl->SDJobBytes = JobBytes;
+ jcr->dir_impl->SDErrors = JobErrors;
break;
}
Dmsg1(400, "end loop use=%d\n", jcr->UseCount());
@@ -460,7 +461,7 @@ extern "C" void* msg_thread(void* arg)
*/
Qmsg(jcr, M_FATAL, 0, _("Director's comm line to SD dropped.\n"));
}
- if (IsBnetError(sd)) { jcr->impl->SDJobStatus = JS_ErrorTerminated; }
+ if (IsBnetError(sd)) { jcr->dir_impl->SDJobStatus = JS_ErrorTerminated; }
pthread_cleanup_pop(1); /* remove and execute the handler */
return NULL;
}
@@ -469,7 +470,7 @@ void WaitForStorageDaemonTermination(JobControlRecord* jcr)
{
int cancel_count = 0;
/* Now wait for Storage daemon to Terminate our message thread */
- while (!jcr->impl->sd_msg_thread_done) {
+ while (!jcr->dir_impl->sd_msg_thread_done) {
struct timeval tv;
struct timezone tz;
struct timespec timeout;
@@ -479,10 +480,10 @@ void WaitForStorageDaemonTermination(JobControlRecord* jcr)
timeout.tv_sec = tv.tv_sec + 5; /* wait 5 seconds */
Dmsg0(400, "I'm waiting for message thread termination.\n");
lock_mutex(mutex);
- pthread_cond_timedwait(&jcr->impl->term_wait, &mutex, &timeout);
+ pthread_cond_timedwait(&jcr->dir_impl->term_wait, &mutex, &timeout);
unlock_mutex(mutex);
if (jcr->IsCanceled()) {
- if (jcr->impl->SD_msg_chan_started) {
+ if (jcr->dir_impl->SD_msg_chan_started) {
jcr->store_bsock->SetTimedOut();
jcr->store_bsock->SetTerminated();
SdMsgThreadSendSignal(jcr, TIMEOUT_SIGNAL);
@@ -492,7 +493,7 @@ void WaitForStorageDaemonTermination(JobControlRecord* jcr)
/* Give SD 30 seconds to clean up after cancel */
if (cancel_count == 6) { break; }
}
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
}
} /* namespace directordaemon */
diff --git a/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc b/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc
index a4d614770..300a235ef 100644
--- a/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc
+++ b/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc
@@ -28,7 +28,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/msgchan.h"
#include "dird/quota.h"
@@ -97,7 +97,7 @@ static inline bool extract_post_backup_stats(JobControlRecord* jcr,
ndm_ee = sess->control_acb->job.result_env_tab.head;
while (ndm_ee) {
if (!jcr->db->CreateNdmpEnvironmentString(
- jcr, &jcr->impl->jr, ndm_ee->pval.name, ndm_ee->pval.value)) {
+ jcr, &jcr->dir_impl->jr, ndm_ee->pval.name, ndm_ee->pval.value)) {
break;
}
ndm_ee = ndm_ee->next;
@@ -108,7 +108,7 @@ static inline bool extract_post_backup_stats(JobControlRecord* jcr,
* level.
*/
if (nbf_options && nbf_options->uses_level) {
- jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->impl->jr, filesystem,
+ jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->dir_impl->jr, filesystem,
sess->control_acb->job.bu_level);
}
@@ -122,21 +122,21 @@ bool DoNdmpBackupInit(JobControlRecord* jcr)
if (!AllowDuplicateJob(jcr)) { return false; }
- jcr->impl->jr.PoolId
- = GetOrCreatePoolRecord(jcr, jcr->impl->res.pool->resource_name_);
- if (jcr->impl->jr.PoolId == 0) { return false; }
+ jcr->dir_impl->jr.PoolId
+ = GetOrCreatePoolRecord(jcr, jcr->dir_impl->res.pool->resource_name_);
+ if (jcr->dir_impl->jr.PoolId == 0) { return false; }
jcr->start_time = time(NULL);
- jcr->impl->jr.StartTime = jcr->start_time;
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->dir_impl->jr.StartTime = jcr->start_time;
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
return false;
}
// If pool storage specified, use it instead of job storage
- CopyWstorage(jcr, jcr->impl->res.pool->storage, _("Pool resource"));
+ CopyWstorage(jcr, jcr->dir_impl->res.pool->storage, _("Pool resource"));
- if (!jcr->impl->res.write_storage_list) {
+ if (!jcr->dir_impl->res.write_storage_list) {
Jmsg(jcr, M_FATAL, 0,
_("No Storage specification found in Job or Pool.\n"));
return false;
@@ -178,16 +178,16 @@ bool DoNdmpBackup(JobControlRecord* jcr)
int NdmpLoglevel;
NdmpLoglevel
- = std::max(jcr->impl->res.client->ndmp_loglevel, me->ndmp_loglevel);
+ = std::max(jcr->dir_impl->res.client->ndmp_loglevel, me->ndmp_loglevel);
// Print Job Start message
Jmsg(jcr, M_INFO, 0, _("Start NDMP Backup JobId %s, Job=%s\n"),
edit_uint64(jcr->JobId, ed1), jcr->Job);
- jcr->setJobStatus(JS_Running);
- Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl->jr.JobId,
- jcr->impl->jr.JobLevel);
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
+ Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->dir_impl->jr.JobId,
+ jcr->dir_impl->jr.JobLevel);
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
return false;
}
@@ -212,16 +212,17 @@ bool DoNdmpBackup(JobControlRecord* jcr)
* data mover which moves the data from the NDMP DATA AGENT to the NDMP
* TAPE AGENT.
*/
- if (jcr->impl->res.write_storage->paired_storage) {
+ if (jcr->dir_impl->res.write_storage->paired_storage) {
SetPairedStorage(jcr);
- jcr->setJobStatus(JS_WaitSD);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitSD);
if (!ConnectToStorageDaemon(jcr, 10, me->SDConnectTimeout, true)) {
return false;
}
// Now start a job with the Storage daemon
- if (!StartStorageDaemonJob(jcr, NULL, jcr->impl->res.write_storage_list)) {
+ if (!StartStorageDaemonJob(jcr, NULL,
+ jcr->dir_impl->res.write_storage_list)) {
return false;
}
@@ -248,8 +249,8 @@ bool DoNdmpBackup(JobControlRecord* jcr)
* and reuse the job definition for each separate sub-backup we perform as
* part of the whole job. We only free the env_table between every sub-backup.
*/
- if (!NdmpBuildClientJob(jcr, jcr->impl->res.client,
- jcr->impl->res.paired_read_write_storage,
+ if (!NdmpBuildClientJob(jcr, jcr->dir_impl->res.client,
+ jcr->dir_impl->res.paired_read_write_storage,
NDM_JOB_OP_BACKUP, &ndmp_job)) {
goto bail_out;
}
@@ -262,7 +263,7 @@ bool DoNdmpBackup(JobControlRecord* jcr)
* included fileset.
*/
cnt = 0;
- fileset = jcr->impl->res.fileset;
+ fileset = jcr->dir_impl->res.fileset;
for (i = 0; i < fileset->include_items.size(); i++) {
@@ -285,7 +286,7 @@ bool DoNdmpBackup(JobControlRecord* jcr)
if (jcr->store_bsock && cnt > 0) {
jcr->store_bsock->fsend("nextrun");
lock_mutex(mutex);
- pthread_cond_wait(&jcr->impl->nextrun_ready, &mutex);
+ pthread_cond_wait(&jcr->dir_impl->nextrun_ready, &mutex);
unlock_mutex(mutex);
}
@@ -306,8 +307,8 @@ bool DoNdmpBackup(JobControlRecord* jcr)
nis->filesystem = item;
nis->FileIndex = cnt + 1;
nis->jcr = jcr;
- nis->save_filehist = jcr->impl->res.job->SaveFileHist;
- nis->filehist_size = jcr->impl->res.job->FileHistSize;
+ nis->save_filehist = jcr->dir_impl->res.job->SaveFileHist;
+ nis->filehist_size = jcr->dir_impl->res.job->FileHistSize;
ndmp_sess.param->log.ctx = nis;
ndmp_sess.param->log_tag = strdup("DIR-NDMP");
@@ -338,9 +339,9 @@ bool DoNdmpBackup(JobControlRecord* jcr)
* the individual file records to it. So we allocate it here once so its
* available during the whole NDMP session.
*/
- if (Bstrcasecmp(jcr->impl->backup_format, "dump")) {
+ if (Bstrcasecmp(jcr->dir_impl->backup_format, "dump")) {
Mmsg(virtual_filename, "/@NDMP%s%%%d", nis->filesystem,
- jcr->impl->DumpLevel);
+ jcr->dir_impl->DumpLevel);
} else {
Mmsg(virtual_filename, "/@NDMP%s", nis->filesystem);
}
@@ -366,7 +367,7 @@ bool DoNdmpBackup(JobControlRecord* jcr)
if (ndmca_control_agent(&ndmp_sess) != 0) { goto cleanup; }
// See if there were any errors during the backup.
- jcr->impl->jr.FileIndex = cnt + 1;
+ jcr->dir_impl->jr.FileIndex = cnt + 1;
if (!extract_post_backup_stats(jcr, item, &ndmp_sess)) { goto cleanup; }
UnregisterCallbackHooks(&ndmp_sess.control_acb->job.index_log);
@@ -447,7 +448,7 @@ cleanup:
bail_out:
// Error handling of failed Job.
status = JS_ErrorTerminated;
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
if (jcr->store_bsock) {
CancelStorageDaemonJob(jcr);
diff --git a/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc b/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc
index 71b8cfc30..9ae40d5e8 100644
--- a/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc
+++ b/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2011-2015 Planets Communications B.V.
- Copyright (C) 2013-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -28,7 +28,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/dird_globals.h"
#include "dird/job.h"
#include "dird/next_vol.h"
@@ -89,10 +89,10 @@ int NdmpLoadNext(struct ndm_session* sess)
bool prune = false;
struct ndmmedia* media;
int index = 1;
- StorageResource* store = jcr->impl->res.write_storage;
+ StorageResource* store = jcr->dir_impl->res.write_storage;
// get the poolid for pool name
- mr.PoolId = jcr->impl->jr.PoolId;
+ mr.PoolId = jcr->dir_impl->jr.PoolId;
if (FindNextVolumeForAppend(jcr, &mr, index, unwanted_volumes, create,
@@ -169,7 +169,7 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr)
char* item;
ndmp_log_level
- = std::max(jcr->impl->res.client->ndmp_loglevel, me->ndmp_loglevel);
+ = std::max(jcr->dir_impl->res.client->ndmp_loglevel, me->ndmp_loglevel);
struct ndmca_media_callbacks media_callbacks;
@@ -186,22 +186,23 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr)
Jmsg(jcr, M_INFO, 0, _("Start NDMP Backup JobId %s, Job=%s\n"),
edit_uint64(jcr->JobId, ed1), jcr->Job);
- jcr->setJobStatus(JS_Running);
- Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl->jr.JobId,
- jcr->impl->jr.JobLevel);
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
+ Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->dir_impl->jr.JobId,
+ jcr->dir_impl->jr.JobLevel);
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
return false;
}
status = 0;
- StorageResource* store = jcr->impl->res.write_storage;
+ StorageResource* store = jcr->dir_impl->res.write_storage;
PoolMem virtual_filename(PM_FNAME);
IncludeExcludeItem* ie;
- if (!NdmpBuildClientAndStorageJob(jcr, jcr->impl->res.write_storage,
- jcr->impl->res.client, true, /* init_tape */
+ if (!NdmpBuildClientAndStorageJob(jcr, jcr->dir_impl->res.write_storage,
+ jcr->dir_impl->res.client,
+ true, /* init_tape */
true, /* init_robot */
NDM_JOB_OP_BACKUP, &ndmp_job)) {
goto bail_out;
@@ -221,7 +222,7 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr)
* Only one include set of the fileset is allowed in NATIVE mode as
* in NDMP also per job only one filesystem can be backed up
*/
- fileset = jcr->impl->res.fileset;
+ fileset = jcr->dir_impl->res.fileset;
if (fileset->include_items.size() > 1) {
Jmsg(jcr, M_ERROR, 0,
@@ -260,8 +261,8 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr)
nis->filesystem = item;
nis->FileIndex = 1;
nis->jcr = jcr;
- nis->save_filehist = jcr->impl->res.job->SaveFileHist;
- nis->filehist_size = jcr->impl->res.job->FileHistSize;
+ nis->save_filehist = jcr->dir_impl->res.job->SaveFileHist;
+ nis->filehist_size = jcr->dir_impl->res.job->FileHistSize;
ndmp_sess.param->log.ctx = nis;
ndmp_sess.param->log_tag = strdup("DIR-NDMP");
@@ -294,9 +295,9 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr)
* individual file records to it. So we allocate it here once so its available
* during the whole NDMP session.
*/
- if (Bstrcasecmp(jcr->impl->backup_format, "dump")) {
+ if (Bstrcasecmp(jcr->dir_impl->backup_format, "dump")) {
Mmsg(virtual_filename, "/@NDMP%s%%%d", nis->filesystem,
- jcr->impl->DumpLevel);
+ jcr->dir_impl->DumpLevel);
} else {
Mmsg(virtual_filename, "/@NDMP%s", nis->filesystem);
}
@@ -329,7 +330,7 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr)
}
// See if there were any errors during the backup.
- jcr->impl->jr.FileIndex = 1;
+ jcr->dir_impl->jr.FileIndex = 1;
if (!extract_post_backup_stats_ndmp_native(jcr, item, &ndmp_sess)) {
goto cleanup;
}
@@ -401,7 +402,7 @@ cleanup:
bail_out:
// Error handling of failed Job.
status = JS_ErrorTerminated;
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
ok_out:
if (nis) {
@@ -421,21 +422,21 @@ bool DoNdmpBackupInitNdmpNative(JobControlRecord* jcr)
if (!AllowDuplicateJob(jcr)) { return false; }
- jcr->impl->jr.PoolId
- = GetOrCreatePoolRecord(jcr, jcr->impl->res.pool->resource_name_);
- if (jcr->impl->jr.PoolId == 0) { return false; }
+ jcr->dir_impl->jr.PoolId
+ = GetOrCreatePoolRecord(jcr, jcr->dir_impl->res.pool->resource_name_);
+ if (jcr->dir_impl->jr.PoolId == 0) { return false; }
jcr->start_time = time(NULL);
- jcr->impl->jr.StartTime = jcr->start_time;
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->dir_impl->jr.StartTime = jcr->start_time;
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
return false;
}
// If pool storage specified, use it instead of job storage
- CopyWstorage(jcr, jcr->impl->res.pool->storage, _("Pool resource"));
+ CopyWstorage(jcr, jcr->dir_impl->res.pool->storage, _("Pool resource"));
- if (!jcr->impl->res.write_storage_list) {
+ if (!jcr->dir_impl->res.write_storage_list) {
Jmsg(jcr, M_FATAL, 0,
_("No Storage specification found in Job or Pool.\n"));
return false;
@@ -473,7 +474,8 @@ static inline bool extract_post_backup_stats_ndmp_native(
// translate Physical to Logical Slot before storing into database
media->slot_addr = GetBareosSlotNumberByElementAddress(
- &jcr->impl->res.write_storage->runtime_storage_status->storage_mapping,
+ &jcr->dir_impl->res.write_storage->runtime_storage_status
+ ->storage_mapping,
slot_type_t::kSlotTypeStorage, media->slot_addr);
# if 0
Jmsg(jcr, M_INFO, 0, _("Physical Slot is %d\n"), media->slot_addr);
@@ -515,7 +517,7 @@ static inline bool extract_post_backup_stats_ndmp_native(
ndm_ee = sess->control_acb->job.result_env_tab.head;
while (ndm_ee) {
if (!jcr->db->CreateNdmpEnvironmentString(
- jcr, &jcr->impl->jr, ndm_ee->pval.name, ndm_ee->pval.value)) {
+ jcr, &jcr->dir_impl->jr, ndm_ee->pval.name, ndm_ee->pval.value)) {
break;
}
ndm_ee = ndm_ee->next;
@@ -526,7 +528,7 @@ static inline bool extract_post_backup_stats_ndmp_native(
* level.
*/
if (nbf_options && nbf_options->uses_level) {
- jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->impl->jr, filesystem,
+ jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->dir_impl->jr, filesystem,
sess->control_acb->job.bu_level);
}
diff --git a/core/src/dird/ndmp_dma_backup_common.cc b/core/src/dird/ndmp_dma_backup_common.cc
index efe385d0e..b32b80010 100644
--- a/core/src/dird/ndmp_dma_backup_common.cc
+++ b/core/src/dird/ndmp_dma_backup_common.cc
@@ -28,7 +28,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/backup.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/ndmp_dma_backup_common.h"
#include "lib/edit.h"
@@ -85,8 +85,8 @@ bool FillBackupEnvironment(JobControlRecord* jcr,
char text_level[50];
// Set the dump level for the backup.
- jcr->impl->DumpLevel = NativeToNdmpLevel(jcr, filesystem);
- job->bu_level = jcr->impl->DumpLevel;
+ jcr->dir_impl->DumpLevel = NativeToNdmpLevel(jcr, filesystem);
+ job->bu_level = jcr->dir_impl->DumpLevel;
if (job->bu_level == -1) { return false; }
pv.name = ndmp_env_keywords[NDMP_ENV_KW_LEVEL];
@@ -167,7 +167,7 @@ bool FillBackupEnvironment(JobControlRecord* jcr,
if (jcr->store_bsock) {
if (nbf_options && nbf_options->uses_level) {
Mmsg(tape_device, "%s@%s%%%d", jcr->sd_auth_key, filesystem,
- jcr->impl->DumpLevel);
+ jcr->dir_impl->DumpLevel);
} else {
Mmsg(tape_device, "%s@%s", jcr->sd_auth_key, filesystem);
}
@@ -183,7 +183,7 @@ int NativeToNdmpLevel(JobControlRecord* jcr, char* filesystem)
{
int level = -1;
- if (!jcr->db->CreateNdmpLevelMapping(jcr, &jcr->impl->jr, filesystem)) {
+ if (!jcr->db->CreateNdmpLevelMapping(jcr, &jcr->dir_impl->jr, filesystem)) {
return -1;
}
@@ -195,7 +195,7 @@ int NativeToNdmpLevel(JobControlRecord* jcr, char* filesystem)
level = 1;
break;
case L_INCREMENTAL:
- level = jcr->db->GetNdmpLevelMapping(jcr, &jcr->impl->jr, filesystem);
+ level = jcr->db->GetNdmpLevelMapping(jcr, &jcr->dir_impl->jr, filesystem);
break;
default:
Jmsg(jcr, M_FATAL, 0, _("Illegal Job Level %c for NDMP Job\n"),
@@ -220,7 +220,7 @@ void RegisterCallbackHooks(struct ndmlog* ixlog)
# ifdef HAVE_LMDB
NIS* nis = (NIS*)ixlog->ctx;
- if (nis->jcr->impl->res.client->ndmp_use_lmdb) {
+ if (nis->jcr->dir_impl->res.client->ndmp_use_lmdb) {
NdmpFhdbLmdbRegister(ixlog);
} else {
NdmpFhdbMemRegister(ixlog);
@@ -235,7 +235,7 @@ void UnregisterCallbackHooks(struct ndmlog* ixlog)
# ifdef HAVE_LMDB
NIS* nis = (NIS*)ixlog->ctx;
- if (nis->jcr->impl->res.client->ndmp_use_lmdb) {
+ if (nis->jcr->dir_impl->res.client->ndmp_use_lmdb) {
NdmpFhdbLmdbUnregister(ixlog);
} else {
NdmpFhdbMemUnregister(ixlog);
@@ -250,7 +250,7 @@ void ProcessFhdb(struct ndmlog* ixlog)
# ifdef HAVE_LMDB
NIS* nis = (NIS*)ixlog->ctx;
- if (nis->jcr->impl->res.client->ndmp_use_lmdb) {
+ if (nis->jcr->dir_impl->res.client->ndmp_use_lmdb) {
NdmpFhdbLmdbProcessDb(ixlog);
} else {
NdmpFhdbMemProcessDb(ixlog);
@@ -271,20 +271,20 @@ void NdmpBackupCleanup(JobControlRecord* jcr, int TermCode)
Dmsg2(100, "Enter NdmpBackupCleanup %d %c\n", TermCode, TermCode);
if (jcr->is_JobStatus(JS_Terminated)
- && (jcr->JobErrors || jcr->impl->SDErrors || jcr->JobWarnings)) {
+ && (jcr->JobErrors || jcr->dir_impl->SDErrors || jcr->JobWarnings)) {
TermCode = JS_Warnings;
}
UpdateJobEnd(jcr, TermCode);
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error getting Job record for Job report: ERR=%s"),
jcr->db->strerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
- bstrncpy(cr.Name, jcr->impl->res.client->resource_name_, sizeof(cr.Name));
+ bstrncpy(cr.Name, jcr->dir_impl->res.client->resource_name_, sizeof(cr.Name));
if (!jcr->db->GetClientRecord(jcr, &cr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error getting Client record for Job report: ERR=%s"),
@@ -293,7 +293,7 @@ void NdmpBackupCleanup(JobControlRecord* jcr, int TermCode)
UpdateBootstrapFile(jcr);
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
TermMsg = _("Backup OK");
break;
@@ -306,8 +306,8 @@ void NdmpBackupCleanup(JobControlRecord* jcr, int TermCode)
msg_type = M_ERROR; /* Generate error message */
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
break;
@@ -315,14 +315,15 @@ void NdmpBackupCleanup(JobControlRecord* jcr, int TermCode)
TermMsg = _("Backup Canceled");
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
break;
default:
TermMsg = term_code;
- sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
+ sprintf(term_code, _("Inappropriate term code: %c\n"),
+ jcr->getJobStatus());
break;
}
diff --git a/core/src/dird/ndmp_dma_generic.cc b/core/src/dird/ndmp_dma_generic.cc
index 03cde6c20..2a17d4faa 100644
--- a/core/src/dird/ndmp_dma_generic.cc
+++ b/core/src/dird/ndmp_dma_generic.cc
@@ -27,7 +27,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/dird_globals.h"
#include "include/auth_protocol_types.h"
#include "include/auth_types.h"
@@ -87,15 +87,15 @@ ndmp_backup_format_option* ndmp_lookup_backup_format_options(
// Validation functions.
bool NdmpValidateClient(JobControlRecord* jcr)
{
- switch (jcr->impl->res.client->Protocol) {
+ switch (jcr->dir_impl->res.client->Protocol) {
case APT_NDMPV2:
case APT_NDMPV3:
case APT_NDMPV4:
- if (jcr->impl->res.client->password_.encoding != p_encoding_clear) {
+ if (jcr->dir_impl->res.client->password_.encoding != p_encoding_clear) {
Jmsg(jcr, M_FATAL, 0,
_("Client %s, has incompatible password encoding for running NDMP "
"backup.\n"),
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
return false;
}
break;
@@ -103,8 +103,9 @@ bool NdmpValidateClient(JobControlRecord* jcr)
Jmsg(jcr, M_FATAL, 0,
_("Client %s, with backup protocol %s not compatible for running "
"NDMP backup.\n"),
- jcr->impl->res.client->resource_name_,
- AuthenticationProtocolTypeToString(jcr->impl->res.client->Protocol));
+ jcr->dir_impl->res.client->resource_name_,
+ AuthenticationProtocolTypeToString(
+ jcr->dir_impl->res.client->Protocol));
return false;
}
@@ -141,12 +142,12 @@ bool NdmpValidateStorage(JobControlRecord* jcr)
{
StorageResource* store = nullptr;
- if (jcr->impl->res.write_storage_list) {
- foreach_alist (store, jcr->impl->res.write_storage_list) {
+ if (jcr->dir_impl->res.write_storage_list) {
+ foreach_alist (store, jcr->dir_impl->res.write_storage_list) {
if (!NdmpValidateStorage(jcr, store)) { return false; }
}
} else {
- foreach_alist (store, jcr->impl->res.read_storage_list) {
+ foreach_alist (store, jcr->dir_impl->res.read_storage_list) {
if (!NdmpValidateStorage(jcr, store)) { return false; }
}
}
@@ -308,7 +309,7 @@ bool NdmpBuildClientJob(JobControlRecord* jcr,
memset(job, 0, sizeof(struct ndm_job_param));
job->operation = operation;
- job->bu_type = jcr->impl->backup_format;
+ job->bu_type = jcr->dir_impl->backup_format;
/*
* For NDMP the backupformat is a prerequite abort the backup job when
@@ -335,30 +336,32 @@ bool NdmpBuildClientJob(JobControlRecord* jcr,
goto bail_out;
}
- if (Bstrcasecmp(jcr->impl->backup_format, "smtape")) {
+ if (Bstrcasecmp(jcr->dir_impl->backup_format, "smtape")) {
// SMTAPE only wants certain blocksizes.
- if (jcr->impl->res.client->ndmp_blocksize < SMTAPE_MIN_BLOCKSIZE
- || jcr->impl->res.client->ndmp_blocksize > SMTAPE_MAX_BLOCKSIZE) {
+ if (jcr->dir_impl->res.client->ndmp_blocksize < SMTAPE_MIN_BLOCKSIZE
+ || jcr->dir_impl->res.client->ndmp_blocksize > SMTAPE_MAX_BLOCKSIZE) {
Jmsg(jcr, M_FATAL, 0,
_("For SMTAPE NDMP jobs the NDMP blocksize needs to be between %d "
"and %d, but is set to %d\n"),
SMTAPE_MIN_BLOCKSIZE, SMTAPE_MAX_BLOCKSIZE,
- jcr->impl->res.client->ndmp_blocksize);
+ jcr->dir_impl->res.client->ndmp_blocksize);
goto bail_out;
}
- if ((jcr->impl->res.client->ndmp_blocksize % SMTAPE_BLOCKSIZE_INCREMENTS)
+ if ((jcr->dir_impl->res.client->ndmp_blocksize
+ % SMTAPE_BLOCKSIZE_INCREMENTS)
!= 0) {
Jmsg(jcr, M_FATAL, 0,
_("For SMTAPE NDMP jobs the NDMP blocksize needs to be in "
"increments of %d bytes, but is set to %d\n"),
- SMTAPE_BLOCKSIZE_INCREMENTS, jcr->impl->res.client->ndmp_blocksize);
+ SMTAPE_BLOCKSIZE_INCREMENTS,
+ jcr->dir_impl->res.client->ndmp_blocksize);
goto bail_out;
}
- job->record_size = jcr->impl->res.client->ndmp_blocksize;
+ job->record_size = jcr->dir_impl->res.client->ndmp_blocksize;
} else {
- job->record_size = jcr->impl->res.client->ndmp_blocksize;
+ job->record_size = jcr->dir_impl->res.client->ndmp_blocksize;
}
return true;
@@ -378,7 +381,7 @@ bool NdmpBuildStorageJob(JobControlRecord* jcr,
memset(job, 0, sizeof(struct ndm_job_param));
job->operation = operation;
- job->bu_type = jcr->impl->backup_format;
+ job->bu_type = jcr->dir_impl->backup_format;
if (!fill_ndmp_agent_config(jcr, &job->data_agent, store->Protocol,
store->AuthType, store->address, store->SDport,
diff --git a/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc b/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc
index 141c7261f..bb6ff375c 100644
--- a/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc
+++ b/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc
@@ -29,7 +29,7 @@
#include "dird.h"
#include "dird/dird_globals.h"
#include "dird/getmsg.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/msgchan.h"
#include "dird/sd_cmds.h"
#include "dird/storage.h"
@@ -69,7 +69,7 @@ static inline char* lookup_fileindex(JobControlRecord* jcr, int32_t FileIndex)
TREE_NODE *node, *parent;
PoolMem restore_pathname, tmp;
- node = FirstTreeNode(jcr->impl->restore_tree_root);
+ node = FirstTreeNode(jcr->dir_impl->restore_tree_root);
while (node) {
// See if this is the wanted FileIndex.
if (node->FileIndex == FileIndex) {
@@ -104,7 +104,7 @@ static inline int set_files_to_restore(JobControlRecord* jcr,
TREE_NODE *node, *parent;
PoolMem restore_pathname, tmp;
- node = FirstTreeNode(jcr->impl->restore_tree_root);
+ node = FirstTreeNode(jcr->dir_impl->restore_tree_root);
while (node) {
// See if this is the wanted FileIndex and the user asked to extract it.
if (node->FileIndex == FileIndex && node->extract) {
@@ -223,7 +223,7 @@ static inline bool fill_restore_environment(JobControlRecord* jcr,
}
// Lookup any meta tags that need to be added.
- fileset = jcr->impl->res.fileset;
+ fileset = jcr->dir_impl->res.fileset;
for (IncludeExcludeItem* ie : fileset->include_items) {
// Loop over each file = entry of the fileset.
for (int j = 0; j < ie->name_list.size(); j++) {
@@ -246,7 +246,7 @@ static inline bool fill_restore_environment(JobControlRecord* jcr,
if (jcr->where) {
restore_prefix = jcr->where;
} else {
- restore_prefix = jcr->impl->res.job->RestoreWhere;
+ restore_prefix = jcr->dir_impl->res.job->RestoreWhere;
}
if (!restore_prefix) { return false; }
@@ -315,7 +315,7 @@ bool DoNdmpRestoreInit(JobControlRecord* jcr)
{
FreeWstorage(jcr); /* we don't write */
- if (!jcr->impl->restore_tree_root) {
+ if (!jcr->dir_impl->restore_tree_root) {
Jmsg(jcr, M_FATAL, 0, _("Cannot NDMP restore without a file selection.\n"));
return false;
}
@@ -325,29 +325,31 @@ bool DoNdmpRestoreInit(JobControlRecord* jcr)
static inline int NdmpWaitForJobTermination(JobControlRecord* jcr)
{
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
/*
* Force cancel in SD if failing, but not for Incomplete jobs
* so that we let the SD despool.
*/
Dmsg4(100, "cancel=%d FDJS=%d JS=%d SDJS=%d\n", jcr->IsCanceled(),
- jcr->impl->FDJobStatus, jcr->JobStatus, jcr->impl->SDJobStatus);
- if (jcr->IsCanceled() || (!jcr->impl->res.job->RescheduleIncompleteJobs)) {
- Dmsg3(100, "FDJS=%d JS=%d SDJS=%d\n", jcr->impl->FDJobStatus,
- jcr->JobStatus, jcr->impl->SDJobStatus);
+ jcr->dir_impl->FDJobStatus.load(), jcr->getJobStatus(),
+ jcr->dir_impl->SDJobStatus.load());
+ if (jcr->IsCanceled()
+ || (!jcr->dir_impl->res.job->RescheduleIncompleteJobs)) {
+ Dmsg3(100, "FDJS=%d JS=%d SDJS=%d\n", jcr->dir_impl->FDJobStatus.load(),
+ jcr->getJobStatus(), jcr->dir_impl->SDJobStatus.load());
CancelStorageDaemonJob(jcr);
}
// Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/JobErrors
WaitForStorageDaemonTermination(jcr);
- jcr->impl->FDJobStatus = JS_Terminated;
- if (jcr->JobStatus != JS_Terminated) { return jcr->JobStatus; }
- if (jcr->impl->FDJobStatus != JS_Terminated) {
- return jcr->impl->FDJobStatus;
+ jcr->dir_impl->FDJobStatus = JS_Terminated;
+ if (jcr->getJobStatus() != JS_Terminated) { return jcr->getJobStatus(); }
+ if (jcr->dir_impl->FDJobStatus != JS_Terminated) {
+ return jcr->dir_impl->FDJobStatus;
}
- return jcr->impl->SDJobStatus;
+ return jcr->dir_impl->SDJobStatus;
}
/**
@@ -375,26 +377,26 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr)
bool retval = false;
int NdmpLoglevel;
- if (jcr->impl->res.client->ndmp_loglevel > me->ndmp_loglevel) {
- NdmpLoglevel = jcr->impl->res.client->ndmp_loglevel;
+ if (jcr->dir_impl->res.client->ndmp_loglevel > me->ndmp_loglevel) {
+ NdmpLoglevel = jcr->dir_impl->res.client->ndmp_loglevel;
} else {
NdmpLoglevel = me->ndmp_loglevel;
}
// We first parse the BootStrapRecord ourself so we know what to restore.
- jcr->impl->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap);
- if (!jcr->impl->bsr) {
+ jcr->dir_impl->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap);
+ if (!jcr->dir_impl->bsr) {
Jmsg(jcr, M_FATAL, 0, _("Error parsing bootstrap file.\n"));
goto bail_out;
}
// Setup all paired read storage.
SetPairedStorage(jcr);
- if (!jcr->impl->res.paired_read_write_storage) {
+ if (!jcr->dir_impl->res.paired_read_write_storage) {
Jmsg(jcr, M_FATAL, 0,
_("Read storage %s doesn't point to storage definition with paired "
"storage option.\n"),
- jcr->impl->res.read_storage->resource_name_);
+ jcr->dir_impl->res.read_storage->resource_name_);
goto bail_out;
}
@@ -405,7 +407,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr)
memset(nis, 0, sizeof(NIS));
// Read the bootstrap file
- bsr = jcr->impl->bsr;
+ bsr = jcr->dir_impl->bsr;
while (!feof(info.bs)) {
if (!SelectNextRstore(jcr, info)) { goto cleanup; }
@@ -415,8 +417,8 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr)
* we perform as part of the whole job. We only free the env_table between
* every sub-restore.
*/
- if (!NdmpBuildClientJob(jcr, jcr->impl->res.client,
- jcr->impl->res.paired_read_write_storage,
+ if (!NdmpBuildClientJob(jcr, jcr->dir_impl->res.client,
+ jcr->dir_impl->res.paired_read_write_storage,
NDM_JOB_OP_EXTRACT, &ndmp_job)) {
goto cleanup;
}
@@ -428,7 +430,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr)
*
*/
Dmsg0(10, "Open connection to storage daemon\n");
- jcr->setJobStatus(JS_WaitSD);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitSD);
// Start conversation with Storage daemon
if (!ConnectToStorageDaemon(jcr, 10, me->SDConnectTimeout, true)) {
@@ -437,11 +439,12 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr)
sd = jcr->store_bsock;
// Now start a job with the Storage daemon
- if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list, NULL)) {
+ if (!StartStorageDaemonJob(jcr, jcr->dir_impl->res.read_storage_list,
+ NULL)) {
goto cleanup;
}
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
// Send the bootstrap file -- what Volumes/files to restore
if (!SendBootstrapFile(jcr, sd, info)
@@ -470,13 +473,13 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr)
bool first_run = true;
bool next_sessid = true;
bool next_fi = true;
- int first_fi = jcr->impl->bsr->FileIndex->findex;
- int last_fi = jcr->impl->bsr->FileIndex->findex2;
- VolumeSessionInfo current_session{jcr->impl->bsr->sessid->sessid,
- jcr->impl->bsr->sesstime->sesstime};
+ int first_fi = jcr->dir_impl->bsr->FileIndex->findex;
+ int last_fi = jcr->dir_impl->bsr->FileIndex->findex2;
+ VolumeSessionInfo current_session{jcr->dir_impl->bsr->sessid->sessid,
+ jcr->dir_impl->bsr->sesstime->sesstime};
cnt = 0;
- for (bsr = jcr->impl->bsr; bsr; bsr = bsr->next) {
+ for (bsr = jcr->dir_impl->bsr; bsr; bsr = bsr->next) {
if (current_session.id != bsr->sessid->sessid) {
current_session = {bsr->sessid->sessid, bsr->sesstime->sesstime};
first_run = true;
@@ -526,7 +529,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr)
if (jcr->store_bsock && cnt > 0) {
jcr->store_bsock->fsend("nextrun");
lock_mutex(mutex);
- pthread_cond_wait(&jcr->impl->nextrun_ready, &mutex);
+ pthread_cond_wait(&jcr->dir_impl->nextrun_ready, &mutex);
unlock_mutex(mutex);
}
@@ -553,7 +556,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr)
session_initialized = true;
// Copy the actual job to perform.
- jcr->impl->jr.FileIndex = current_fi;
+ jcr->dir_impl->jr.FileIndex = current_fi;
memcpy(&ndmp_sess.control_acb->job, &ndmp_job,
sizeof(struct ndm_job_param));
@@ -662,8 +665,8 @@ cleanup:
CloseBootstrapFile(info);
bail_out:
- FreeTree(jcr->impl->restore_tree_root);
- jcr->impl->restore_tree_root = NULL;
+ FreeTree(jcr->dir_impl->restore_tree_root);
+ jcr->dir_impl->restore_tree_root = NULL;
return retval;
}
@@ -673,14 +676,14 @@ bool DoNdmpRestore(JobControlRecord* jcr)
{
int status;
- jcr->impl->jr.JobLevel = L_FULL; /* Full restore */
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->dir_impl->jr.JobLevel = L_FULL; /* Full restore */
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
goto bail_out;
}
Dmsg0(20, "Updated job start record\n");
- Dmsg1(20, "RestoreJobId=%d\n", jcr->impl->res.job->RestoreJobId);
+ Dmsg1(20, "RestoreJobId=%d\n", jcr->dir_impl->res.job->RestoreJobId);
// Validate the Job to have a NDMP client.
if (!NdmpValidateClient(jcr)) { return false; }
diff --git a/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc b/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc
index a2916f54d..e945a31a9 100644
--- a/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc
+++ b/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc
@@ -41,7 +41,7 @@
# include "ndmp/ndmagents.h"
# include "dird/ndmp_dma_storage.h"
# include "ndmp_dma_priv.h"
-# include "dird/jcr_private.h"
+# include "dird/director_jcr_impl.h"
# include "dird/ndmp_dma_restore_common.h"
# include "dird/ndmp_dma_generic.h"
@@ -104,7 +104,7 @@ static inline bool fill_restore_environment_ndmp_native(
if (jcr->where) {
restore_prefix = jcr->where;
} else {
- restore_prefix = jcr->impl->res.job->RestoreWhere;
+ restore_prefix = jcr->dir_impl->res.job->RestoreWhere;
}
if (!restore_prefix) { return false; }
@@ -164,7 +164,7 @@ int SetFilesToRestoreNdmpNative(JobControlRecord* jcr,
TREE_NODE *node, *parent;
PoolMem restore_pathname, tmp;
- node = FirstTreeNode(jcr->impl->restore_tree_root);
+ node = FirstTreeNode(jcr->dir_impl->restore_tree_root);
while (node) {
/*
* node->extract_dir means that only the directory should be selected for
@@ -235,7 +235,7 @@ static bool DoNdmpNativeRestore(JobControlRecord* jcr)
slot_number_t ndmp_slot;
StorageResource* store = NULL;
- store = jcr->impl->res.read_storage;
+ store = jcr->dir_impl->res.read_storage;
memset(&ndmp_sess, 0, sizeof(ndmp_sess));
@@ -243,9 +243,9 @@ static bool DoNdmpNativeRestore(JobControlRecord* jcr)
memset(nis, 0, sizeof(NIS));
NdmpLoglevel
- = std::max(jcr->impl->res.client->ndmp_loglevel, me->ndmp_loglevel);
+ = std::max(jcr->dir_impl->res.client->ndmp_loglevel, me->ndmp_loglevel);
- if (!NdmpBuildClientAndStorageJob(jcr, store, jcr->impl->res.client,
+ if (!NdmpBuildClientAndStorageJob(jcr, store, jcr->dir_impl->res.client,
true, /* init_tape */
true, /* init_robot */
NDM_JOB_OP_EXTRACT, &ndmp_job)) {
@@ -305,7 +305,7 @@ static bool DoNdmpNativeRestore(JobControlRecord* jcr)
ndmp_sess.dump_media_info = 1; // for debugging
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
// Initialize the session structure.
if (ndma_session_initialize(&ndmp_sess)) { goto cleanup_ndmp; }
@@ -400,8 +400,8 @@ cleanup_ndmp:
cleanup:
free(nis);
- FreeTree(jcr->impl->restore_tree_root);
- jcr->impl->restore_tree_root = NULL;
+ FreeTree(jcr->dir_impl->restore_tree_root);
+ jcr->dir_impl->restore_tree_root = NULL;
return retval;
}
@@ -410,14 +410,14 @@ bool DoNdmpRestoreNdmpNative(JobControlRecord* jcr)
{
int status;
- jcr->impl->jr.JobLevel = L_FULL; /* Full restore */
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->dir_impl->jr.JobLevel = L_FULL; /* Full restore */
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
goto bail_out;
}
Dmsg0(20, "Updated job start record\n");
- Dmsg1(20, "RestoreJobId=%d\n", jcr->impl->res.job->RestoreJobId);
+ Dmsg1(20, "RestoreJobId=%d\n", jcr->dir_impl->res.job->RestoreJobId);
// Validate the Job to have a NDMP client.
if (!NdmpValidateClient(jcr)) { return false; }
diff --git a/core/src/dird/ndmp_dma_restore_common.cc b/core/src/dird/ndmp_dma_restore_common.cc
index 9b9f22302..793b5ecf8 100644
--- a/core/src/dird/ndmp_dma_restore_common.cc
+++ b/core/src/dird/ndmp_dma_restore_common.cc
@@ -30,7 +30,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/restore.h"
@@ -179,16 +179,16 @@ void NdmpRestoreCleanup(JobControlRecord* jcr, int TermCode)
Dmsg0(20, "In NdmpRestoreCleanup\n");
UpdateJobEnd(jcr, TermCode);
- if (jcr->impl->unlink_bsr && jcr->RestoreBootstrap) {
+ if (jcr->dir_impl->unlink_bsr && jcr->RestoreBootstrap) {
SecureErase(jcr, jcr->RestoreBootstrap);
- jcr->impl->unlink_bsr = false;
+ jcr->dir_impl->unlink_bsr = false;
}
if (JobCanceled(jcr)) { CancelStorageDaemonJob(jcr); }
switch (TermCode) {
case JS_Terminated:
- if (jcr->impl->ExpectedFiles > jcr->impl->jr.JobFiles) {
+ if (jcr->dir_impl->ExpectedFiles > jcr->dir_impl->jr.JobFiles) {
TermMsg = _("Restore OK -- warning file count mismatch");
} else {
TermMsg = _("Restore OK");
@@ -203,8 +203,8 @@ void NdmpRestoreCleanup(JobControlRecord* jcr, int TermCode)
msg_type = M_ERROR; /* Generate error message */
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
break;
@@ -212,8 +212,8 @@ void NdmpRestoreCleanup(JobControlRecord* jcr, int TermCode)
TermMsg = _("Restore Canceled");
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
break;
diff --git a/core/src/dird/ndmp_dma_storage.cc b/core/src/dird/ndmp_dma_storage.cc
index 744537478..9a381535d 100644
--- a/core/src/dird/ndmp_dma_storage.cc
+++ b/core/src/dird/ndmp_dma_storage.cc
@@ -28,7 +28,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/sd_cmds.h"
#include "dird/storage.h"
#include "dird/ndmp_slot2elemaddr.h"
@@ -68,10 +68,10 @@ int get_tape_info_cb(struct ndm_session* sess,
}
if (jcr->is_JobType(JT_BACKUP)) {
- store = jcr->impl->res.write_storage;
+ store = jcr->dir_impl->res.write_storage;
} else if (jcr->is_JobType(JT_RESTORE)) {
- store = jcr->impl->res.read_storage;
+ store = jcr->dir_impl->res.read_storage;
} else {
return -1;
@@ -180,7 +180,7 @@ void DoNdmpNativeStorageStatus(UaContext* ua, StorageResource* store, char*)
{
struct ndm_job_param ndmp_job;
- ua->jcr->impl->res.write_storage = store;
+ ua->jcr->dir_impl->res.write_storage = store;
if (!NdmpBuildStorageJob(ua->jcr, store, true, /* Query Tape Agent */
true, /* Query Robot Agent */
@@ -1072,7 +1072,7 @@ bool ndmp_native_setup_robot_and_tape_for_native_backup_job(
ndmp_job.have_robot = 1;
// unload tape if tape is in drive
ndmp_job.auto_remedy = 1;
- ndmp_job.record_size = jcr->impl->res.client->ndmp_blocksize;
+ ndmp_job.record_size = jcr->dir_impl->res.client->ndmp_blocksize;
Jmsg(jcr, M_INFO, 0, _("Using Data host %s\n"), ndmp_job.data_agent.host);
Jmsg(jcr, M_INFO, 0, _("Using Tape host:device:address %s:%s:@%d\n"),
diff --git a/core/src/dird/newvol.cc b/core/src/dird/newvol.cc
index 496256569..7d2136dd8 100644
--- a/core/src/dird/newvol.cc
+++ b/core/src/dird/newvol.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
- Copyright (C) 2013-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -36,7 +36,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/expand.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/next_vol.h"
#include "cats/sql.h"
#include "dird/ua_db.h"
@@ -71,7 +71,7 @@ bool newVolume(JobControlRecord* jcr, MediaDbRecord* mr, StorageResource* store)
*mr = MediaDbRecord{};
SetPoolDbrDefaultsInMediaDbr(mr, &pr);
jcr->VolumeName[0] = 0;
- bstrncpy(mr->MediaType, jcr->impl->res.write_storage->media_type,
+ bstrncpy(mr->MediaType, jcr->dir_impl->res.write_storage->media_type,
sizeof(mr->MediaType));
GeneratePluginEvent(jcr, bDirEventNewVolume); /* return void... */
if (jcr->VolumeName[0] && IsVolumeNameLegal(NULL, jcr->VolumeName)) {
@@ -163,7 +163,7 @@ static bool PerformFullNameSubstitution(JobControlRecord* jcr,
bool ok = false;
POOLMEM* label = GetPoolMemory(PM_FNAME);
- jcr->impl->NumVols = pr->NumVols;
+ jcr->dir_impl->NumVols = pr->NumVols;
if (VariableExpansion(jcr, pr->LabelFormat, label)) {
bstrncpy(mr->VolumeName, label, sizeof(mr->VolumeName));
ok = true;
diff --git a/core/src/dird/next_vol.cc b/core/src/dird/next_vol.cc
index 830acfce3..3a56ed17e 100644
--- a/core/src/dird/next_vol.cc
+++ b/core/src/dird/next_vol.cc
@@ -32,7 +32,7 @@
#include "dird.h"
#include "dird/autoprune.h"
#include "dird/autorecycle.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/next_vol.h"
#include "dird/newvol.h"
#include "dird/ua_db.h"
@@ -74,7 +74,7 @@ int FindNextVolumeForAppend(JobControlRecord* jcr,
int retry = 0;
bool ok;
bool InChanger;
- StorageResource* store = jcr->impl->res.write_storage;
+ StorageResource* store = jcr->dir_impl->res.write_storage;
bstrncpy(mr->MediaType, store->media_type, sizeof(mr->MediaType));
Dmsg3(debuglevel,
@@ -151,12 +151,12 @@ int FindNextVolumeForAppend(JobControlRecord* jcr,
// Look at more drastic ways to find an Appendable Volume
if (!ok
- && (jcr->impl->res.pool->purge_oldest_volume
- || jcr->impl->res.pool->recycle_oldest_volume)) {
+ && (jcr->dir_impl->res.pool->purge_oldest_volume
+ || jcr->dir_impl->res.pool->recycle_oldest_volume)) {
Dmsg2(debuglevel,
"No next volume found. PurgeOldest=%d\n RecyleOldest=%d",
- jcr->impl->res.pool->purge_oldest_volume,
- jcr->impl->res.pool->recycle_oldest_volume);
+ jcr->dir_impl->res.pool->purge_oldest_volume,
+ jcr->dir_impl->res.pool->recycle_oldest_volume);
// Find oldest volume to recycle
SetStorageidInMr(store, mr);
@@ -168,11 +168,11 @@ int FindNextVolumeForAppend(JobControlRecord* jcr,
Dmsg0(debuglevel, "Try purge Volume.\n");
// 7. Try to purging oldest volume only if not UA calling us.
ua = new_ua_context(jcr);
- if (jcr->impl->res.pool->purge_oldest_volume && create) {
+ if (jcr->dir_impl->res.pool->purge_oldest_volume && create) {
Jmsg(jcr, M_INFO, 0, _("Purging oldest volume \"%s\"\n"),
mr->VolumeName);
ok = PurgeJobsFromVolume(ua, mr);
- } else if (jcr->impl->res.pool->recycle_oldest_volume) {
+ } else if (jcr->dir_impl->res.pool->recycle_oldest_volume) {
// 8. Try recycling the oldest volume
Jmsg(jcr, M_INFO, 0, _("Pruning oldest volume \"%s\"\n"),
mr->VolumeName);
@@ -336,7 +336,7 @@ void CheckIfVolumeValidOrRecyclable(JobControlRecord* jcr,
* try to catch close calls ...
*/
if ((mr->LastWritten + mr->VolRetention - 60) < (utime_t)time(NULL)
- && jcr->impl->res.pool->recycle_current_volume
+ && jcr->dir_impl->res.pool->recycle_current_volume
&& (bstrcmp(mr->VolStatus, "Full") || bstrcmp(mr->VolStatus, "Used"))) {
// Attempt prune of current volume to see if we can recycle it for use.
UaContext* ua;
@@ -419,7 +419,8 @@ bool GetScratchVolume(JobControlRecord* jcr,
* add a Volume.
*/
PoolDbRecord pr;
- bstrncpy(pr.Name, jcr->impl->res.pool->resource_name_, sizeof(pr.Name));
+ bstrncpy(pr.Name, jcr->dir_impl->res.pool->resource_name_,
+ sizeof(pr.Name));
if (!jcr->db->GetPoolRecord(jcr, &pr)) {
Jmsg(jcr, M_WARNING, 0, _("Unable to get Pool record: ERR=%s\n"),
@@ -431,7 +432,7 @@ bool GetScratchVolume(JobControlRecord* jcr,
if (pr.MaxVols > 0 && pr.NumVols >= pr.MaxVols) {
Jmsg(jcr, M_WARNING, 0,
_("Unable add Scratch Volume, Pool \"%s\" full MaxVols=%d\n"),
- jcr->impl->res.pool->resource_name_, pr.MaxVols);
+ jcr->dir_impl->res.pool->resource_name_, pr.MaxVols);
goto bail_out;
}
diff --git a/core/src/dird/quota.cc b/core/src/dird/quota.cc
index 38462ac50..c10629b53 100644
--- a/core/src/dird/quota.cc
+++ b/core/src/dird/quota.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
- Copyright (C) 2013-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version two of the GNU General Public
@@ -28,7 +28,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
namespace directordaemon {
@@ -44,39 +44,42 @@ uint64_t FetchRemainingQuotas(JobControlRecord* jcr)
uint64_t now = (uint64_t)time(NULL);
// Quotas not being used ?
- if (!jcr->impl->HasQuota) { return 0; }
+ if (!jcr->dir_impl->HasQuota) { return 0; }
Dmsg2(debuglevel, "JobSumTotalBytes for JobId %d is %llu\n", jcr->JobId,
- jcr->impl->jr.JobSumTotalBytes);
+ jcr->dir_impl->jr.JobSumTotalBytes);
Dmsg1(debuglevel, "Fetching remaining quotas for JobId %d\n", jcr->JobId);
// If strict quotas on and grace exceeded, enforce the softquota
- if (jcr->impl->res.client->StrictQuotas && jcr->impl->res.client->SoftQuota
- && jcr->impl->res.client->GraceTime > 0
- && (now - (uint64_t)jcr->impl->res.client->GraceTime)
- > (uint64_t)jcr->impl->res.client->SoftQuotaGracePeriod
- && jcr->impl->res.client->SoftQuotaGracePeriod > 0) {
- remaining
- = jcr->impl->res.client->SoftQuota - jcr->impl->jr.JobSumTotalBytes;
- } else if (!jcr->impl->res.client->StrictQuotas
- && jcr->impl->res.client->SoftQuota
- && jcr->impl->res.client->GraceTime > 0
- && jcr->impl->res.client->SoftQuotaGracePeriod > 0
- && (now - (uint64_t)jcr->impl->res.client->GraceTime)
- > (uint64_t)jcr->impl->res.client->SoftQuotaGracePeriod) {
+ if (jcr->dir_impl->res.client->StrictQuotas
+ && jcr->dir_impl->res.client->SoftQuota
+ && jcr->dir_impl->res.client->GraceTime > 0
+ && (now - (uint64_t)jcr->dir_impl->res.client->GraceTime)
+ > (uint64_t)jcr->dir_impl->res.client->SoftQuotaGracePeriod
+ && jcr->dir_impl->res.client->SoftQuotaGracePeriod > 0) {
+ remaining = jcr->dir_impl->res.client->SoftQuota
+ - jcr->dir_impl->jr.JobSumTotalBytes;
+ } else if (!jcr->dir_impl->res.client->StrictQuotas
+ && jcr->dir_impl->res.client->SoftQuota
+ && jcr->dir_impl->res.client->GraceTime > 0
+ && jcr->dir_impl->res.client->SoftQuotaGracePeriod > 0
+ && (now - (uint64_t)jcr->dir_impl->res.client->GraceTime)
+ > (uint64_t)
+ jcr->dir_impl->res.client->SoftQuotaGracePeriod) {
// If strict quotas turned off and grace exceeded use the last known limit
- if (jcr->impl->res.client->QuotaLimit > jcr->impl->res.client->SoftQuota) {
- remaining
- = jcr->impl->res.client->QuotaLimit - jcr->impl->jr.JobSumTotalBytes;
+ if (jcr->dir_impl->res.client->QuotaLimit
+ > jcr->dir_impl->res.client->SoftQuota) {
+ remaining = jcr->dir_impl->res.client->QuotaLimit
+ - jcr->dir_impl->jr.JobSumTotalBytes;
} else {
- remaining
- = jcr->impl->res.client->SoftQuota - jcr->impl->jr.JobSumTotalBytes;
+ remaining = jcr->dir_impl->res.client->SoftQuota
+ - jcr->dir_impl->jr.JobSumTotalBytes;
}
- } else if (jcr->impl->jr.JobSumTotalBytes
- < jcr->impl->res.client->HardQuota) {
+ } else if (jcr->dir_impl->jr.JobSumTotalBytes
+ < jcr->dir_impl->res.client->HardQuota) {
// If within the hardquota.
- remaining
- = jcr->impl->res.client->HardQuota - jcr->impl->jr.JobSumTotalBytes;
+ remaining = jcr->dir_impl->res.client->HardQuota
+ - jcr->dir_impl->jr.JobSumTotalBytes;
} else {
/*
* If just over quota return 0. This shouldnt happen because quotas
@@ -87,8 +90,8 @@ uint64_t FetchRemainingQuotas(JobControlRecord* jcr)
Dmsg4(debuglevel,
"Quota for %s is %llu. Remainder is %llu, QuotaLimit: %llu\n",
- jcr->impl->jr.Name, jcr->impl->jr.JobSumTotalBytes, remaining,
- jcr->impl->res.client->QuotaLimit);
+ jcr->dir_impl->jr.Name, jcr->dir_impl->jr.JobSumTotalBytes, remaining,
+ jcr->dir_impl->res.client->QuotaLimit);
return remaining;
}
@@ -107,35 +110,38 @@ bool CheckHardquotas(JobControlRecord* jcr)
bool retval = false;
// Do not check if hardquota is not set
- if (jcr->impl->res.client->HardQuota == 0) { goto bail_out; }
+ if (jcr->dir_impl->res.client->HardQuota == 0) { goto bail_out; }
Dmsg1(debuglevel, "Checking hard quotas for JobId %d\n", jcr->JobId);
- if (!jcr->impl->HasQuota) {
- if (jcr->impl->res.client->QuotaIncludeFailedJobs) {
- if (!jcr->db->get_quota_jobbytes(jcr, &jcr->impl->jr,
- jcr->impl->res.client->JobRetention)) {
+ if (!jcr->dir_impl->HasQuota) {
+ if (jcr->dir_impl->res.client->QuotaIncludeFailedJobs) {
+ if (!jcr->db->get_quota_jobbytes(
+ jcr, &jcr->dir_impl->jr,
+ jcr->dir_impl->res.client->JobRetention)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s\n"),
jcr->db->strerror());
goto bail_out;
}
} else {
if (!jcr->db->get_quota_jobbytes_nofailed(
- jcr, &jcr->impl->jr, jcr->impl->res.client->JobRetention)) {
+ jcr, &jcr->dir_impl->jr,
+ jcr->dir_impl->res.client->JobRetention)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s\n"),
jcr->db->strerror());
goto bail_out;
}
}
- jcr->impl->HasQuota = true;
+ jcr->dir_impl->HasQuota = true;
}
- if (jcr->impl->jr.JobSumTotalBytes > jcr->impl->res.client->HardQuota) {
+ if (jcr->dir_impl->jr.JobSumTotalBytes
+ > jcr->dir_impl->res.client->HardQuota) {
retval = true;
goto bail_out;
}
- Dmsg2(debuglevel, "Quota for JobID: %d is %llu\n", jcr->impl->jr.JobId,
- jcr->impl->jr.JobSumTotalBytes);
+ Dmsg2(debuglevel, "Quota for JobID: %d is %llu\n", jcr->dir_impl->jr.JobId,
+ jcr->dir_impl->jr.JobSumTotalBytes);
bail_out:
return retval;
@@ -163,13 +169,14 @@ bool CheckSoftquotas(JobControlRecord* jcr)
uint64_t now = (uint64_t)time(NULL);
// Do not check if the softquota is not set
- if (jcr->impl->res.client->SoftQuota == 0) { goto bail_out; }
+ if (jcr->dir_impl->res.client->SoftQuota == 0) { goto bail_out; }
Dmsg1(debuglevel, "Checking soft quotas for JobId %d\n", jcr->JobId);
- if (!jcr->impl->HasQuota) {
- if (jcr->impl->res.client->QuotaIncludeFailedJobs) {
- if (!jcr->db->get_quota_jobbytes(jcr, &jcr->impl->jr,
- jcr->impl->res.client->JobRetention)) {
+ if (!jcr->dir_impl->HasQuota) {
+ if (jcr->dir_impl->res.client->QuotaIncludeFailedJobs) {
+ if (!jcr->db->get_quota_jobbytes(
+ jcr, &jcr->dir_impl->jr,
+ jcr->dir_impl->res.client->JobRetention)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s\n"),
jcr->db->strerror());
goto bail_out;
@@ -177,70 +184,75 @@ bool CheckSoftquotas(JobControlRecord* jcr)
Dmsg0(debuglevel, "Quota Includes Failed Jobs\n");
} else {
if (!jcr->db->get_quota_jobbytes_nofailed(
- jcr, &jcr->impl->jr, jcr->impl->res.client->JobRetention)) {
+ jcr, &jcr->dir_impl->jr,
+ jcr->dir_impl->res.client->JobRetention)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s\n"),
jcr->db->strerror());
goto bail_out;
}
Jmsg(jcr, M_INFO, 0, _("Quota does NOT include Failed Jobs\n"));
}
- jcr->impl->HasQuota = true;
+ jcr->dir_impl->HasQuota = true;
}
- Dmsg2(debuglevel, "Quota for %s is %llu\n", jcr->impl->jr.Name,
- jcr->impl->jr.JobSumTotalBytes);
- Dmsg2(debuglevel, "QuotaLimit for %s is %llu\n", jcr->impl->jr.Name,
- jcr->impl->res.client->QuotaLimit);
- Dmsg2(debuglevel, "HardQuota for %s is %llu\n", jcr->impl->jr.Name,
- jcr->impl->res.client->HardQuota);
- Dmsg2(debuglevel, "SoftQuota for %s is %llu\n", jcr->impl->jr.Name,
- jcr->impl->res.client->SoftQuota);
- Dmsg2(debuglevel, "SoftQuota Grace Period for %s is %d\n", jcr->impl->jr.Name,
- jcr->impl->res.client->SoftQuotaGracePeriod);
- Dmsg2(debuglevel, "SoftQuota Grace Time for %s is %d\n", jcr->impl->jr.Name,
- jcr->impl->res.client->GraceTime);
+ Dmsg2(debuglevel, "Quota for %s is %llu\n", jcr->dir_impl->jr.Name,
+ jcr->dir_impl->jr.JobSumTotalBytes);
+ Dmsg2(debuglevel, "QuotaLimit for %s is %llu\n", jcr->dir_impl->jr.Name,
+ jcr->dir_impl->res.client->QuotaLimit);
+ Dmsg2(debuglevel, "HardQuota for %s is %llu\n", jcr->dir_impl->jr.Name,
+ jcr->dir_impl->res.client->HardQuota);
+ Dmsg2(debuglevel, "SoftQuota for %s is %llu\n", jcr->dir_impl->jr.Name,
+ jcr->dir_impl->res.client->SoftQuota);
+ Dmsg2(debuglevel, "SoftQuota Grace Period for %s is %d\n",
+ jcr->dir_impl->jr.Name,
+ jcr->dir_impl->res.client->SoftQuotaGracePeriod);
+ Dmsg2(debuglevel, "SoftQuota Grace Time for %s is %d\n",
+ jcr->dir_impl->jr.Name, jcr->dir_impl->res.client->GraceTime);
- if ((jcr->impl->jr.JobSumTotalBytes + jcr->impl->SDJobBytes)
- > jcr->impl->res.client->SoftQuota) {
+ if ((jcr->dir_impl->jr.JobSumTotalBytes + jcr->dir_impl->SDJobBytes)
+ > jcr->dir_impl->res.client->SoftQuota) {
/*
* Only warn once about softquotas in the job
* Check if gracetime has been set
*/
- if (jcr->impl->res.client->GraceTime == 0
- && jcr->impl->res.client->SoftQuotaGracePeriod) {
+ if (jcr->dir_impl->res.client->GraceTime == 0
+ && jcr->dir_impl->res.client->SoftQuotaGracePeriod) {
Dmsg1(debuglevel, "UpdateQuotaGracetime: %d\n", now);
- if (!jcr->db->UpdateQuotaGracetime(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->UpdateQuotaGracetime(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0, _("Error setting Quota gracetime: ERR=%s\n"),
jcr->db->strerror());
} else {
Jmsg(jcr, M_ERROR, 0,
_("Softquota Exceeded, Grace Period starts now.\n"));
}
- jcr->impl->res.client->GraceTime = now;
+ jcr->dir_impl->res.client->GraceTime = now;
goto bail_out;
- } else if (jcr->impl->res.client->SoftQuotaGracePeriod
- && (now - (uint64_t)jcr->impl->res.client->GraceTime)
- < (uint64_t)jcr->impl->res.client->SoftQuotaGracePeriod) {
+ } else if (jcr->dir_impl->res.client->SoftQuotaGracePeriod
+ && (now - (uint64_t)jcr->dir_impl->res.client->GraceTime)
+ < (uint64_t)
+ jcr->dir_impl->res.client->SoftQuotaGracePeriod) {
Jmsg(jcr, M_ERROR, 0,
_("Softquota Exceeded, will be enforced after Grace Period "
"expires.\n"));
- } else if (jcr->impl->res.client->SoftQuotaGracePeriod
- && (now - (uint64_t)jcr->impl->res.client->GraceTime)
- > (uint64_t)jcr->impl->res.client->SoftQuotaGracePeriod) {
+ } else if (jcr->dir_impl->res.client->SoftQuotaGracePeriod
+ && (now - (uint64_t)jcr->dir_impl->res.client->GraceTime)
+ > (uint64_t)
+ jcr->dir_impl->res.client->SoftQuotaGracePeriod) {
/*
* If gracetime has expired update else check more if not set softlimit
* yet then set and bail out.
*/
- if (jcr->impl->res.client->QuotaLimit < 1) {
- if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->impl->jr)) {
+ if (jcr->dir_impl->res.client->QuotaLimit < 1) {
+ if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0, _("Error setting Quota Softlimit: ERR=%s\n"),
jcr->db->strerror());
}
Jmsg(jcr, M_WARNING, 0,
_("Softquota Exceeded and Grace Period expired.\n"));
Jmsg(jcr, M_INFO, 0, _("Setting Burst Quota to %d Bytes.\n"),
- jcr->impl->jr.JobSumTotalBytes);
- jcr->impl->res.client->QuotaLimit = jcr->impl->jr.JobSumTotalBytes;
+ jcr->dir_impl->jr.JobSumTotalBytes);
+ jcr->dir_impl->res.client->QuotaLimit
+ = jcr->dir_impl->jr.JobSumTotalBytes;
retval = true;
goto bail_out;
} else {
@@ -248,8 +260,8 @@ bool CheckSoftquotas(JobControlRecord* jcr)
* If gracetime has expired update else check more if not set softlimit
* yet then set and bail out.
*/
- if (jcr->impl->res.client->QuotaLimit < 1) {
- if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->impl->jr)) {
+ if (jcr->dir_impl->res.client->QuotaLimit < 1) {
+ if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error setting Quota Softlimit: ERR=%s\n"),
jcr->db->strerror());
@@ -257,23 +269,24 @@ bool CheckSoftquotas(JobControlRecord* jcr)
Jmsg(jcr, M_WARNING, 0,
_("Soft Quota exceeded and Grace Period expired.\n"));
Jmsg(jcr, M_INFO, 0, _("Setting Burst Quota to %d Bytes.\n"),
- jcr->impl->jr.JobSumTotalBytes);
- jcr->impl->res.client->QuotaLimit = jcr->impl->jr.JobSumTotalBytes;
+ jcr->dir_impl->jr.JobSumTotalBytes);
+ jcr->dir_impl->res.client->QuotaLimit
+ = jcr->dir_impl->jr.JobSumTotalBytes;
retval = true;
goto bail_out;
} else {
// If we use strict quotas enforce the pure soft quota limit.
- if (jcr->impl->res.client->StrictQuotas) {
- if (jcr->impl->jr.JobSumTotalBytes
- > jcr->impl->res.client->SoftQuota) {
+ if (jcr->dir_impl->res.client->StrictQuotas) {
+ if (jcr->dir_impl->jr.JobSumTotalBytes
+ > jcr->dir_impl->res.client->SoftQuota) {
Dmsg0(debuglevel,
"Soft Quota exceeded, enforcing Strict Quota Limit.\n");
retval = true;
goto bail_out;
}
} else {
- if (jcr->impl->jr.JobSumTotalBytes
- >= jcr->impl->res.client->QuotaLimit) {
+ if (jcr->dir_impl->jr.JobSumTotalBytes
+ >= jcr->dir_impl->res.client->QuotaLimit) {
// If strict quotas turned off use the last known limit
Jmsg(jcr, M_WARNING, 0,
_("Soft Quota exceeded, enforcing Burst Quota Limit.\n"));
@@ -284,15 +297,15 @@ bool CheckSoftquotas(JobControlRecord* jcr)
}
}
}
- } else if (jcr->impl->res.client->GraceTime != 0) {
+ } else if (jcr->dir_impl->res.client->GraceTime != 0) {
// Reset softquota
ClientDbRecord cr;
- cr.ClientId = jcr->impl->jr.ClientId;
+ cr.ClientId = jcr->dir_impl->jr.ClientId;
if (!jcr->db->ResetQuotaRecord(jcr, &cr)) {
Jmsg(jcr, M_WARNING, 0, _("Error setting Quota gracetime: ERR=%s\n"),
jcr->db->strerror());
} else {
- jcr->impl->res.client->GraceTime = 0;
+ jcr->dir_impl->res.client->GraceTime = 0;
Jmsg(jcr, M_INFO, 0, _("Soft Quota reset, Grace Period ends now.\n"));
}
}
diff --git a/core/src/dird/recycle.cc b/core/src/dird/recycle.cc
index 9317d0b87..3c63dd5ba 100644
--- a/core/src/dird/recycle.cc
+++ b/core/src/dird/recycle.cc
@@ -3,7 +3,7 @@
Copyright (C) 2002-2012 Free Software Foundation Europe e.V.
Copyright (C) 2016-2016 Planets Communications B.V.
- Copyright (C) 2016-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -29,7 +29,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/autorecycle.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/next_vol.h"
namespace directordaemon {
@@ -45,8 +45,8 @@ bool FindRecycledVolume(JobControlRecord* jcr,
bstrncpy(mr->VolStatus, "Recycle", sizeof(mr->VolStatus));
SetStorageidInMr(store, mr);
if (jcr->db->FindNextVolume(jcr, 1, InChanger, mr, unwanted_volumes)) {
- jcr->impl->MediaId = mr->MediaId;
- Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->impl->MediaId);
+ jcr->dir_impl->MediaId = mr->MediaId;
+ Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->dir_impl->MediaId);
PmStrcpy(jcr->VolumeName, mr->VolumeName);
SetStorageidInMr(store, mr);
diff --git a/core/src/dird/restore.cc b/core/src/dird/restore.cc
index f14bd02cb..1091a335f 100644
--- a/core/src/dird/restore.cc
+++ b/core/src/dird/restore.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -44,7 +44,7 @@
#include "dird/backup.h"
#include "dird/fd_cmds.h"
#include "dird/getmsg.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/msgchan.h"
#include "dird/restore.h"
@@ -80,10 +80,10 @@ static void BuildRestoreCommand(JobControlRecord* jcr, PoolMem& ret)
char empty = '\0';
// Build the restore command
- if (jcr->impl->replace != 0) {
- replace = jcr->impl->replace;
- } else if (jcr->impl->res.job->replace != 0) {
- replace = jcr->impl->res.job->replace;
+ if (jcr->dir_impl->replace != 0) {
+ replace = jcr->dir_impl->replace;
+ } else if (jcr->dir_impl->res.job->replace != 0) {
+ replace = jcr->dir_impl->res.job->replace;
} else {
replace = REPLACE_ALWAYS; /* always replace */
}
@@ -91,21 +91,22 @@ static void BuildRestoreCommand(JobControlRecord* jcr, PoolMem& ret)
if (jcr->RegexWhere) {
where = jcr->RegexWhere; /* override */
cmd = restorecmdR;
- } else if (jcr->impl->res.job->RegexWhere) {
- where = jcr->impl->res.job->RegexWhere; /* no override take from job */
+ } else if (jcr->dir_impl->res.job->RegexWhere) {
+ where = jcr->dir_impl->res.job->RegexWhere; /* no override take from job */
cmd = restorecmdR;
} else if (jcr->where) {
where = jcr->where; /* override */
cmd = restorecmd;
- } else if (jcr->impl->res.job->RestoreWhere) {
- where = jcr->impl->res.job->RestoreWhere; /* no override take from job */
+ } else if (jcr->dir_impl->res.job->RestoreWhere) {
+ where
+ = jcr->dir_impl->res.job->RestoreWhere; /* no override take from job */
cmd = restorecmd;
} else { /* nothing was specified */
where = &empty; /* use default */
cmd = restorecmd;
}
- jcr->prefix_links = jcr->impl->res.job->PrefixLinks;
+ jcr->prefix_links = jcr->dir_impl->res.job->PrefixLinks;
BashSpaces(where);
Mmsg(ret, cmd, replace, jcr->prefix_links, where);
@@ -133,7 +134,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
PoolMem RestoreCmd(PM_MESSAGE);
char* connection_target_address;
- client = jcr->impl->res.client;
+ client = jcr->dir_impl->res.client;
// This command is used for each part
BuildRestoreCommand(jcr, RestoreCmd);
@@ -144,7 +145,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
jcr->passive_client = client->passive;
while (!feof(info.bs)) {
if (!SelectNextRstore(jcr, info)) { goto bail_out; }
- store = jcr->impl->res.read_storage;
+ store = jcr->dir_impl->res.read_storage;
/**
* Open a message channel connection with the Storage
@@ -153,7 +154,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
*
*/
Dmsg0(10, "Open connection with storage daemon\n");
- jcr->setJobStatus(JS_WaitSD);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitSD);
// Start conversation with Storage daemon
if (!ConnectToStorageDaemon(jcr, 10, me->SDConnectTimeout, true)) {
@@ -162,14 +163,16 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
sd = jcr->store_bsock;
// Now start a job with the Storage daemon
- if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list, NULL)) {
+ if (!StartStorageDaemonJob(jcr, jcr->dir_impl->res.read_storage_list,
+ NULL)) {
goto bail_out;
}
if (first_time) {
// Start conversation with File daemon
- jcr->setJobStatus(JS_WaitFD);
- jcr->impl->keep_sd_auth_key = true; /* don't clear the sd_auth_key now */
+ jcr->setJobStatusWithPriorityCheck(JS_WaitFD);
+ jcr->dir_impl->keep_sd_auth_key
+ = true; /* don't clear the sd_auth_key now */
if (!ConnectToFileDaemon(jcr, 10, me->FDConnectTimeout, true)) {
goto bail_out;
@@ -182,16 +185,16 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
}
// Check if the file daemon supports passive client mode.
- if (jcr->passive_client && jcr->impl->FDVersion < FD_VERSION_51) {
+ if (jcr->passive_client && jcr->dir_impl->FDVersion < FD_VERSION_51) {
Jmsg(jcr, M_FATAL, 0,
_("Client \"%s\" doesn't support passive client mode. "
"Please upgrade your client or disable compat mode.\n"),
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
goto bail_out;
}
}
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
// Send the bootstrap file -- what Volumes/files to restore
bool success = false;
@@ -224,7 +227,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
// TLS Requirement
TlsPolicy tls_policy;
- if (jcr->impl->res.client->connection_successful_handshake_
+ if (jcr->dir_impl->res.client->connection_successful_handshake_
!= ClientConnectionHandshakeMode::kTlsFirst) {
tls_policy = store->GetPolicy();
} else {
@@ -260,7 +263,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
TlsPolicy tls_policy;
- if (jcr->impl->res.client->connection_successful_handshake_
+ if (jcr->dir_impl->res.client->connection_successful_handshake_
!= ClientConnectionHandshakeMode::kTlsFirst) {
tls_policy = client->GetPolicy();
} else {
@@ -297,7 +300,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
if (!SendRunscriptsCommands(jcr)) { goto bail_out; }
// Only FD version 52 and later understand the sending of plugin options.
- if (jcr->impl->FDVersion >= FD_VERSION_52) {
+ if (jcr->dir_impl->FDVersion >= FD_VERSION_52) {
if (!SendPluginOptions(jcr)) {
Dmsg0(000, "FAIL: Send plugin options\n");
goto bail_out;
@@ -307,11 +310,11 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
* Plugin options specified and not a FD that understands the new
* protocol keyword.
*/
- if (jcr->impl->plugin_options) {
+ if (jcr->dir_impl->plugin_options) {
Jmsg(jcr, M_FATAL, 0,
_("Client \"%s\" doesn't support plugin option passing. "
"Please upgrade your client or disable compat mode.\n"),
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
goto bail_out;
}
}
@@ -328,8 +331,8 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
goto bail_out;
}
- if (jcr->impl->FDVersion < FD_VERSION_2) { /* Old FD */
- break; /* we do only one loop */
+ if (jcr->dir_impl->FDVersion < FD_VERSION_2) { /* Old FD */
+ break; /* we do only one loop */
} else {
if (!response(jcr, fd, OKstoreend, "Store end", DISPLAY_ERROR)) {
goto bail_out;
@@ -338,7 +341,9 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr)
}
} /* the whole boostrap has been send */
- if (fd && jcr->impl->FDVersion >= FD_VERSION_2) { fd->fsend("endrestore"); }
+ if (fd && jcr->dir_impl->FDVersion >= FD_VERSION_2) {
+ fd->fsend("endrestore");
+ }
CloseBootstrapFile(info);
return true;
@@ -378,14 +383,14 @@ bool DoNativeRestore(JobControlRecord* jcr)
{
int status;
- jcr->impl->jr.JobLevel = L_FULL; /* Full restore */
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->dir_impl->jr.JobLevel = L_FULL; /* Full restore */
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
goto bail_out;
}
Dmsg0(20, "Updated job start record\n");
- Dmsg1(20, "RestoreJobId=%d\n", jcr->impl->res.job->RestoreJobId);
+ Dmsg1(20, "RestoreJobId=%d\n", jcr->dir_impl->res.job->RestoreJobId);
if (!jcr->RestoreBootstrap) {
Jmsg(jcr, M_FATAL, 0,
@@ -421,16 +426,16 @@ void NativeRestoreCleanup(JobControlRecord* jcr, int TermCode)
Dmsg0(20, "In NativeRestoreCleanup\n");
UpdateJobEnd(jcr, TermCode);
- if (jcr->impl->unlink_bsr && jcr->RestoreBootstrap) {
+ if (jcr->dir_impl->unlink_bsr && jcr->RestoreBootstrap) {
SecureErase(jcr, jcr->RestoreBootstrap);
- jcr->impl->unlink_bsr = false;
+ jcr->dir_impl->unlink_bsr = false;
}
if (JobCanceled(jcr)) { CancelStorageDaemonJob(jcr); }
switch (TermCode) {
case JS_Terminated:
- if (jcr->impl->ExpectedFiles > jcr->impl->jr.JobFiles) {
+ if (jcr->dir_impl->ExpectedFiles > jcr->dir_impl->jr.JobFiles) {
TermMsg = _("Restore OK -- warning file count mismatch");
} else {
TermMsg = _("Restore OK");
@@ -445,8 +450,8 @@ void NativeRestoreCleanup(JobControlRecord* jcr, int TermCode)
msg_type = M_ERROR; /* Generate error message */
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
break;
@@ -454,8 +459,8 @@ void NativeRestoreCleanup(JobControlRecord* jcr, int TermCode)
TermMsg = _("Restore Canceled");
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
break;
@@ -487,18 +492,20 @@ void GenerateRestoreSummary(JobControlRecord* jcr,
double kbps;
PoolMem temp, secure_erase_status;
- bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime);
- bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime);
- RunTime = jcr->impl->jr.EndTime - jcr->impl->jr.StartTime;
+ bstrftimes(sdt, sizeof(sdt), jcr->dir_impl->jr.StartTime);
+ bstrftimes(edt, sizeof(edt), jcr->dir_impl->jr.EndTime);
+ RunTime = jcr->dir_impl->jr.EndTime - jcr->dir_impl->jr.StartTime;
if (RunTime <= 0) {
kbps = 0;
} else {
- kbps = ((double)jcr->impl->jr.JobBytes) / (1000.0 * (double)RunTime);
+ kbps = ((double)jcr->dir_impl->jr.JobBytes) / (1000.0 * (double)RunTime);
}
if (kbps < 0.05) { kbps = 0; }
- JobstatusToAscii(jcr->impl->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
- JobstatusToAscii(jcr->impl->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
+ JobstatusToAscii(jcr->dir_impl->FDJobStatus, fd_term_msg,
+ sizeof(fd_term_msg));
+ JobstatusToAscii(jcr->dir_impl->SDJobStatus, sd_term_msg,
+ sizeof(sd_term_msg));
switch (jcr->getJobProtocol()) {
case PT_NDMP_BAREOS:
@@ -522,28 +529,28 @@ void GenerateRestoreSummary(JobControlRecord* jcr,
" Termination: %s\n\n"),
BAREOS, my_name, kBareosVersionStrings.Full,
kBareosVersionStrings.ShortDate, kBareosVersionStrings.GetOsInfo(),
- jcr->impl->jr.JobId, jcr->impl->jr.Job,
- jcr->impl->res.client->resource_name_, sdt, edt,
+ jcr->dir_impl->jr.JobId, jcr->dir_impl->jr.Job,
+ jcr->dir_impl->res.client->resource_name_, sdt, edt,
edit_utime(RunTime, elapsed, sizeof(elapsed)),
- edit_uint64_with_commas((uint64_t)jcr->impl->ExpectedFiles, ec1),
- edit_uint64_with_commas((uint64_t)jcr->impl->jr.JobFiles, ec2),
- edit_uint64_with_commas(jcr->impl->jr.JobBytes, ec3), (float)kbps,
- sd_term_msg, kBareosVersionStrings.JoblogMessage,
- JobTriggerToString(jcr->impl->job_trigger).c_str(), TermMsg);
+ edit_uint64_with_commas((uint64_t)jcr->dir_impl->ExpectedFiles, ec1),
+ edit_uint64_with_commas((uint64_t)jcr->dir_impl->jr.JobFiles, ec2),
+ edit_uint64_with_commas(jcr->dir_impl->jr.JobBytes, ec3),
+ (float)kbps, sd_term_msg, kBareosVersionStrings.JoblogMessage,
+ JobTriggerToString(jcr->dir_impl->job_trigger).c_str(), TermMsg);
break;
default:
if (me->secure_erase_cmdline) {
Mmsg(temp, " Dir Secure Erase Cmd: %s\n", me->secure_erase_cmdline);
PmStrcat(secure_erase_status, temp.c_str());
}
- if (!bstrcmp(jcr->impl->FDSecureEraseCmd, "*None*")) {
+ if (!bstrcmp(jcr->dir_impl->FDSecureEraseCmd, "*None*")) {
Mmsg(temp, " FD Secure Erase Cmd: %s\n",
- jcr->impl->FDSecureEraseCmd);
+ jcr->dir_impl->FDSecureEraseCmd);
PmStrcat(secure_erase_status, temp.c_str());
}
- if (!bstrcmp(jcr->impl->SDSecureEraseCmd, "*None*")) {
+ if (!bstrcmp(jcr->dir_impl->SDSecureEraseCmd, "*None*")) {
Mmsg(temp, " SD Secure Erase Cmd: %s\n",
- jcr->impl->SDSecureEraseCmd);
+ jcr->dir_impl->SDSecureEraseCmd);
PmStrcat(secure_erase_status, temp.c_str());
}
@@ -569,15 +576,15 @@ void GenerateRestoreSummary(JobControlRecord* jcr,
" Termination: %s\n\n"),
BAREOS, my_name, kBareosVersionStrings.Full,
kBareosVersionStrings.ShortDate, kBareosVersionStrings.GetOsInfo(),
- jcr->impl->jr.JobId, jcr->impl->jr.Job,
- jcr->impl->res.client->resource_name_, sdt, edt,
+ jcr->dir_impl->jr.JobId, jcr->dir_impl->jr.Job,
+ jcr->dir_impl->res.client->resource_name_, sdt, edt,
edit_utime(RunTime, elapsed, sizeof(elapsed)),
- edit_uint64_with_commas((uint64_t)jcr->impl->ExpectedFiles, ec1),
- edit_uint64_with_commas((uint64_t)jcr->impl->jr.JobFiles, ec2),
- edit_uint64_with_commas(jcr->impl->jr.JobBytes, ec3), (float)kbps,
- jcr->JobErrors, fd_term_msg, sd_term_msg,
+ edit_uint64_with_commas((uint64_t)jcr->dir_impl->ExpectedFiles, ec1),
+ edit_uint64_with_commas((uint64_t)jcr->dir_impl->jr.JobFiles, ec2),
+ edit_uint64_with_commas(jcr->dir_impl->jr.JobBytes, ec3),
+ (float)kbps, jcr->JobErrors, fd_term_msg, sd_term_msg,
secure_erase_status.c_str(), kBareosVersionStrings.JoblogMessage,
- JobTriggerToString(jcr->impl->job_trigger).c_str(), TermMsg);
+ JobTriggerToString(jcr->dir_impl->job_trigger).c_str(), TermMsg);
break;
}
}
diff --git a/core/src/dird/run_on_incoming_connect_interval.cc b/core/src/dird/run_on_incoming_connect_interval.cc
index 15b5673c9..0175b5ee9 100644
--- a/core/src/dird/run_on_incoming_connect_interval.cc
+++ b/core/src/dird/run_on_incoming_connect_interval.cc
@@ -27,7 +27,7 @@
#include "dird/get_database_connection.h"
#include "dird/job.h"
#include "dird/job_trigger.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/run_on_incoming_connect_interval.h"
#include "dird/scheduler.h"
#include "dird/jcr_util.h"
diff --git a/core/src/dird/scheduler.cc b/core/src/dird/scheduler.cc
index 52808c48e..e85cdbf9b 100644
--- a/core/src/dird/scheduler.cc
+++ b/core/src/dird/scheduler.cc
@@ -36,7 +36,7 @@
#include "dird/scheduler.h"
#include "dird/scheduler_private.h"
#include "dird/scheduler_time_adapter.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/storage.h"
#include "lib/parse_conf.h"
diff --git a/core/src/dird/scheduler_private.cc b/core/src/dird/scheduler_private.cc
index 514513217..c05792343 100644
--- a/core/src/dird/scheduler_private.cc
+++ b/core/src/dird/scheduler_private.cc
@@ -25,7 +25,7 @@
#include "dird/dird.h"
#include "dird/dird_conf.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/run_hour_validator.h"
#include "dird/scheduler.h"
@@ -70,34 +70,34 @@ static void SetJcrFromRunResource(JobControlRecord* jcr, RunResource* run)
}
if (run->pool != nullptr) {
- jcr->impl->res.pool = run->pool; /* override pool */
- jcr->impl->res.run_pool_override = true;
+ jcr->dir_impl->res.pool = run->pool; /* override pool */
+ jcr->dir_impl->res.run_pool_override = true;
}
if (run->full_pool != nullptr) {
- jcr->impl->res.full_pool = run->full_pool; /* override full pool */
- jcr->impl->res.run_full_pool_override = true;
+ jcr->dir_impl->res.full_pool = run->full_pool; /* override full pool */
+ jcr->dir_impl->res.run_full_pool_override = true;
}
if (run->vfull_pool != nullptr) {
- jcr->impl->res.vfull_pool
+ jcr->dir_impl->res.vfull_pool
= run->vfull_pool; /* override virtual full pool */
- jcr->impl->res.run_vfull_pool_override = true;
+ jcr->dir_impl->res.run_vfull_pool_override = true;
}
if (run->inc_pool != nullptr) {
- jcr->impl->res.inc_pool = run->inc_pool; /* override inc pool */
- jcr->impl->res.run_inc_pool_override = true;
+ jcr->dir_impl->res.inc_pool = run->inc_pool; /* override inc pool */
+ jcr->dir_impl->res.run_inc_pool_override = true;
}
if (run->diff_pool != nullptr) {
- jcr->impl->res.diff_pool = run->diff_pool; /* override diff pool */
- jcr->impl->res.run_diff_pool_override = true;
+ jcr->dir_impl->res.diff_pool = run->diff_pool; /* override diff pool */
+ jcr->dir_impl->res.run_diff_pool_override = true;
}
if (run->next_pool != nullptr) {
- jcr->impl->res.next_pool = run->next_pool; /* override next pool */
- jcr->impl->res.run_next_pool_override = true;
+ jcr->dir_impl->res.next_pool = run->next_pool; /* override next pool */
+ jcr->dir_impl->res.run_next_pool_override = true;
}
if (run->storage != nullptr) {
@@ -108,19 +108,19 @@ static void SetJcrFromRunResource(JobControlRecord* jcr, RunResource* run)
}
if (run->msgs != nullptr) {
- jcr->impl->res.messages = run->msgs; /* override messages */
+ jcr->dir_impl->res.messages = run->msgs; /* override messages */
}
if (run->Priority != 0) { jcr->JobPriority = run->Priority; }
- if (run->spool_data_set) { jcr->impl->spool_data = run->spool_data; }
+ if (run->spool_data_set) { jcr->dir_impl->spool_data = run->spool_data; }
if (run->accurate_set) {
jcr->accurate = run->accurate; /* overwrite accurate mode */
}
if (run->MaxRunSchedTime_set) {
- jcr->impl->MaxRunSchedTime = run->MaxRunSchedTime;
+ jcr->dir_impl->MaxRunSchedTime = run->MaxRunSchedTime;
}
}
@@ -153,7 +153,7 @@ void SchedulerPrivate::WaitForJobsToRun()
if (jcr != nullptr) {
Dmsg1(local_debuglevel, "Scheduler: Running job %s.\n",
run_job.job->resource_name_);
- jcr->impl->job_trigger = next_job.job_trigger;
+ jcr->dir_impl->job_trigger = next_job.job_trigger;
ExecuteJobCallback_(jcr);
}
diff --git a/core/src/dird/sd_cmds.cc b/core/src/dird/sd_cmds.cc
index 57a763dd9..2455d8866 100644
--- a/core/src/dird/sd_cmds.cc
+++ b/core/src/dird/sd_cmds.cc
@@ -34,7 +34,7 @@
#include "dird/dird_globals.h"
#include "dird/authenticate.h"
#include "dird/getmsg.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/msgchan.h"
#include "dird/storage.h"
@@ -94,10 +94,10 @@ bool ConnectToStorageDaemon(JobControlRecord* jcr,
if (jcr->store_bsock) { return true; /* already connected */ }
StorageResource* store;
- if (jcr->impl->res.write_storage) {
- store = jcr->impl->res.write_storage;
+ if (jcr->dir_impl->res.write_storage) {
+ store = jcr->dir_impl->res.write_storage;
} else {
- store = jcr->impl->res.read_storage;
+ store = jcr->dir_impl->res.read_storage;
}
if (!store) {
@@ -154,7 +154,7 @@ bool ConnectToStorageDaemon(JobControlRecord* jcr,
BareosSocket* open_sd_bsock(UaContext* ua)
{
- StorageResource* store = ua->jcr->impl->res.write_storage;
+ StorageResource* store = ua->jcr->dir_impl->res.write_storage;
if (!store) {
Dmsg0(200, "open_sd_bsock: No storage resource pointer set\n");
@@ -183,12 +183,12 @@ char* get_volume_name_from_SD(UaContext* ua,
drive_number_t drive)
{
BareosSocket* sd;
- StorageResource* store = ua->jcr->impl->res.write_storage;
+ StorageResource* store = ua->jcr->dir_impl->res.write_storage;
char dev_name[MAX_NAME_LENGTH];
char* VolName = nullptr;
int rtn_slot;
- ua->jcr->impl->res.write_storage = store;
+ ua->jcr->dir_impl->res.write_storage = store;
if (!(sd = open_sd_bsock(ua))) {
ua->ErrorMsg(_("Could not open SD socket.\n"));
return nullptr;
@@ -264,7 +264,7 @@ dlist<vol_list_t>* native_get_vol_list(UaContext* ua,
dlist<vol_list_t>* vol_list;
BareosSocket* sd = nullptr;
- ua->jcr->impl->res.write_storage = store;
+ ua->jcr->dir_impl->res.write_storage = store;
if (!(sd = open_sd_bsock(ua))) { return nullptr; }
bstrncpy(dev_name, store->dev_name(), sizeof(dev_name));
@@ -531,7 +531,7 @@ slot_number_t NativeGetNumSlots(UaContext* ua, StorageResource* store)
BareosSocket* sd;
slot_number_t slots = 0;
- ua->jcr->impl->res.write_storage = store;
+ ua->jcr->dir_impl->res.write_storage = store;
if (!(sd = open_sd_bsock(ua))) { return 0; }
bstrncpy(dev_name, store->dev_name(), sizeof(dev_name));
@@ -559,7 +559,7 @@ drive_number_t NativeGetNumDrives(UaContext* ua, StorageResource* store)
BareosSocket* sd;
drive_number_t drives = 0;
- ua->jcr->impl->res.write_storage = store;
+ ua->jcr->dir_impl->res.write_storage = store;
if (!(sd = open_sd_bsock(ua))) { return 0; }
bstrncpy(dev_name, store->dev_name(), sizeof(dev_name));
@@ -591,7 +591,7 @@ bool CancelStorageDaemonJob(UaContext* ua, StorageResource* store, char* JobId)
control_jcr = new_control_jcr("*JobCancel*", JT_SYSTEM);
- control_jcr->impl->res.write_storage = store;
+ control_jcr->dir_impl->res.write_storage = store;
/* the next call will set control_jcr->store_bsock */
if (!ConnectToStorageDaemon(control_jcr, 10, me->SDConnectTimeout, true)) {
@@ -619,20 +619,20 @@ bool CancelStorageDaemonJob(UaContext* ua,
JobControlRecord* jcr,
bool interactive)
{
- if (!ua->jcr->impl->res.write_storage_list) {
- if (jcr->impl->res.read_storage_list) {
- CopyWstorage(ua->jcr, jcr->impl->res.read_storage_list,
+ if (!ua->jcr->dir_impl->res.write_storage_list) {
+ if (jcr->dir_impl->res.read_storage_list) {
+ CopyWstorage(ua->jcr, jcr->dir_impl->res.read_storage_list,
_("Job resource"));
} else {
- CopyWstorage(ua->jcr, jcr->impl->res.write_storage_list,
+ CopyWstorage(ua->jcr, jcr->dir_impl->res.write_storage_list,
_("Job resource"));
}
} else {
UnifiedStorageResource store;
- if (jcr->impl->res.read_storage_list) {
- store.store = jcr->impl->res.read_storage;
+ if (jcr->dir_impl->res.read_storage_list) {
+ store.store = jcr->dir_impl->res.read_storage;
} else {
- store.store = jcr->impl->res.write_storage;
+ store.store = jcr->dir_impl->res.write_storage;
}
if (!store.store) {
Dmsg0(200, "CancelStorageDaemonJob: No storage resource pointer set\n");
@@ -661,7 +661,7 @@ bool CancelStorageDaemonJob(UaContext* ua,
TerminateAndCloseJcrStoreSocket(ua->jcr);
- if (!interactive) { jcr->impl->sd_canceled = true; }
+ if (!interactive) { jcr->dir_impl->sd_canceled = true; }
SdMsgThreadSendSignal(jcr, TIMEOUT_SIGNAL);
@@ -672,7 +672,7 @@ bool CancelStorageDaemonJob(UaContext* ua,
void CancelStorageDaemonJob(JobControlRecord* jcr)
{
- if (jcr->impl->sd_canceled) { return; /* cancel only once */ }
+ if (jcr->dir_impl->sd_canceled) { return; /* cancel only once */ }
UaContext* ua = new_ua_context(jcr);
JobControlRecord* control_jcr = new_control_jcr("*JobCancel*", JT_SYSTEM);
@@ -754,7 +754,7 @@ bool NativeTransferVolume(UaContext* ua,
bool retval = true;
char dev_name[MAX_NAME_LENGTH];
- ua->jcr->impl->res.write_storage = store;
+ ua->jcr->dir_impl->res.write_storage = store;
if (!(sd = open_sd_bsock(ua))) { return false; }
bstrncpy(dev_name, store->dev_name(), sizeof(dev_name));
@@ -793,7 +793,7 @@ bool NativeAutochangerVolumeOperation(UaContext* ua,
bool retval = true;
char dev_name[MAX_NAME_LENGTH];
- ua->jcr->impl->res.write_storage = store;
+ ua->jcr->dir_impl->res.write_storage = store;
if (!(sd = open_sd_bsock(ua))) { return false; }
bstrncpy(dev_name, store->dev_name(), sizeof(dev_name));
@@ -830,21 +830,23 @@ bool SendSecureEraseReqToSd(JobControlRecord* jcr)
int32_t n;
BareosSocket* sd = jcr->store_bsock;
- if (!jcr->impl->SDSecureEraseCmd) {
- jcr->impl->SDSecureEraseCmd = GetPoolMemory(PM_NAME);
+ if (!jcr->dir_impl->SDSecureEraseCmd) {
+ jcr->dir_impl->SDSecureEraseCmd = GetPoolMemory(PM_NAME);
}
sd->fsend(getSecureEraseCmd);
while ((n = BgetDirmsg(sd)) >= 0) {
- jcr->impl->SDSecureEraseCmd
- = CheckPoolMemorySize(jcr->impl->SDSecureEraseCmd, sd->message_length);
- if (sscanf(sd->msg, OKSecureEraseCmd, jcr->impl->SDSecureEraseCmd) == 1) {
- Dmsg1(421, "Got SD Secure Erase Cmd: %s\n", jcr->impl->SDSecureEraseCmd);
+ jcr->dir_impl->SDSecureEraseCmd = CheckPoolMemorySize(
+ jcr->dir_impl->SDSecureEraseCmd, sd->message_length);
+ if (sscanf(sd->msg, OKSecureEraseCmd, jcr->dir_impl->SDSecureEraseCmd)
+ == 1) {
+ Dmsg1(421, "Got SD Secure Erase Cmd: %s\n",
+ jcr->dir_impl->SDSecureEraseCmd);
break;
} else {
Jmsg(jcr, M_WARNING, 0, _("Unexpected SD Secure Erase Cmd: %s\n"),
sd->msg);
- PmStrcpy(jcr->impl->SDSecureEraseCmd, "*None*");
+ PmStrcpy(jcr->dir_impl->SDSecureEraseCmd, "*None*");
return false;
}
}
@@ -874,7 +876,7 @@ bool DoStorageResolve(UaContext* ua, StorageResource* store)
PmStrcpy(lstore.store_source, _("unknown source"));
SetWstorage(ua->jcr, &lstore);
- ua->jcr->impl->res.write_storage = store;
+ ua->jcr->dir_impl->res.write_storage = store;
if (!(sd = open_sd_bsock(ua))) { return false; }
for (int i = 1; i < ua->argc; i++) {
@@ -896,10 +898,10 @@ bool SendStoragePluginOptions(JobControlRecord* jcr)
const char* plugin_options;
BareosSocket* sd = jcr->store_bsock;
- if (jcr->impl->res.job && jcr->impl->res.job->SdPluginOptions
- && jcr->impl->res.job->SdPluginOptions->size()) {
+ if (jcr->dir_impl->res.job && jcr->dir_impl->res.job->SdPluginOptions
+ && jcr->dir_impl->res.job->SdPluginOptions->size()) {
foreach_alist_index (i, plugin_options,
- jcr->impl->res.job->SdPluginOptions) {
+ jcr->dir_impl->res.job->SdPluginOptions) {
PmStrcpy(cur_plugin_options, plugin_options);
BashSpaces(cur_plugin_options.c_str());
diff --git a/core/src/dird/stats.cc b/core/src/dird/stats.cc
index eb8bc4b67..6ac3e5715 100644
--- a/core/src/dird/stats.cc
+++ b/core/src/dird/stats.cc
@@ -29,7 +29,7 @@
#include "dird.h"
#include "dird/dird_globals.h"
#include "dird/get_database_connection.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "cats/sql_pooling.h"
#include "dird/sd_cmds.h"
#include "dird/ua_server.h"
@@ -129,12 +129,12 @@ extern "C" void* statistics_thread(void*)
jcr = new_control_jcr("*StatisticsCollector*", JT_SYSTEM);
- jcr->impl->res.catalog
+ jcr->dir_impl->res.catalog
= (CatalogResource*)my_config->GetNextRes(R_CATALOG, NULL);
jcr->db = GetDatabaseConnection(jcr);
if (jcr->db == NULL) {
Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"),
- jcr->impl->res.catalog->db_name);
+ jcr->dir_impl->res.catalog->db_name);
goto bail_out;
}
@@ -191,7 +191,7 @@ extern "C" void* statistics_thread(void*)
continue;
}
- jcr->impl->res.read_storage = store;
+ jcr->dir_impl->res.read_storage = store;
if (!ConnectToStorageDaemon(jcr, 2, 1, false)) {
UnlockRes(my_config);
continue;
diff --git a/core/src/dird/storage.cc b/core/src/dird/storage.cc
index 34038ed89..058473135 100644
--- a/core/src/dird/storage.cc
+++ b/core/src/dird/storage.cc
@@ -31,7 +31,7 @@
#include "include/bareos.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/sd_cmds.h"
#include "include/auth_protocol_types.h"
#include "lib/parse_conf.h"
@@ -100,21 +100,21 @@ void CopyRstorage(JobControlRecord* jcr,
{
if (storage) {
StorageResource* store = nullptr;
- if (jcr->impl->res.read_storage_list) {
- delete jcr->impl->res.read_storage_list;
+ if (jcr->dir_impl->res.read_storage_list) {
+ delete jcr->dir_impl->res.read_storage_list;
}
- jcr->impl->res.read_storage_list
+ jcr->dir_impl->res.read_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
foreach_alist (store, storage) {
- jcr->impl->res.read_storage_list->append(store);
+ jcr->dir_impl->res.read_storage_list->append(store);
}
- if (!jcr->impl->res.rstore_source) {
- jcr->impl->res.rstore_source = GetPoolMemory(PM_MESSAGE);
+ if (!jcr->dir_impl->res.rstore_source) {
+ jcr->dir_impl->res.rstore_source = GetPoolMemory(PM_MESSAGE);
}
- PmStrcpy(jcr->impl->res.rstore_source, where);
- if (jcr->impl->res.read_storage_list) {
- jcr->impl->res.read_storage
- = (StorageResource*)jcr->impl->res.read_storage_list->first();
+ PmStrcpy(jcr->dir_impl->res.rstore_source, where);
+ if (jcr->dir_impl->res.read_storage_list) {
+ jcr->dir_impl->res.read_storage
+ = (StorageResource*)jcr->dir_impl->res.read_storage_list->first();
}
}
}
@@ -128,30 +128,30 @@ void SetRstorage(JobControlRecord* jcr, UnifiedStorageResource* store)
StorageResource* storage = nullptr;
if (!store->store) { return; }
- if (jcr->impl->res.read_storage_list) { FreeRstorage(jcr); }
- if (!jcr->impl->res.read_storage_list) {
- jcr->impl->res.read_storage_list
+ if (jcr->dir_impl->res.read_storage_list) { FreeRstorage(jcr); }
+ if (!jcr->dir_impl->res.read_storage_list) {
+ jcr->dir_impl->res.read_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
}
- jcr->impl->res.read_storage = store->store;
- if (!jcr->impl->res.rstore_source) {
- jcr->impl->res.rstore_source = GetPoolMemory(PM_MESSAGE);
+ jcr->dir_impl->res.read_storage = store->store;
+ if (!jcr->dir_impl->res.rstore_source) {
+ jcr->dir_impl->res.rstore_source = GetPoolMemory(PM_MESSAGE);
}
- PmStrcpy(jcr->impl->res.rstore_source, store->store_source);
- foreach_alist (storage, jcr->impl->res.read_storage_list) {
+ PmStrcpy(jcr->dir_impl->res.rstore_source, store->store_source);
+ foreach_alist (storage, jcr->dir_impl->res.read_storage_list) {
if (store->store == storage) { return; }
}
/* Store not in list, so add it */
- jcr->impl->res.read_storage_list->prepend(store->store);
+ jcr->dir_impl->res.read_storage_list->prepend(store->store);
}
void FreeRstorage(JobControlRecord* jcr)
{
- if (jcr->impl->res.read_storage_list) {
- delete jcr->impl->res.read_storage_list;
- jcr->impl->res.read_storage_list = NULL;
+ if (jcr->dir_impl->res.read_storage_list) {
+ delete jcr->dir_impl->res.read_storage_list;
+ jcr->dir_impl->res.read_storage_list = NULL;
}
- jcr->impl->res.read_storage = NULL;
+ jcr->dir_impl->res.read_storage = NULL;
}
// Copy the storage definitions from an alist to the JobControlRecord
@@ -161,25 +161,25 @@ void CopyWstorage(JobControlRecord* jcr,
{
if (storage) {
StorageResource* st = nullptr;
- if (jcr->impl->res.write_storage_list) {
- delete jcr->impl->res.write_storage_list;
+ if (jcr->dir_impl->res.write_storage_list) {
+ delete jcr->dir_impl->res.write_storage_list;
}
- jcr->impl->res.write_storage_list
+ jcr->dir_impl->res.write_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
foreach_alist (st, storage) {
Dmsg1(100, "write_storage_list=%s\n", st->resource_name_);
- jcr->impl->res.write_storage_list->append(st);
+ jcr->dir_impl->res.write_storage_list->append(st);
}
- if (!jcr->impl->res.wstore_source) {
- jcr->impl->res.wstore_source = GetPoolMemory(PM_MESSAGE);
+ if (!jcr->dir_impl->res.wstore_source) {
+ jcr->dir_impl->res.wstore_source = GetPoolMemory(PM_MESSAGE);
}
- PmStrcpy(jcr->impl->res.wstore_source, where);
- if (jcr->impl->res.write_storage_list) {
- jcr->impl->res.write_storage
- = (StorageResource*)jcr->impl->res.write_storage_list->first();
+ PmStrcpy(jcr->dir_impl->res.wstore_source, where);
+ if (jcr->dir_impl->res.write_storage_list) {
+ jcr->dir_impl->res.write_storage
+ = (StorageResource*)jcr->dir_impl->res.write_storage_list->first();
Dmsg2(100, "write_storage=%s where=%s\n",
- jcr->impl->res.write_storage->resource_name_,
- jcr->impl->res.wstore_source);
+ jcr->dir_impl->res.write_storage->resource_name_,
+ jcr->dir_impl->res.wstore_source);
}
}
}
@@ -193,34 +193,34 @@ void SetWstorage(JobControlRecord* jcr, UnifiedStorageResource* store)
StorageResource* storage = nullptr;
if (!store->store) { return; }
- if (jcr->impl->res.write_storage_list) { FreeWstorage(jcr); }
- if (!jcr->impl->res.write_storage_list) {
- jcr->impl->res.write_storage_list
+ if (jcr->dir_impl->res.write_storage_list) { FreeWstorage(jcr); }
+ if (!jcr->dir_impl->res.write_storage_list) {
+ jcr->dir_impl->res.write_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
}
- jcr->impl->res.write_storage = store->store;
- if (!jcr->impl->res.wstore_source) {
- jcr->impl->res.wstore_source = GetPoolMemory(PM_MESSAGE);
+ jcr->dir_impl->res.write_storage = store->store;
+ if (!jcr->dir_impl->res.wstore_source) {
+ jcr->dir_impl->res.wstore_source = GetPoolMemory(PM_MESSAGE);
}
- PmStrcpy(jcr->impl->res.wstore_source, store->store_source);
+ PmStrcpy(jcr->dir_impl->res.wstore_source, store->store_source);
Dmsg2(50, "write_storage=%s where=%s\n",
- jcr->impl->res.write_storage->resource_name_,
- jcr->impl->res.wstore_source);
- foreach_alist (storage, jcr->impl->res.write_storage_list) {
+ jcr->dir_impl->res.write_storage->resource_name_,
+ jcr->dir_impl->res.wstore_source);
+ foreach_alist (storage, jcr->dir_impl->res.write_storage_list) {
if (store->store == storage) { return; }
}
// Store not in list, so add it
- jcr->impl->res.write_storage_list->prepend(store->store);
+ jcr->dir_impl->res.write_storage_list->prepend(store->store);
}
void FreeWstorage(JobControlRecord* jcr)
{
- if (jcr->impl->res.write_storage_list) {
- delete jcr->impl->res.write_storage_list;
- jcr->impl->res.write_storage_list = NULL;
+ if (jcr->dir_impl->res.write_storage_list) {
+ delete jcr->dir_impl->res.write_storage_list;
+ jcr->dir_impl->res.write_storage_list = NULL;
}
- jcr->impl->res.write_storage = NULL;
+ jcr->dir_impl->res.write_storage = NULL;
}
/**
@@ -236,35 +236,37 @@ void SetPairedStorage(JobControlRecord* jcr)
switch (jcr->getJobType()) {
case JT_BACKUP:
// For a backup we look at the write storage.
- if (jcr->impl->res.write_storage_list) {
+ if (jcr->dir_impl->res.write_storage_list) {
/*
- * Setup the jcr->impl_->res.write_storage_list to point to all
+ * Setup the jcr->dir_impl_->res.write_storage_list to point to all
* paired_storage entries of all the storage currently in the
* jcrres.->write_storage_list. Save the original list under
- * jcr->impl_->res.paired_read_write_storage_list.
+ * jcr->dir_impl_->res.paired_read_write_storage_list.
*/
- jcr->impl->res.paired_read_write_storage_list
- = jcr->impl->res.write_storage_list;
- jcr->impl->res.write_storage_list
+ jcr->dir_impl->res.paired_read_write_storage_list
+ = jcr->dir_impl->res.write_storage_list;
+ jcr->dir_impl->res.write_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
- foreach_alist (store, jcr->impl->res.paired_read_write_storage_list) {
+ foreach_alist (store,
+ jcr->dir_impl->res.paired_read_write_storage_list) {
if (store->paired_storage) {
Dmsg1(100, "write_storage_list=%s\n",
store->paired_storage->resource_name_);
- jcr->impl->res.write_storage_list->append(store->paired_storage);
+ jcr->dir_impl->res.write_storage_list->append(
+ store->paired_storage);
}
}
/*
- * Swap the actual jcr->impl_->res.write_storage to point to the paired
- * storage entry. We save the actual storage entry in
+ * Swap the actual jcr->dir_impl_->res.write_storage to point to the
+ * paired storage entry. We save the actual storage entry in
* paired_read_write_storage which is for restore in the
* FreePairedStorage() function.
*/
- store = jcr->impl->res.write_storage;
+ store = jcr->dir_impl->res.write_storage;
if (store->paired_storage) {
- jcr->impl->res.write_storage = store->paired_storage;
- jcr->impl->res.paired_read_write_storage = store;
+ jcr->dir_impl->res.write_storage = store->paired_storage;
+ jcr->dir_impl->res.paired_read_write_storage = store;
}
} else {
Jmsg(jcr, M_FATAL, 0,
@@ -273,16 +275,16 @@ void SetPairedStorage(JobControlRecord* jcr)
break;
case JT_RESTORE:
// For a restores we look at the read storage.
- if (jcr->impl->res.read_storage_list) {
+ if (jcr->dir_impl->res.read_storage_list) {
/*
- * Setup the jcr->impl_->res.paired_read_write_storage_list to point to
- * all paired_storage entries of all the storage currently in the
- * jcr->impl_->res.read_storage_list.
+ * Setup the jcr->dir_impl_->res.paired_read_write_storage_list to point
+ * to all paired_storage entries of all the storage currently in the
+ * jcr->dir_impl_->res.read_storage_list.
*/
- jcr->impl->res.paired_read_write_storage_list
+ jcr->dir_impl->res.paired_read_write_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
foreach_alist (paired_read_write_storage,
- jcr->impl->res.read_storage_list) {
+ jcr->dir_impl->res.read_storage_list) {
store = (StorageResource*)my_config->GetNextRes(R_STORAGE, NULL);
while (store) {
if (store->paired_storage == paired_read_write_storage) { break; }
@@ -296,15 +298,15 @@ void SetPairedStorage(JobControlRecord* jcr)
* paired_read_write_storage as its paired storage.
*/
if (store) {
- jcr->impl->res.paired_read_write_storage_list->append(store);
+ jcr->dir_impl->res.paired_read_write_storage_list->append(store);
/*
* If the current processed paired_read_write_storage is also the
- * current entry in jcr->impl_->res.read_storage update the
+ * current entry in jcr->dir_impl_->res.read_storage update the
* jcr->paired_read_write_storage to point to this storage entry.
*/
- if (paired_read_write_storage == jcr->impl->res.read_storage) {
- jcr->impl->res.paired_read_write_storage = store;
+ if (paired_read_write_storage == jcr->dir_impl->res.read_storage) {
+ jcr->dir_impl->res.paired_read_write_storage = store;
}
}
}
@@ -316,35 +318,36 @@ void SetPairedStorage(JobControlRecord* jcr)
case JT_MIGRATE:
case JT_COPY:
// For a migrate or copy we look at the read storage.
- if (jcr->impl->res.read_storage_list) {
+ if (jcr->dir_impl->res.read_storage_list) {
/*
- * Setup the jcr->impl_->res.read_storage_list to point to all
+ * Setup the jcr->dir_impl_->res.read_storage_list to point to all
* paired_storage entries of all the storage currently in the
- * jcr->impl_->res.read_storage_list. Save the original list under
- * jcr->impl_->res.paired_read_write_storage_list.
+ * jcr->dir_impl_->res.read_storage_list. Save the original list under
+ * jcr->dir_impl_->res.paired_read_write_storage_list.
*/
- jcr->impl->res.paired_read_write_storage_list
- = jcr->impl->res.read_storage_list;
- jcr->impl->res.read_storage_list
+ jcr->dir_impl->res.paired_read_write_storage_list
+ = jcr->dir_impl->res.read_storage_list;
+ jcr->dir_impl->res.read_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
- foreach_alist (store, jcr->impl->res.paired_read_write_storage_list) {
+ foreach_alist (store,
+ jcr->dir_impl->res.paired_read_write_storage_list) {
if (store->paired_storage) {
Dmsg1(100, "read_storage_list=%s\n",
store->paired_storage->resource_name_);
- jcr->impl->res.read_storage_list->append(store->paired_storage);
+ jcr->dir_impl->res.read_storage_list->append(store->paired_storage);
}
}
/*
- * Swap the actual jcr->impl_->res.read_storage to point to the paired
- * storage entry. We save the actual storage entry in
+ * Swap the actual jcr->dir_impl_->res.read_storage to point to the
+ * paired storage entry. We save the actual storage entry in
* paired_read_write_storage which is for restore in the
* FreePairedStorage() function.
*/
- store = jcr->impl->res.read_storage;
+ store = jcr->dir_impl->res.read_storage;
if (store->paired_storage) {
- jcr->impl->res.read_storage = store->paired_storage;
- jcr->impl->res.paired_read_write_storage = store;
+ jcr->dir_impl->res.read_storage = store->paired_storage;
+ jcr->dir_impl->res.paired_read_write_storage = store;
}
} else {
Jmsg(jcr, M_FATAL, 0,
@@ -366,51 +369,51 @@ void SetPairedStorage(JobControlRecord* jcr)
*/
void FreePairedStorage(JobControlRecord* jcr)
{
- if (jcr->impl->res.paired_read_write_storage_list) {
+ if (jcr->dir_impl->res.paired_read_write_storage_list) {
switch (jcr->getJobType()) {
case JT_BACKUP:
// For a backup we look at the write storage.
- if (jcr->impl->res.write_storage_list) {
+ if (jcr->dir_impl->res.write_storage_list) {
/*
- * The jcr->impl_->res.write_storage_list contain a set of paired
+ * The jcr->dir_impl_->res.write_storage_list contain a set of paired
* storages. We just delete it content and swap back to the real
* master storage.
*/
- delete jcr->impl->res.write_storage_list;
- jcr->impl->res.write_storage_list
- = jcr->impl->res.paired_read_write_storage_list;
- jcr->impl->res.paired_read_write_storage_list = NULL;
- jcr->impl->res.write_storage
- = jcr->impl->res.paired_read_write_storage;
- jcr->impl->res.paired_read_write_storage = NULL;
+ delete jcr->dir_impl->res.write_storage_list;
+ jcr->dir_impl->res.write_storage_list
+ = jcr->dir_impl->res.paired_read_write_storage_list;
+ jcr->dir_impl->res.paired_read_write_storage_list = NULL;
+ jcr->dir_impl->res.write_storage
+ = jcr->dir_impl->res.paired_read_write_storage;
+ jcr->dir_impl->res.paired_read_write_storage = NULL;
}
break;
case JT_RESTORE:
/*
- * The jcr->impl_->res.read_storage_list contain a set of paired
+ * The jcr->dir_impl_->res.read_storage_list contain a set of paired
* storages. For the read we created a list of alternative storage which
* we can just drop now.
*/
- delete jcr->impl->res.paired_read_write_storage_list;
- jcr->impl->res.paired_read_write_storage_list = NULL;
- jcr->impl->res.paired_read_write_storage = NULL;
+ delete jcr->dir_impl->res.paired_read_write_storage_list;
+ jcr->dir_impl->res.paired_read_write_storage_list = NULL;
+ jcr->dir_impl->res.paired_read_write_storage = NULL;
break;
case JT_MIGRATE:
case JT_COPY:
// For a migrate or copy we look at the read storage.
- if (jcr->impl->res.read_storage_list) {
+ if (jcr->dir_impl->res.read_storage_list) {
/*
- * The jcr->impl_->res.read_storage_list contains a set of paired
+ * The jcr->dir_impl_->res.read_storage_list contains a set of paired
* storages. We just delete it content and swap back to the real
* master storage.
*/
- delete jcr->impl->res.read_storage_list;
- jcr->impl->res.read_storage_list
- = jcr->impl->res.paired_read_write_storage_list;
- jcr->impl->res.paired_read_write_storage_list = NULL;
- jcr->impl->res.read_storage
- = jcr->impl->res.paired_read_write_storage;
- jcr->impl->res.paired_read_write_storage = NULL;
+ delete jcr->dir_impl->res.read_storage_list;
+ jcr->dir_impl->res.read_storage_list
+ = jcr->dir_impl->res.paired_read_write_storage_list;
+ jcr->dir_impl->res.paired_read_write_storage_list = NULL;
+ jcr->dir_impl->res.read_storage
+ = jcr->dir_impl->res.paired_read_write_storage;
+ jcr->dir_impl->res.paired_read_write_storage = NULL;
}
break;
default:
@@ -430,8 +433,8 @@ bool HasPairedStorage(JobControlRecord* jcr)
switch (jcr->getJobType()) {
case JT_BACKUP:
// For a backup we look at the write storage.
- if (jcr->impl->res.write_storage_list) {
- foreach_alist (store, jcr->impl->res.write_storage_list) {
+ if (jcr->dir_impl->res.write_storage_list) {
+ foreach_alist (store, jcr->dir_impl->res.write_storage_list) {
if (!store->paired_storage) { return false; }
}
} else {
@@ -444,8 +447,8 @@ bool HasPairedStorage(JobControlRecord* jcr)
case JT_RESTORE:
case JT_MIGRATE:
case JT_COPY:
- if (jcr->impl->res.read_storage_list) {
- foreach_alist (store, jcr->impl->res.read_storage_list) {
+ if (jcr->dir_impl->res.read_storage_list) {
+ foreach_alist (store, jcr->dir_impl->res.read_storage_list) {
if (!store->paired_storage) { return false; }
}
} else {
@@ -472,7 +475,7 @@ bool SelectNextRstore(JobControlRecord* jcr, bootstrap_info& info)
{
UnifiedStorageResource ustore;
- if (bstrcmp(jcr->impl->res.read_storage->resource_name_, info.storage)) {
+ if (bstrcmp(jcr->dir_impl->res.read_storage->resource_name_, info.storage)) {
return true; /* Same SD nothing to change */
}
@@ -480,7 +483,7 @@ bool SelectNextRstore(JobControlRecord* jcr, bootstrap_info& info)
R_STORAGE, info.storage))) {
Jmsg(jcr, M_FATAL, 0, _("Could not get storage resource '%s'.\n"),
info.storage);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -498,13 +501,13 @@ bool SelectNextRstore(JobControlRecord* jcr, bootstrap_info& info)
DecReadStore(jcr);
FreeRstorage(jcr);
SetRstorage(jcr, &ustore);
- jcr->setJobStatus(JS_WaitSD);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitSD);
// Wait for up to 6 hours to increment read stoage counter
for (int i = 0; i < MAX_TRIES; i++) {
// Try to get read storage counter incremented
if (IncReadStore(jcr)) {
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
return true;
}
Bmicrosleep(10, 0); /* Sleep 10 secs */
diff --git a/core/src/dird/testfind.cc b/core/src/dird/testfind.cc
index 516a6c97b..b723b303f 100644
--- a/core/src/dird/testfind.cc
+++ b/core/src/dird/testfind.cc
@@ -35,7 +35,7 @@
#include "dird/jcr_util.h"
#include "dird/dird_globals.h"
#include "dird/dird_conf.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "lib/recent_job_results_list.h"
#include "findlib/attribs.h"
#include "filed/fileset.h"
@@ -53,9 +53,9 @@ void TestfindFreeJcr(JobControlRecord* jcr)
{
Dmsg0(200, "Start testfind FreeJcr\n");
- if (jcr->impl) {
- delete jcr->impl;
- jcr->impl = nullptr;
+ if (jcr->dir_impl) {
+ delete jcr->dir_impl;
+ jcr->dir_impl = nullptr;
}
Dmsg0(200, "End testfind FreeJcr\n");
@@ -162,10 +162,10 @@ int main(int argc, char* const* argv)
}
jcr = NewDirectorJcr(TestfindFreeJcr);
- jcr->impl->res.fileset
+ jcr->dir_impl->res.fileset
= (FilesetResource*)my_config->GetResWithName(R_FILESET, fileset_name);
- if (jcr->impl->res.fileset == NULL) {
+ if (jcr->dir_impl->res.fileset == NULL) {
fprintf(stderr, "%s: Fileset not found\n", fileset_name);
FilesetResource* var;
@@ -433,7 +433,7 @@ static void CountFiles(FindFilesPacket* ar)
static bool CopyFileset(FindFilesPacket* ff, JobControlRecord* jcr)
{
- FilesetResource* jcr_fileset = jcr->impl->res.fileset;
+ FilesetResource* jcr_fileset = jcr->dir_impl->res.fileset;
int num;
bool include = true;
diff --git a/core/src/dird/ua_cmds.cc b/core/src/dird/ua_cmds.cc
index c86e986b1..70a6577e0 100644
--- a/core/src/dird/ua_cmds.cc
+++ b/core/src/dird/ua_cmds.cc
@@ -34,7 +34,7 @@
#include "dird/ua_cmdstruct.h"
#include "dird/expand.h"
#include "dird/fd_cmds.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/next_vol.h"
#include "dird/sd_cmds.h"
@@ -590,9 +590,9 @@ bool Do_a_command(UaContext* ua)
Dmsg1(900, "Command: %s\n", ua->argk[0]);
if (ua->argc == 0) { return false; }
- while (ua->jcr->impl->res.write_storage_list
- && ua->jcr->impl->res.write_storage_list->size()) {
- ua->jcr->impl->res.write_storage_list->remove(0);
+ while (ua->jcr->dir_impl->res.write_storage_list
+ && ua->jcr->dir_impl->res.write_storage_list->size()) {
+ ua->jcr->dir_impl->res.write_storage_list->remove(0);
}
len = strlen(ua->argk[0]);
@@ -623,7 +623,7 @@ bool Do_a_command(UaContext* ua)
* ua->jcr->setJobStatus(JS_Running)
* isn't enough, as it does not overwrite error states.
*/
- ua->jcr->JobStatus = JS_Running;
+ ua->jcr->setJobStatus(JS_Running);
if (ua->api) { user->signal(BNET_CMD_BEGIN); }
ua->send->SetMode(ua->api);
@@ -894,7 +894,7 @@ static inline bool SetbwlimitFiled(UaContext* ua,
char* Job)
{
// Connect to File daemon
- ua->jcr->impl->res.client = client;
+ ua->jcr->dir_impl->res.client = client;
ua->jcr->max_bandwidth = limit;
// Try to connect for 15 seconds
@@ -917,7 +917,7 @@ static inline bool SetbwlimitFiled(UaContext* ua,
ua->jcr->file_bsock->close();
delete ua->jcr->file_bsock;
ua->jcr->file_bsock = NULL;
- ua->jcr->impl->res.client = NULL;
+ ua->jcr->dir_impl->res.client = NULL;
ua->jcr->max_bandwidth = 0;
return true;
@@ -942,7 +942,7 @@ static inline bool setbwlimit_stored(UaContext* ua,
}
// Connect to Storage daemon
- ua->jcr->impl->res.write_storage = store;
+ ua->jcr->dir_impl->res.write_storage = store;
ua->jcr->max_bandwidth = limit;
// Try to connect for 15 seconds
@@ -965,7 +965,7 @@ static inline bool setbwlimit_stored(UaContext* ua,
ua->jcr->store_bsock->close();
delete ua->jcr->store_bsock;
ua->jcr->store_bsock = NULL;
- ua->jcr->impl->res.write_storage = NULL;
+ ua->jcr->dir_impl->res.write_storage = NULL;
ua->jcr->max_bandwidth = 0;
return true;
@@ -1005,10 +1005,10 @@ static bool SetbwlimitCmd(UaContext* ua, const char*)
switch (jcr->getJobType()) {
case JT_COPY:
case JT_MIGRATE:
- store = jcr->impl->res.read_storage;
+ store = jcr->dir_impl->res.read_storage;
break;
default:
- client = jcr->impl->res.client;
+ client = jcr->dir_impl->res.client;
break;
}
FreeJcr(jcr);
@@ -1230,7 +1230,7 @@ static void DoClientSetdebug(UaContext* ua,
}
// Connect to File daemon
- ua->jcr->impl->res.client = client;
+ ua->jcr->dir_impl->res.client = client;
// Try to connect for 15 seconds
ua->SendMsg(_("Connecting to Client %s at %s:%d\n"), client->resource_name_,
@@ -1243,7 +1243,7 @@ static void DoClientSetdebug(UaContext* ua,
Dmsg0(120, "Connected to file daemon\n");
fd = ua->jcr->file_bsock;
- if (ua->jcr->impl->FDVersion >= FD_VERSION_53) {
+ if (ua->jcr->dir_impl->FDVersion >= FD_VERSION_53) {
fd->fsend("setdebug=%d trace=%d hangup=%d timestamp=%d\n", level,
trace_flag, hangup_flag, timestamp_flag);
} else {
@@ -1884,8 +1884,8 @@ static bool EstimateCmd(UaContext* ua, const char*)
return false;
}
- jcr->impl->res.client = client;
- jcr->impl->res.fileset = fileset;
+ jcr->dir_impl->res.client = client;
+ jcr->dir_impl->res.fileset = fileset;
CloseDb(ua);
switch (client->Protocol) {
@@ -1904,7 +1904,7 @@ static bool EstimateCmd(UaContext* ua, const char*)
if (!OpenDb(ua)) { return false; }
- jcr->impl->res.job = job;
+ jcr->dir_impl->res.job = job;
jcr->setJobType(JT_BACKUP);
jcr->start_time = time(NULL);
InitJcrJobRecord(jcr);
@@ -1916,8 +1916,9 @@ static bool EstimateCmd(UaContext* ua, const char*)
GetLevelSinceTime(jcr);
ua->SendMsg(_("Connecting to Client %s at %s:%d\n"),
- jcr->impl->res.client->resource_name_,
- jcr->impl->res.client->address, jcr->impl->res.client->FDport);
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->res.client->address,
+ jcr->dir_impl->res.client->FDport);
if (!ConnectToFileDaemon(jcr, 1, 15, false)) {
ua->ErrorMsg(_("Failed to connect to Client.\n"));
return false;
@@ -2221,14 +2222,15 @@ static bool DoTruncate(UaContext* ua,
}
// Choose storage
- ua->jcr->impl->res.write_storage = ua->GetStoreResWithName(storage_dbr.Name);
- if (!ua->jcr->impl->res.write_storage) {
+ ua->jcr->dir_impl->res.write_storage
+ = ua->GetStoreResWithName(storage_dbr.Name);
+ if (!ua->jcr->dir_impl->res.write_storage) {
ua->ErrorMsg("failed to determine storage resource by name %s\n",
storage_dbr.Name);
goto bail_out;
}
- if (SendLabelRequest(ua, ua->jcr->impl->res.write_storage, &mr, &mr,
+ if (SendLabelRequest(ua, ua->jcr->dir_impl->res.write_storage, &mr, &mr,
&pool_dbr,
/* bool media_record_exists */
true,
@@ -2243,7 +2245,7 @@ static bool DoTruncate(UaContext* ua,
}
bail_out:
- ua->jcr->impl->res.write_storage = NULL;
+ ua->jcr->dir_impl->res.write_storage = NULL;
return retval;
}
@@ -2586,7 +2588,7 @@ static void DoMountCmd(UaContext* ua, const char* cmd)
if (!do_alldrives) {
DoAutochangerVolumeOperation(ua, store.store, cmd, drive, slot);
} else {
- nr_drives = GetNumDrives(ua, ua->jcr->impl->res.write_storage);
+ nr_drives = GetNumDrives(ua, ua->jcr->dir_impl->res.write_storage);
for (drive_number_t i = 0; i < nr_drives; i++) {
DoAutochangerVolumeOperation(ua, store.store, cmd, i, slot);
}
@@ -2741,8 +2743,8 @@ static bool wait_cmd(UaContext* ua, const char*)
for (bool waiting = false; !waiting;) {
foreach_jcr (jcr) {
if (jcr->JobId != 0
- && (jcr->JobStatus == JS_WaitMedia
- || jcr->JobStatus == JS_WaitMount)) {
+ && (jcr->getJobStatus() == JS_WaitMedia
+ || jcr->getJobStatus() == JS_WaitMount)) {
waiting = true;
break;
}
diff --git a/core/src/dird/ua_db.cc b/core/src/dird/ua_db.cc
index b07f3f930..5514f4627 100644
--- a/core/src/dird/ua_db.cc
+++ b/core/src/dird/ua_db.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -28,7 +28,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/ua_db.h"
#include "cats/sql_pooling.h"
#include "dird/ua_select.h"
@@ -132,7 +132,7 @@ bool OpenDb(UaContext* ua, bool use_private)
mult_db_conn = ua->catalog->mult_db_connections;
if (use_private) { mult_db_conn = true; }
- ua->jcr->impl->res.catalog = ua->catalog;
+ ua->jcr->dir_impl->res.catalog = ua->catalog;
Dmsg0(100, "UA Open database\n");
ua->db = DbSqlGetPooledConnection(
ua->jcr, ua->catalog->db_driver, ua->catalog->db_name,
diff --git a/core/src/dird/ua_dotcmds.cc b/core/src/dird/ua_dotcmds.cc
index 35bebcde9..ef58132d6 100644
--- a/core/src/dird/ua_dotcmds.cc
+++ b/core/src/dird/ua_dotcmds.cc
@@ -33,7 +33,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/dird_globals.h"
#include "dird/sd_cmds.h"
@@ -727,7 +727,7 @@ static void DoClientCmd(UaContext* ua, ClientResource* client const char*)
/* Connect to File daemon */
- ua->jcr->impl->res.client = client;
+ ua->jcr->dir_impl->res.client = client;
/* Try to connect for 15 seconds */
ua->SendMsg(_("Connecting to Client %s at %s:%d\n"), client->resource_name_,
client->address, client->FDport);
diff --git a/core/src/dird/ua_label.cc b/core/src/dird/ua_label.cc
index c0d39ed07..837aee4c2 100644
--- a/core/src/dird/ua_label.cc
+++ b/core/src/dird/ua_label.cc
@@ -37,7 +37,7 @@
#endif
#include "dird/ndmp_dma_storage.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/sd_cmds.h"
#include "dird/storage.h"
#include "dird/ua_db.h"
@@ -65,7 +65,7 @@ static inline bool update_database(UaContext* ua,
if (media_record_exists) {
// Update existing media record.
mr->InChanger = mr->Slot > 0; /* If slot give assume in changer */
- SetStorageidInMr(ua->jcr->impl->res.write_storage, mr);
+ SetStorageidInMr(ua->jcr->dir_impl->res.write_storage, mr);
if (!ua->db->UpdateMediaRecord(ua->jcr, mr)) {
ua->ErrorMsg("%s", ua->db->strerror());
retval = false;
@@ -75,7 +75,7 @@ static inline bool update_database(UaContext* ua,
SetPoolDbrDefaultsInMediaDbr(mr, pr);
mr->InChanger = mr->Slot > 0; /* If slot give assume in changer */
mr->Enabled = 1;
- SetStorageidInMr(ua->jcr->impl->res.write_storage, mr);
+ SetStorageidInMr(ua->jcr->dir_impl->res.write_storage, mr);
if (ua->db->CreateMediaRecord(ua->jcr, mr)) {
ua->InfoMsg(_("Catalog record for Volume \"%s\", Slot %hd successfully "
@@ -111,7 +111,7 @@ static inline bool native_send_label_request(UaContext* ua,
if (!(sd = open_sd_bsock(ua))) { return false; }
- bstrncpy(dev_name, ua->jcr->impl->res.write_storage->dev_name(),
+ bstrncpy(dev_name, ua->jcr->dir_impl->res.write_storage->dev_name(),
sizeof(dev_name));
BashSpaces(dev_name);
BashSpaces(mr->VolumeName);
@@ -271,19 +271,20 @@ static inline bool IsCleaningTape(UaContext* ua,
bool retval;
// Find Pool resource
- ua->jcr->impl->res.pool = ua->GetPoolResWithName(pr->Name, false);
- if (!ua->jcr->impl->res.pool) {
+ ua->jcr->dir_impl->res.pool = ua->GetPoolResWithName(pr->Name, false);
+ if (!ua->jcr->dir_impl->res.pool) {
ua->ErrorMsg(_("Pool \"%s\" resource not found for volume \"%s\"!\n"),
pr->Name, mr->VolumeName);
return false;
}
- retval = bstrncmp(mr->VolumeName, ua->jcr->impl->res.pool->cleaning_prefix,
- strlen(ua->jcr->impl->res.pool->cleaning_prefix));
+ retval
+ = bstrncmp(mr->VolumeName, ua->jcr->dir_impl->res.pool->cleaning_prefix,
+ strlen(ua->jcr->dir_impl->res.pool->cleaning_prefix));
Dmsg4(100, "CLNprefix=%s: Vol=%s: len=%d bstrncmp=%s\n",
- ua->jcr->impl->res.pool->cleaning_prefix, mr->VolumeName,
- strlen(ua->jcr->impl->res.pool->cleaning_prefix),
+ ua->jcr->dir_impl->res.pool->cleaning_prefix, mr->VolumeName,
+ strlen(ua->jcr->dir_impl->res.pool->cleaning_prefix),
retval ? "true" : "false");
return retval;
@@ -299,7 +300,7 @@ static void label_from_barcodes(UaContext* ua,
bool label_encrypt,
bool yes)
{
- StorageResource* store = ua->jcr->impl->res.write_storage;
+ StorageResource* store = ua->jcr->dir_impl->res.write_storage;
PoolDbRecord pr;
MediaDbRecord mr;
vol_list_t* vl;
@@ -309,7 +310,7 @@ static void label_from_barcodes(UaContext* ua,
int max_slots;
- max_slots = GetNumSlots(ua, ua->jcr->impl->res.write_storage);
+ max_slots = GetNumSlots(ua, ua->jcr->dir_impl->res.write_storage);
if (max_slots <= 0) {
ua->WarningMsg(_("No slots in changer to scan.\n"));
return;
diff --git a/core/src/dird/ua_output.cc b/core/src/dird/ua_output.cc
index f9838ee0a..3d9803faf 100644
--- a/core/src/dird/ua_output.cc
+++ b/core/src/dird/ua_output.cc
@@ -32,7 +32,7 @@
#include "dird.h"
#include "dird/dird_globals.h"
#include "dird/get_database_connection.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/ua_cmdstruct.h"
#include "cats/sql_pooling.h"
@@ -1286,17 +1286,17 @@ static bool ListNextvol(UaContext* ua, int ndays)
found = false;
goto get_out;
}
- if (!jcr->impl->jr.PoolId) {
+ if (!jcr->dir_impl->jr.PoolId) {
ua->ErrorMsg(_("Could not find Pool for Job %s\n"), job->resource_name_);
continue;
}
PoolDbRecord pr;
- pr.PoolId = jcr->impl->jr.PoolId;
+ pr.PoolId = jcr->dir_impl->jr.PoolId;
if (!ua->db->GetPoolRecord(jcr, &pr)) {
bstrncpy(pr.Name, "*UnknownPool*", sizeof(pr.Name));
}
MediaDbRecord mr;
- mr.PoolId = jcr->impl->jr.PoolId;
+ mr.PoolId = jcr->dir_impl->jr.PoolId;
GetJobStorage(&store, job, run);
SetStorageidInMr(store.store, &mr);
/* no need to set ScratchPoolId, since we use fnv_no_create_vol */
@@ -1409,7 +1409,7 @@ bool CompleteJcrForJob(JobControlRecord* jcr,
PoolResource* pool)
{
SetJcrDefaults(jcr, job);
- if (pool) { jcr->impl->res.pool = pool; /* override */ }
+ if (pool) { jcr->dir_impl->res.pool = pool; /* override */ }
if (jcr->db) {
Dmsg0(100, "complete_jcr close db\n");
DbSqlClosePooledConnection(jcr, jcr->db);
@@ -1420,14 +1420,14 @@ bool CompleteJcrForJob(JobControlRecord* jcr,
jcr->db = GetDatabaseConnection(jcr);
if (jcr->db == NULL) {
Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"),
- jcr->impl->res.catalog->db_name);
+ jcr->dir_impl->res.catalog->db_name);
return false;
}
PoolDbRecord pr;
- bstrncpy(pr.Name, jcr->impl->res.pool->resource_name_, sizeof(pr.Name));
+ bstrncpy(pr.Name, jcr->dir_impl->res.pool->resource_name_, sizeof(pr.Name));
while (!jcr->db->GetPoolRecord(jcr, &pr)) { /* get by Name */
/* Try to create the pool */
- if (CreatePool(jcr, jcr->db, jcr->impl->res.pool, POOL_OP_CREATE) < 0) {
+ if (CreatePool(jcr, jcr->db, jcr->dir_impl->res.pool, POOL_OP_CREATE) < 0) {
Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s\n"), pr.Name,
jcr->db->strerror());
if (jcr->db) {
@@ -1439,7 +1439,7 @@ bool CompleteJcrForJob(JobControlRecord* jcr,
Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name);
}
}
- jcr->impl->jr.PoolId = pr.PoolId;
+ jcr->dir_impl->jr.PoolId = pr.PoolId;
return true;
}
diff --git a/core/src/dird/ua_purge.cc b/core/src/dird/ua_purge.cc
index a6427705a..0bc39445f 100644
--- a/core/src/dird/ua_purge.cc
+++ b/core/src/dird/ua_purge.cc
@@ -32,7 +32,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/next_vol.h"
#include "dird/sd_cmds.h"
#include "dird/ua_db.h"
@@ -620,7 +620,7 @@ static bool ActionOnPurgeCmd(UaContext* ua, const char*)
}
// Choose storage
- ua->jcr->impl->res.write_storage = store = get_storage_resource(ua);
+ ua->jcr->dir_impl->res.write_storage = store = get_storage_resource(ua);
if (!store) { goto bail_out; }
switch (store->Protocol) {
@@ -695,7 +695,7 @@ static bool ActionOnPurgeCmd(UaContext* ua, const char*)
bail_out:
CloseDb(ua);
if (sd) { CloseSdBsock(ua); }
- ua->jcr->impl->res.write_storage = NULL;
+ ua->jcr->dir_impl->res.write_storage = NULL;
if (results) { free(results); }
return true;
diff --git a/core/src/dird/ua_restore.cc b/core/src/dird/ua_restore.cc
index e79f5908e..b78a25225 100644
--- a/core/src/dird/ua_restore.cc
+++ b/core/src/dird/ua_restore.cc
@@ -36,7 +36,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/ua_db.h"
#include "dird/ua_input.h"
#include "dird/ua_select.h"
@@ -1232,7 +1232,7 @@ static bool BuildDirectoryTree(UaContext* ua, RestoreContext* rx)
* For NDMP restores its used in the DMA to know what to restore.
* The tree is freed by the DMA when its done.
*/
- ua->jcr->impl->restore_tree_root = tree.root;
+ ua->jcr->dir_impl->restore_tree_root = tree.root;
return OK;
}
diff --git a/core/src/dird/ua_run.cc b/core/src/dird/ua_run.cc
index 9bca71c6a..e97b28dd8 100644
--- a/core/src/dird/ua_run.cc
+++ b/core/src/dird/ua_run.cc
@@ -26,7 +26,7 @@
*/
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/migration.h"
#include "dird/storage.h"
@@ -390,9 +390,9 @@ int DoRunCmd(UaContext* ua, const char*)
if (!jcr) {
jcr = NewDirectorJcr(DirdFreeJcr);
SetJcrDefaults(jcr, rc.job);
- jcr->impl->unlink_bsr
- = ua->jcr->impl->unlink_bsr; /* copy unlink flag from caller */
- ua->jcr->impl->unlink_bsr = false;
+ jcr->dir_impl->unlink_bsr
+ = ua->jcr->dir_impl->unlink_bsr; /* copy unlink flag from caller */
+ ua->jcr->dir_impl->unlink_bsr = false;
}
// Transfer JobIds to new restore Job
@@ -402,9 +402,9 @@ int DoRunCmd(UaContext* ua, const char*)
}
// Transfer selected restore tree to new restore Job
- if (ua->jcr->impl->restore_tree_root) {
- jcr->impl->restore_tree_root = ua->jcr->impl->restore_tree_root;
- ua->jcr->impl->restore_tree_root = NULL;
+ if (ua->jcr->dir_impl->restore_tree_root) {
+ jcr->dir_impl->restore_tree_root = ua->jcr->dir_impl->restore_tree_root;
+ ua->jcr->dir_impl->restore_tree_root = NULL;
}
try_again:
@@ -490,28 +490,29 @@ try_again:
* For interactive runs we set IgnoreLevelPoolOverrides as we already
* performed the actual overrrides.
*/
- jcr->impl->IgnoreLevelPoolOverrides = true;
+ jcr->dir_impl->IgnoreLevelPoolOverrides = true;
if (ua->cmd[0] == 0 || bstrncasecmp(ua->cmd, NT_("yes"), strlen(ua->cmd))
|| bstrncasecmp(ua->cmd, _("yes"), strlen(ua->cmd))) {
JobId_t JobId;
- Dmsg1(800, "Calling RunJob job=%x\n", jcr->impl->res.job);
+ Dmsg1(800, "Calling RunJob job=%x\n", jcr->dir_impl->res.job);
start_job:
Dmsg3(100, "JobId=%u using pool %s priority=%d\n", (int)jcr->JobId,
- jcr->impl->res.pool->resource_name_, jcr->JobPriority);
- Dmsg1(900, "Running a job; its spool_data = %d\n", jcr->impl->spool_data);
+ jcr->dir_impl->res.pool->resource_name_, jcr->JobPriority);
+ Dmsg1(900, "Running a job; its spool_data = %d\n",
+ jcr->dir_impl->spool_data);
JobId = RunJob(jcr);
Dmsg4(100, "JobId=%u NewJobId=%d using pool %s priority=%d\n",
- (int)jcr->JobId, JobId, jcr->impl->res.pool->resource_name_,
+ (int)jcr->JobId, JobId, jcr->dir_impl->res.pool->resource_name_,
jcr->JobPriority);
- jcr->impl->job_trigger = JobTrigger::kUser;
+ jcr->dir_impl->job_trigger = JobTrigger::kUser;
// For interactive runs we send a message to the audit log
- if (jcr->impl->IgnoreLevelPoolOverrides) {
+ if (jcr->dir_impl->IgnoreLevelPoolOverrides) {
char buf[50];
ua->LogAuditEventInfoMsg(_("Job queued. JobId=%s"),
edit_int64(jcr->JobId, buf));
@@ -593,7 +594,7 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc)
case JT_BACKUP:
if (!rc.pool_override && !jcr->is_JobLevel(L_VIRTUAL_FULL)) {
ApplyPoolOverrides(jcr, true);
- rc.pool = jcr->impl->res.pool;
+ rc.pool = jcr->dir_impl->res.pool;
rc.level_override = true;
}
break;
@@ -614,7 +615,7 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc)
/* Job */
rc.job = select_job_resource(ua);
if (rc.job) {
- jcr->impl->res.job = rc.job;
+ jcr->dir_impl->res.job = rc.job;
SetJcrDefaults(jcr, rc.job);
goto try_again;
}
@@ -623,7 +624,7 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc)
/* FileSet */
rc.fileset = select_fileset_resource(ua);
if (rc.fileset) {
- jcr->impl->res.fileset = rc.fileset;
+ jcr->dir_impl->res.fileset = rc.fileset;
goto try_again;
}
break;
@@ -631,18 +632,18 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc)
/* Client */
rc.client = select_client_resource(ua);
if (rc.client) {
- jcr->impl->res.client = rc.client;
+ jcr->dir_impl->res.client = rc.client;
goto try_again;
}
break;
case 5:
/* Backup Format */
if (GetCmd(ua, _("Please enter Backup Format: "))) {
- if (jcr->impl->backup_format) {
- free(jcr->impl->backup_format);
- jcr->impl->backup_format = NULL;
+ if (jcr->dir_impl->backup_format) {
+ free(jcr->dir_impl->backup_format);
+ jcr->dir_impl->backup_format = NULL;
}
- jcr->impl->backup_format = strdup(ua->cmd);
+ jcr->dir_impl->backup_format = strdup(ua->cmd);
goto try_again;
}
break;
@@ -680,11 +681,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc)
|| jcr->is_JobType(JT_VERIFY)) { /* Pool */
rc.pool = select_pool_resource(ua);
if (rc.pool) {
- jcr->impl->res.pool = rc.pool;
+ jcr->dir_impl->res.pool = rc.pool;
rc.level_override = false;
rc.pool_override = true;
Dmsg1(100, "Set new pool=%s\n",
- jcr->impl->res.pool->resource_name_);
+ jcr->dir_impl->res.pool->resource_name_);
goto try_again;
}
} else {
@@ -720,14 +721,14 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc)
&& jcr->is_JobLevel(L_VIRTUAL_FULL))) { /* NextPool */
rc.next_pool = select_pool_resource(ua);
if (rc.next_pool) {
- jcr->impl->res.next_pool = rc.next_pool;
+ jcr->dir_impl->res.next_pool = rc.next_pool;
Dmsg1(100, "Set new next_pool=%s\n",
- jcr->impl->res.next_pool->resource_name_);
+ jcr->dir_impl->res.next_pool->resource_name_);
goto try_again;
}
} else if (jcr->is_JobType(JT_VERIFY)) { /* Verify Job */
rc.verify_job = select_job_resource(ua);
- if (rc.verify_job) { jcr->impl->res.verify_job = rc.verify_job; }
+ if (rc.verify_job) { jcr->dir_impl->res.verify_job = rc.verify_job; }
goto try_again;
} else if (jcr->is_JobType(JT_RESTORE)) { /* Where */
if (GetCmd(ua, _("Please enter the full path prefix for restore (/ "
@@ -748,11 +749,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc)
}
} else { /* Plugin Options */
if (GetCmd(ua, _("Please enter Plugin Options string: "))) {
- if (jcr->impl->plugin_options) {
- free(jcr->impl->plugin_options);
- jcr->impl->plugin_options = NULL;
+ if (jcr->dir_impl->plugin_options) {
+ free(jcr->dir_impl->plugin_options);
+ jcr->dir_impl->plugin_options = NULL;
}
- jcr->impl->plugin_options = strdup(ua->cmd);
+ jcr->dir_impl->plugin_options = strdup(ua->cmd);
goto try_again;
}
}
@@ -764,11 +765,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc)
goto try_again;
} else if (jcr->is_JobType(JT_BACKUP)) {
if (GetCmd(ua, _("Please enter Plugin Options string: "))) {
- if (jcr->impl->plugin_options) {
- free(jcr->impl->plugin_options);
- jcr->impl->plugin_options = NULL;
+ if (jcr->dir_impl->plugin_options) {
+ free(jcr->dir_impl->plugin_options);
+ jcr->dir_impl->plugin_options = NULL;
}
- jcr->impl->plugin_options = strdup(ua->cmd);
+ jcr->dir_impl->plugin_options = strdup(ua->cmd);
goto try_again;
}
}
@@ -782,13 +783,13 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc)
opt = DoPrompt(ua, "", _("Select replace option"), NULL, 0);
if (opt >= 0) {
rc.replace = ReplaceOptions[opt].name;
- jcr->impl->replace = ReplaceOptions[opt].token;
+ jcr->dir_impl->replace = ReplaceOptions[opt].token;
}
goto try_again;
case 12:
/* JobId */
rc.jid = NULL; /* force reprompt */
- jcr->impl->RestoreJobId = 0;
+ jcr->dir_impl->RestoreJobId = 0;
if (jcr->RestoreBootstrap) {
ua->SendMsg(
_("You must set the bootstrap file to NULL to be able to specify "
@@ -798,11 +799,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc)
case 13:
/* Plugin Options */
if (GetCmd(ua, _("Please enter Plugin Options string: "))) {
- if (jcr->impl->plugin_options) {
- free(jcr->impl->plugin_options);
- jcr->impl->plugin_options = NULL;
+ if (jcr->dir_impl->plugin_options) {
+ free(jcr->dir_impl->plugin_options);
+ jcr->dir_impl->plugin_options = NULL;
}
- jcr->impl->plugin_options = strdup(ua->cmd);
+ jcr->dir_impl->plugin_options = strdup(ua->cmd);
goto try_again;
}
break;
@@ -830,10 +831,10 @@ static bool ResetRestoreContext(UaContext* ua,
JobControlRecord* jcr,
RunContext& rc)
{
- jcr->impl->res.verify_job = rc.verify_job;
- jcr->impl->res.previous_job = rc.previous_job;
- jcr->impl->res.pool = rc.pool;
- jcr->impl->res.next_pool = rc.next_pool;
+ jcr->dir_impl->res.verify_job = rc.verify_job;
+ jcr->dir_impl->res.previous_job = rc.previous_job;
+ jcr->dir_impl->res.pool = rc.pool;
+ jcr->dir_impl->res.next_pool = rc.next_pool;
/*
* See if an explicit pool override was performed.
@@ -842,32 +843,33 @@ static bool ResetRestoreContext(UaContext* ua,
* overrides are ignored.
*/
if (rc.pool_name) {
- PmStrcpy(jcr->impl->res.pool_source, _("command line"));
- jcr->impl->IgnoreLevelPoolOverrides = true;
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("command line"));
+ jcr->dir_impl->IgnoreLevelPoolOverrides = true;
} else if (!rc.level_override
- && jcr->impl->res.pool != jcr->impl->res.job->pool) {
- PmStrcpy(jcr->impl->res.pool_source, _("user input"));
+ && jcr->dir_impl->res.pool != jcr->dir_impl->res.job->pool) {
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("user input"));
}
SetRwstorage(jcr, rc.store);
if (rc.next_pool_name) {
- PmStrcpy(jcr->impl->res.npool_source, _("command line"));
- jcr->impl->res.run_next_pool_override = true;
- } else if (jcr->impl->res.next_pool != jcr->impl->res.pool->NextPool) {
- PmStrcpy(jcr->impl->res.npool_source, _("user input"));
- jcr->impl->res.run_next_pool_override = true;
+ PmStrcpy(jcr->dir_impl->res.npool_source, _("command line"));
+ jcr->dir_impl->res.run_next_pool_override = true;
+ } else if (jcr->dir_impl->res.next_pool
+ != jcr->dir_impl->res.pool->NextPool) {
+ PmStrcpy(jcr->dir_impl->res.npool_source, _("user input"));
+ jcr->dir_impl->res.run_next_pool_override = true;
}
- jcr->impl->res.client = rc.client;
- if (jcr->impl->res.client) {
+ jcr->dir_impl->res.client = rc.client;
+ if (jcr->dir_impl->res.client) {
PmStrcpy(jcr->client_name, rc.client->resource_name_);
}
- jcr->impl->res.fileset = rc.fileset;
- jcr->impl->ExpectedFiles = rc.files;
+ jcr->dir_impl->res.fileset = rc.fileset;
+ jcr->dir_impl->ExpectedFiles = rc.files;
if (rc.catalog) {
- jcr->impl->res.catalog = rc.catalog;
- PmStrcpy(jcr->impl->res.catalog_source, _("user input"));
+ jcr->dir_impl->res.catalog = rc.catalog;
+ PmStrcpy(jcr->dir_impl->res.catalog_source, _("user input"));
}
PmStrcpy(jcr->comment, rc.comment);
@@ -900,26 +902,26 @@ static bool ResetRestoreContext(UaContext* ua,
}
if (rc.plugin_options) {
- if (jcr->impl->plugin_options) { free(jcr->impl->plugin_options); }
- jcr->impl->plugin_options = strdup(rc.plugin_options);
+ if (jcr->dir_impl->plugin_options) { free(jcr->dir_impl->plugin_options); }
+ jcr->dir_impl->plugin_options = strdup(rc.plugin_options);
rc.plugin_options = NULL;
}
if (rc.replace) {
- jcr->impl->replace = 0;
+ jcr->dir_impl->replace = 0;
for (int i = 0; ReplaceOptions[i].name; i++) {
if (Bstrcasecmp(rc.replace, ReplaceOptions[i].name)) {
- jcr->impl->replace = ReplaceOptions[i].token;
+ jcr->dir_impl->replace = ReplaceOptions[i].token;
}
}
- if (!jcr->impl->replace) {
+ if (!jcr->dir_impl->replace) {
ua->SendMsg(_("Invalid replace option: %s\n"), rc.replace);
return false;
}
} else if (rc.job->replace) {
- jcr->impl->replace = rc.job->replace;
+ jcr->dir_impl->replace = rc.job->replace;
} else {
- jcr->impl->replace = REPLACE_ALWAYS;
+ jcr->dir_impl->replace = REPLACE_ALWAYS;
}
rc.replace = NULL;
@@ -944,7 +946,7 @@ static bool ResetRestoreContext(UaContext* ua,
}
if (rc.cloned) {
- jcr->impl->cloned = rc.cloned;
+ jcr->dir_impl->cloned = rc.cloned;
rc.cloned = false;
}
@@ -958,7 +960,7 @@ static bool ResetRestoreContext(UaContext* ua,
}
rc.replace = ReplaceOptions[0].name;
for (int i = 0; ReplaceOptions[i].name; i++) {
- if (ReplaceOptions[i].token == jcr->impl->replace) {
+ if (ReplaceOptions[i].token == jcr->dir_impl->replace) {
rc.replace = ReplaceOptions[i].name;
}
}
@@ -973,20 +975,20 @@ static bool ResetRestoreContext(UaContext* ua,
if (rc.jid) {
if (jcr->is_JobType(JT_BACKUP) && jcr->is_JobLevel(L_VIRTUAL_FULL)) {
- if (!jcr->impl->vf_jobids) {
- jcr->impl->vf_jobids = GetPoolMemory(PM_MESSAGE);
+ if (!jcr->dir_impl->vf_jobids) {
+ jcr->dir_impl->vf_jobids = GetPoolMemory(PM_MESSAGE);
}
- PmStrcpy(jcr->impl->vf_jobids, rc.jid);
+ PmStrcpy(jcr->dir_impl->vf_jobids, rc.jid);
} else {
// Note, this is also MigrateJobId and a VerifyJobId
- jcr->impl->RestoreJobId = str_to_int64(rc.jid);
+ jcr->dir_impl->RestoreJobId = str_to_int64(rc.jid);
}
rc.jid = NULL;
}
if (rc.backup_format) {
- if (jcr->impl->backup_format) { free(jcr->impl->backup_format); }
- jcr->impl->backup_format = strdup(rc.backup_format);
+ if (jcr->dir_impl->backup_format) { free(jcr->dir_impl->backup_format); }
+ jcr->dir_impl->backup_format = strdup(rc.backup_format);
rc.backup_format = NULL;
}
@@ -994,7 +996,7 @@ static bool ResetRestoreContext(UaContext* ua,
* Some options are not available through the menu
* TODO: Add an advanced menu?
*/
- if (rc.spool_data_set) { jcr->impl->spool_data = rc.spool_data; }
+ if (rc.spool_data_set) { jcr->dir_impl->spool_data = rc.spool_data; }
if (rc.accurate_set) { jcr->accurate = rc.accurate; }
@@ -1003,7 +1005,7 @@ static bool ResetRestoreContext(UaContext* ua,
* but can run at the same time
*/
if (rc.ignoreduplicatecheck_set) {
- jcr->impl->IgnoreDuplicateJobChecking = rc.ignoreduplicatecheck;
+ jcr->dir_impl->IgnoreDuplicateJobChecking = rc.ignoreduplicatecheck;
}
return true;
@@ -1231,27 +1233,27 @@ static bool DisplayJobParameters(UaContext* ua,
"Storage: %s\n"
"When: %s\n"
"Priority: %d\n",
- job->resource_name_, jcr->impl->res.fileset->resource_name_,
- NPRT(jcr->impl->res.client->resource_name_),
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
+ job->resource_name_, jcr->dir_impl->res.fileset->resource_name_,
+ NPRT(jcr->dir_impl->res.client->resource_name_),
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
: _("*None*"),
bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority);
} else {
- ua->SendMsg(_("Run Admin Job\n"
- "JobName: %s\n"
- "FileSet: %s\n"
- "Client: %s\n"
- "Storage: %s\n"
- "When: %s\n"
- "Priority: %d\n"),
- job->resource_name_, jcr->impl->res.fileset->resource_name_,
- NPRT(jcr->impl->res.client->resource_name_),
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
- : _("*None*"),
- bstrutime(dt, sizeof(dt), jcr->sched_time),
- jcr->JobPriority);
+ ua->SendMsg(
+ _("Run Admin Job\n"
+ "JobName: %s\n"
+ "FileSet: %s\n"
+ "Client: %s\n"
+ "Storage: %s\n"
+ "When: %s\n"
+ "Priority: %d\n"),
+ job->resource_name_, jcr->dir_impl->res.fileset->resource_name_,
+ NPRT(jcr->dir_impl->res.client->resource_name_),
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
+ : _("*None*"),
+ bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority);
}
jcr->setJobLevel(L_FULL);
break;
@@ -1267,27 +1269,27 @@ static bool DisplayJobParameters(UaContext* ua,
"Storage: %s\n"
"When: %s\n"
"Priority: %d\n",
- job->resource_name_, jcr->impl->res.fileset->resource_name_,
- NPRT(jcr->impl->res.client->resource_name_),
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
+ job->resource_name_, jcr->dir_impl->res.fileset->resource_name_,
+ NPRT(jcr->dir_impl->res.client->resource_name_),
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
: _("*None*"),
bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority);
} else {
- ua->SendMsg(_("Run Archive Job\n"
- "JobName: %s\n"
- "FileSet: %s\n"
- "Client: %s\n"
- "Storage: %s\n"
- "When: %s\n"
- "Priority: %d\n"),
- job->resource_name_, jcr->impl->res.fileset->resource_name_,
- NPRT(jcr->impl->res.client->resource_name_),
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
- : _("*None*"),
- bstrutime(dt, sizeof(dt), jcr->sched_time),
- jcr->JobPriority);
+ ua->SendMsg(
+ _("Run Archive Job\n"
+ "JobName: %s\n"
+ "FileSet: %s\n"
+ "Client: %s\n"
+ "Storage: %s\n"
+ "When: %s\n"
+ "Priority: %d\n"),
+ job->resource_name_, jcr->dir_impl->res.fileset->resource_name_,
+ NPRT(jcr->dir_impl->res.client->resource_name_),
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
+ : _("*None*"),
+ bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority);
}
jcr->setJobLevel(L_FULL);
break;
@@ -1303,27 +1305,27 @@ static bool DisplayJobParameters(UaContext* ua,
"Storage: %s\n"
"When: %s\n"
"Priority: %d\n",
- job->resource_name_, jcr->impl->res.fileset->resource_name_,
- NPRT(jcr->impl->res.client->resource_name_),
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
+ job->resource_name_, jcr->dir_impl->res.fileset->resource_name_,
+ NPRT(jcr->dir_impl->res.client->resource_name_),
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
: _("*None*"),
bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority);
} else {
- ua->SendMsg(_("Run Consolidate Job\n"
- "JobName: %s\n"
- "FileSet: %s\n"
- "Client: %s\n"
- "Storage: %s\n"
- "When: %s\n"
- "Priority: %d\n"),
- job->resource_name_, jcr->impl->res.fileset->resource_name_,
- NPRT(jcr->impl->res.client->resource_name_),
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
- : _("*None*"),
- bstrutime(dt, sizeof(dt), jcr->sched_time),
- jcr->JobPriority);
+ ua->SendMsg(
+ _("Run Consolidate Job\n"
+ "JobName: %s\n"
+ "FileSet: %s\n"
+ "Client: %s\n"
+ "Storage: %s\n"
+ "When: %s\n"
+ "Priority: %d\n"),
+ job->resource_name_, jcr->dir_impl->res.fileset->resource_name_,
+ NPRT(jcr->dir_impl->res.client->resource_name_),
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
+ : _("*None*"),
+ bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority);
}
jcr->setJobLevel(L_FULL);
break;
@@ -1349,22 +1351,24 @@ static bool DisplayJobParameters(UaContext* ua,
"Priority: %d\n"
"%s%s%s",
job->resource_name_, JobLevelToString(jcr->getJobLevel()),
- jcr->impl->res.client->resource_name_, jcr->impl->backup_format,
- jcr->impl->res.fileset->resource_name_,
- NPRT(jcr->impl->res.pool->resource_name_),
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->backup_format,
+ jcr->dir_impl->res.fileset->resource_name_,
+ NPRT(jcr->dir_impl->res.pool->resource_name_),
is_virtual ? "NextPool: " : "",
- is_virtual ? (jcr->impl->res.next_pool
- ? jcr->impl->res.next_pool->resource_name_
+ is_virtual ? (jcr->dir_impl->res.next_pool
+ ? jcr->dir_impl->res.next_pool->resource_name_
: _("*None*"))
: "",
is_virtual ? "\n" : "",
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
: _("*None*"),
bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority,
- jcr->impl->plugin_options ? "Plugin Options: " : "",
- jcr->impl->plugin_options ? jcr->impl->plugin_options : "",
- jcr->impl->plugin_options ? "\n" : "");
+ jcr->dir_impl->plugin_options ? "Plugin Options: " : "",
+ jcr->dir_impl->plugin_options ? jcr->dir_impl->plugin_options
+ : "",
+ jcr->dir_impl->plugin_options ? "\n" : "");
} else {
ua->SendMsg(
_("Run Backup job\n"
@@ -1380,35 +1384,37 @@ static bool DisplayJobParameters(UaContext* ua,
"Priority: %d\n"
"%s%s%s"),
job->resource_name_, JobLevelToString(jcr->getJobLevel()),
- jcr->impl->res.client->resource_name_, jcr->impl->backup_format,
- jcr->impl->res.fileset->resource_name_,
- NPRT(jcr->impl->res.pool->resource_name_),
- jcr->impl->res.pool_source, is_virtual ? "NextPool: " : "",
- is_virtual ? (jcr->impl->res.next_pool
- ? jcr->impl->res.next_pool->resource_name_
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->backup_format,
+ jcr->dir_impl->res.fileset->resource_name_,
+ NPRT(jcr->dir_impl->res.pool->resource_name_),
+ jcr->dir_impl->res.pool_source, is_virtual ? "NextPool: " : "",
+ is_virtual ? (jcr->dir_impl->res.next_pool
+ ? jcr->dir_impl->res.next_pool->resource_name_
: _("*None*"))
: "",
is_virtual ? " (From " : "",
- is_virtual ? jcr->impl->res.npool_source : "",
+ is_virtual ? jcr->dir_impl->res.npool_source : "",
is_virtual ? ")\n" : "",
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
: _("*None*"),
- jcr->impl->res.wstore_source,
+ jcr->dir_impl->res.wstore_source,
bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority,
- jcr->impl->plugin_options ? "Plugin Options: " : "",
- jcr->impl->plugin_options ? jcr->impl->plugin_options : "",
- jcr->impl->plugin_options ? "\n" : "");
+ jcr->dir_impl->plugin_options ? "Plugin Options: " : "",
+ jcr->dir_impl->plugin_options ? jcr->dir_impl->plugin_options
+ : "",
+ jcr->dir_impl->plugin_options ? "\n" : "");
}
} else { /* JT_VERIFY */
JobDbRecord jr;
const char* Name;
- if (jcr->impl->res.verify_job) {
- Name = jcr->impl->res.verify_job->resource_name_;
- } else if (jcr->impl->RestoreJobId) { /* Display job name if jobid
- * requested
- */
- jr.JobId = jcr->impl->RestoreJobId;
+ if (jcr->dir_impl->res.verify_job) {
+ Name = jcr->dir_impl->res.verify_job->resource_name_;
+ } else if (jcr->dir_impl->RestoreJobId) { /* Display job name if jobid
+ * requested
+ */
+ jr.JobId = jcr->dir_impl->RestoreJobId;
if (!ua->db->GetJobRecord(jcr, &jr)) {
ua->ErrorMsg(
_("Could not get job record for selected JobId. ERR=%s"),
@@ -1437,12 +1443,12 @@ static bool DisplayJobParameters(UaContext* ua,
"When: %s\n"
"Priority: %d\n",
job->resource_name_, JobLevelToString(jcr->getJobLevel()),
- jcr->impl->res.client->resource_name_,
- jcr->impl->res.fileset->resource_name_,
- NPRT(jcr->impl->res.pool->resource_name_),
- jcr->impl->res.pool_source,
- jcr->impl->res.read_storage->resource_name_,
- jcr->impl->res.rstore_source, Name, verify_list,
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->res.fileset->resource_name_,
+ NPRT(jcr->dir_impl->res.pool->resource_name_),
+ jcr->dir_impl->res.pool_source,
+ jcr->dir_impl->res.read_storage->resource_name_,
+ jcr->dir_impl->res.rstore_source, Name, verify_list,
bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority);
} else {
ua->SendMsg(_("Run Verify Job\n"
@@ -1457,21 +1463,21 @@ static bool DisplayJobParameters(UaContext* ua,
"When: %s\n"
"Priority: %d\n"),
job->resource_name_, JobLevelToString(jcr->getJobLevel()),
- jcr->impl->res.client->resource_name_,
- jcr->impl->res.fileset->resource_name_,
- NPRT(jcr->impl->res.pool->resource_name_),
- jcr->impl->res.pool_source,
- jcr->impl->res.read_storage->resource_name_,
- jcr->impl->res.rstore_source, Name, verify_list,
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->res.fileset->resource_name_,
+ NPRT(jcr->dir_impl->res.pool->resource_name_),
+ jcr->dir_impl->res.pool_source,
+ jcr->dir_impl->res.read_storage->resource_name_,
+ jcr->dir_impl->res.rstore_source, Name, verify_list,
bstrutime(dt, sizeof(dt), jcr->sched_time),
jcr->JobPriority);
}
}
break;
case JT_RESTORE:
- if (jcr->impl->RestoreJobId == 0 && !jcr->RestoreBootstrap) {
+ if (jcr->dir_impl->RestoreJobId == 0 && !jcr->RestoreBootstrap) {
if (rc.jid) {
- jcr->impl->RestoreJobId = str_to_int64(rc.jid);
+ jcr->dir_impl->RestoreJobId = str_to_int64(rc.jid);
} else {
if (!GetPint(ua, _("Please enter a JobId for restore: "))) {
return false;
@@ -1483,12 +1489,12 @@ static bool DisplayJobParameters(UaContext* ua,
return false;
}
- jcr->impl->RestoreJobId = ua->int64_val;
+ jcr->dir_impl->RestoreJobId = ua->int64_val;
}
}
jcr->setJobLevel(L_FULL); /* default level */
- Dmsg1(800, "JobId to restore=%d\n", jcr->impl->RestoreJobId);
- if (jcr->impl->RestoreJobId == 0) {
+ Dmsg1(800, "JobId to restore=%d\n", jcr->dir_impl->RestoreJobId);
+ if (jcr->dir_impl->RestoreJobId == 0) {
/* RegexWhere is take before RestoreWhere */
if (jcr->RegexWhere || (job->RegexWhere && !jcr->where)) {
if (ua->api) {
@@ -1511,12 +1517,13 @@ static bool DisplayJobParameters(UaContext* ua,
"Plugin Options: %s\n",
job->resource_name_, NPRT(jcr->RestoreBootstrap),
jcr->RegexWhere ? jcr->RegexWhere : job->RegexWhere, rc.replace,
- jcr->impl->res.fileset->resource_name_, rc.client_name,
- jcr->impl->res.client->resource_name_, jcr->impl->backup_format,
- jcr->impl->res.read_storage->resource_name_,
+ jcr->dir_impl->res.fileset->resource_name_, rc.client_name,
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->backup_format,
+ jcr->dir_impl->res.read_storage->resource_name_,
bstrutime(dt, sizeof(dt), jcr->sched_time),
- jcr->impl->res.catalog->resource_name_, jcr->JobPriority,
- NPRT(jcr->impl->plugin_options));
+ jcr->dir_impl->res.catalog->resource_name_, jcr->JobPriority,
+ NPRT(jcr->dir_impl->plugin_options));
} else {
ua->SendMsg(_("Run Restore job\n"
"JobName: %s\n"
@@ -1534,13 +1541,14 @@ static bool DisplayJobParameters(UaContext* ua,
"Plugin Options: %s\n"),
job->resource_name_, NPRT(jcr->RestoreBootstrap),
jcr->RegexWhere ? jcr->RegexWhere : job->RegexWhere,
- rc.replace, jcr->impl->res.fileset->resource_name_,
- rc.client_name, jcr->impl->res.client->resource_name_,
- jcr->impl->backup_format,
- jcr->impl->res.read_storage->resource_name_,
+ rc.replace, jcr->dir_impl->res.fileset->resource_name_,
+ rc.client_name,
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->backup_format,
+ jcr->dir_impl->res.read_storage->resource_name_,
bstrutime(dt, sizeof(dt), jcr->sched_time),
- jcr->impl->res.catalog->resource_name_,
- jcr->JobPriority, NPRT(jcr->impl->plugin_options));
+ jcr->dir_impl->res.catalog->resource_name_,
+ jcr->JobPriority, NPRT(jcr->dir_impl->plugin_options));
}
} else {
if (ua->api) {
@@ -1563,12 +1571,13 @@ static bool DisplayJobParameters(UaContext* ua,
"Plugin Options: %s\n",
job->resource_name_, NPRT(jcr->RestoreBootstrap),
jcr->where ? jcr->where : NPRT(job->RestoreWhere), rc.replace,
- jcr->impl->res.fileset->resource_name_, rc.client_name,
- jcr->impl->res.client->resource_name_, jcr->impl->backup_format,
- jcr->impl->res.read_storage->resource_name_,
+ jcr->dir_impl->res.fileset->resource_name_, rc.client_name,
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->backup_format,
+ jcr->dir_impl->res.read_storage->resource_name_,
bstrutime(dt, sizeof(dt), jcr->sched_time),
- jcr->impl->res.catalog->resource_name_, jcr->JobPriority,
- NPRT(jcr->impl->plugin_options));
+ jcr->dir_impl->res.catalog->resource_name_, jcr->JobPriority,
+ NPRT(jcr->dir_impl->plugin_options));
} else {
ua->SendMsg(_("Run Restore job\n"
"JobName: %s\n"
@@ -1586,13 +1595,14 @@ static bool DisplayJobParameters(UaContext* ua,
"Plugin Options: %s\n"),
job->resource_name_, NPRT(jcr->RestoreBootstrap),
jcr->where ? jcr->where : NPRT(job->RestoreWhere),
- rc.replace, jcr->impl->res.fileset->resource_name_,
- rc.client_name, jcr->impl->res.client->resource_name_,
- jcr->impl->backup_format,
- jcr->impl->res.read_storage->resource_name_,
+ rc.replace, jcr->dir_impl->res.fileset->resource_name_,
+ rc.client_name,
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->backup_format,
+ jcr->dir_impl->res.read_storage->resource_name_,
bstrutime(dt, sizeof(dt), jcr->sched_time),
- jcr->impl->res.catalog->resource_name_,
- jcr->JobPriority, NPRT(jcr->impl->plugin_options));
+ jcr->dir_impl->res.catalog->resource_name_,
+ jcr->JobPriority, NPRT(jcr->dir_impl->plugin_options));
}
}
@@ -1621,15 +1631,15 @@ static bool DisplayJobParameters(UaContext* ua,
"Catalog: %s\n"
"Priority: %d\n"
"Plugin Options: %s\n"),
- rc.replace, jcr->impl->res.client->resource_name_,
- jcr->impl->backup_format,
- jcr->impl->res.read_storage->resource_name_,
- (jcr->impl->RestoreJobId == 0)
+ rc.replace, jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->backup_format,
+ jcr->dir_impl->res.read_storage->resource_name_,
+ (jcr->dir_impl->RestoreJobId == 0)
? _("*None*")
- : edit_uint64(jcr->impl->RestoreJobId, ec1),
+ : edit_uint64(jcr->dir_impl->RestoreJobId, ec1),
bstrutime(dt, sizeof(dt), jcr->sched_time),
- jcr->impl->res.catalog->resource_name_, jcr->JobPriority,
- NPRT(jcr->impl->plugin_options));
+ jcr->dir_impl->res.catalog->resource_name_,
+ jcr->JobPriority, NPRT(jcr->dir_impl->plugin_options));
}
break;
case JT_COPY:
@@ -1657,20 +1667,21 @@ static bool DisplayJobParameters(UaContext* ua,
"Catalog: %s\n"
"Priority: %d\n",
prt_type, job->resource_name_, NPRT(jcr->RestoreBootstrap),
- jcr->impl->res.read_storage
- ? jcr->impl->res.read_storage->resource_name_
+ jcr->dir_impl->res.read_storage
+ ? jcr->dir_impl->res.read_storage->resource_name_
: _("*None*"),
- NPRT(jcr->impl->res.pool->resource_name_),
- jcr->impl->res.next_pool ? jcr->impl->res.next_pool->resource_name_
- : _("*None*"),
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
+ NPRT(jcr->dir_impl->res.pool->resource_name_),
+ jcr->dir_impl->res.next_pool
+ ? jcr->dir_impl->res.next_pool->resource_name_
: _("*None*"),
- (jcr->impl->MigrateJobId == 0)
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
+ : _("*None*"),
+ (jcr->dir_impl->MigrateJobId == 0)
? _("*None*")
- : edit_uint64(jcr->impl->MigrateJobId, ec1),
+ : edit_uint64(jcr->dir_impl->MigrateJobId, ec1),
bstrutime(dt, sizeof(dt), jcr->sched_time),
- jcr->impl->res.catalog->resource_name_, jcr->JobPriority);
+ jcr->dir_impl->res.catalog->resource_name_, jcr->JobPriority);
} else {
if (jcr->is_JobType(JT_COPY)) {
prt_type = _("Run Copy job\n");
@@ -1689,25 +1700,26 @@ static bool DisplayJobParameters(UaContext* ua,
"Catalog: %s\n"
"Priority: %d\n"),
prt_type, job->resource_name_, NPRT(jcr->RestoreBootstrap),
- jcr->impl->res.read_storage
- ? jcr->impl->res.read_storage->resource_name_
+ jcr->dir_impl->res.read_storage
+ ? jcr->dir_impl->res.read_storage->resource_name_
: _("*None*"),
- jcr->impl->res.rstore_source,
- NPRT(jcr->impl->res.pool->resource_name_),
- jcr->impl->res.pool_source,
- jcr->impl->res.write_storage
- ? jcr->impl->res.write_storage->resource_name_
+ jcr->dir_impl->res.rstore_source,
+ NPRT(jcr->dir_impl->res.pool->resource_name_),
+ jcr->dir_impl->res.pool_source,
+ jcr->dir_impl->res.write_storage
+ ? jcr->dir_impl->res.write_storage->resource_name_
: _("*None*"),
- jcr->impl->res.wstore_source,
- jcr->impl->res.next_pool
- ? jcr->impl->res.next_pool->resource_name_
+ jcr->dir_impl->res.wstore_source,
+ jcr->dir_impl->res.next_pool
+ ? jcr->dir_impl->res.next_pool->resource_name_
: _("*None*"),
- NPRT(jcr->impl->res.npool_source),
- jcr->impl->MigrateJobId == 0
+ NPRT(jcr->dir_impl->res.npool_source),
+ jcr->dir_impl->MigrateJobId == 0
? _("*None*")
- : edit_uint64(jcr->impl->MigrateJobId, ec1),
+ : edit_uint64(jcr->dir_impl->MigrateJobId, ec1),
bstrutime(dt, sizeof(dt), jcr->sched_time),
- jcr->impl->res.catalog->resource_name_, jcr->JobPriority);
+ jcr->dir_impl->res.catalog->resource_name_,
+ jcr->JobPriority);
}
break;
default:
diff --git a/core/src/dird/ua_select.cc b/core/src/dird/ua_select.cc
index cc0b3a7ff..d3ba0e83b 100644
--- a/core/src/dird/ua_select.cc
+++ b/core/src/dird/ua_select.cc
@@ -29,7 +29,7 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/storage.h"
#include "dird/ua_input.h"
#include "dird/ua_select.h"
@@ -1332,7 +1332,7 @@ StorageResource* get_storage_resource(UaContext* ua,
ua->ErrorMsg(_("JobId %s is not running.\n"), edit_int64(jobid, ed1));
return NULL;
}
- store = jcr->impl->res.write_storage;
+ store = jcr->dir_impl->res.write_storage;
FreeJcr(jcr);
break;
} else if (Bstrcasecmp(ua->argk[i], NT_("job"))
@@ -1345,7 +1345,7 @@ StorageResource* get_storage_resource(UaContext* ua,
ua->ErrorMsg(_("Job \"%s\" is not running.\n"), ua->argv[i]);
return NULL;
}
- store = jcr->impl->res.write_storage;
+ store = jcr->dir_impl->res.write_storage;
FreeJcr(jcr);
break;
} else if (Bstrcasecmp(ua->argk[i], NT_("ujobid"))) {
@@ -1357,7 +1357,7 @@ StorageResource* get_storage_resource(UaContext* ua,
ua->ErrorMsg(_("Job \"%s\" is not running.\n"), ua->argv[i]);
return NULL;
}
- store = jcr->impl->res.write_storage;
+ store = jcr->dir_impl->res.write_storage;
FreeJcr(jcr);
break;
}
@@ -1595,8 +1595,8 @@ alist<JobId_t*>* select_jobs(UaContext* ua, const char* reason)
}
if (jcr) {
- if (jcr->impl->res.job
- && !ua->AclAccessOk(Job_ACL, jcr->impl->res.job->resource_name_,
+ if (jcr->dir_impl->res.job
+ && !ua->AclAccessOk(Job_ACL, jcr->dir_impl->res.job->resource_name_,
true)) {
ua->ErrorMsg(_("Unauthorized command from this console.\n"));
goto bail_out;
@@ -1624,7 +1624,7 @@ alist<JobId_t*>* select_jobs(UaContext* ua, const char* reason)
continue;
}
tjobs++; /* Count of all jobs */
- if (!ua->AclAccessOk(Job_ACL, jcr->impl->res.job->resource_name_)) {
+ if (!ua->AclAccessOk(Job_ACL, jcr->dir_impl->res.job->resource_name_)) {
continue; /* Skip not authorized */
}
njobs++; /* Count of authorized jobs */
@@ -1682,7 +1682,7 @@ alist<JobId_t*>* select_jobs(UaContext* ua, const char* reason)
continue;
}
- if (!ua->AclAccessOk(Job_ACL, jcr->impl->res.job->resource_name_)) {
+ if (!ua->AclAccessOk(Job_ACL, jcr->dir_impl->res.job->resource_name_)) {
continue; /* Skip not authorized */
}
@@ -1691,16 +1691,20 @@ alist<JobId_t*>* select_jobs(UaContext* ua, const char* reason)
case all_jobs:
break;
case created_jobs:
- if (jcr->JobStatus != JS_Created) { continue; }
+ if (jcr->getJobStatus() != JS_Created) { continue; }
break;
case blocked_jobs:
- if (!jcr->job_started || jcr->JobStatus != JS_Blocked) { continue; }
+ if (!jcr->job_started || jcr->getJobStatus() != JS_Blocked) {
+ continue;
+ }
break;
case waiting_jobs:
if (!JobWaiting(jcr)) { continue; }
break;
case running_jobs:
- if (!jcr->job_started || jcr->JobStatus != JS_Running) { continue; }
+ if (!jcr->job_started || jcr->getJobStatus() != JS_Running) {
+ continue;
+ }
break;
default:
break;
@@ -1735,7 +1739,7 @@ alist<JobId_t*>* select_jobs(UaContext* ua, const char* reason)
if (jcr->JobId == 0) { /* This is us */
continue;
}
- if (!ua->AclAccessOk(Job_ACL, jcr->impl->res.job->resource_name_)) {
+ if (!ua->AclAccessOk(Job_ACL, jcr->dir_impl->res.job->resource_name_)) {
continue; /* Skip not authorized */
}
Bsnprintf(buf, sizeof(buf), _("JobId=%s Job=%s"),
diff --git a/core/src/dird/ua_server.cc b/core/src/dird/ua_server.cc
index 280f4ebdf..eb24aa7fd 100644
--- a/core/src/dird/ua_server.cc
+++ b/core/src/dird/ua_server.cc
@@ -31,7 +31,7 @@
#include "dird/dird_globals.h"
#include "dird/authenticate.h"
#include "dird/authenticate_console.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/pthread_detach_if_not_detached.h"
#include "dird/ua_cmds.h"
@@ -58,14 +58,14 @@ JobControlRecord* new_control_jcr(const char* base_name, int job_type)
// exclude JT_SYSTEM job from shared config counting
if (job_type == JT_SYSTEM) {
- jcr->impl->job_config_resources_container_ = nullptr;
+ jcr->dir_impl->job_config_resources_container_ = nullptr;
}
/* The job and defaults are not really used, but we set them up to ensure that
* everything is correctly initialized. */
LockRes(my_config);
- jcr->impl->res.job = (JobResource*)my_config->GetNextRes(R_JOB, NULL);
- SetJcrDefaults(jcr, jcr->impl->res.job);
+ jcr->dir_impl->res.job = (JobResource*)my_config->GetNextRes(R_JOB, NULL);
+ SetJcrDefaults(jcr, jcr->dir_impl->res.job);
UnlockRes(my_config);
jcr->sd_auth_key = strdup("dummy"); /* dummy Storage daemon key */
@@ -73,7 +73,7 @@ JobControlRecord* new_control_jcr(const char* base_name, int job_type)
jcr->sched_time = jcr->start_time;
jcr->setJobType(job_type);
jcr->setJobLevel(L_NONE);
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
jcr->JobId = 0;
return jcr;
diff --git a/core/src/dird/ua_status.cc b/core/src/dird/ua_status.cc
index f73af0b90..3bb4f9e9b 100644
--- a/core/src/dird/ua_status.cc
+++ b/core/src/dird/ua_status.cc
@@ -28,7 +28,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/run_hour_validator.h"
#include "dird/dird_globals.h"
#include "dird/fd_cmds.h"
@@ -109,9 +109,10 @@ bool DotStatusCmd(UaContext* ua, const char* cmd)
ua->SendMsg(OKdotstatus, ua->argk[2]);
foreach_jcr (njcr) {
if (njcr->JobId != 0
- && ua->AclAccessOk(Job_ACL, njcr->impl->res.job->resource_name_)) {
+ && ua->AclAccessOk(Job_ACL,
+ njcr->dir_impl->res.job->resource_name_)) {
ua->SendMsg(DotStatusJob, edit_int64(njcr->JobId, ed1),
- njcr->JobStatus, njcr->JobErrors);
+ njcr->getJobStatus(), njcr->JobErrors);
}
}
endeach_jcr(njcr);
@@ -291,12 +292,12 @@ static void DoAllStatus(UaContext* ua)
}
UnlockRes(my_config);
- previous_JobStatus = ua->jcr->JobStatus;
+ previous_JobStatus = ua->jcr->getJobStatus();
/* Call each unique Storage daemon */
for (j = 0; j < i; j++) {
StorageStatus(ua, unique_store[j], NULL);
- ua->jcr->JobStatus = previous_JobStatus;
+ ua->jcr->setJobStatus(previous_JobStatus);
}
free(unique_store);
@@ -326,12 +327,12 @@ static void DoAllStatus(UaContext* ua)
}
UnlockRes(my_config);
- previous_JobStatus = ua->jcr->JobStatus;
+ previous_JobStatus = ua->jcr->getJobStatus();
/* Call each unique File daemon */
for (j = 0; j < i; j++) {
ClientStatus(ua, unique_client[j], NULL);
- ua->jcr->JobStatus = previous_JobStatus;
+ ua->jcr->setJobStatus(previous_JobStatus);
}
free(unique_client);
}
@@ -799,12 +800,12 @@ static void PrtRuntime(UaContext* ua, sched_pkt* sp)
if (sp->job->JobType == JT_BACKUP) {
jcr->db = NULL;
ok = CompleteJcrForJob(jcr, sp->job, sp->pool);
- Dmsg1(250, "Using pool=%s\n", jcr->impl->res.pool->resource_name_);
+ Dmsg1(250, "Using pool=%s\n", jcr->dir_impl->res.pool->resource_name_);
if (jcr->db) { CloseDb = true; /* new db opened, remember to close it */ }
if (ok) {
- mr.PoolId = jcr->impl->jr.PoolId;
- jcr->impl->res.write_storage = sp->store;
- SetStorageidInMr(jcr->impl->res.write_storage, &mr);
+ mr.PoolId = jcr->dir_impl->jr.PoolId;
+ jcr->dir_impl->res.write_storage = sp->store;
+ SetStorageidInMr(jcr->dir_impl->res.write_storage, &mr);
Dmsg0(250, "call FindNextVolumeForAppend\n");
/* no need to set ScratchPoolId, since we use fnv_no_create_vol */
ok = FindNextVolumeForAppend(jcr, &mr, 1, NULL, fnv_no_create_vol,
@@ -966,11 +967,11 @@ static void ListRunningJobs(UaContext* ua)
}
foreach_jcr (jcr) {
if (jcr->JobId == 0
- || !ua->AclAccessOk(Job_ACL, jcr->impl->res.job->resource_name_)) {
+ || !ua->AclAccessOk(Job_ACL, jcr->dir_impl->res.job->resource_name_)) {
continue;
}
njobs++;
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Created:
msg = _("is waiting execution");
break;
@@ -1003,23 +1004,23 @@ static void ListRunningJobs(UaContext* ua)
break;
case JS_WaitFD:
emsg = (char*)GetPoolMemory(PM_FNAME);
- if (!jcr->impl->res.client) {
+ if (!jcr->dir_impl->res.client) {
Mmsg(emsg, _("is waiting on Client"));
} else {
Mmsg(emsg, _("is waiting on Client %s"),
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
}
pool_mem = true;
msg = emsg;
break;
case JS_WaitSD:
emsg = (char*)GetPoolMemory(PM_FNAME);
- if (jcr->impl->res.write_storage) {
+ if (jcr->dir_impl->res.write_storage) {
Mmsg(emsg, _("is waiting on Storage \"%s\""),
- jcr->impl->res.write_storage->resource_name_);
- } else if (jcr->impl->res.read_storage) {
+ jcr->dir_impl->res.write_storage->resource_name_);
+ } else if (jcr->dir_impl->res.read_storage) {
Mmsg(emsg, _("is waiting on Storage \"%s\""),
- jcr->impl->res.read_storage->resource_name_);
+ jcr->dir_impl->res.read_storage->resource_name_);
} else {
Mmsg(emsg, _("is waiting on Storage"));
}
@@ -1068,13 +1069,13 @@ static void ListRunningJobs(UaContext* ua)
default:
emsg = (char*)GetPoolMemory(PM_FNAME);
- Mmsg(emsg, _("is in unknown state %c"), jcr->JobStatus);
+ Mmsg(emsg, _("is in unknown state %c"), jcr->getJobStatus());
pool_mem = true;
msg = emsg;
break;
}
// Now report Storage daemon status code
- switch (jcr->impl->SDJobStatus) {
+ switch (jcr->dir_impl->SDJobStatus) {
case JS_WaitMount:
if (pool_mem) {
FreePoolMemory(emsg);
@@ -1098,12 +1099,13 @@ static void ListRunningJobs(UaContext* ua)
// client initiated connection
Mmsg(emsg, _("is waiting for Client to connect (Client Initiated "
"Connection)"));
- } else if (!jcr->impl->res.client || !jcr->impl->res.write_storage) {
+ } else if (!jcr->dir_impl->res.client
+ || !jcr->dir_impl->res.write_storage) {
Mmsg(emsg, _("is waiting for Client to connect to Storage daemon"));
} else {
Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"),
- jcr->impl->res.client->resource_name_,
- jcr->impl->res.write_storage->resource_name_);
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->res.write_storage->resource_name_);
}
msg = emsg;
break;
@@ -1597,7 +1599,7 @@ static void StatusSlots(UaContext* ua, StorageResource* store)
slot_number_t max_slots;
changer_vol_list_t* vol_list = NULL;
- ua->jcr->impl->res.write_storage = store;
+ ua->jcr->dir_impl->res.write_storage = store;
// Slot | Volume | Status | MediaType | Pool
const char* slot_hformat = " %4i%c| %16s | %9s | %14s | %24s |\n";
diff --git a/core/src/dird/ua_update.cc b/core/src/dird/ua_update.cc
index f30e66446..6566b5604 100644
--- a/core/src/dird/ua_update.cc
+++ b/core/src/dird/ua_update.cc
@@ -31,7 +31,7 @@
#include "include/bareos.h"
#include "dird.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/next_vol.h"
#include "dird/sd_cmds.h"
#include "dird/storage.h"
@@ -1014,7 +1014,7 @@ static void UpdateSlots(UaContext* ua)
have_enabled = false;
}
- max_slots = GetNumSlots(ua, ua->jcr->impl->res.write_storage);
+ max_slots = GetNumSlots(ua, ua->jcr->dir_impl->res.write_storage);
Dmsg1(100, "max_slots=%d\n", max_slots);
if (max_slots <= 0) {
ua->WarningMsg(_("No slots in changer to scan.\n"));
diff --git a/core/src/dird/vbackup.cc b/core/src/dird/vbackup.cc
index e06c12619..c7358c907 100644
--- a/core/src/dird/vbackup.cc
+++ b/core/src/dird/vbackup.cc
@@ -39,7 +39,7 @@
#include "dird/dird_globals.h"
#include "dird/backup.h"
#include "dird/bsr.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/migration.h"
#include "dird/msgchan.h"
@@ -102,12 +102,12 @@ class JobConsistencyChecker {
std::string GetVfJobids(JobControlRecord& jcr)
{
// See if we already got a list of jobids to use.
- if (jcr.impl->vf_jobids) {
- Dmsg1(10, "jobids=%s\n", jcr.impl->vf_jobids);
- return jcr.impl->vf_jobids;
+ if (jcr.dir_impl->vf_jobids) {
+ Dmsg1(10, "jobids=%s\n", jcr.dir_impl->vf_jobids);
+ return jcr.dir_impl->vf_jobids;
} else {
db_list_ctx jobids_ctx;
- jcr.db->AccurateGetJobids(&jcr, &jcr.impl->jr, &jobids_ctx);
+ jcr.db->AccurateGetJobids(&jcr, &jcr.dir_impl->jr, &jobids_ctx);
Dmsg1(10, "consolidate candidates: %s.\n",
jobids_ctx.GetAsString().c_str());
return jobids_ctx.GetAsString();
@@ -128,9 +128,9 @@ bool DoNativeVbackupInit(JobControlRecord* jcr)
if (!AllowDuplicateJob(jcr)) { return false; }
- jcr->impl->jr.PoolId
- = GetOrCreatePoolRecord(jcr, jcr->impl->res.pool->resource_name_);
- if (jcr->impl->jr.PoolId == 0) {
+ jcr->dir_impl->jr.PoolId
+ = GetOrCreatePoolRecord(jcr, jcr->dir_impl->res.pool->resource_name_);
+ if (jcr->dir_impl->jr.PoolId == 0) {
Dmsg1(dbglevel, "JobId=%d no PoolId\n", (int)jcr->JobId);
Jmsg(jcr, M_FATAL, 0, _("Could not get or create a Pool record.\n"));
return false;
@@ -142,38 +142,41 @@ bool DoNativeVbackupInit(JobControlRecord* jcr)
* pool will be changed to point to the write pool,
* which comes from pool->NextPool.
*/
- jcr->impl->res.rpool = jcr->impl->res.pool; /* save read pool */
- PmStrcpy(jcr->impl->res.rpool_source, jcr->impl->res.pool_source);
+ jcr->dir_impl->res.rpool = jcr->dir_impl->res.pool; /* save read pool */
+ PmStrcpy(jcr->dir_impl->res.rpool_source, jcr->dir_impl->res.pool_source);
// If pool storage specified, use it for restore
- CopyRstorage(jcr, jcr->impl->res.pool->storage, _("Pool resource"));
+ CopyRstorage(jcr, jcr->dir_impl->res.pool->storage, _("Pool resource"));
Dmsg2(dbglevel, "Read pool=%s (From %s)\n",
- jcr->impl->res.rpool->resource_name_, jcr->impl->res.rpool_source);
+ jcr->dir_impl->res.rpool->resource_name_,
+ jcr->dir_impl->res.rpool_source);
jcr->start_time = time(NULL);
- jcr->impl->jr.StartTime = jcr->start_time;
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ jcr->dir_impl->jr.StartTime = jcr->start_time;
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
}
// See if there is a next pool override.
- if (jcr->impl->res.run_next_pool_override) {
- PmStrcpy(jcr->impl->res.npool_source, _("Run NextPool override"));
- PmStrcpy(jcr->impl->res.pool_source, _("Run NextPool override"));
+ if (jcr->dir_impl->res.run_next_pool_override) {
+ PmStrcpy(jcr->dir_impl->res.npool_source, _("Run NextPool override"));
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("Run NextPool override"));
storage_source = _("Storage from Run NextPool override");
} else {
// See if there is a next pool override in the Job definition.
- if (jcr->impl->res.job->next_pool) {
- jcr->impl->res.next_pool = jcr->impl->res.job->next_pool;
- PmStrcpy(jcr->impl->res.npool_source, _("Job's NextPool resource"));
- PmStrcpy(jcr->impl->res.pool_source, _("Job's NextPool resource"));
+ if (jcr->dir_impl->res.job->next_pool) {
+ jcr->dir_impl->res.next_pool = jcr->dir_impl->res.job->next_pool;
+ PmStrcpy(jcr->dir_impl->res.npool_source, _("Job's NextPool resource"));
+ PmStrcpy(jcr->dir_impl->res.pool_source, _("Job's NextPool resource"));
storage_source = _("Storage from Job's NextPool resource");
} else {
// Fall back to the pool's NextPool definition.
- jcr->impl->res.next_pool = jcr->impl->res.pool->NextPool;
- PmStrcpy(jcr->impl->res.npool_source, _("Job Pool's NextPool resource"));
- PmStrcpy(jcr->impl->res.pool_source, _("Job Pool's NextPool resource"));
+ jcr->dir_impl->res.next_pool = jcr->dir_impl->res.pool->NextPool;
+ PmStrcpy(jcr->dir_impl->res.npool_source,
+ _("Job Pool's NextPool resource"));
+ PmStrcpy(jcr->dir_impl->res.pool_source,
+ _("Job Pool's NextPool resource"));
storage_source = _("Storage from Pool's NextPool resource");
}
}
@@ -183,22 +186,22 @@ bool DoNativeVbackupInit(JobControlRecord* jcr)
* record exists in the database. Note, in this case, we
* will be migrating from pool to pool->NextPool.
*/
- if (jcr->impl->res.next_pool) {
- jcr->impl->jr.PoolId
- = GetOrCreatePoolRecord(jcr, jcr->impl->res.next_pool->resource_name_);
- if (jcr->impl->jr.PoolId == 0) { return false; }
+ if (jcr->dir_impl->res.next_pool) {
+ jcr->dir_impl->jr.PoolId = GetOrCreatePoolRecord(
+ jcr, jcr->dir_impl->res.next_pool->resource_name_);
+ if (jcr->dir_impl->jr.PoolId == 0) { return false; }
}
- if (!SetMigrationWstorage(jcr, jcr->impl->res.pool, jcr->impl->res.next_pool,
- storage_source)) {
+ if (!SetMigrationWstorage(jcr, jcr->dir_impl->res.pool,
+ jcr->dir_impl->res.next_pool, storage_source)) {
return false;
}
- jcr->impl->res.pool = jcr->impl->res.next_pool;
+ jcr->dir_impl->res.pool = jcr->dir_impl->res.next_pool;
Dmsg2(dbglevel, "Write pool=%s read rpool=%s\n",
- jcr->impl->res.pool->resource_name_,
- jcr->impl->res.rpool->resource_name_);
+ jcr->dir_impl->res.pool->resource_name_,
+ jcr->dir_impl->res.rpool->resource_name_);
// CreateClones(jcr);
@@ -214,22 +217,23 @@ bool DoNativeVbackupInit(JobControlRecord* jcr)
*/
bool DoNativeVbackup(JobControlRecord* jcr)
{
- if (!jcr->impl->res.read_storage_list) {
+ if (!jcr->dir_impl->res.read_storage_list) {
Jmsg(jcr, M_FATAL, 0, _("No storage for reading given.\n"));
return false;
}
- if (!jcr->impl->res.write_storage_list) {
+ if (!jcr->dir_impl->res.write_storage_list) {
Jmsg(jcr, M_FATAL, 0, _("No storage for writing given.\n"));
return false;
}
Dmsg2(100, "read_storage_list=%p write_storage_list=%p\n",
- jcr->impl->res.read_storage_list, jcr->impl->res.write_storage_list);
+ jcr->dir_impl->res.read_storage_list,
+ jcr->dir_impl->res.write_storage_list);
Dmsg2(100, "Read store=%s, write store=%s\n",
- ((StorageResource*)jcr->impl->res.read_storage_list->first())
+ ((StorageResource*)jcr->dir_impl->res.read_storage_list->first())
->resource_name_,
- ((StorageResource*)jcr->impl->res.write_storage_list->first())
+ ((StorageResource*)jcr->dir_impl->res.write_storage_list->first())
->resource_name_);
Jmsg(jcr, M_INFO, 0, _("Start Virtual Backup JobId %lu, Job=%s\n"),
@@ -295,11 +299,11 @@ bool DoNativeVbackup(JobControlRecord* jcr)
* values from that job so that anything changed after that
* time will be picked up on the next backup.
*/
- jcr->impl->previous_jr = JobDbRecord{};
- jcr->impl->previous_jr.JobId = str_to_int64(jobid_list.back().c_str());
+ jcr->dir_impl->previous_jr = JobDbRecord{};
+ jcr->dir_impl->previous_jr.JobId = str_to_int64(jobid_list.back().c_str());
Dmsg1(10, "Previous JobId=%s\n", jobid_list.back().c_str());
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) {
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->previous_jr)) {
Jmsg(jcr, M_FATAL, 0,
_("Error getting Job record for previous Job: ERR=%s\n"),
jcr->db->strerror());
@@ -312,14 +316,14 @@ bool DoNativeVbackup(JobControlRecord* jcr)
}
Jmsg(jcr, M_INFO, 0, _("Consolidating JobIds %s containing %d files\n"),
- jobids.c_str(), jcr->impl->ExpectedFiles);
+ jobids.c_str(), jcr->dir_impl->ExpectedFiles);
/*
* Open a message channel connection with the Storage
* daemon.
*/
Dmsg0(110, "Open connection with storage daemon\n");
- jcr->setJobStatus(JS_WaitSD);
+ jcr->setJobStatusWithPriorityCheck(JS_WaitSD);
// Start conversation with Storage daemon
if (!ConnectToStorageDaemon(jcr, 10, me->SDConnectTimeout, true)) {
@@ -327,8 +331,8 @@ bool DoNativeVbackup(JobControlRecord* jcr)
}
// Now start a job with the Storage daemon
- if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list,
- jcr->impl->res.write_storage_list,
+ if (!StartStorageDaemonJob(jcr, jcr->dir_impl->res.read_storage_list,
+ jcr->dir_impl->res.write_storage_list,
/* send_bsr */ true)) {
return false;
}
@@ -345,12 +349,12 @@ bool DoNativeVbackup(JobControlRecord* jcr)
* is after the start of this run.
*/
jcr->start_time = time(NULL);
- jcr->impl->jr.StartTime = jcr->start_time;
- jcr->impl->jr.JobTDate = jcr->start_time;
- jcr->setJobStatus(JS_Running);
+ jcr->dir_impl->jr.StartTime = jcr->start_time;
+ jcr->dir_impl->jr.JobTDate = jcr->start_time;
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
// Update job start record
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
return false;
}
@@ -368,23 +372,23 @@ bool DoNativeVbackup(JobControlRecord* jcr)
// Now start a Storage daemon message thread
if (!StartStorageDaemonMessageThread(jcr)) { return false; }
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
/*
* Pickup Job termination data
* Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/JobErrors
*/
WaitForStorageDaemonTermination(jcr);
- jcr->setJobStatus(jcr->impl->SDJobStatus);
+ jcr->setJobStatusWithPriorityCheck(jcr->dir_impl->SDJobStatus);
jcr->db_batch->WriteBatchFileRecords(
jcr); /* used by bulk batch file insert */
if (!jcr->is_JobStatus(JS_Terminated)) { return false; }
- NativeVbackupCleanup(jcr, jcr->JobStatus, JobLevel_of_first_job);
+ NativeVbackupCleanup(jcr, jcr->getJobStatus(), JobLevel_of_first_job);
// Remove the successfully consolidated jobids from the database
- if (jcr->impl->res.job->AlwaysIncremental
- && jcr->impl->res.job->AlwaysIncrementalJobRetention) {
+ if (jcr->dir_impl->res.job->AlwaysIncremental
+ && jcr->dir_impl->res.job->AlwaysIncrementalJobRetention) {
UaContext* ua;
ua = new_ua_context(jcr);
PurgeJobsFromCatalog(ua, jobids.c_str());
@@ -407,11 +411,11 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel)
Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode);
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
case JS_Warnings:
- jcr->impl->jr.JobLevel = JobLevel; /* We want this to appear as what the
- first consolidated job was */
+ jcr->dir_impl->jr.JobLevel = JobLevel; /* We want this to appear as what
+ the first consolidated job was */
Jmsg(jcr, M_INFO, 0,
_("Joblevel was set to joblevel of first consolidated job: %s\n"),
job_level_to_str(JobLevel));
@@ -420,11 +424,11 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel)
break;
}
- jcr->JobFiles = jcr->impl->SDJobFiles;
- jcr->JobBytes = jcr->impl->SDJobBytes;
+ jcr->JobFiles = jcr->dir_impl->SDJobFiles;
+ jcr->JobBytes = jcr->dir_impl->SDJobBytes;
if (jcr->getJobStatus() == JS_Terminated
- && (jcr->JobErrors || jcr->impl->SDErrors)) {
+ && (jcr->JobErrors || jcr->dir_impl->SDErrors)) {
TermCode = JS_Warnings;
}
@@ -434,20 +438,21 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel)
Mmsg(query,
"UPDATE Job SET StartTime='%s',EndTime='%s',"
"JobTDate=%s WHERE JobId=%s",
- jcr->impl->previous_jr.cStartTime, jcr->impl->previous_jr.cEndTime,
- edit_uint64(jcr->impl->previous_jr.JobTDate, ec1),
+ jcr->dir_impl->previous_jr.cStartTime,
+ jcr->dir_impl->previous_jr.cEndTime,
+ edit_uint64(jcr->dir_impl->previous_jr.JobTDate, ec1),
edit_uint64(jcr->JobId, ec2));
jcr->db->SqlQuery(query.c_str());
// Get the fully updated job record
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error getting Job record for Job report: ERR=%s\n"),
jcr->db->strerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
- bstrncpy(cr.Name, jcr->impl->res.client->resource_name_, sizeof(cr.Name));
+ bstrncpy(cr.Name, jcr->dir_impl->res.client->resource_name_, sizeof(cr.Name));
if (!jcr->db->GetClientRecord(jcr, &cr)) {
Jmsg(jcr, M_WARNING, 0,
_("Error getting Client record for Job report: ERR=%s\n"),
@@ -456,7 +461,7 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel)
UpdateBootstrapFile(jcr);
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
TermMsg = _("Backup OK");
break;
@@ -469,8 +474,8 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel)
msg_type = M_ERROR; /* Generate error message */
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
break;
@@ -478,14 +483,15 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel)
TermMsg = _("Backup Canceled");
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
- if (jcr->impl->SD_msg_chan_started) {
- pthread_cancel(jcr->impl->SD_msg_chan);
+ if (jcr->dir_impl->SD_msg_chan_started) {
+ pthread_cancel(jcr->dir_impl->SD_msg_chan);
}
}
break;
default:
TermMsg = term_code;
- sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
+ sprintf(term_code, _("Inappropriate term code: %c\n"),
+ jcr->getJobStatus());
break;
}
@@ -538,11 +544,11 @@ static bool CreateBootstrapFile(JobControlRecord& jcr,
UaContext* ua = new_ua_context(&jcr);
AddVolumeInformationToBsr(ua, rx.bsr.get());
- jcr.impl->ExpectedFiles = WriteBsrFile(ua, rx);
- Dmsg1(10, "Found %d files to consolidate.\n", jcr.impl->ExpectedFiles);
+ jcr.dir_impl->ExpectedFiles = WriteBsrFile(ua, rx);
+ Dmsg1(10, "Found %d files to consolidate.\n", jcr.dir_impl->ExpectedFiles);
FreeUaContext(ua);
rx.bsr.reset(nullptr);
- return jcr.impl->ExpectedFiles != 0;
+ return jcr.dir_impl->ExpectedFiles != 0;
}
} /* namespace directordaemon */
diff --git a/core/src/dird/verify.cc b/core/src/dird/verify.cc
index 17a8d3b93..0bb7a7c89 100644
--- a/core/src/dird/verify.cc
+++ b/core/src/dird/verify.cc
@@ -39,7 +39,7 @@
#include "dird/backup.h"
#include "dird/fd_cmds.h"
#include "dird/getmsg.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/msgchan.h"
#include "dird/sd_cmds.h"
@@ -118,7 +118,7 @@ bool DoVerify(JobControlRecord* jcr)
FreeWstorage(jcr); /* we don't write */
- new (&jcr->impl->previous_jr)
+ new (&jcr->dir_impl->previous_jr)
JobDbRecord(); // placement new instead of memset
/*
@@ -138,19 +138,19 @@ bool DoVerify(JobControlRecord* jcr)
case L_VERIFY_CATALOG:
case L_VERIFY_VOLUME_TO_CATALOG:
case L_VERIFY_DISK_TO_CATALOG:
- jr = jcr->impl->jr;
- if (jcr->impl->res.verify_job
+ jr = jcr->dir_impl->jr;
+ if (jcr->dir_impl->res.verify_job
&& (JobLevel == L_VERIFY_VOLUME_TO_CATALOG
|| JobLevel == L_VERIFY_DISK_TO_CATALOG)) {
- Name = jcr->impl->res.verify_job->resource_name_;
+ Name = jcr->dir_impl->res.verify_job->resource_name_;
} else {
Name = NULL;
}
Dmsg1(100, "find last jobid for: %s\n", NPRT(Name));
// See if user supplied a jobid= as run argument or from menu
- if (jcr->impl->VerifyJobId) {
- verify_jobid = jcr->impl->VerifyJobId;
+ if (jcr->dir_impl->VerifyJobId) {
+ verify_jobid = jcr->dir_impl->VerifyJobId;
Dmsg1(100, "Supplied jobid=%d\n", verify_jobid);
} else {
@@ -174,22 +174,22 @@ bool DoVerify(JobControlRecord* jcr)
* Now get the job record for the previous backup that interests
* us. We use the verify_jobid that we found above.
*/
- jcr->impl->previous_jr.JobId = verify_jobid;
- if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) {
+ jcr->dir_impl->previous_jr.JobId = verify_jobid;
+ if (!jcr->db->GetJobRecord(jcr, &jcr->dir_impl->previous_jr)) {
Jmsg(jcr, M_FATAL, 0,
_("Could not get job record for previous Job. ERR=%s\n"),
jcr->db->strerror());
return false;
}
- if (!(jcr->impl->previous_jr.JobStatus == JS_Terminated
- || jcr->impl->previous_jr.JobStatus == JS_Warnings)) {
+ if (!(jcr->dir_impl->previous_jr.JobStatus == JS_Terminated
+ || jcr->dir_impl->previous_jr.JobStatus == JS_Warnings)) {
Jmsg(jcr, M_FATAL, 0,
_("Last Job %d did not Terminate normally. JobStatus=%c\n"),
- verify_jobid, jcr->impl->previous_jr.JobStatus);
+ verify_jobid, jcr->dir_impl->previous_jr.JobStatus);
return false;
}
Jmsg(jcr, M_INFO, 0, _("Verifying against JobId=%d Job=%s\n"),
- jcr->impl->previous_jr.JobId, jcr->impl->previous_jr.Job);
+ jcr->dir_impl->previous_jr.JobId, jcr->dir_impl->previous_jr.Job);
}
/*
@@ -213,8 +213,8 @@ bool DoVerify(JobControlRecord* jcr)
return true; /* get out */
}
- if (jcr->impl->res.verify_job) {
- jcr->impl->res.fileset = jcr->impl->res.verify_job->fileset;
+ if (jcr->dir_impl->res.verify_job) {
+ jcr->dir_impl->res.fileset = jcr->dir_impl->res.verify_job->fileset;
}
break;
default:
@@ -222,10 +222,10 @@ bool DoVerify(JobControlRecord* jcr)
break;
}
- Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->impl->previous_jr.ClientId,
+ Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->dir_impl->previous_jr.ClientId,
JobLevel);
- if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) {
+ if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
return false;
}
@@ -237,19 +237,20 @@ bool DoVerify(JobControlRecord* jcr)
switch (JobLevel) {
case L_VERIFY_VOLUME_TO_CATALOG:
// Start conversation with Storage daemon
- jcr->setJobStatus(JS_Blocked);
+ jcr->setJobStatusWithPriorityCheck(JS_Blocked);
if (!ConnectToStorageDaemon(jcr, 10, me->SDConnectTimeout, true)) {
return false;
}
sd = jcr->store_bsock;
// Now start a job with the Storage daemon
- if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list, NULL,
+ if (!StartStorageDaemonJob(jcr, jcr->dir_impl->res.read_storage_list,
+ NULL,
/* send_bsr */ true)) {
return false;
}
- jcr->passive_client = jcr->impl->res.client->passive;
+ jcr->passive_client = jcr->dir_impl->res.client->passive;
if (!jcr->passive_client) {
// Start the Job in the SD.
if (!sd->fsend("run")) { return false; }
@@ -260,7 +261,7 @@ bool DoVerify(JobControlRecord* jcr)
}
// OK, now connect to the File daemon and ask him for the files.
- jcr->setJobStatus(JS_Blocked);
+ jcr->setJobStatusWithPriorityCheck(JS_Blocked);
if (!ConnectToFileDaemon(jcr, 10, me->FDConnectTimeout, true)) {
goto bail_out;
}
@@ -268,17 +269,17 @@ bool DoVerify(JobControlRecord* jcr)
fd = jcr->file_bsock;
// Check if the file daemon supports passive client mode.
- if (jcr->passive_client && jcr->impl->FDVersion < FD_VERSION_51) {
+ if (jcr->passive_client && jcr->dir_impl->FDVersion < FD_VERSION_51) {
Jmsg(jcr, M_FATAL, 0,
_("Client \"%s\" doesn't support passive client mode. "
"Please upgrade your client or disable compat mode.\n"),
- jcr->impl->res.client->resource_name_);
+ jcr->dir_impl->res.client->resource_name_);
goto bail_out;
}
break;
default:
// OK, now connect to the File daemon and ask him for the files.
- jcr->setJobStatus(JS_Blocked);
+ jcr->setJobStatusWithPriorityCheck(JS_Blocked);
if (!ConnectToFileDaemon(jcr, 10, me->FDConnectTimeout, true)) {
goto bail_out;
}
@@ -287,7 +288,7 @@ bool DoVerify(JobControlRecord* jcr)
break;
}
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
Dmsg0(30, ">filed: Send include list\n");
if (!SendIncludeList(jcr)) { goto bail_out; }
@@ -313,12 +314,12 @@ bool DoVerify(JobControlRecord* jcr)
}
if (!jcr->passive_client) {
- StorageResource* store = jcr->impl->res.read_storage;
+ StorageResource* store = jcr->dir_impl->res.read_storage;
// Send Storage daemon address to the File daemon
TlsPolicy tls_policy;
- if (jcr->impl->res.client->connection_successful_handshake_
+ if (jcr->dir_impl->res.client->connection_successful_handshake_
!= ClientConnectionHandshakeMode::kTlsFirst) {
tls_policy = store->GetPolicy();
} else {
@@ -334,10 +335,10 @@ bool DoVerify(JobControlRecord* jcr)
goto bail_out;
}
} else {
- ClientResource* client = jcr->impl->res.client;
+ ClientResource* client = jcr->dir_impl->res.client;
TlsPolicy tls_policy;
- if (jcr->impl->res.client->connection_successful_handshake_
+ if (jcr->dir_impl->res.client->connection_successful_handshake_
!= ClientConnectionHandshakeMode::kTlsFirst) {
tls_policy = client->GetPolicy();
} else {
@@ -393,30 +394,30 @@ bool DoVerify(JobControlRecord* jcr)
case L_VERIFY_CATALOG:
// Verify from catalog
Dmsg0(10, "Verify level=catalog\n");
- jcr->impl->sd_msg_thread_done
+ jcr->dir_impl->sd_msg_thread_done
= true; /* no SD msg thread, so it is done */
- jcr->impl->SDJobStatus = JS_Terminated;
- GetAttributesAndCompareToCatalog(jcr, jcr->impl->previous_jr.JobId);
+ jcr->dir_impl->SDJobStatus = JS_Terminated;
+ GetAttributesAndCompareToCatalog(jcr, jcr->dir_impl->previous_jr.JobId);
break;
case L_VERIFY_VOLUME_TO_CATALOG:
// Verify Volume to catalog entries
Dmsg0(10, "Verify level=volume\n");
- GetAttributesAndCompareToCatalog(jcr, jcr->impl->previous_jr.JobId);
+ GetAttributesAndCompareToCatalog(jcr, jcr->dir_impl->previous_jr.JobId);
break;
case L_VERIFY_DISK_TO_CATALOG:
// Verify Disk attributes to catalog
Dmsg0(10, "Verify level=disk_to_catalog\n");
- jcr->impl->sd_msg_thread_done
+ jcr->dir_impl->sd_msg_thread_done
= true; /* no SD msg thread, so it is done */
- jcr->impl->SDJobStatus = JS_Terminated;
- GetAttributesAndCompareToCatalog(jcr, jcr->impl->previous_jr.JobId);
+ jcr->dir_impl->SDJobStatus = JS_Terminated;
+ GetAttributesAndCompareToCatalog(jcr, jcr->dir_impl->previous_jr.JobId);
break;
case L_VERIFY_INIT:
// Build catalog
Dmsg0(10, "Verify level=init\n");
- jcr->impl->sd_msg_thread_done
+ jcr->dir_impl->sd_msg_thread_done
= true; /* no SD msg thread, so it is done */
- jcr->impl->SDJobStatus = JS_Terminated;
+ jcr->dir_impl->SDJobStatus = JS_Terminated;
GetAttributesAndPutInCatalog(jcr);
jcr->db->EndTransaction(jcr); /* Terminate any open transaction */
jcr->db_batch->WriteBatchFileRecords(jcr);
@@ -456,9 +457,9 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode)
JobLevel = jcr->getJobLevel();
Dmsg3(900, "JobLevel=%c Expected=%u JobFiles=%u\n", JobLevel,
- jcr->impl->ExpectedFiles, jcr->JobFiles);
+ jcr->dir_impl->ExpectedFiles, jcr->JobFiles);
if (JobLevel == L_VERIFY_VOLUME_TO_CATALOG
- && jcr->impl->ExpectedFiles != jcr->JobFiles) {
+ && jcr->dir_impl->ExpectedFiles != jcr->JobFiles) {
TermCode = JS_ErrorTerminated;
}
@@ -466,9 +467,9 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode)
if (JobCanceled(jcr)) { CancelStorageDaemonJob(jcr); }
- if (jcr->impl->unlink_bsr && jcr->RestoreBootstrap) {
+ if (jcr->dir_impl->unlink_bsr && jcr->RestoreBootstrap) {
SecureErase(jcr, jcr->RestoreBootstrap);
- jcr->impl->unlink_bsr = false;
+ jcr->dir_impl->unlink_bsr = false;
}
msg_type = M_INFO; /* By default INFO message */
@@ -496,18 +497,19 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode)
_("Inappropriate term code: %d %c\n"), TermCode, TermCode);
break;
}
- bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime);
- bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime);
- if (jcr->impl->res.verify_job) {
- Name = jcr->impl->res.verify_job->resource_name_;
+ bstrftimes(sdt, sizeof(sdt), jcr->dir_impl->jr.StartTime);
+ bstrftimes(edt, sizeof(edt), jcr->dir_impl->jr.EndTime);
+ if (jcr->dir_impl->res.verify_job) {
+ Name = jcr->dir_impl->res.verify_job->resource_name_;
} else {
Name = "";
}
- JobstatusToAscii(jcr->impl->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
+ JobstatusToAscii(jcr->dir_impl->FDJobStatus, fd_term_msg,
+ sizeof(fd_term_msg));
switch (JobLevel) {
case L_VERIFY_VOLUME_TO_CATALOG:
- JobstatusToAscii(jcr->impl->SDJobStatus, sd_term_msg,
+ JobstatusToAscii(jcr->dir_impl->SDJobStatus, sd_term_msg,
sizeof(sd_term_msg));
Jmsg(jcr, msg_type, 0,
_("%s %s %s (%s):\n"
@@ -531,14 +533,15 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode)
" Termination: %s\n\n"),
BAREOS, my_name, kBareosVersionStrings.Full,
kBareosVersionStrings.ShortDate, kBareosVersionStrings.GetOsInfo(),
- jcr->impl->jr.JobId, jcr->impl->jr.Job,
- jcr->impl->res.fileset->resource_name_, JobLevelToString(JobLevel),
- jcr->impl->res.client->resource_name_, jcr->impl->previous_jr.JobId,
- Name, sdt, edt,
- edit_uint64_with_commas(jcr->impl->ExpectedFiles, ec1),
+ jcr->dir_impl->jr.JobId, jcr->dir_impl->jr.Job,
+ jcr->dir_impl->res.fileset->resource_name_,
+ JobLevelToString(JobLevel),
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->previous_jr.JobId, Name, sdt, edt,
+ edit_uint64_with_commas(jcr->dir_impl->ExpectedFiles, ec1),
edit_uint64_with_commas(jcr->JobFiles, ec2), jcr->JobErrors,
fd_term_msg, sd_term_msg, kBareosVersionStrings.JoblogMessage,
- JobTriggerToString(jcr->impl->job_trigger).c_str(), TermMsg);
+ JobTriggerToString(jcr->dir_impl->job_trigger).c_str(), TermMsg);
break;
default:
Jmsg(jcr, msg_type, 0,
@@ -561,12 +564,14 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode)
" Termination: %s\n\n"),
BAREOS, my_name, kBareosVersionStrings.Full,
kBareosVersionStrings.ShortDate, kBareosVersionStrings.GetOsInfo(),
- jcr->impl->jr.JobId, jcr->impl->jr.Job,
- jcr->impl->res.fileset->resource_name_, JobLevelToString(JobLevel),
- jcr->impl->res.client->resource_name_, jcr->impl->previous_jr.JobId,
- Name, sdt, edt, edit_uint64_with_commas(jcr->JobFiles, ec1),
- jcr->JobErrors, fd_term_msg, kBareosVersionStrings.JoblogMessage,
- JobTriggerToString(jcr->impl->job_trigger).c_str(), TermMsg);
+ jcr->dir_impl->jr.JobId, jcr->dir_impl->jr.Job,
+ jcr->dir_impl->res.fileset->resource_name_,
+ JobLevelToString(JobLevel),
+ jcr->dir_impl->res.client->resource_name_,
+ jcr->dir_impl->previous_jr.JobId, Name, sdt, edt,
+ edit_uint64_with_commas(jcr->JobFiles, ec1), jcr->JobErrors,
+ fd_term_msg, kBareosVersionStrings.JoblogMessage,
+ JobTriggerToString(jcr->dir_impl->job_trigger).c_str(), TermMsg);
break;
}
@@ -588,7 +593,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
fd = jcr->file_bsock;
fdbr.JobId = JobId;
- jcr->impl->FileIndex = 0;
+ jcr->dir_impl->FileIndex = 0;
Dmsg0(20, "dir: waiting to receive file attributes\n");
/*
@@ -608,8 +613,8 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
if (JobCanceled(jcr)) { goto bail_out; }
fname = CheckPoolMemorySize(fname, fd->message_length);
- jcr->impl->fname
- = CheckPoolMemorySize(jcr->impl->fname, fd->message_length);
+ jcr->dir_impl->fname
+ = CheckPoolMemorySize(jcr->dir_impl->fname, fd->message_length);
Dmsg1(200, "Atts+Digest=%s\n", fd->msg);
if ((len = sscanf(fd->msg, "%ld %d %100s", &file_index, &stream, fname))
!= 3) {
@@ -643,25 +648,27 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
int32_t LinkFIf, LinkFIc;
Dmsg2(400, "file_index=%d attr=%s\n", file_index, attr);
jcr->JobFiles++;
- jcr->impl->FileIndex = file_index; /* remember attribute file_index */
- jcr->impl->previous_jr.FileIndex = file_index;
+ jcr->dir_impl->FileIndex
+ = file_index; /* remember attribute file_index */
+ jcr->dir_impl->previous_jr.FileIndex = file_index;
DecodeStat(attr, &statf, sizeof(statf),
&LinkFIf); /* decode file stat packet */
do_Digest = CRYPTO_DIGEST_NONE;
- jcr->impl->fn_printed = false;
- PmStrcpy(jcr->impl->fname,
+ jcr->dir_impl->fn_printed = false;
+ PmStrcpy(jcr->dir_impl->fname,
fname); /* move filename into JobControlRecord */
- Dmsg2(040, "dird<filed: stream=%d %s\n", stream, jcr->impl->fname);
+ Dmsg2(040, "dird<filed: stream=%d %s\n", stream, jcr->dir_impl->fname);
Dmsg1(020, "dird<filed: attr=%s\n", attr);
// Find equivalent record in the database
fdbr.FileId = 0;
- if (!jcr->db->GetFileAttributesRecord(jcr, jcr->impl->fname,
- &jcr->impl->previous_jr, &fdbr)) {
- Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->impl->fname);
- Dmsg1(020, _("File not in catalog: %s\n"), jcr->impl->fname);
- jcr->setJobStatus(JS_Differences);
+ if (!jcr->db->GetFileAttributesRecord(jcr, jcr->dir_impl->fname,
+ &jcr->dir_impl->previous_jr,
+ &fdbr)) {
+ Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->dir_impl->fname);
+ Dmsg1(020, _("File not in catalog: %s\n"), jcr->dir_impl->fname);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
continue;
} else {
/*
@@ -671,8 +678,8 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
jcr->db->MarkFileRecord(jcr, fdbr.FileId, jcr->JobId);
}
- Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->impl->fname,
- file_index, Opts_Digest.c_str());
+ Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n",
+ jcr->dir_impl->fname, file_index, Opts_Digest.c_str());
DecodeStat(fdbr.LStat, &statc, sizeof(statc),
&LinkFIc); /* decode catalog stat */
/*
@@ -689,7 +696,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
_(" st_ino differ. Cat: %s File: %s\n"),
edit_uint64((uint64_t)statc.st_ino, ed1),
edit_uint64((uint64_t)statf.st_ino, ed2));
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
break;
case 'p': /* permissions bits */
@@ -698,7 +705,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
Jmsg(jcr, M_INFO, 0,
_(" st_mode differ. Cat: %x File: %x\n"),
(uint32_t)statc.st_mode, (uint32_t)statf.st_mode);
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
break;
case 'n': /* number of links */
@@ -707,7 +714,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
Jmsg(jcr, M_INFO, 0,
_(" st_nlink differ. Cat: %d File: %d\n"),
(uint32_t)statc.st_nlink, (uint32_t)statf.st_nlink);
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
break;
case 'u': /* user id */
@@ -716,7 +723,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
Jmsg(jcr, M_INFO, 0,
_(" st_uid differ. Cat: %u File: %u\n"),
(uint32_t)statc.st_uid, (uint32_t)statf.st_uid);
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
break;
case 'g': /* group id */
@@ -725,7 +732,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
Jmsg(jcr, M_INFO, 0,
_(" st_gid differ. Cat: %u File: %u\n"),
(uint32_t)statc.st_gid, (uint32_t)statf.st_gid);
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
break;
case 's': /* size */
@@ -735,28 +742,28 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
_(" st_size differ. Cat: %s File: %s\n"),
edit_uint64((uint64_t)statc.st_size, ed1),
edit_uint64((uint64_t)statf.st_size, ed2));
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
break;
case 'a': /* access time */
if (statc.st_atime != statf.st_atime) {
PrtFname(jcr);
Jmsg(jcr, M_INFO, 0, _(" st_atime differs\n"));
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
break;
case 'm':
if (statc.st_mtime != statf.st_mtime) {
PrtFname(jcr);
Jmsg(jcr, M_INFO, 0, _(" st_mtime differs\n"));
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
break;
case 'c': /* ctime */
if (statc.st_ctime != statf.st_ctime) {
PrtFname(jcr);
Jmsg(jcr, M_INFO, 0, _(" st_ctime differs\n"));
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
break;
case 'd': /* file size decrease */
@@ -766,11 +773,11 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
_(" st_size decrease. Cat: %s File: %s\n"),
edit_uint64((uint64_t)statc.st_size, ed1),
edit_uint64((uint64_t)statf.st_size, ed2));
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
break;
case '5': /* compare MD5 */
- Dmsg1(500, "set Do_MD5 for %s\n", jcr->impl->fname);
+ Dmsg1(500, "set Do_MD5 for %s\n", jcr->dir_impl->fname);
do_Digest = CRYPTO_DIGEST_MD5;
break;
case '1': /* compare SHA1 */
@@ -785,7 +792,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
break;
case STREAM_RESTORE_OBJECT:
- Dmsg1(400, "RESTORE_OBJECT %s\n", jcr->impl->fname);
+ Dmsg1(400, "RESTORE_OBJECT %s\n", jcr->dir_impl->fname);
break;
default:
@@ -800,10 +807,10 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
* When ever we get a digest it MUST have been
* preceded by an attributes record, which sets attr_file_index
*/
- if (jcr->impl->FileIndex != (uint32_t)file_index) {
+ if (jcr->dir_impl->FileIndex != (uint32_t)file_index) {
Jmsg2(jcr, M_FATAL, 0,
_("MD5/SHA1 index %d not same as attributes %d\n"),
- file_index, jcr->impl->FileIndex);
+ file_index, jcr->dir_impl->FileIndex);
goto bail_out;
}
if (do_Digest != CRYPTO_DIGEST_NONE) {
@@ -813,7 +820,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
PrtFname(jcr);
Jmsg(jcr, M_INFO, 0, _(" %s differs. File=%s Cat=%s\n"),
stream_to_ascii(stream), buf.c_str(), fdbr.Digest);
- jcr->setJobStatus(JS_Differences);
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
}
do_Digest = CRYPTO_DIGEST_NONE;
}
@@ -834,7 +841,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
/* Now find all the files that are missing -- i.e. all files in
* the database where the MarkId != current JobId
*/
- jcr->impl->fn_printed = false;
+ jcr->dir_impl->fn_printed = false;
Mmsg(buf,
"SELECT Path.Path,File.Name FROM File,Path "
"WHERE File.JobId=%d AND File.FileIndex > 0 "
@@ -842,7 +849,9 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId)
JobId, jcr->JobId);
/* MissingHandler is called for each file found */
jcr->db->SqlQuery(buf.c_str(), MissingHandler, (void*)jcr);
- if (jcr->impl->fn_printed) { jcr->setJobStatus(JS_Differences); }
+ if (jcr->dir_impl->fn_printed) {
+ jcr->setJobStatusWithPriorityCheck(JS_Differences);
+ }
bail_out:
FreePoolMemory(fname);
@@ -859,12 +868,12 @@ static int MissingHandler(void* ctx, int, char** row)
JobControlRecord* jcr = (JobControlRecord*)ctx;
if (JobCanceled(jcr)) { return 1; }
- if (!jcr->impl->fn_printed) {
+ if (!jcr->dir_impl->fn_printed) {
Qmsg(jcr, M_WARNING, 0,
_("The following files are in the Catalog but not on %s:\n"),
jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG ? "the Volume(s)"
: "disk");
- jcr->impl->fn_printed = true;
+ jcr->dir_impl->fn_printed = true;
}
Qmsg(jcr, M_INFO, 0, " %s%s\n", row[0] ? row[0] : "",
row[1] ? row[1] : "");
@@ -874,9 +883,9 @@ static int MissingHandler(void* ctx, int, char** row)
// Print filename for verify
static void PrtFname(JobControlRecord* jcr)
{
- if (!jcr->impl->fn_printed) {
- Jmsg(jcr, M_INFO, 0, _("File: %s\n"), jcr->impl->fname);
- jcr->impl->fn_printed = true;
+ if (!jcr->dir_impl->fn_printed) {
+ Jmsg(jcr, M_INFO, 0, _("File: %s\n"), jcr->dir_impl->fname);
+ jcr->dir_impl->fn_printed = true;
}
}
} /* namespace directordaemon */
diff --git a/core/src/droplet/CMakeLists.txt b/core/src/droplet/CMakeLists.txt
index 42f33fceb..6ccbceec2 100644
--- a/core/src/droplet/CMakeLists.txt
+++ b/core/src/droplet/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOSĀ® - Backup Archiving REcovery Open Sourced
#
-# Copyright (C) 2020-2020 Bareos GmbH & Co. KG
+# Copyright (C) 2020-2022 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
@@ -21,7 +21,6 @@ message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "Try to configure LibDroplet")
list(APPEND CMAKE_MESSAGE_INDENT " ")
-cmake_minimum_required(VERSION 3.0)
project(droplet C)
set(default_build_type "Debug")
diff --git a/core/src/droplet/libdroplet/CMakeLists.txt b/core/src/droplet/libdroplet/CMakeLists.txt
index 9ff8108fd..52792cbc8 100644
--- a/core/src/droplet/libdroplet/CMakeLists.txt
+++ b/core/src/droplet/libdroplet/CMakeLists.txt
@@ -18,10 +18,8 @@
# 02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
-cmake_minimum_required(VERSION 3.0)
-
add_library(
- droplet SHARED
+ droplet STATIC
src/conn.c
src/converters.c
src/value.c
@@ -112,6 +110,7 @@ bareos_disable_warnings(
C_ONLY
ADD_FOR_LTO
)
+set_property(TARGET droplet PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(
droplet PUBLIC include ${LIBXML2_INCLUDE_DIR} ${JSONC_INCLUDE_DIRS}
@@ -120,5 +119,3 @@ target_include_directories(
target_link_libraries(
droplet ${LIBXML2_LIBRARIES} ${JSONC_LIBRARIES} ${OPENSSL_LIBRARIES}
)
-
-install(TARGETS droplet DESTINATION ${libdir})
diff --git a/core/src/fastlz/CMakeLists.txt b/core/src/fastlz/CMakeLists.txt
index 57e4c425c..4bffee628 100644
--- a/core/src/fastlz/CMakeLists.txt
+++ b/core/src/fastlz/CMakeLists.txt
@@ -17,7 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
-cmake_minimum_required(VERSION 3.0)
project(bareosfastlz LANGUAGES C)
add_library(
diff --git a/core/src/filed/accurate.cc b/core/src/filed/accurate.cc
index e6b611cd3..a169418d9 100644
--- a/core/src/filed/accurate.cc
+++ b/core/src/filed/accurate.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
Copyright (C) 2013-2014 Planets Communications B.V.
- Copyright (C) 2013-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -25,7 +25,7 @@
#include "filed/filed.h"
#include "filed/accurate.h"
#include "filed/filed_globals.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "filed/verify.h"
#include "lib/attribs.h"
#include "lib/bsock.h"
@@ -39,11 +39,11 @@ bool AccurateMarkFileAsSeen(JobControlRecord* jcr, char* fname)
{
accurate_payload* temp;
- if (!jcr->accurate || !jcr->impl->file_list) { return false; }
+ if (!jcr->accurate || !jcr->fd_impl->file_list) { return false; }
- temp = jcr->impl->file_list->lookup_payload(fname);
+ temp = jcr->fd_impl->file_list->lookup_payload(fname);
if (temp) {
- jcr->impl->file_list->MarkFileAsSeen(temp);
+ jcr->fd_impl->file_list->MarkFileAsSeen(temp);
Dmsg1(debuglevel, "marked <%s> as seen\n", fname);
} else {
Dmsg1(debuglevel, "<%s> not found to be marked as seen\n", fname);
@@ -56,11 +56,11 @@ bool accurate_unMarkFileAsSeen(JobControlRecord* jcr, char* fname)
{
accurate_payload* temp;
- if (!jcr->accurate || !jcr->impl->file_list) { return false; }
+ if (!jcr->accurate || !jcr->fd_impl->file_list) { return false; }
- temp = jcr->impl->file_list->lookup_payload(fname);
+ temp = jcr->fd_impl->file_list->lookup_payload(fname);
if (temp) {
- jcr->impl->file_list->UnmarkFileAsSeen(temp);
+ jcr->fd_impl->file_list->UnmarkFileAsSeen(temp);
Dmsg1(debuglevel, "unmarked <%s> as seen\n", fname);
} else {
Dmsg1(debuglevel, "<%s> not found to be unmarked as seen\n", fname);
@@ -71,17 +71,17 @@ bool accurate_unMarkFileAsSeen(JobControlRecord* jcr, char* fname)
bool AccurateMarkAllFilesAsSeen(JobControlRecord* jcr)
{
- if (!jcr->accurate || !jcr->impl->file_list) { return false; }
+ if (!jcr->accurate || !jcr->fd_impl->file_list) { return false; }
- jcr->impl->file_list->MarkAllFilesAsSeen();
+ jcr->fd_impl->file_list->MarkAllFilesAsSeen();
return true;
}
bool accurate_unMarkAllFilesAsSeen(JobControlRecord* jcr)
{
- if (!jcr->accurate || !jcr->impl->file_list) { return false; }
+ if (!jcr->accurate || !jcr->fd_impl->file_list) { return false; }
- jcr->impl->file_list->UnmarkAllFilesAsSeen();
+ jcr->fd_impl->file_list->UnmarkAllFilesAsSeen();
return true;
}
@@ -91,7 +91,7 @@ static inline bool AccurateLookup(JobControlRecord* jcr,
{
bool found = false;
- *payload = jcr->impl->file_list->lookup_payload(fname);
+ *payload = jcr->fd_impl->file_list->lookup_payload(fname);
if (*payload) {
found = true;
Dmsg1(debuglevel, "lookup <%s> ok\n", fname);
@@ -102,9 +102,9 @@ static inline bool AccurateLookup(JobControlRecord* jcr,
void AccurateFree(JobControlRecord* jcr)
{
- if (jcr->impl->file_list) {
- delete jcr->impl->file_list;
- jcr->impl->file_list = NULL;
+ if (jcr->fd_impl->file_list) {
+ delete jcr->fd_impl->file_list;
+ jcr->fd_impl->file_list = NULL;
}
}
@@ -118,19 +118,19 @@ bool AccurateFinish(JobControlRecord* jcr)
return retval;
}
- if (jcr->accurate && jcr->impl->file_list) {
+ if (jcr->accurate && jcr->fd_impl->file_list) {
if (jcr->is_JobLevel(L_FULL)) {
if (!jcr->rerunning) {
- retval = jcr->impl->file_list->SendBaseFileList();
+ retval = jcr->fd_impl->file_list->SendBaseFileList();
}
} else {
- retval = jcr->impl->file_list->SendDeletedList();
+ retval = jcr->fd_impl->file_list->SendDeletedList();
}
AccurateFree(jcr);
if (jcr->is_JobLevel(L_FULL)) {
Jmsg(jcr, M_INFO, 0, _("Space saved with Base jobs: %lld MB\n"),
- jcr->impl->base_size / (1024 * 1024));
+ jcr->fd_impl->base_size / (1024 * 1024));
}
}
@@ -160,7 +160,7 @@ bool AccurateCheckFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt)
if (!jcr->accurate && !jcr->rerunning) { return true; }
- if (!jcr->impl->file_list) { return true; /** Not initialized properly */ }
+ if (!jcr->fd_impl->file_list) { return true; /** Not initialized properly */ }
// Apply path stripping for lookup in accurate data.
StripPath(ff_pkt);
@@ -316,11 +316,11 @@ bool AccurateCheckFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt)
if (jcr->getJobLevel() == L_FULL) {
if (!status) {
// Compute space saved with basefile.
- jcr->impl->base_size += ff_pkt->statp.st_size;
- jcr->impl->file_list->MarkFileAsSeen(payload);
+ jcr->fd_impl->base_size += ff_pkt->statp.st_size;
+ jcr->fd_impl->file_list->MarkFileAsSeen(payload);
}
} else {
- jcr->impl->file_list->MarkFileAsSeen(payload);
+ jcr->fd_impl->file_list->MarkFileAsSeen(payload);
}
bail_out:
@@ -346,18 +346,18 @@ bool AccurateCmd(JobControlRecord* jcr)
if (me->always_use_lmdb
|| (me->lmdb_threshold > 0
&& number_of_previous_files >= me->lmdb_threshold)) {
- jcr->impl->file_list
+ jcr->fd_impl->file_list
= new BareosAccurateFilelistLmdb(jcr, number_of_previous_files);
} else {
- jcr->impl->file_list
+ jcr->fd_impl->file_list
= new BareosAccurateFilelistHtable(jcr, number_of_previous_files);
}
#else
- jcr->impl->file_list
+ jcr->fd_impl->file_list
= new BareosAccurateFilelistHtable(jcr, number_of_previous_files);
#endif
- if (!jcr->impl->file_list->init()) { return false; }
+ if (!jcr->fd_impl->file_list->init()) { return false; }
jcr->accurate = true;
@@ -388,11 +388,11 @@ bool AccurateCmd(JobControlRecord* jcr)
}
}
- jcr->impl->file_list->AddFile(fname, fname_length, lstat, lstat_length,
- chksum, chksum_length, delta_seq);
+ jcr->fd_impl->file_list->AddFile(fname, fname_length, lstat, lstat_length,
+ chksum, chksum_length, delta_seq);
}
- if (!jcr->impl->file_list->EndLoad()) { return false; }
+ if (!jcr->fd_impl->file_list->EndLoad()) { return false; }
return true;
}
diff --git a/core/src/filed/authenticate.cc b/core/src/filed/authenticate.cc
index 4cf0b3a7d..570e45d64 100644
--- a/core/src/filed/authenticate.cc
+++ b/core/src/filed/authenticate.cc
@@ -29,7 +29,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "filed/restore.h"
#include "lib/bnet.h"
#include "lib/bsock.h"
@@ -146,7 +146,7 @@ bool AuthenticateDirector(JobControlRecord* jcr)
return false;
}
- jcr->impl->director = director;
+ jcr->fd_impl->director = director;
return dir->fsend("%s", (me->compatible) ? OK_hello_compat : OK_hello);
}
diff --git a/core/src/filed/backup.cc b/core/src/filed/backup.cc
index 371bb32c3..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
@@ -105,7 +105,7 @@ bool BlastDataToStorageDaemon(JobControlRecord* jcr,
sd = jcr->store_bsock;
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
Dmsg1(300, "filed: opened data connection %d to stored\n", sd->fd_);
@@ -120,7 +120,7 @@ bool BlastDataToStorageDaemon(JobControlRecord* jcr,
buf_size = 0; /* use default */
}
if (!sd->SetBufferSize(buf_size, BNET_SETBUF_WRITE)) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
Jmsg(jcr, M_FATAL, 0, _("Cannot set buffer size FD->SD.\n"));
return false;
}
@@ -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->setJobStatus(JS_ErrorTerminated);
+ 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,12 +1212,12 @@ 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
if (hangup && (jcr->JobFiles > (uint32_t)hangup)) {
- jcr->setJobStatus(JS_Incomplete);
+ jcr->setJobStatusWithPriorityCheck(JS_Incomplete);
Jmsg1(jcr, M_FATAL, 0, "Debug hangup requested after %d files.\n", hangup);
SetHangup(0);
return false;
@@ -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;
diff --git a/core/src/filed/compression.cc b/core/src/filed/compression.cc
index de1bea4f8..cc73d821d 100644
--- a/core/src/filed/compression.cc
+++ b/core/src/filed/compression.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -32,7 +32,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#if defined(HAVE_LIBZ)
# include <zlib.h>
@@ -45,7 +45,7 @@ namespace filedaemon {
// For compression we enable all used compressors in the fileset.
bool AdjustCompressionBuffers(JobControlRecord* jcr)
{
- findFILESET* fileset = jcr->impl->ff->fileset;
+ findFILESET* fileset = jcr->fd_impl->ff->fileset;
uint32_t compress_buf_size = 0;
if (fileset) {
@@ -166,7 +166,7 @@ bool SetupCompressionContext(b_ctx& bctx)
!= Z_OK) {
Jmsg(bctx.jcr, M_FATAL, 0,
_("Compression deflateParams error: %d\n"), zstat);
- bctx.jcr->setJobStatus(JS_ErrorTerminated);
+ bctx.jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
goto bail_out;
}
}
@@ -203,7 +203,7 @@ bool SetupCompressionContext(b_ctx& bctx)
!= Z_OK) {
Jmsg(bctx.jcr, M_FATAL, 0,
_("Compression fastlzlibSetCompressor error: %d\n"), zstat);
- bctx.jcr->setJobStatus(JS_ErrorTerminated);
+ bctx.jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
goto bail_out;
}
}
diff --git a/core/src/filed/crypto.cc b/core/src/filed/crypto.cc
index e07f3410f..73fd0beba 100644
--- a/core/src/filed/crypto.cc
+++ b/core/src/filed/crypto.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -31,7 +31,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "filed/restore.h"
#include "findlib/find_one.h"
#include "lib/bsock.h"
@@ -62,13 +62,13 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher)
* structure. We use a single session key for each backup, so we'll encode
* the session data only once.
*/
- if (jcr->impl->crypto.pki_encrypt) {
+ if (jcr->fd_impl->crypto.pki_encrypt) {
uint32_t size = 0;
// Create per-job session encryption context
- jcr->impl->crypto.pki_session
- = crypto_session_new(cipher, jcr->impl->crypto.pki_recipients);
- if (!jcr->impl->crypto.pki_session) {
+ jcr->fd_impl->crypto.pki_session
+ = crypto_session_new(cipher, jcr->fd_impl->crypto.pki_recipients);
+ if (!jcr->fd_impl->crypto.pki_session) {
Jmsg(jcr, M_FATAL, 0,
_("Cannot create a new crypto session probably unsupported cipher "
"configured.\n"));
@@ -76,7 +76,7 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher)
}
// Get the session data size
- if (!CryptoSessionEncode(jcr->impl->crypto.pki_session, (uint8_t*)0,
+ if (!CryptoSessionEncode(jcr->fd_impl->crypto.pki_session, (uint8_t*)0,
&size)) {
Jmsg(jcr, M_FATAL, 0,
_("An error occurred while encrypting the stream.\n"));
@@ -84,11 +84,11 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher)
}
// Allocate buffer
- jcr->impl->crypto.pki_session_encoded = GetMemory(size);
+ jcr->fd_impl->crypto.pki_session_encoded = GetMemory(size);
// Encode session data
- if (!CryptoSessionEncode(jcr->impl->crypto.pki_session,
- (uint8_t*)jcr->impl->crypto.pki_session_encoded,
+ if (!CryptoSessionEncode(jcr->fd_impl->crypto.pki_session,
+ (uint8_t*)jcr->fd_impl->crypto.pki_session_encoded,
&size)) {
Jmsg(jcr, M_FATAL, 0,
_("An error occurred while encrypting the stream.\n"));
@@ -96,10 +96,10 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher)
}
// ... and store the encoded size
- jcr->impl->crypto.pki_session_encoded_size = size;
+ jcr->fd_impl->crypto.pki_session_encoded_size = size;
// Allocate the encryption/decryption buffer
- jcr->impl->crypto.crypto_buf = GetMemory(CRYPTO_CIPHER_MAX_BLOCK_SIZE);
+ jcr->fd_impl->crypto.crypto_buf = GetMemory(CRYPTO_CIPHER_MAX_BLOCK_SIZE);
}
return true;
@@ -107,16 +107,16 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher)
void CryptoSessionEnd(JobControlRecord* jcr)
{
- if (jcr->impl->crypto.crypto_buf) {
- FreePoolMemory(jcr->impl->crypto.crypto_buf);
- jcr->impl->crypto.crypto_buf = NULL;
+ if (jcr->fd_impl->crypto.crypto_buf) {
+ FreePoolMemory(jcr->fd_impl->crypto.crypto_buf);
+ jcr->fd_impl->crypto.crypto_buf = NULL;
}
- if (jcr->impl->crypto.pki_session) {
- CryptoSessionFree(jcr->impl->crypto.pki_session);
+ if (jcr->fd_impl->crypto.pki_session) {
+ CryptoSessionFree(jcr->fd_impl->crypto.pki_session);
}
- if (jcr->impl->crypto.pki_session_encoded) {
- FreePoolMemory(jcr->impl->crypto.pki_session_encoded);
- jcr->impl->crypto.pki_session_encoded = NULL;
+ if (jcr->fd_impl->crypto.pki_session_encoded) {
+ FreePoolMemory(jcr->fd_impl->crypto.pki_session_encoded);
+ jcr->fd_impl->crypto.pki_session_encoded = NULL;
}
}
@@ -130,8 +130,8 @@ bool CryptoSessionSend(JobControlRecord* jcr, BareosSocket* sd)
sd->fsend("%ld %d 0", jcr->JobFiles, STREAM_ENCRYPTED_SESSION_DATA);
msgsave = sd->msg;
- sd->msg = jcr->impl->crypto.pki_session_encoded;
- sd->message_length = jcr->impl->crypto.pki_session_encoded_size;
+ sd->msg = jcr->fd_impl->crypto.pki_session_encoded;
+ sd->message_length = jcr->fd_impl->crypto.pki_session_encoded_size;
jcr->JobBytes += sd->message_length;
Dmsg1(100, "Send data len=%d\n", sd->message_length);
@@ -159,46 +159,47 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx)
crypto_digest_t algorithm;
SIGNATURE* sig = rctx.sig;
- if (!jcr->impl->crypto.pki_sign) {
+ if (!jcr->fd_impl->crypto.pki_sign) {
// no signature OK
return true;
}
if (!sig) {
if (rctx.type == FT_REGE || rctx.type == FT_REG || rctx.type == FT_RAW) {
Jmsg1(jcr, M_ERROR, 0, _("Missing cryptographic signature for %s\n"),
- jcr->impl->last_fname);
+ jcr->fd_impl->last_fname);
goto bail_out;
}
return true;
}
// Iterate through the trusted signers
- foreach_alist (keypair, jcr->impl->crypto.pki_signers) {
- err = CryptoSignGetDigest(sig, jcr->impl->crypto.pki_keypair, algorithm,
+ foreach_alist (keypair, jcr->fd_impl->crypto.pki_signers) {
+ err = CryptoSignGetDigest(sig, jcr->fd_impl->crypto.pki_keypair, algorithm,
&digest);
switch (err) {
case CRYPTO_ERROR_NONE:
Dmsg0(50, "== Got digest\n");
/*
- * We computed jcr->impl_->crypto.digest using signing_algorithm while
- * writing the file. If it is not the same as the algorithm used for
- * this file, punt by releasing the computed algorithm and
- * computing by re-reading the file.
+ * We computed jcr->fd_impl_->crypto.digest using signing_algorithm
+ * while writing the file. If it is not the same as the algorithm used
+ * for this file, punt by releasing the computed algorithm and computing
+ * by re-reading the file.
*/
if (algorithm != signing_algorithm) {
- if (jcr->impl->crypto.digest) {
- CryptoDigestFree(jcr->impl->crypto.digest);
- jcr->impl->crypto.digest = NULL;
+ if (jcr->fd_impl->crypto.digest) {
+ CryptoDigestFree(jcr->fd_impl->crypto.digest);
+ jcr->fd_impl->crypto.digest = NULL;
}
}
- if (jcr->impl->crypto.digest) {
+ if (jcr->fd_impl->crypto.digest) {
// Use digest computed while writing the file to verify the signature
- if ((err = CryptoSignVerify(sig, keypair, jcr->impl->crypto.digest))
+ if ((err
+ = CryptoSignVerify(sig, keypair, jcr->fd_impl->crypto.digest))
!= CRYPTO_ERROR_NONE) {
- Dmsg1(50, "Bad signature on %s\n", jcr->impl->last_fname);
+ Dmsg1(50, "Bad signature on %s\n", jcr->fd_impl->last_fname);
Jmsg2(jcr, M_ERROR, 0,
_("Signature validation failed for file %s: ERR=%s\n"),
- jcr->impl->last_fname, crypto_strerror(err));
+ jcr->fd_impl->last_fname, crypto_strerror(err));
goto bail_out;
}
} else {
@@ -206,18 +207,18 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx)
* Signature found, digest allocated. Old method,
* re-read the file and compute the digest
*/
- jcr->impl->crypto.digest = digest;
+ jcr->fd_impl->crypto.digest = digest;
/*
* Checksum the entire file
* Make sure we don't modify JobBytes by saving and restoring it
*/
saved_bytes = jcr->JobBytes;
- if (FindOneFile(jcr, jcr->impl->ff, DoFileDigest,
- jcr->impl->last_fname, (dev_t)-1, 1)
+ if (FindOneFile(jcr, jcr->fd_impl->ff, DoFileDigest,
+ jcr->fd_impl->last_fname, (dev_t)-1, 1)
!= 0) {
Jmsg(jcr, M_ERROR, 0, _("Digest one file failed for file: %s\n"),
- jcr->impl->last_fname);
+ jcr->fd_impl->last_fname);
jcr->JobBytes = saved_bytes;
goto bail_out;
}
@@ -226,17 +227,17 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx)
// Verify the signature
if ((err = CryptoSignVerify(sig, keypair, digest))
!= CRYPTO_ERROR_NONE) {
- Dmsg1(50, "Bad signature on %s\n", jcr->impl->last_fname);
+ Dmsg1(50, "Bad signature on %s\n", jcr->fd_impl->last_fname);
Jmsg2(jcr, M_ERROR, 0,
_("Signature validation failed for file %s: ERR=%s\n"),
- jcr->impl->last_fname, crypto_strerror(err));
+ jcr->fd_impl->last_fname, crypto_strerror(err));
goto bail_out;
}
- jcr->impl->crypto.digest = NULL;
+ jcr->fd_impl->crypto.digest = NULL;
}
// Valid signature
- Dmsg1(50, "Signature good on %s\n", jcr->impl->last_fname);
+ Dmsg1(50, "Signature good on %s\n", jcr->fd_impl->last_fname);
CryptoDigestFree(digest);
return true;
@@ -250,14 +251,14 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx)
default:
// Something strange happened (that shouldn't happen!)...
Qmsg2(jcr, M_ERROR, 0, _("Signature validation failed for %s: %s\n"),
- jcr->impl->last_fname, crypto_strerror(err));
+ jcr->fd_impl->last_fname, crypto_strerror(err));
goto bail_out;
}
}
// No signer
Dmsg1(50, "Could not find a valid public key for signature on %s\n",
- jcr->impl->last_fname);
+ jcr->fd_impl->last_fname);
bail_out:
if (digest) { CryptoDigestFree(digest); }
@@ -293,7 +294,7 @@ again:
// Writing out the final, buffered block failed. Shouldn't happen.
Jmsg3(jcr, M_ERROR, 0,
_("Decryption error. buf_len=%d decrypt_len=%d on file %s\n"),
- cipher_ctx->buf_len, decrypted_len, jcr->impl->last_fname);
+ cipher_ctx->buf_len, decrypted_len, jcr->fd_impl->last_fname);
}
Dmsg2(130, "Flush decrypt len=%d buf_len=%d\n", decrypted_len,
@@ -320,7 +321,7 @@ again:
}
if (BitIsSet(FO_COMPRESS, flags)) {
- if (!DecompressData(jcr, jcr->impl->last_fname, stream, &wbuf, &wsize,
+ if (!DecompressData(jcr, jcr->fd_impl->last_fname, stream, &wbuf, &wsize,
false)) {
return false;
}
@@ -395,8 +396,8 @@ bool SetupEncryptionContext(b_ctx& bctx)
goto bail_out;
}
// Allocate the cipher context
- if ((bctx.cipher_ctx = crypto_cipher_new(bctx.jcr->impl->crypto.pki_session,
- true, &cipher_block_size))
+ if ((bctx.cipher_ctx = crypto_cipher_new(
+ bctx.jcr->fd_impl->crypto.pki_session, true, &cipher_block_size))
== NULL) {
// Shouldn't happen!
Jmsg0(bctx.jcr, M_FATAL, 0,
@@ -411,15 +412,15 @@ bool SetupEncryptionContext(b_ctx& bctx)
* could be returned for the given read buffer size.
* (Using the larger of either rsize or max_compress_len)
*/
- bctx.jcr->impl->crypto.crypto_buf
- = CheckPoolMemorySize(bctx.jcr->impl->crypto.crypto_buf,
+ bctx.jcr->fd_impl->crypto.crypto_buf
+ = CheckPoolMemorySize(bctx.jcr->fd_impl->crypto.crypto_buf,
(MAX(bctx.jcr->buf_size + (int)sizeof(uint32_t),
(int32_t)bctx.max_compress_len)
+ cipher_block_size - 1)
/ cipher_block_size * cipher_block_size);
bctx.wbuf
- = bctx.jcr->impl->crypto
+ = bctx.jcr->fd_impl->crypto
.crypto_buf; /* Encrypted, possibly compressed output here. */
}
@@ -435,7 +436,7 @@ bool SetupDecryptionContext(r_ctx& rctx, RestoreCipherContext& rcctx)
if (!rctx.cs) {
Jmsg1(rctx.jcr, M_ERROR, 0,
_("Missing encryption session data stream for %s\n"),
- rctx.jcr->impl->last_fname);
+ rctx.jcr->fd_impl->last_fname);
return false;
}
@@ -443,7 +444,7 @@ bool SetupDecryptionContext(r_ctx& rctx, RestoreCipherContext& rcctx)
== NULL) {
Jmsg1(rctx.jcr, M_ERROR, 0,
_("Failed to initialize decryption context for %s\n"),
- rctx.jcr->impl->last_fname);
+ rctx.jcr->fd_impl->last_fname);
FreeSession(rctx);
return false;
}
@@ -484,7 +485,7 @@ bool EncryptData(b_ctx* bctx, bool* need_more_data)
Dmsg1(20, "Encrypt len=%d\n", bctx->cipher_input_len);
if (!CryptoCipherUpdate(bctx->cipher_ctx, packet_len, sizeof(packet_len),
- (uint8_t*)bctx->jcr->impl->crypto.crypto_buf,
+ (uint8_t*)bctx->jcr->fd_impl->crypto.crypto_buf,
&initial_len)) {
// Encryption failed. Shouldn't happen.
Jmsg(bctx->jcr, M_FATAL, 0, _("Encryption error\n"));
@@ -494,7 +495,7 @@ bool EncryptData(b_ctx* bctx, bool* need_more_data)
// Encrypt the input block
if (CryptoCipherUpdate(
bctx->cipher_ctx, bctx->cipher_input, bctx->cipher_input_len,
- (uint8_t*)&bctx->jcr->impl->crypto.crypto_buf[initial_len],
+ (uint8_t*)&bctx->jcr->fd_impl->crypto.crypto_buf[initial_len],
&bctx->encrypted_len)) {
if ((initial_len + bctx->encrypted_len) == 0) {
// No full block of data available, read more data
@@ -529,7 +530,7 @@ bool DecryptData(JobControlRecord* jcr,
ASSERT(cipher_ctx->cipher);
/*
- * NOTE: We must implement block preserving semantics for the
+ * NOTE: We must fd_implement block preserving semantics for the
* non-streaming compression and sparse code.
*
* Grow the crypto buffer, if necessary.
diff --git a/core/src/filed/dir_cmd.cc b/core/src/filed/dir_cmd.cc
index 342c0aee9..5a49052f5 100644
--- a/core/src/filed/dir_cmd.cc
+++ b/core/src/filed/dir_cmd.cc
@@ -36,7 +36,7 @@
#include "filed/evaluate_job_command.h"
#include "filed/heartbeat.h"
#include "filed/fileset.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "filed/socket_server.h"
#include "filed/restore.h"
#include "filed/verify.h"
@@ -68,7 +68,7 @@ extern bool restore_only_mode;
/**
* As Windows saves ACLs as part of the standard backup stream
- * we just pretend here that is has implicit acl support.
+ * we just pretend here that is has fd_implicit acl support.
*/
#if defined(HAVE_ACL) || defined(HAVE_WIN32)
const bool have_acl = true;
@@ -273,7 +273,7 @@ static bool ValidateCommand(JobControlRecord* jcr,
const char* cmd,
alist<const char*>* allowed_job_cmds)
{
- char* allowed_job_cmd = nullptr;
+ const char* allowed_job_cmd = nullptr;
bool allowed = false;
// If there is no explicit list of allowed cmds allow all cmds.
@@ -302,7 +302,7 @@ static inline void CleanupFileset(JobControlRecord* jcr)
findIncludeExcludeItem* incexe;
findFOPTS* fo;
- fileset = jcr->impl->ff->fileset;
+ fileset = jcr->fd_impl->ff->fileset;
if (fileset) {
// Delete FileSet Include lists
for (int i = 0; i < fileset->include_list.size(); i++) {
@@ -363,7 +363,7 @@ static inline void CleanupFileset(JobControlRecord* jcr)
fileset->exclude_list.destroy();
free(fileset);
}
- jcr->impl->ff->fileset = nullptr;
+ jcr->fd_impl->ff->fileset = nullptr;
}
static inline bool AreMaxConcurrentJobsExceeded()
@@ -382,7 +382,7 @@ static inline bool AreMaxConcurrentJobsExceeded()
static JobControlRecord* NewFiledJcr()
{
JobControlRecord* jcr = new_jcr(FiledFreeJcr);
- jcr->impl = new JobControlRecordPrivate;
+ jcr->fd_impl = new FiledJcrImpl;
return jcr;
}
@@ -392,19 +392,19 @@ JobControlRecord* create_new_director_session(BareosSocket* dir)
JobControlRecord* jcr{NewFiledJcr()};
jcr->dir_bsock = dir;
- jcr->impl->ff = init_find_files();
+ jcr->fd_impl->ff = init_find_files();
jcr->start_time = time(nullptr);
- jcr->impl->RunScripts = new alist<RunScript*>(10, not_owned_by_alist);
- jcr->impl->last_fname = GetPoolMemory(PM_FNAME);
- jcr->impl->last_fname[0] = 0;
+ jcr->fd_impl->RunScripts = new alist<RunScript*>(10, not_owned_by_alist);
+ jcr->fd_impl->last_fname = GetPoolMemory(PM_FNAME);
+ jcr->fd_impl->last_fname[0] = 0;
jcr->client_name = GetMemory(strlen(my_name) + 1);
PmStrcpy(jcr->client_name, my_name);
bstrncpy(jcr->Job, jobname, sizeof(jobname)); /* dummy */
- jcr->impl->crypto.pki_sign = me->pki_sign;
- jcr->impl->crypto.pki_encrypt = me->pki_encrypt;
- jcr->impl->crypto.pki_keypair = me->pki_keypair;
- jcr->impl->crypto.pki_signers = me->pki_signers;
- jcr->impl->crypto.pki_recipients = me->pki_recipients;
+ jcr->fd_impl->crypto.pki_sign = me->pki_sign;
+ jcr->fd_impl->crypto.pki_encrypt = me->pki_encrypt;
+ jcr->fd_impl->crypto.pki_keypair = me->pki_keypair;
+ jcr->fd_impl->crypto.pki_signers = me->pki_signers;
+ jcr->fd_impl->crypto.pki_recipients = me->pki_recipients;
if (dir) { dir->SetJcr(jcr); }
SetJcrInThreadSpecificData(jcr);
@@ -436,7 +436,7 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir)
for (int i = 0; cmds[i].cmd; i++) {
if (bstrncmp(cmds[i].cmd, dir->msg, strlen(cmds[i].cmd))) {
found = true; /* indicate command found */
- if ((!cmds[i].monitoraccess) && (jcr->impl->director->monitor)) {
+ if ((!cmds[i].monitoraccess) && (jcr->fd_impl->director->monitor)) {
Dmsg1(100, "Command \"%s\" is invalid.\n", cmds[i].cmd);
dir->fsend(invalid_cmd);
dir->signal(BNET_EOD);
@@ -461,20 +461,21 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir)
if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); }
// Run the after job
- if (jcr->impl->RunScripts) {
- RunScripts(jcr, jcr->impl->RunScripts, "ClientAfterJob",
- (jcr->impl->director && jcr->impl->director->allowed_script_dirs)
- ? jcr->impl->director->allowed_script_dirs
- : me->allowed_script_dirs);
+ if (jcr->fd_impl->RunScripts) {
+ RunScripts(
+ jcr, jcr->fd_impl->RunScripts, "ClientAfterJob",
+ (jcr->fd_impl->director && jcr->fd_impl->director->allowed_script_dirs)
+ ? jcr->fd_impl->director->allowed_script_dirs
+ : me->allowed_script_dirs);
}
if (jcr->JobId) { /* send EndJob if running a job */
char ed1[50], ed2[50];
// Send termination status back to Dir
- dir->fsend(EndJob, jcr->JobStatus, jcr->JobFiles,
+ dir->fsend(EndJob, jcr->getJobStatus(), jcr->JobFiles,
edit_uint64(jcr->ReadBytes, ed1),
edit_uint64(jcr->JobBytes, ed2), jcr->JobErrors,
- jcr->impl->enable_vss, jcr->impl->crypto.pki_encrypt);
+ jcr->fd_impl->enable_vss, jcr->fd_impl->crypto.pki_encrypt);
Dmsg1(110, "End FD msg: %s\n", dir->msg);
}
@@ -486,7 +487,7 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir)
dir->signal(BNET_TERMINATE);
FreePlugins(jcr); /* release instantiated plugins */
- FreeAndNullPoolMemory(jcr->impl->job_metadata);
+ FreeAndNullPoolMemory(jcr->fd_impl->job_metadata);
// Clean up fileset
CleanupFileset(jcr);
@@ -757,7 +758,7 @@ static bool CancelCmd(JobControlRecord* jcr)
dir->fsend(_("2901 Job %s not found.\n"), Job);
} else {
GeneratePluginEvent(cjcr, bEventCancelCommand, nullptr);
- cjcr->setJobStatus(JS_Canceled);
+ cjcr->setJobStatusWithPriorityCheck(JS_Canceled);
if (cjcr->store_bsock) {
cjcr->store_bsock->SetTimedOut();
cjcr->store_bsock->SetTerminated();
@@ -878,14 +879,14 @@ static bool EstimateCmd(JobControlRecord* jcr)
// See if we are allowed to run estimate cmds.
if (!ValidateCommand(
jcr, "estimate",
- (jcr->impl->director && jcr->impl->director->allowed_job_cmds)
- ? jcr->impl->director->allowed_job_cmds
+ (jcr->fd_impl->director && jcr->fd_impl->director->allowed_job_cmds)
+ ? jcr->fd_impl->director->allowed_job_cmds
: me->allowed_job_cmds)) {
dir->fsend(_("2992 Bad estimate command.\n"));
return 0;
}
- if (sscanf(dir->msg, Estimatecmd, &jcr->impl->listing) != 1) {
+ if (sscanf(dir->msg, Estimatecmd, &jcr->fd_impl->listing) != 1) {
PmStrcpy(jcr->errmsg, dir->msg);
Jmsg(jcr, M_FATAL, 0, _("Bad estimate command: %s\n"), jcr->errmsg);
dir->fsend(_("2992 Bad estimate command.\n"));
@@ -894,7 +895,8 @@ static bool EstimateCmd(JobControlRecord* jcr)
MakeEstimate(jcr);
- dir->fsend(OKest, edit_uint64_with_commas(jcr->impl->num_files_examined, ed1),
+ dir->fsend(OKest,
+ edit_uint64_with_commas(jcr->fd_impl->num_files_examined, ed1),
edit_uint64_with_commas(jcr->JobBytes, ed2));
dir->signal(BNET_EOD);
@@ -990,10 +992,11 @@ static bool RunbeforenowCmd(JobControlRecord* jcr)
{
BareosSocket* dir = jcr->dir_bsock;
- RunScripts(jcr, jcr->impl->RunScripts, "ClientBeforeJob",
- (jcr->impl->director && jcr->impl->director->allowed_script_dirs)
- ? jcr->impl->director->allowed_script_dirs
- : me->allowed_script_dirs);
+ RunScripts(
+ jcr, jcr->fd_impl->RunScripts, "ClientBeforeJob",
+ (jcr->fd_impl->director && jcr->fd_impl->director->allowed_script_dirs)
+ ? jcr->fd_impl->director->allowed_script_dirs
+ : me->allowed_script_dirs);
if (JobCanceled(jcr)) {
dir->fsend(FailedRunScript);
@@ -1037,7 +1040,7 @@ static bool RunafterCmd(JobControlRecord* jcr)
script->when = SCRIPT_After;
FreeMemory(cmd);
- jcr->impl->RunScripts->append(script);
+ jcr->fd_impl->RunScripts->append(script);
return dir->fsend(OKRunAfter);
}
@@ -1052,8 +1055,8 @@ static bool RunscriptCmd(JobControlRecord* jcr)
// See if we are allowed to run runscript cmds.
if (!ValidateCommand(
jcr, "runscript",
- (jcr->impl->director && jcr->impl->director->allowed_job_cmds)
- ? jcr->impl->director->allowed_job_cmds
+ (jcr->fd_impl->director && jcr->fd_impl->director->allowed_job_cmds)
+ ? jcr->fd_impl->director->allowed_job_cmds
: me->allowed_job_cmds)) {
dir->fsend(FailedRunScript);
return 0;
@@ -1085,7 +1088,7 @@ static bool RunscriptCmd(JobControlRecord* jcr)
cmd->SetCommand(msg);
cmd->Debug();
- jcr->impl->RunScripts->append(cmd);
+ jcr->fd_impl->RunScripts->append(cmd);
FreePoolMemory(msg);
@@ -1218,7 +1221,7 @@ static bool RestoreObjectCmd(JobControlRecord* jcr)
// We still need to do this to detect a vss restore
if (bstrcmp(rop.object_name, "job_metadata.xml")) {
Dmsg0(100, "got job metadata\n");
- jcr->impl->got_metadata = true;
+ jcr->fd_impl->got_metadata = true;
}
GeneratePluginEvent(jcr, bEventRestoreObject, (void*)&rop);
@@ -1244,7 +1247,7 @@ static inline int CountIncludeListFileEntries(JobControlRecord* jcr)
findFILESET* fileset;
findIncludeExcludeItem* incexe;
- fileset = jcr->impl->ff->fileset;
+ fileset = jcr->fd_impl->ff->fileset;
if (fileset) {
for (int i = 0; i < fileset->include_list.size(); i++) {
incexe = (findIncludeExcludeItem*)fileset->include_list.get(i);
@@ -1278,13 +1281,13 @@ static bool FilesetCmd(JobControlRecord* jcr)
if (!TermFileset(jcr)) { return false; }
#if defined(WIN32_VSS)
- jcr->impl->enable_vss
+ jcr->fd_impl->enable_vss
= (vss && (CountIncludeListFileEntries(jcr) > 0)) ? true : false;
#endif
retval = dir->fsend(OKinc);
GeneratePluginEvent(jcr, bEventEndFileSet);
- CheckIncludeListShadowing(jcr, jcr->impl->ff->fileset);
+ CheckIncludeListShadowing(jcr, jcr->fd_impl->ff->fileset);
return retval;
}
@@ -1332,7 +1335,7 @@ static bool BootstrapCmd(JobControlRecord* jcr)
*/
while (dir->recv() >= 0) {}
FreeBootstrap(jcr);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -1389,7 +1392,7 @@ static bool LevelCmd(JobControlRecord* jcr)
}
if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d prev_job=%127s",
- buf, &mtime_only, jcr->impl->PrevJob)
+ buf, &mtime_only, jcr->fd_impl->PrevJob)
!= 3) {
if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d", buf,
&mtime_only)
@@ -1399,7 +1402,8 @@ static bool LevelCmd(JobControlRecord* jcr)
}
since_time = str_to_uint64(buf); /* this is the since time */
- Dmsg2(100, "since_time=%lld prev_job=%s\n", since_time, jcr->impl->PrevJob);
+ Dmsg2(100, "since_time=%lld prev_job=%s\n", since_time,
+ jcr->fd_impl->PrevJob);
/*
* Sync clocks by polling him for the time. We take 10 samples of his time
* throwing out the first two.
@@ -1445,9 +1449,11 @@ static bool LevelCmd(JobControlRecord* jcr)
dir->signal(BNET_EOD);
Dmsg2(100, "adj=%lld since_time=%lld\n", adj, since_time);
- jcr->impl->incremental = true; /* set incremental or decremental backup */
- jcr->impl->since_time = since_time; /* set since time */
- GeneratePluginEvent(jcr, bEventSince, (void*)(time_t)jcr->impl->since_time);
+ jcr->fd_impl->incremental
+ = true; /* set incremental or decremental backup */
+ jcr->fd_impl->since_time = since_time; /* set since time */
+ GeneratePluginEvent(jcr, bEventSince,
+ (void*)(time_t)jcr->fd_impl->since_time);
} else {
Jmsg1(jcr, M_FATAL, 0, _("Unknown backup level: %s\n"), level);
FreeMemory(level);
@@ -1479,8 +1485,9 @@ static bool SessionCmd(JobControlRecord* jcr)
Dmsg1(100, "SessionCmd: %s", dir->msg);
if (sscanf(dir->msg, sessioncmd, jcr->VolumeName, &jcr->VolSessionId,
- &jcr->VolSessionTime, &jcr->impl->StartFile, &jcr->impl->EndFile,
- &jcr->impl->StartBlock, &jcr->impl->EndBlock)
+ &jcr->VolSessionTime, &jcr->fd_impl->StartFile,
+ &jcr->fd_impl->EndFile, &jcr->fd_impl->StartBlock,
+ &jcr->fd_impl->EndBlock)
!= 7) {
PmStrcpy(jcr->errmsg, dir->msg);
Jmsg(jcr, M_FATAL, 0, _("Bad session command: %s\n"), jcr->errmsg);
@@ -1516,7 +1523,7 @@ static void SetStorageAuthKeyAndTlsPolicy(JobControlRecord* jcr,
* restore
*/
Dmsg0(5, "set multi_restore=true\n");
- jcr->impl->multi_restore = true;
+ jcr->fd_impl->multi_restore = true;
free(jcr->sd_auth_key);
}
@@ -1559,8 +1566,8 @@ static bool StorageCmd(JobControlRecord* jcr)
// TODO: see if we put limit on restore and backup...
if (!jcr->max_bandwidth) {
- if (jcr->impl->director->max_bandwidth_per_job) {
- jcr->max_bandwidth = jcr->impl->director->max_bandwidth_per_job;
+ if (jcr->fd_impl->director->max_bandwidth_per_job) {
+ jcr->max_bandwidth = jcr->fd_impl->director->max_bandwidth_per_job;
} else if (me->max_bandwidth_per_job) {
jcr->max_bandwidth = me->max_bandwidth_per_job;
}
@@ -1622,7 +1629,7 @@ static void LogFlagStatus(JobControlRecord* jcr,
int flag,
const char* flag_text)
{
- findFILESET* fileset = jcr->impl->ff->fileset;
+ findFILESET* fileset = jcr->fd_impl->ff->fileset;
bool found = false;
if (fileset) {
for (int i = 0; i < fileset->include_list.size() && !found; i++) {
@@ -1656,7 +1663,7 @@ static inline void ClearFlagInFileset(JobControlRecord* jcr,
findFILESET* fileset;
bool cleared_flag = false;
- fileset = jcr->impl->ff->fileset;
+ fileset = jcr->fd_impl->ff->fileset;
if (fileset) {
for (int i = 0; i < fileset->include_list.size(); i++) {
findIncludeExcludeItem* incexe
@@ -1686,7 +1693,7 @@ static inline void ClearCompressionFlagInFileset(JobControlRecord* jcr)
{
findFILESET* fileset;
- fileset = jcr->impl->ff->fileset;
+ fileset = jcr->fd_impl->ff->fileset;
if (fileset) {
for (int i = 0; i < fileset->include_list.size(); i++) {
findIncludeExcludeItem* incexe
@@ -1742,7 +1749,7 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr,
* Walk the fileset and check for the FO_FORCE_ENCRYPT flag and any forced
* crypto cipher.
*/
- fileset = jcr->impl->ff->fileset;
+ fileset = jcr->fd_impl->ff->fileset;
if (fileset) {
for (int i = 0; i < fileset->include_list.size(); i++) {
findIncludeExcludeItem* incexe
@@ -1762,7 +1769,7 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr,
}
// See if pki_encrypt is already set for this Job.
- if (!jcr->impl->crypto.pki_encrypt) {
+ if (!jcr->fd_impl->crypto.pki_encrypt) {
if (!me->pki_keypair_file) {
Jmsg(jcr, M_FATAL, 0,
_("Fileset contains cipher settings but PKI Key Pair is not "
@@ -1771,8 +1778,8 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr,
}
// Enable encryption and signing for this Job.
- jcr->impl->crypto.pki_sign = true;
- jcr->impl->crypto.pki_encrypt = true;
+ jcr->fd_impl->crypto.pki_sign = true;
+ jcr->fd_impl->crypto.pki_encrypt = true;
}
wanted_cipher = (crypto_cipher_t)fo->Encryption_cipher;
@@ -1794,7 +1801,7 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr,
* See if FO_FORCE_ENCRYPT is set and encryption is not configured for the
* filed.
*/
- if (force_encrypt && !jcr->impl->crypto.pki_encrypt) {
+ if (force_encrypt && !jcr->fd_impl->crypto.pki_encrypt) {
Jmsg(jcr, M_FATAL, 0,
_("Fileset forces encryption but encryption is not configured\n"));
return false;
@@ -1829,14 +1836,14 @@ static bool BackupCmd(JobControlRecord* jcr)
// See if we are allowed to run backup cmds.
if (!ValidateCommand(
jcr, "backup",
- (jcr->impl->director && jcr->impl->director->allowed_job_cmds)
- ? jcr->impl->director->allowed_job_cmds
+ (jcr->fd_impl->director && jcr->fd_impl->director->allowed_job_cmds)
+ ? jcr->fd_impl->director->allowed_job_cmds
: me->allowed_job_cmds)) {
goto cleanup;
}
#if defined(WIN32_VSS)
- if (jcr->impl->enable_vss) { VSSInit(jcr); }
+ if (jcr->fd_impl->enable_vss) { VSSInit(jcr); }
#endif
if (sscanf(dir->msg, "backup FileIndex=%ld\n", &FileIndex) == 1) {
@@ -1878,9 +1885,9 @@ static bool BackupCmd(JobControlRecord* jcr)
goto cleanup;
}
- jcr->setJobStatus(JS_Blocked);
+ jcr->setJobStatusWithPriorityCheck(JS_Blocked);
jcr->setJobType(JT_BACKUP);
- Dmsg1(100, "begin backup ff=%p\n", jcr->impl->ff);
+ Dmsg1(100, "begin backup ff=%p\n", jcr->fd_impl->ff);
if (sd == nullptr) {
Jmsg(jcr, M_FATAL, 0, _("Cannot contact Storage daemon\n"));
@@ -1898,18 +1905,18 @@ static bool BackupCmd(JobControlRecord* jcr)
// Expect to receive back the Ticket number
if (BgetMsg(sd) >= 0) {
Dmsg1(110, "<stored: %s", sd->msg);
- if (sscanf(sd->msg, OK_open, &jcr->impl->Ticket) != 1) {
+ if (sscanf(sd->msg, OK_open, &jcr->fd_impl->Ticket) != 1) {
Jmsg(jcr, M_FATAL, 0, _("Bad response to append open: %s\n"), sd->msg);
goto cleanup;
}
- Dmsg1(110, "Got Ticket=%d\n", jcr->impl->Ticket);
+ Dmsg1(110, "Got Ticket=%d\n", jcr->fd_impl->Ticket);
} else {
Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to open command\n"));
goto cleanup;
}
// Send Append data command to Storage daemon
- sd->fsend(append_data, jcr->impl->Ticket);
+ sd->fsend(append_data, jcr->fd_impl->Ticket);
Dmsg1(110, ">stored: %s", sd->msg);
// Expect to get OK data
@@ -1923,8 +1930,8 @@ static bool BackupCmd(JobControlRecord* jcr)
#if defined(WIN32_VSS)
// START VSS ON WIN32
- if (jcr->impl->pVSSClient) {
- if (jcr->impl->pVSSClient->InitializeForBackup(jcr)) {
+ if (jcr->fd_impl->pVSSClient) {
+ if (jcr->fd_impl->pVSSClient->InitializeForBackup(jcr)) {
int drive_count;
char szWinDriveLetters[27];
bool onefs_disabled;
@@ -1937,19 +1944,19 @@ static bool BackupCmd(JobControlRecord* jcr)
// Plugin driver can return drive letters
GeneratePluginEvent(jcr, bEventVssPrepareSnapshot, szWinDriveLetters);
- drive_count
- = get_win32_driveletters(jcr->impl->ff->fileset, szWinDriveLetters);
+ drive_count = get_win32_driveletters(jcr->fd_impl->ff->fileset,
+ szWinDriveLetters);
- onefs_disabled = win32_onefs_is_disabled(jcr->impl->ff->fileset);
+ onefs_disabled = win32_onefs_is_disabled(jcr->fd_impl->ff->fileset);
if (drive_count > 0) {
Jmsg(jcr, M_INFO, 0,
_("Generate VSS snapshots. Driver=\"%s\", Drive(s)=\"%s\"\n"),
- jcr->impl->pVSSClient->GetDriverName(),
+ jcr->fd_impl->pVSSClient->GetDriverName(),
(drive_count) ? szWinDriveLetters : "None");
- if (!jcr->impl->pVSSClient->CreateSnapshots(szWinDriveLetters,
- onefs_disabled)) {
+ if (!jcr->fd_impl->pVSSClient->CreateSnapshots(szWinDriveLetters,
+ onefs_disabled)) {
BErrNo be;
Jmsg(jcr, M_FATAL, 0,
_("CreateSGenerate VSS snapshots failed. ERR=%s\n"),
@@ -1958,7 +1965,7 @@ static bool BackupCmd(JobControlRecord* jcr)
GeneratePluginEvent(jcr, bEventVssCreateSnapshots);
// Inform about VMPs if we have them
- jcr->impl->pVSSClient->ShowVolumeMountPointStats(jcr);
+ jcr->fd_impl->pVSSClient->ShowVolumeMountPointStats(jcr);
// Tell user if snapshot creation of a specific drive failed
for (int i = 0; i < (int)strlen(szWinDriveLetters); i++) {
@@ -1970,10 +1977,11 @@ static bool BackupCmd(JobControlRecord* jcr)
}
// Inform user about writer states
- for (size_t i = 0; i < jcr->impl->pVSSClient->GetWriterCount(); i++) {
- if (jcr->impl->pVSSClient->GetWriterState(i) < 1) {
+ for (size_t i = 0; i < jcr->fd_impl->pVSSClient->GetWriterCount();
+ i++) {
+ if (jcr->fd_impl->pVSSClient->GetWriterState(i) < 1) {
Jmsg(jcr, M_INFO, 0, _("VSS Writer (PrepareForBackup): %s\n"),
- jcr->impl->pVSSClient->GetWriterInfo(i));
+ jcr->fd_impl->pVSSClient->GetWriterInfo(i));
}
}
}
@@ -1989,21 +1997,22 @@ static bool BackupCmd(JobControlRecord* jcr)
be.bstrerror());
}
- RunScripts(jcr, jcr->impl->RunScripts, "ClientAfterVSS",
- (jcr->impl->director && jcr->impl->director->allowed_script_dirs)
- ? jcr->impl->director->allowed_script_dirs
- : me->allowed_script_dirs);
+ RunScripts(
+ jcr, jcr->fd_impl->RunScripts, "ClientAfterVSS",
+ (jcr->fd_impl->director && jcr->fd_impl->director->allowed_script_dirs)
+ ? jcr->fd_impl->director->allowed_script_dirs
+ : me->allowed_script_dirs);
}
#endif
// Send Files to Storage daemon
- Dmsg1(110, "begin blast ff=%p\n", (FindFilesPacket*)jcr->impl->ff);
+ Dmsg1(110, "begin blast ff=%p\n", (FindFilesPacket*)jcr->fd_impl->ff);
if (!BlastDataToStorageDaemon(jcr, nullptr, cipher)) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
BnetSuppressErrorMessages(sd, 1);
Dmsg0(110, "Error in blast_data.\n");
} else {
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
/* Note, the above set status will not override an error */
if (!jcr->IsTerminatedOk()) {
BnetSuppressErrorMessages(sd, 1);
@@ -2011,20 +2020,20 @@ static bool BackupCmd(JobControlRecord* jcr)
}
// Expect to get response to append_data from Storage daemon
if (!response(jcr, sd, OK_append, "Append Data")) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
goto cleanup;
}
// Send Append End Data to Storage daemon
- sd->fsend(append_end, jcr->impl->Ticket);
+ sd->fsend(append_end, jcr->fd_impl->Ticket);
/* Get end OK */
if (!response(jcr, sd, OK_end, "Append End")) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
goto cleanup;
}
// Send Append Close to Storage daemon
- sd->fsend(append_close, jcr->impl->Ticket);
+ sd->fsend(append_close, jcr->fd_impl->Ticket);
while (BgetMsg(sd) >= 0) { /* stop on signal or error */
if (sscanf(sd->msg, OK_close, &SDJobStatus) == 1) {
ok = 1;
@@ -2043,7 +2052,9 @@ static bool BackupCmd(JobControlRecord* jcr)
cleanup:
#if defined(WIN32_VSS)
- if (jcr->impl->pVSSClient) { jcr->impl->pVSSClient->DestroyWriterInfo(); }
+ if (jcr->fd_impl->pVSSClient) {
+ jcr->fd_impl->pVSSClient->DestroyWriterInfo();
+ }
#endif
GeneratePluginEvent(jcr, bEventEndBackupJob);
@@ -2063,8 +2074,8 @@ static bool VerifyCmd(JobControlRecord* jcr)
// See if we are allowed to run verify cmds.
if (!ValidateCommand(
jcr, "verify",
- (jcr->impl->director && jcr->impl->director->allowed_job_cmds)
- ? jcr->impl->director->allowed_job_cmds
+ (jcr->fd_impl->director && jcr->fd_impl->director->allowed_job_cmds)
+ ? jcr->fd_impl->director->allowed_job_cmds
: me->allowed_job_cmds)) {
dir->fsend(_("2994 Bad verify command: %s\n"), dir->msg);
return 0;
@@ -2109,7 +2120,7 @@ static bool VerifyCmd(JobControlRecord* jcr)
DoVerifyVolume(jcr);
StopDirHeartbeat(jcr);
// Send Close session command to Storage daemon
- sd->fsend(read_close, jcr->impl->Ticket);
+ sd->fsend(read_close, jcr->fd_impl->Ticket);
Dmsg1(130, "filed>stored: %s", sd->msg);
/* ****FIXME**** check response */
@@ -2185,7 +2196,7 @@ static BareosSocket* connect_to_director(JobControlRecord* jcr,
director_socket->recv();
ParseOkVersion(director_socket->msg);
- jcr->impl->director = dir_res;
+ jcr->fd_impl->director = dir_res;
return director_socket.release();
}
@@ -2215,8 +2226,8 @@ static bool RestoreCmd(JobControlRecord* jcr)
// See if we are allowed to run restore cmds.
if (!ValidateCommand(
jcr, "restore",
- (jcr->impl->director && jcr->impl->director->allowed_job_cmds)
- ? jcr->impl->director->allowed_job_cmds
+ (jcr->fd_impl->director && jcr->fd_impl->director->allowed_job_cmds)
+ ? jcr->fd_impl->director->allowed_job_cmds
: me->allowed_job_cmds)) {
return 0;
}
@@ -2245,9 +2256,9 @@ static bool RestoreCmd(JobControlRecord* jcr)
#if defined(WIN32_VSS)
// No need to enable VSS for restore if we do not have plugin data to restore
- jcr->impl->enable_vss = jcr->impl->got_metadata;
+ jcr->fd_impl->enable_vss = jcr->fd_impl->got_metadata;
- if (jcr->impl->enable_vss) { VSSInit(jcr); }
+ if (jcr->fd_impl->enable_vss) { VSSInit(jcr); }
#endif
// Turn / into nothing
@@ -2271,20 +2282,20 @@ static bool RestoreCmd(JobControlRecord* jcr)
}
FreePoolMemory(args);
- jcr->impl->replace = replace;
+ jcr->fd_impl->replace = replace;
jcr->prefix_links = prefix_links;
dir->fsend(OKrestore);
Dmsg1(110, "filed>dird: %s", dir->msg);
- jcr->setJobStatus(JS_Blocked);
+ jcr->setJobStatusWithPriorityCheck(JS_Blocked);
if (!OpenSdReadSession(jcr)) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
goto bail_out;
}
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
// Do restore of files and data
StartDirHeartbeat(jcr);
@@ -2292,8 +2303,8 @@ static bool RestoreCmd(JobControlRecord* jcr)
#if defined(WIN32_VSS)
// START VSS ON WIN32
- if (jcr->impl->pVSSClient) {
- if (!jcr->impl->pVSSClient->InitializeForRestore(jcr)) {
+ if (jcr->fd_impl->pVSSClient) {
+ if (!jcr->fd_impl->pVSSClient->InitializeForRestore(jcr)) {
BErrNo be;
Jmsg(jcr, M_WARNING, 0,
_("VSS was not initialized properly. VSS support is disabled. "
@@ -2303,10 +2314,11 @@ static bool RestoreCmd(JobControlRecord* jcr)
GeneratePluginEvent(jcr, bEventVssRestoreLoadComponentMetadata);
- RunScripts(jcr, jcr->impl->RunScripts, "ClientAfterVSS",
- (jcr->impl->director && jcr->impl->director->allowed_script_dirs)
- ? jcr->impl->director->allowed_script_dirs
- : me->allowed_script_dirs);
+ RunScripts(
+ jcr, jcr->fd_impl->RunScripts, "ClientAfterVSS",
+ (jcr->fd_impl->director && jcr->fd_impl->director->allowed_script_dirs)
+ ? jcr->fd_impl->director->allowed_script_dirs
+ : me->allowed_script_dirs);
}
#endif
@@ -2314,13 +2326,13 @@ static bool RestoreCmd(JobControlRecord* jcr)
StopDirHeartbeat(jcr);
if (jcr->JobWarnings) {
- jcr->setJobStatus(JS_Warnings);
+ jcr->setJobStatusWithPriorityCheck(JS_Warnings);
} else {
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
}
// Send Close session command to Storage daemon
- sd->fsend(read_close, jcr->impl->Ticket);
+ sd->fsend(read_close, jcr->fd_impl->Ticket);
Dmsg1(100, "filed>stored: %s", sd->msg);
BgetMsg(sd); /* get OK */
@@ -2333,24 +2345,24 @@ static bool RestoreCmd(JobControlRecord* jcr)
* STOP VSS ON WIN32
* Tell vss to close the restore session
*/
- if (jcr->impl->pVSSClient) {
+ if (jcr->fd_impl->pVSSClient) {
Dmsg0(100, "About to call CloseRestore\n");
GeneratePluginEvent(jcr, bEventVssCloseRestore);
Dmsg0(100, "Really about to call CloseRestore\n");
- if (jcr->impl->pVSSClient->CloseRestore()) {
+ if (jcr->fd_impl->pVSSClient->CloseRestore()) {
Dmsg0(100, "CloseRestore success\n");
// 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 (RestoreComplete): %s\n"),
- jcr->impl->pVSSClient->GetWriterInfo(i));
+ jcr->fd_impl->pVSSClient->GetWriterInfo(i));
}
} else {
Dmsg1(100, "CloseRestore fail - %08x\n", errno);
@@ -2361,11 +2373,13 @@ static bool RestoreCmd(JobControlRecord* jcr)
bail_out:
BfreeAndNull(jcr->where);
- if (jcr->JobErrors) { jcr->setJobStatus(JS_ErrorTerminated); }
+ if (jcr->JobErrors) {
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
+ }
Dmsg0(100, "Done in job.c\n");
- if (jcr->impl->multi_restore) {
+ if (jcr->fd_impl->multi_restore) {
Dmsg0(100, OKstoreend);
dir->fsend(OKstoreend);
retval = true; /* we continue the loop, waiting for next part */
@@ -2398,29 +2412,29 @@ static bool OpenSdReadSession(JobControlRecord* jcr)
return false;
}
Dmsg4(120, "VolSessId=%ld VolsessT=%ld SF=%ld EF=%ld\n", jcr->VolSessionId,
- jcr->VolSessionTime, jcr->impl->StartFile, jcr->impl->EndFile);
+ jcr->VolSessionTime, jcr->fd_impl->StartFile, jcr->fd_impl->EndFile);
Dmsg2(120, "JobId=%d vol=%s\n", jcr->JobId, "DummyVolume");
// Open Read Session with Storage daemon
sd->fsend(read_open, "DummyVolume", jcr->VolSessionId, jcr->VolSessionTime,
- jcr->impl->StartFile, jcr->impl->EndFile, jcr->impl->StartBlock,
- jcr->impl->EndBlock);
+ jcr->fd_impl->StartFile, jcr->fd_impl->EndFile,
+ jcr->fd_impl->StartBlock, jcr->fd_impl->EndBlock);
Dmsg1(110, ">stored: %s", sd->msg);
// Get ticket number
if (BgetMsg(sd) >= 0) {
Dmsg1(110, "filed<stored: %s", sd->msg);
- if (sscanf(sd->msg, OK_open, &jcr->impl->Ticket) != 1) {
+ if (sscanf(sd->msg, OK_open, &jcr->fd_impl->Ticket) != 1) {
Jmsg(jcr, M_FATAL, 0, _("Bad response to SD read open: %s\n"), sd->msg);
return false;
}
- Dmsg1(110, "filed: got Ticket=%d\n", jcr->impl->Ticket);
+ Dmsg1(110, "filed: got Ticket=%d\n", jcr->fd_impl->Ticket);
} else {
Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to read open command\n"));
return false;
}
// Start read of data with Storage daemon
- sd->fsend(read_data, jcr->impl->Ticket);
+ sd->fsend(read_data, jcr->fd_impl->Ticket);
Dmsg1(110, ">stored: %s", sd->msg);
// Get OK data
@@ -2433,9 +2447,9 @@ static bool OpenSdReadSession(JobControlRecord* jcr)
static void FiledFreeJcr(JobControlRecord* jcr)
{
#if defined(WIN32_VSS)
- if (jcr->impl->pVSSClient) {
- delete jcr->impl->pVSSClient;
- jcr->impl->pVSSClient = nullptr;
+ if (jcr->fd_impl->pVSSClient) {
+ delete jcr->fd_impl->pVSSClient;
+ jcr->fd_impl->pVSSClient = nullptr;
}
#endif
@@ -2451,29 +2465,29 @@ static void FiledFreeJcr(JobControlRecord* jcr)
jcr->dir_bsock = nullptr;
}
- if (jcr->impl->last_fname) { FreePoolMemory(jcr->impl->last_fname); }
+ if (jcr->fd_impl->last_fname) { FreePoolMemory(jcr->fd_impl->last_fname); }
FreeBootstrap(jcr);
- FreeRunscripts(jcr->impl->RunScripts);
- delete jcr->impl->RunScripts;
- jcr->impl->RunScripts = nullptr;
+ FreeRunscripts(jcr->fd_impl->RunScripts);
+ delete jcr->fd_impl->RunScripts;
+ jcr->fd_impl->RunScripts = nullptr;
if (jcr->path_list) {
FreePathList(jcr->path_list);
jcr->path_list = nullptr;
}
- TermFindFiles(jcr->impl->ff);
- jcr->impl->ff = nullptr;
+ TermFindFiles(jcr->fd_impl->ff);
+ jcr->fd_impl->ff = nullptr;
if (jcr->JobId != 0) {
WriteStateFile(me->working_directory, "bareos-fd",
GetFirstPortHostOrder(me->FDaddrs));
}
- if (jcr->impl) {
- delete jcr->impl;
- jcr->impl = nullptr;
+ if (jcr->fd_impl) {
+ delete jcr->fd_impl;
+ jcr->fd_impl = nullptr;
}
return;
diff --git a/core/src/filed/estimate.cc b/core/src/filed/estimate.cc
index a423cbc23..7f7b5b20b 100644
--- a/core/src/filed/estimate.cc
+++ b/core/src/filed/estimate.cc
@@ -28,7 +28,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "filed/accurate.h"
namespace filedaemon {
@@ -40,16 +40,17 @@ int MakeEstimate(JobControlRecord* jcr)
{
int status;
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
- 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 overwrite the find_one check function */
if (jcr->accurate) {
- SetFindChangedFunction((FindFilesPacket*)jcr->impl->ff, AccurateCheckFile);
+ SetFindChangedFunction((FindFilesPacket*)jcr->fd_impl->ff,
+ AccurateCheckFile);
}
- status = FindFiles(jcr, (FindFilesPacket*)jcr->impl->ff, TallyFile,
+ status = FindFiles(jcr, (FindFilesPacket*)jcr->fd_impl->ff, TallyFile,
PluginEstimate);
AccurateFree(jcr);
return status;
@@ -103,9 +104,9 @@ static int TallyFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
}
#endif
}
- jcr->impl->num_files_examined++;
+ jcr->fd_impl->num_files_examined++;
jcr->JobFiles++; /* increment number of files seen */
- if (jcr->impl->listing) {
+ if (jcr->fd_impl->listing) {
memcpy(&attr.statp, &ff_pkt->statp, sizeof(struct stat));
attr.type = ff_pkt->type;
attr.ofname = (POOLMEM*)ff_pkt->fname;
diff --git a/core/src/filed/evaluate_job_command.cc b/core/src/filed/evaluate_job_command.cc
index 81c99707d..f3b70c7c8 100644
--- a/core/src/filed/evaluate_job_command.cc
+++ b/core/src/filed/evaluate_job_command.cc
@@ -1,7 +1,7 @@
/**
BAREOSĀ® - Backup Archiving REcovery Open Sourced
- Copyright (C) 2019-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2019-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -33,10 +33,10 @@ JobCommand::JobCommand(const char* msg) : job_{0}, sd_auth_key_{0}
{
ProtocolVersion protocol = ProtocolVersion::kVersionUndefinded;
- std::vector<ProtocolVersion> implemented_protocols{
+ std::vector<ProtocolVersion> fd_implemented_protocols{
ProtocolVersion::kVersionFrom_18_2, ProtocolVersion::KVersionBefore_18_2};
- for (auto protocol_try : implemented_protocols) {
+ for (auto protocol_try : fd_implemented_protocols) {
switch (protocol_try) {
case ProtocolVersion::kVersionFrom_18_2:
if (sscanf(msg, jobcmdssl_.c_str(), &job_id_, job_, &vol_session_id_,
diff --git a/core/src/filed/fd_plugins.cc b/core/src/filed/fd_plugins.cc
index 07ffdefd3..3ca73d3bc 100644
--- a/core/src/filed/fd_plugins.cc
+++ b/core/src/filed/fd_plugins.cc
@@ -32,7 +32,7 @@
#include "filed/heartbeat.h"
#include "filed/fileset.h"
#include "filed/heartbeat.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "findlib/attribs.h"
#include "findlib/find.h"
#include "findlib/find_one.h"
@@ -740,8 +740,8 @@ int PluginSave(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
goto bail_out;
}
- jcr->impl->plugin_sp = &sp;
- ff_pkt = jcr->impl->ff;
+ jcr->fd_impl->plugin_sp = &sp;
+ ff_pkt = jcr->fd_impl->ff;
// Save original flags.
CopyBits(FO_MAX, ff_pkt->flags, flags);
@@ -987,13 +987,13 @@ int PluginEstimate(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
default:
break;
}
- jcr->impl->num_files_examined++;
+ jcr->fd_impl->num_files_examined++;
if (sp.type != FT_LNKSAVED && S_ISREG(sp.statp.st_mode)) {
if (sp.statp.st_size > 0) { jcr->JobBytes += sp.statp.st_size; }
}
- if (jcr->impl->listing) {
+ if (jcr->fd_impl->listing) {
memcpy(&attr.statp, &sp.statp, sizeof(struct stat));
attr.type = sp.type;
attr.ofname = (POOLMEM*)sp.fname;
@@ -1033,7 +1033,7 @@ bool SendPluginName(JobControlRecord* jcr, BareosSocket* sd, bool start)
{
int status;
int index = jcr->JobFiles;
- struct save_pkt* sp = (struct save_pkt*)jcr->impl->plugin_sp;
+ struct save_pkt* sp = (struct save_pkt*)jcr->fd_impl->plugin_sp;
if (!sp) {
Jmsg0(jcr, M_FATAL, 0, _("Plugin save packet not found.\n"));
@@ -1229,7 +1229,7 @@ int PluginCreateFile(JobControlRecord* jcr,
rp.olname = attr->olname;
rp.where = jcr->where;
rp.RegexWhere = jcr->RegexWhere;
- rp.replace = jcr->impl->replace;
+ rp.replace = jcr->fd_impl->replace;
rp.create_status = CF_ERROR;
Dmsg4(debuglevel,
@@ -1321,7 +1321,7 @@ bool PluginSetAttributes(JobControlRecord* jcr,
rp.olname = attr->olname;
rp.where = jcr->where;
rp.RegexWhere = jcr->RegexWhere;
- rp.replace = jcr->impl->replace;
+ rp.replace = jcr->fd_impl->replace;
rp.create_status = CF_ERROR;
PlugFunc(plugin)->setFileAttributes(jcr->plugin_ctx, &rp);
@@ -2049,19 +2049,19 @@ static bRC bareosGetValue(PluginContext* ctx, bVariable var, void* value)
NPRT(*((char**)value)));
break;
case bVarPrevJobName:
- *((char**)value) = jcr->impl->PrevJob;
+ *((char**)value) = jcr->fd_impl->PrevJob;
Dmsg1(debuglevel, "fd-plugin: return bVarPrevJobName=%s\n",
NPRT(*((char**)value)));
break;
case bVarJobStatus:
- *((int*)value) = jcr->JobStatus;
+ *((int*)value) = jcr->getJobStatus();
Dmsg1(debuglevel, "fd-plugin: return bVarJobStatus=%d\n",
- jcr->JobStatus);
+ jcr->getJobStatus());
break;
case bVarSinceTime:
- *((int*)value) = (int)jcr->impl->since_time;
+ *((int*)value) = (int)jcr->fd_impl->since_time;
Dmsg1(debuglevel, "fd-plugin: return bVarSinceTime=%d\n",
- (int)jcr->impl->since_time);
+ (int)jcr->fd_impl->since_time);
break;
case bVarAccurate:
*((int*)value) = (int)jcr->accurate;
@@ -2072,8 +2072,8 @@ static bRC bareosGetValue(PluginContext* ctx, bVariable var, void* value)
break; /* a write only variable, ignore read request */
case bVarVssClient:
#ifdef HAVE_WIN32
- if (jcr->impl->pVSSClient) {
- *(void**)value = jcr->impl->pVSSClient;
+ if (jcr->fd_impl->pVSSClient) {
+ *(void**)value = jcr->fd_impl->pVSSClient;
Dmsg1(debuglevel, "fd-plugin: return bVarVssClient=%p\n",
*(void**)value);
break;
@@ -2114,7 +2114,7 @@ static bRC bareosSetValue(PluginContext* ctx, bVariable var, void* value)
switch (var) {
case bVarSinceTime:
- jcr->impl->since_time = (*(int*)value);
+ jcr->fd_impl->since_time = (*(int*)value);
break;
case bVarLevel:
jcr->setJobLevel(*(int*)value);
@@ -2124,7 +2124,7 @@ static bRC bareosSetValue(PluginContext* ctx, bVariable var, void* value)
break;
default:
Jmsg1(jcr, M_ERROR, 0,
- "Warning: bareosSetValue not implemented for var %d.\n", var);
+ "Warning: bareosSetValue not fd_implemented for var %d.\n", var);
break;
}
@@ -2278,12 +2278,14 @@ static bRC bareosAddExclude(PluginContext* ctx, const char* fname)
// Not right time to add exlude
if (!old) { return bRC_Error; }
- if (!bctx->exclude) { bctx->exclude = new_exclude(jcr->impl->ff->fileset); }
+ if (!bctx->exclude) {
+ bctx->exclude = new_exclude(jcr->fd_impl->ff->fileset);
+ }
// Set the Exclude context
SetIncexe(jcr, bctx->exclude);
- AddFileToFileset(jcr, fname, true, jcr->impl->ff->fileset);
+ AddFileToFileset(jcr, fname, true, jcr->fd_impl->ff->fileset);
// Restore the current context
SetIncexe(jcr, old);
@@ -2316,7 +2318,7 @@ static bRC bareosAddInclude(PluginContext* ctx, const char* fname)
if (!bctx->include) { bctx->include = old; }
SetIncexe(jcr, bctx->include);
- AddFileToFileset(jcr, fname, true, jcr->impl->ff->fileset);
+ AddFileToFileset(jcr, fname, true, jcr->fd_impl->ff->fileset);
// Restore the current context
SetIncexe(jcr, old);
@@ -2374,7 +2376,7 @@ static bRC bareosNewOptions(PluginContext* ctx)
b_plugin_ctx* bctx;
if (!IsCtxGood(ctx, jcr, bctx)) { return bRC_Error; }
- (void)NewOptions(jcr->impl->ff, jcr->impl->ff->fileset->incexe);
+ (void)NewOptions(jcr->fd_impl->ff, jcr->fd_impl->ff->fileset->incexe);
return bRC_OK;
}
@@ -2385,7 +2387,7 @@ static bRC bareosNewInclude(PluginContext* ctx)
b_plugin_ctx* bctx;
if (!IsCtxGood(ctx, jcr, bctx)) { return bRC_Error; }
- (void)new_include(jcr->impl->ff->fileset);
+ (void)new_include(jcr->fd_impl->ff->fileset);
return bRC_OK;
}
@@ -2397,8 +2399,8 @@ static bRC bareosNewPreInclude(PluginContext* ctx)
if (!IsCtxGood(ctx, jcr, bctx)) { return bRC_Error; }
- bctx->include = new_preinclude(jcr->impl->ff->fileset);
- NewOptions(jcr->impl->ff, bctx->include);
+ bctx->include = new_preinclude(jcr->fd_impl->ff->fileset);
+ NewOptions(jcr->fd_impl->ff, bctx->include);
SetIncexe(jcr, bctx->include);
return bRC_OK;
@@ -2416,7 +2418,7 @@ static bRC bareosCheckChanges(PluginContext* ctx, struct save_pkt* sp)
if (!sp) { goto bail_out; }
- ff_pkt = jcr->impl->ff;
+ ff_pkt = jcr->fd_impl->ff;
/*
* Copy fname and link because SaveFile() zaps them.
* This avoids zapping the plugin's strings.
@@ -2462,7 +2464,7 @@ static bRC bareosAcceptFile(PluginContext* ctx, struct save_pkt* sp)
if (!IsCtxGood(ctx, jcr, bctx)) { goto bail_out; }
if (!sp) { goto bail_out; }
- ff_pkt = jcr->impl->ff;
+ ff_pkt = jcr->fd_impl->ff;
ff_pkt->fname = sp->fname;
memcpy(&ff_pkt->statp, &sp->statp, sizeof(ff_pkt->statp));
diff --git a/core/src/filed/filed.cc b/core/src/filed/filed.cc
index b13da1a6e..a67bcefad 100644
--- a/core/src/filed/filed.cc
+++ b/core/src/filed/filed.cc
@@ -340,7 +340,7 @@ static bool CheckResources()
#endif
}
- /* pki_encrypt implies pki_sign */
+ /* pki_encrypt fd_implies pki_sign */
if (me->pki_encrypt) { me->pki_sign = true; }
if ((me->pki_encrypt || me->pki_sign) && !me->pki_keypair_file) {
@@ -354,7 +354,7 @@ static bool CheckResources()
/* If everything is well, attempt to initialize our public/private keys */
if (OK && (me->pki_encrypt || me->pki_sign)) {
- char* filepath = nullptr;
+ const char* filepath = nullptr;
/* Load our keypair */
me->pki_keypair = crypto_keypair_new();
if (!me->pki_keypair) {
diff --git a/core/src/filed/jcr_private.h b/core/src/filed/filed_jcr_impl.h
index 920b48cfd..df7aa6be0 100644
--- a/core/src/filed/jcr_private.h
+++ b/core/src/filed/filed_jcr_impl.h
@@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -21,8 +21,8 @@
02110-1301, USA.
*/
-#ifndef BAREOS_FILED_JCR_PRIVATE_H_
-#define BAREOS_FILED_JCR_PRIVATE_H_
+#ifndef BAREOS_FILED_FILED_JCR_IMPL_H_
+#define BAREOS_FILED_FILED_JCR_IMPL_H_
#include "include/bareos.h"
@@ -49,7 +49,7 @@ struct CryptoContext {
int32_t pki_session_encoded_size{}; /**< Size of DER-encoded pki_session */
};
-struct JobControlRecordPrivate {
+struct FiledJcrImpl {
uint32_t num_files_examined{}; /**< Files examined this job */
POOLMEM* last_fname{}; /**< Last file saved/verified */
POOLMEM* job_metadata{}; /**< VSS job metadata */
@@ -89,4 +89,4 @@ struct JobControlRecordPrivate {
};
/* clang-format on */
-#endif // BAREOS_FILED_JCR_PRIVATE_H_
+#endif // BAREOS_FILED_FILED_JCR_IMPL_H_
diff --git a/core/src/filed/fileset.cc b/core/src/filed/fileset.cc
index eff30211b..99582a500 100644
--- a/core/src/filed/fileset.cc
+++ b/core/src/filed/fileset.cc
@@ -32,7 +32,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "findlib/match.h"
#include "lib/berrno.h"
#include "lib/edit.h"
@@ -62,10 +62,12 @@ extern "C" char* job_code_callback_filed(JobControlRecord* jcr,
switch (param[0]) {
case 'D':
- if (jcr->impl->director) { return jcr->impl->director->resource_name_; }
+ if (jcr->fd_impl->director) {
+ return jcr->fd_impl->director->resource_name_;
+ }
break;
case 'm':
- return edit_uint64(jcr->impl->since_time, str);
+ return edit_uint64(jcr->fd_impl->since_time, str);
}
return NULL;
@@ -76,8 +78,8 @@ bool InitFileset(JobControlRecord* jcr)
FindFilesPacket* ff;
findFILESET* fileset;
- if (!jcr->impl->ff) { return false; }
- ff = jcr->impl->ff;
+ if (!jcr->fd_impl->ff) { return false; }
+ ff = jcr->fd_impl->ff;
if (ff->fileset) { return false; }
fileset = (findFILESET*)malloc(sizeof(findFILESET));
*fileset = findFILESET{};
@@ -174,8 +176,8 @@ void AddFileToFileset(JobControlRecord* jcr,
findIncludeExcludeItem* get_incexe(JobControlRecord* jcr)
{
- if (jcr->impl->ff && jcr->impl->ff->fileset) {
- return jcr->impl->ff->fileset->incexe;
+ if (jcr->fd_impl->ff && jcr->fd_impl->ff->fileset) {
+ return jcr->fd_impl->ff->fileset->incexe;
}
return NULL;
@@ -183,14 +185,14 @@ findIncludeExcludeItem* get_incexe(JobControlRecord* jcr)
void SetIncexe(JobControlRecord* jcr, findIncludeExcludeItem* incexe)
{
- findFILESET* fileset = jcr->impl->ff->fileset;
+ findFILESET* fileset = jcr->fd_impl->ff->fileset;
fileset->incexe = incexe;
}
// Add a regex to the current fileset
int AddRegexToFileset(JobControlRecord* jcr, const char* item, int type)
{
- findFOPTS* current_opts = start_options(jcr->impl->ff);
+ findFOPTS* current_opts = start_options(jcr->fd_impl->ff);
regex_t* preg;
int rc;
char prbuf[500];
@@ -224,7 +226,7 @@ int AddRegexToFileset(JobControlRecord* jcr, const char* item, int type)
// Add a wild card to the current fileset
int AddWildToFileset(JobControlRecord* jcr, const char* item, int type)
{
- findFOPTS* current_opts = start_options(jcr->impl->ff);
+ findFOPTS* current_opts = start_options(jcr->fd_impl->ff);
if (type == ' ') {
current_opts->wild.append(strdup(item));
@@ -244,7 +246,7 @@ int AddWildToFileset(JobControlRecord* jcr, const char* item, int type)
// Add options to the current fileset
int AddOptionsToFileset(JobControlRecord* jcr, const char* item)
{
- findFOPTS* current_opts = start_options(jcr->impl->ff);
+ findFOPTS* current_opts = start_options(jcr->fd_impl->ff);
SetOptions(current_opts, item);
@@ -253,7 +255,7 @@ int AddOptionsToFileset(JobControlRecord* jcr, const char* item)
void AddFileset(JobControlRecord* jcr, const char* item)
{
- FindFilesPacket* ff = jcr->impl->ff;
+ FindFilesPacket* ff = jcr->fd_impl->ff;
findFILESET* fileset = ff->fileset;
int code, subcode;
int state = fileset->state;
@@ -290,21 +292,21 @@ void AddFileset(JobControlRecord* jcr, const char* item)
}
switch (code) {
case 'I':
- (void)new_include(jcr->impl->ff->fileset);
+ (void)new_include(jcr->fd_impl->ff->fileset);
break;
case 'E':
- (void)new_exclude(jcr->impl->ff->fileset);
+ (void)new_exclude(jcr->fd_impl->ff->fileset);
break;
case 'N': /* Null */
state = state_none;
break;
case 'F': /* File */
state = state_include;
- AddFileToFileset(jcr, item, true, jcr->impl->ff->fileset);
+ AddFileToFileset(jcr, item, true, jcr->fd_impl->ff->fileset);
break;
case 'P': /* Plugin */
state = state_include;
- AddFileToFileset(jcr, item, false, jcr->impl->ff->fileset);
+ AddFileToFileset(jcr, item, false, jcr->fd_impl->ff->fileset);
break;
case 'R': /* Regex */
state = AddRegexToFileset(jcr, item, subcode);
@@ -360,16 +362,16 @@ bool TermFileset(JobControlRecord* jcr)
{
findFILESET* fileset;
- fileset = jcr->impl->ff->fileset;
+ fileset = jcr->fd_impl->ff->fileset;
#ifdef HAVE_WIN32
/*
* Expand the fileset to include all drive letters when the fileset includes a
* File = / entry.
*/
- if (!expand_win32_fileset(jcr->impl->ff->fileset)) { return false; }
+ if (!expand_win32_fileset(jcr->fd_impl->ff->fileset)) { return false; }
// Exclude entries in NotToBackup registry key
- if (!exclude_win32_not_to_backup_registry_entries(jcr, jcr->impl->ff)) {
+ if (!exclude_win32_not_to_backup_registry_entries(jcr, jcr->fd_impl->ff)) {
return false;
}
#endif
@@ -388,7 +390,7 @@ bool TermFileset(JobControlRecord* jcr)
}
}
- return jcr->impl->ff->fileset->state != state_error;
+ return jcr->fd_impl->ff->fileset->state != state_error;
}
/**
diff --git a/core/src/filed/heartbeat.cc b/core/src/filed/heartbeat.cc
index 9f5440562..64a091f48 100644
--- a/core/src/filed/heartbeat.cc
+++ b/core/src/filed/heartbeat.cc
@@ -3,7 +3,7 @@
Copyright (C) 2003-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2020 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -30,7 +30,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "filed/filed_globals.h"
#include "lib/bnet.h"
#include "lib/bsock.h"
@@ -63,12 +63,12 @@ extern "C" void* sd_heartbeat_thread(void* arg)
sd.reset(jcr->store_bsock->clone());
dir.reset(jcr->dir_bsock->clone());
- jcr->impl->hb_bsock = sd;
- jcr->impl->hb_running = true;
- jcr->impl->hb_dir_bsock = dir;
+ jcr->fd_impl->hb_bsock = sd;
+ jcr->fd_impl->hb_running = true;
+ jcr->fd_impl->hb_dir_bsock = dir;
dir->suppress_error_msgs_ = true;
sd->suppress_error_msgs_ = true;
- jcr->impl->hb_initialized_once
+ jcr->fd_impl->hb_initialized_once
= true; // initialize last to avoid race condition
/* Hang reading the socket to the SD, and every time we get
@@ -102,9 +102,9 @@ extern "C" void* sd_heartbeat_thread(void* arg)
sd->close();
dir->close();
- jcr->impl->hb_bsock.reset();
- jcr->impl->hb_running = false;
- jcr->impl->hb_dir_bsock = NULL;
+ jcr->fd_impl->hb_bsock.reset();
+ jcr->fd_impl->hb_running = false;
+ jcr->fd_impl->hb_dir_bsock = NULL;
return NULL;
}
@@ -118,11 +118,11 @@ void StartHeartbeatMonitor(JobControlRecord* jcr)
* make debugging impossible.
*/
if (!no_signals) {
- jcr->impl->hb_bsock = NULL;
- jcr->impl->hb_running = false;
- jcr->impl->hb_initialized_once = false;
- jcr->impl->hb_dir_bsock = NULL;
- pthread_create(&jcr->impl->heartbeat_id, NULL, sd_heartbeat_thread,
+ jcr->fd_impl->hb_bsock = NULL;
+ jcr->fd_impl->hb_running = false;
+ jcr->fd_impl->hb_initialized_once = false;
+ jcr->fd_impl->hb_dir_bsock = NULL;
+ pthread_create(&jcr->fd_impl->heartbeat_id, NULL, sd_heartbeat_thread,
(void*)jcr);
}
}
@@ -134,47 +134,47 @@ void StopHeartbeatMonitor(JobControlRecord* jcr)
if (no_signals) { return; }
/* Wait max 10 secs for heartbeat thread to start */
- while (!jcr->impl->hb_initialized_once && cnt++ < 200) {
+ while (!jcr->fd_impl->hb_initialized_once && cnt++ < 200) {
Bmicrosleep(0, 50000); /* wait for start */
}
- if (jcr->impl->hb_running) {
- jcr->impl->hb_bsock->SetTimedOut(); /* set timed_out to Terminate read */
- jcr->impl->hb_bsock->SetTerminated(); /* set to Terminate read */
+ if (jcr->fd_impl->hb_running) {
+ jcr->fd_impl->hb_bsock->SetTimedOut(); /* set timed_out to Terminate read */
+ jcr->fd_impl->hb_bsock->SetTerminated(); /* set to Terminate read */
}
- if (jcr->impl->hb_dir_bsock) {
- jcr->impl->hb_dir_bsock
+ if (jcr->fd_impl->hb_dir_bsock) {
+ jcr->fd_impl->hb_dir_bsock
->SetTimedOut(); /* set timed_out to Terminate read */
- jcr->impl->hb_dir_bsock->SetTerminated(); /* set to Terminate read */
+ jcr->fd_impl->hb_dir_bsock->SetTerminated(); /* set to Terminate read */
}
- if (jcr->impl->hb_running) {
+ if (jcr->fd_impl->hb_running) {
Dmsg0(100, "Send kill to heartbeat id\n");
- pthread_kill(jcr->impl->heartbeat_id,
+ pthread_kill(jcr->fd_impl->heartbeat_id,
TIMEOUT_SIGNAL); /* make heartbeat thread go away */
Bmicrosleep(0, 50000);
}
cnt = 0;
// Wait max 100 secs for heartbeat thread to stop
- while (jcr->impl->hb_running && cnt++ < 200) {
- pthread_kill(jcr->impl->heartbeat_id,
+ while (jcr->fd_impl->hb_running && cnt++ < 200) {
+ pthread_kill(jcr->fd_impl->heartbeat_id,
TIMEOUT_SIGNAL); /* make heartbeat thread go away */
Bmicrosleep(0, 500000);
}
- if (jcr->impl->hb_bsock) {
- // delete jcr->impl_->hb_bsock;
- jcr->impl->hb_bsock.reset();
+ if (jcr->fd_impl->hb_bsock) {
+ // delete jcr->fd_impl_->hb_bsock;
+ jcr->fd_impl->hb_bsock.reset();
}
- if (jcr->impl->hb_dir_bsock) {
- // delete jcr->impl_->hb_dir_bsock;
- jcr->impl->hb_dir_bsock.reset();
+ if (jcr->fd_impl->hb_dir_bsock) {
+ // delete jcr->fd_impl_->hb_dir_bsock;
+ jcr->fd_impl->hb_dir_bsock.reset();
}
- jcr->impl->hb_initialized_once = false;
+ jcr->fd_impl->hb_initialized_once = false;
}
/**
@@ -193,10 +193,10 @@ extern "C" void* dir_heartbeat_thread(void* arg)
// Get our own local copy
dir = jcr->dir_bsock->clone();
- jcr->impl->hb_bsock.reset(dir);
- jcr->impl->hb_running = true;
+ jcr->fd_impl->hb_bsock.reset(dir);
+ jcr->fd_impl->hb_running = true;
dir->suppress_error_msgs_ = true;
- jcr->impl->hb_initialized_once
+ jcr->fd_impl->hb_initialized_once
= true; // initialize last to avoid race condition
while (!dir->IsStop()) {
@@ -212,8 +212,8 @@ extern "C" void* dir_heartbeat_thread(void* arg)
Bmicrosleep(next, 0);
}
dir->close();
- jcr->impl->hb_bsock.reset();
- jcr->impl->hb_running = false;
+ jcr->fd_impl->hb_bsock.reset();
+ jcr->fd_impl->hb_running = false;
return NULL;
}
@@ -222,7 +222,7 @@ void StartDirHeartbeat(JobControlRecord* jcr)
{
if (me->heartbeat_interval) {
jcr->dir_bsock->SetLocking();
- pthread_create(&jcr->impl->heartbeat_id, NULL, dir_heartbeat_thread,
+ pthread_create(&jcr->fd_impl->heartbeat_id, NULL, dir_heartbeat_thread,
(void*)jcr);
}
}
diff --git a/core/src/filed/restore.cc b/core/src/filed/restore.cc
index 5458f80e8..d4eece457 100644
--- a/core/src/filed/restore.cc
+++ b/core/src/filed/restore.cc
@@ -29,7 +29,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "filed/compression.h"
#include "filed/crypto.h"
#include "filed/restore.h"
@@ -130,7 +130,7 @@ static int BcloseChksize(JobControlRecord* jcr,
Qmsg3(jcr, M_WARNING, 0,
_("Size of data or stream of %s not correct. Original %s, restored "
"%s.\n"),
- jcr->impl->last_fname, edit_uint64(osize, ec1),
+ jcr->fd_impl->last_fname, edit_uint64(osize, ec1),
edit_uint64(fsize, ec2));
return -1;
}
@@ -149,16 +149,16 @@ static inline bool RestoreFinderinfo(JobControlRecord* jcr,
attrList.commonattr = ATTR_CMN_FNDRINFO;
Dmsg0(130, "Restoring Finder Info\n");
- SetBit(FO_HFSPLUS, jcr->impl->ff->flags);
+ SetBit(FO_HFSPLUS, jcr->fd_impl->ff->flags);
if (buflen != 32) {
Jmsg(jcr, M_WARNING, 0,
_("Invalid length of Finder Info (got %d, not 32)\n"), buflen);
return false;
}
- if (setattrlist(jcr->impl->last_fname, &attrList, buf, buflen, 0) != 0) {
+ if (setattrlist(jcr->fd_impl->last_fname, &attrList, buf, buflen, 0) != 0) {
Jmsg(jcr, M_WARNING, 0, _("Could not set Finder Info on %s\n"),
- jcr->impl->last_fname);
+ jcr->fd_impl->last_fname);
return false;
}
@@ -216,14 +216,14 @@ static inline bool do_reStoreAcl(JobControlRecord* jcr,
{
bacl_exit_code retval;
- jcr->impl->acl_data->last_fname = jcr->impl->last_fname;
+ jcr->fd_impl->acl_data->last_fname = jcr->fd_impl->last_fname;
switch (stream) {
case STREAM_ACL_PLUGIN:
- retval = plugin_parse_acl_streams(jcr, jcr->impl->acl_data.get(), stream,
- content, content_length);
+ retval = plugin_parse_acl_streams(jcr, jcr->fd_impl->acl_data.get(),
+ stream, content, content_length);
break;
default:
- retval = parse_acl_streams(jcr, jcr->impl->acl_data.get(), stream,
+ retval = parse_acl_streams(jcr, jcr->fd_impl->acl_data.get(), stream,
content, content_length);
break;
}
@@ -237,11 +237,11 @@ static inline bool do_reStoreAcl(JobControlRecord* jcr,
* ACL_REPORT_ERR_MAX_PER_JOB print the error message set by the lower
* level routine in jcr->errmsg.
*/
- if (jcr->impl->acl_data->u.parse->nr_errors
+ if (jcr->fd_impl->acl_data->u.parse->nr_errors
< ACL_REPORT_ERR_MAX_PER_JOB) {
Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
}
- jcr->impl->acl_data->u.parse->nr_errors++;
+ jcr->fd_impl->acl_data->u.parse->nr_errors++;
break;
case bacl_exit_ok:
break;
@@ -261,14 +261,14 @@ static inline bool do_restore_xattr(JobControlRecord* jcr,
{
BxattrExitCode retval;
- jcr->impl->xattr_data->last_fname = jcr->impl->last_fname;
+ jcr->fd_impl->xattr_data->last_fname = jcr->fd_impl->last_fname;
switch (stream) {
case STREAM_XATTR_PLUGIN:
- retval = PluginParseXattrStreams(jcr, jcr->impl->xattr_data.get(), stream,
- content, content_length);
+ retval = PluginParseXattrStreams(jcr, jcr->fd_impl->xattr_data.get(),
+ stream, content, content_length);
break;
default:
- retval = ParseXattrStreams(jcr, jcr->impl->xattr_data.get(), stream,
+ retval = ParseXattrStreams(jcr, jcr->fd_impl->xattr_data.get(), stream,
content, content_length);
break;
}
@@ -281,7 +281,7 @@ static inline bool do_restore_xattr(JobControlRecord* jcr,
break;
case BxattrExitCode::kError:
Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
- jcr->impl->xattr_data->u.parse->nr_errors++;
+ jcr->fd_impl->xattr_data->u.parse->nr_errors++;
break;
case BxattrExitCode::kSuccess:
break;
@@ -414,7 +414,7 @@ void DoRestore(JobControlRecord* jcr)
rctx.jcr = jcr;
sd = jcr->store_bsock;
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
LockRes(my_config);
ClientResource* client
@@ -426,7 +426,7 @@ void DoRestore(JobControlRecord* jcr)
buf_size = 0; /* use default */
}
if (!BnetSetBufferSize(sd, buf_size, BNET_SETBUF_WRITE)) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return;
}
jcr->buf_size = sd->message_length;
@@ -471,16 +471,16 @@ void DoRestore(JobControlRecord* jcr)
binit(&rctx.forkbfd);
attr = rctx.attr = new_attr(jcr);
if (have_acl) {
- jcr->impl->acl_data = std::make_unique<AclData>();
- jcr->impl->acl_data->u.parse
+ jcr->fd_impl->acl_data = std::make_unique<AclData>();
+ jcr->fd_impl->acl_data->u.parse
= (acl_parse_data_t*)malloc(sizeof(acl_parse_data_t));
- memset(jcr->impl->acl_data->u.parse, 0, sizeof(acl_parse_data_t));
+ memset(jcr->fd_impl->acl_data->u.parse, 0, sizeof(acl_parse_data_t));
}
if (have_xattr) {
- jcr->impl->xattr_data = std::make_unique<XattrData>();
- jcr->impl->xattr_data->u.parse
+ jcr->fd_impl->xattr_data = std::make_unique<XattrData>();
+ jcr->fd_impl->xattr_data->u.parse
= (xattr_parse_data_t*)malloc(sizeof(xattr_parse_data_t));
- memset(jcr->impl->xattr_data->u.parse, 0, sizeof(xattr_parse_data_t));
+ memset(jcr->fd_impl->xattr_data->u.parse, 0, sizeof(xattr_parse_data_t));
}
while (BgetMsg(sd) >= 0 && !JobCanceled(jcr)) {
@@ -572,20 +572,21 @@ void DoRestore(JobControlRecord* jcr)
* Try to actually create the file, which returns a status telling
* us if we need to extract or not.
*/
- jcr->impl->num_files_examined++;
+ jcr->fd_impl->num_files_examined++;
rctx.extract = false;
status = CF_CORE; /* By default, let Bareos's core handle it */
if (jcr->IsPlugin()) {
- status = PluginCreateFile(jcr, attr, &rctx.bfd, jcr->impl->replace);
+ status
+ = PluginCreateFile(jcr, attr, &rctx.bfd, jcr->fd_impl->replace);
}
if (status == CF_CORE) {
- status = CreateFile(jcr, attr, &rctx.bfd, jcr->impl->replace);
+ status = CreateFile(jcr, attr, &rctx.bfd, jcr->fd_impl->replace);
}
jcr->lock();
- PmStrcpy(jcr->impl->last_fname, attr->ofname);
- jcr->impl->last_type = attr->type;
+ PmStrcpy(jcr->fd_impl->last_fname, attr->ofname);
+ jcr->fd_impl->last_type = attr->type;
jcr->unlock();
Dmsg2(130, "Outfile=%s CreateFile status=%d\n", attr->ofname, status);
switch (status) {
@@ -644,7 +645,7 @@ void DoRestore(JobControlRecord* jcr)
}
// Do we have any keys at all?
- if (!jcr->impl->crypto.pki_recipients) {
+ if (!jcr->fd_impl->crypto.pki_recipients) {
Jmsg(jcr, M_ERROR, 0,
_("No private decryption keys have been defined to decrypt "
"encrypted backup data.\n"));
@@ -653,11 +654,12 @@ void DoRestore(JobControlRecord* jcr)
break;
}
- if (jcr->impl->crypto.digest) {
- CryptoDigestFree(jcr->impl->crypto.digest);
+ if (jcr->fd_impl->crypto.digest) {
+ CryptoDigestFree(jcr->fd_impl->crypto.digest);
}
- jcr->impl->crypto.digest = crypto_digest_new(jcr, signing_algorithm);
- if (!jcr->impl->crypto.digest) {
+ jcr->fd_impl->crypto.digest
+ = crypto_digest_new(jcr, signing_algorithm);
+ if (!jcr->fd_impl->crypto.digest) {
Jmsg0(jcr, M_FATAL, 0, _("Could not create digest.\n"));
rctx.extract = false;
bclose(&rctx.bfd);
@@ -667,7 +669,7 @@ void DoRestore(JobControlRecord* jcr)
// Decode and save session keys.
cryptoerr = CryptoSessionDecode(
(uint8_t*)sd->msg, (uint32_t)sd->message_length,
- jcr->impl->crypto.pki_recipients, &rctx.cs);
+ jcr->fd_impl->crypto.pki_recipients, &rctx.cs);
switch (cryptoerr) {
case CRYPTO_ERROR_NONE:
// Success
@@ -817,7 +819,7 @@ void DoRestore(JobControlRecord* jcr)
case STREAM_MACOS_FORK_DATA:
if (have_darwin_os) {
ClearAllBits(FO_MAX, rctx.fork_flags);
- SetBit(FO_HFSPLUS, jcr->impl->ff->flags);
+ SetBit(FO_HFSPLUS, jcr->fd_impl->ff->flags);
if (rctx.stream == STREAM_ENCRYPTED_MACOS_FORK_DATA) {
SetBit(FO_ENCRYPT, rctx.fork_flags);
@@ -832,12 +834,12 @@ void DoRestore(JobControlRecord* jcr)
if (rctx.extract) {
if (rctx.prev_stream != rctx.stream) {
- if (BopenRsrc(&rctx.forkbfd, jcr->impl->last_fname,
+ if (BopenRsrc(&rctx.forkbfd, jcr->fd_impl->last_fname,
O_WRONLY | O_TRUNC | O_BINARY, 0)
< 0) {
Jmsg(jcr, M_WARNING, 0,
_("Cannot open resource fork for %s.\n"),
- jcr->impl->last_fname);
+ jcr->fd_impl->last_fname);
rctx.extract = false;
continue;
}
@@ -898,8 +900,8 @@ void DoRestore(JobControlRecord* jcr)
* b) and it is not a directory (they are never "extracted")
* c) or the file name is empty
*/
- if ((!rctx.extract && jcr->impl->last_type != FT_DIREND)
- || (*jcr->impl->last_fname == 0)) {
+ if ((!rctx.extract && jcr->fd_impl->last_type != FT_DIREND)
+ || (*jcr->fd_impl->last_fname == 0)) {
break;
}
if (have_acl) {
@@ -907,7 +909,7 @@ void DoRestore(JobControlRecord* jcr)
* For anything that is not a directory we delay
* the restore of acls till a later stage.
*/
- if (jcr->impl->last_type != FT_DIREND) {
+ if (jcr->fd_impl->last_type != FT_DIREND) {
PushDelayedDataStream(rctx, sd);
} else {
if (!do_reStoreAcl(jcr, rctx.stream, sd->msg, sd->message_length)) {
@@ -936,8 +938,8 @@ void DoRestore(JobControlRecord* jcr)
* b) and it is not a directory (they are never "extracted")
* c) or the file name is empty
*/
- if ((!rctx.extract && jcr->impl->last_type != FT_DIREND)
- || (*jcr->impl->last_fname == 0)) {
+ if ((!rctx.extract && jcr->fd_impl->last_type != FT_DIREND)
+ || (*jcr->fd_impl->last_fname == 0)) {
break;
}
if (have_xattr) {
@@ -945,7 +947,7 @@ void DoRestore(JobControlRecord* jcr)
* For anything that is not a directory we delay
* the restore of xattr till a later stage.
*/
- if (jcr->impl->last_type != FT_DIREND) {
+ if (jcr->fd_impl->last_type != FT_DIREND) {
PushDelayedDataStream(rctx, sd);
} else {
if (!do_restore_xattr(jcr, rctx.stream, sd->msg,
@@ -965,8 +967,8 @@ void DoRestore(JobControlRecord* jcr)
* b) and it is not a directory (they are never "extracted")
* c) or the file name is empty
*/
- if ((!rctx.extract && jcr->impl->last_type != FT_DIREND)
- || (*jcr->impl->last_fname == 0)) {
+ if ((!rctx.extract && jcr->fd_impl->last_type != FT_DIREND)
+ || (*jcr->fd_impl->last_fname == 0)) {
break;
}
if (have_xattr) {
@@ -994,7 +996,7 @@ void DoRestore(JobControlRecord* jcr)
== NULL) {
Jmsg1(jcr, M_ERROR, 0,
_("Failed to decode message signature for %s\n"),
- jcr->impl->last_fname);
+ jcr->fd_impl->last_fname);
}
break;
@@ -1040,11 +1042,11 @@ void DoRestore(JobControlRecord* jcr)
}
if (!ClosePreviousStream(jcr, rctx)) { goto bail_out; }
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
goto ok_out;
bail_out:
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
ok_out:
#ifdef HAVE_WIN32
@@ -1055,15 +1057,15 @@ ok_out:
// First output the statistics.
Dmsg2(10, "End Do Restore. Files=%d Bytes=%s\n", jcr->JobFiles,
edit_uint64(jcr->JobBytes, ec1));
- if (have_acl && jcr->impl->acl_data->u.parse->nr_errors > 0) {
+ if (have_acl && jcr->fd_impl->acl_data->u.parse->nr_errors > 0) {
Jmsg(jcr, M_WARNING, 0,
_("Encountered %ld acl errors while doing restore\n"),
- jcr->impl->acl_data->u.parse->nr_errors);
+ jcr->fd_impl->acl_data->u.parse->nr_errors);
}
- if (have_xattr && jcr->impl->xattr_data->u.parse->nr_errors > 0) {
+ if (have_xattr && jcr->fd_impl->xattr_data->u.parse->nr_errors > 0) {
Jmsg(jcr, M_WARNING, 0,
_("Encountered %ld xattr errors while doing restore\n"),
- jcr->impl->xattr_data->u.parse->nr_errors);
+ jcr->fd_impl->xattr_data->u.parse->nr_errors);
}
if (non_support_data > 1 || non_support_attr > 1) {
Jmsg(jcr, M_WARNING, 0,
@@ -1095,9 +1097,9 @@ ok_out:
// Free Signature & Crypto Data
FreeSignature(rctx);
FreeSession(rctx);
- if (jcr->impl->crypto.digest) {
- CryptoDigestFree(jcr->impl->crypto.digest);
- jcr->impl->crypto.digest = NULL;
+ if (jcr->fd_impl->crypto.digest) {
+ CryptoDigestFree(jcr->fd_impl->crypto.digest);
+ jcr->fd_impl->crypto.digest = NULL;
}
// Free file cipher restore context
@@ -1121,10 +1123,12 @@ ok_out:
rctx.fork_cipher_ctx.buf = NULL;
}
- if (have_acl && jcr->impl->acl_data) { free(jcr->impl->acl_data->u.parse); }
+ if (have_acl && jcr->fd_impl->acl_data) {
+ free(jcr->fd_impl->acl_data->u.parse);
+ }
- if (have_xattr && jcr->impl->xattr_data) {
- free(jcr->impl->xattr_data->u.parse);
+ if (have_xattr && jcr->fd_impl->xattr_data) {
+ free(jcr->fd_impl->xattr_data->u.parse);
}
// Free the delayed stream stack list.
@@ -1143,7 +1147,7 @@ ok_out:
int DoFileDigest(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
{
Dmsg1(50, "DoFileDigest jcr=%p\n", jcr);
- return (DigestFile(jcr, ff_pkt, jcr->impl->crypto.digest));
+ return (DigestFile(jcr, ff_pkt, jcr->fd_impl->crypto.digest));
}
bool SparseData(JobControlRecord* jcr,
@@ -1163,7 +1167,7 @@ bool SparseData(JobControlRecord* jcr,
if (blseek(bfd, (boffset_t)*addr, SEEK_SET) < 0) {
BErrNo be;
Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
- edit_uint64(*addr, ec1), jcr->impl->last_fname,
+ edit_uint64(*addr, ec1), jcr->fd_impl->last_fname,
be.bstrerror(bfd->BErrNo));
return false;
}
@@ -1179,8 +1183,8 @@ bool StoreData(JobControlRecord* jcr,
const int32_t length,
bool win32_decomp)
{
- if (jcr->impl->crypto.digest) {
- CryptoDigestUpdate(jcr->impl->crypto.digest, (uint8_t*)data, length);
+ if (jcr->fd_impl->crypto.digest) {
+ CryptoDigestUpdate(jcr->fd_impl->crypto.digest, (uint8_t*)data, length);
}
if (win32_decomp) {
@@ -1188,7 +1192,7 @@ bool StoreData(JobControlRecord* jcr,
BErrNo be;
Jmsg2(jcr, M_ERROR, 0,
_("Write error in Win32 Block Decomposition on %s: %s\n"),
- jcr->impl->last_fname, be.bstrerror(bfd->BErrNo));
+ jcr->fd_impl->last_fname, be.bstrerror(bfd->BErrNo));
return false;
}
#ifdef HAVE_WIN32
@@ -1198,22 +1202,22 @@ bool StoreData(JobControlRecord* jcr,
!= (ssize_t)length) {
BErrNo be;
Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"),
- jcr->impl->last_fname, be.bstrerror(bfd->BErrNo));
+ jcr->fd_impl->last_fname, be.bstrerror(bfd->BErrNo));
return false;
}
} else {
if (bwrite(bfd, data, length) != (ssize_t)length) {
BErrNo be;
Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"),
- jcr->impl->last_fname, be.bstrerror(bfd->BErrNo));
+ jcr->fd_impl->last_fname, be.bstrerror(bfd->BErrNo));
}
}
}
#else
} else if (bwrite(bfd, data, length) != (ssize_t)length) {
BErrNo be;
- Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), jcr->impl->last_fname,
- be.bstrerror(bfd->BErrNo));
+ Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"),
+ jcr->fd_impl->last_fname, be.bstrerror(bfd->BErrNo));
return false;
}
#endif
@@ -1256,7 +1260,7 @@ int32_t ExtractData(JobControlRecord* jcr,
}
if (BitIsSet(FO_COMPRESS, flags)) {
- if (!DecompressData(jcr, jcr->impl->last_fname, stream, &wbuf, &wsize,
+ if (!DecompressData(jcr, jcr->fd_impl->last_fname, stream, &wbuf, &wsize,
false)) {
goto bail_out;
}
@@ -1333,7 +1337,7 @@ static bool ClosePreviousStream(JobControlRecord* jcr, r_ctx& rctx)
// Free Signature
FreeSignature(rctx);
FreeSession(rctx);
- ClearAllBits(FO_MAX, rctx.jcr->impl->ff->flags);
+ ClearAllBits(FO_MAX, rctx.jcr->fd_impl->ff->flags);
Dmsg0(130, "Stop extracting.\n");
} else if (IsBopen(&rctx.bfd)) {
Jmsg0(rctx.jcr, M_ERROR, 0,
diff --git a/core/src/filed/sd_cmds.cc b/core/src/filed/sd_cmds.cc
index 91991ab3f..f976ca1f4 100644
--- a/core/src/filed/sd_cmds.cc
+++ b/core/src/filed/sd_cmds.cc
@@ -1,7 +1,7 @@
/*
BAREOSĀ® - Backup Archiving REcovery Open Sourced
- Copyright (C) 2013-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -27,7 +27,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "filed/authenticate.h"
#include "lib/bnet.h"
#include "lib/bsock.h"
@@ -84,15 +84,15 @@ void* handle_stored_connection(BareosSocket* sd)
if (!AuthenticateStoragedaemon(jcr)) {
Dmsg1(50, "Authentication failed Job %s\n", jcr->Job);
Jmsg(jcr, M_FATAL, 0, _("Unable to authenticate Storage daemon\n"));
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
} else {
Dmsg2(50, "OK Authentication jid=%u Job %s\n", (uint32_t)jcr->JobId,
jcr->Job);
}
if (!jcr->max_bandwidth) {
- if (jcr->impl->director->max_bandwidth_per_job) {
- jcr->max_bandwidth = jcr->impl->director->max_bandwidth_per_job;
+ if (jcr->fd_impl->director->max_bandwidth_per_job) {
+ jcr->max_bandwidth = jcr->fd_impl->director->max_bandwidth_per_job;
} else if (me->max_bandwidth_per_job) {
jcr->max_bandwidth = me->max_bandwidth_per_job;
}
diff --git a/core/src/filed/status.cc b/core/src/filed/status.cc
index 6355a2a7b..99fa079c4 100644
--- a/core/src/filed/status.cc
+++ b/core/src/filed/status.cc
@@ -30,7 +30,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "lib/status_packet.h"
#include "lib/bsock.h"
#include "lib/edit.h"
@@ -169,21 +169,21 @@ static void ListRunningJobsPlain(StatusPacket* sp)
njcr->Job);
sp->send(msg, len);
#ifdef WIN32_VSS
- len = Mmsg(
- msg, _(" %s%s %s Job started: %s\n"),
- (njcr->impl->pVSSClient && njcr->impl->pVSSClient->IsInitialized())
- ? "VSS "
- : "",
- JobLevelToString(njcr->getJobLevel()),
- job_type_to_str(njcr->getJobType()), dt);
+ len = Mmsg(msg, _(" %s%s %s Job started: %s\n"),
+ (njcr->fd_impl->pVSSClient
+ && njcr->fd_impl->pVSSClient->IsInitialized())
+ ? "VSS "
+ : "",
+ JobLevelToString(njcr->getJobLevel()),
+ job_type_to_str(njcr->getJobType()), dt);
#else
len = Mmsg(msg, _(" %s %s Job started: %s\n"),
JobLevelToString(njcr->getJobLevel()),
job_type_to_str(njcr->getJobType()), dt);
#endif
- } else if ((njcr->JobId == 0) && (njcr->impl->director)) {
+ } else if ((njcr->JobId == 0) && (njcr->fd_impl->director)) {
len = Mmsg(msg, _("%s (director) connected at: %s\n"),
- njcr->impl->director->resource_name_, dt);
+ njcr->fd_impl->director->resource_name_, dt);
} else {
/*
* This should only occur shortly, until the JobControlRecord values are
@@ -205,11 +205,12 @@ static void ListRunningJobsPlain(StatusPacket* sp)
edit_uint64_with_commas(njcr->max_bandwidth, b4));
sp->send(msg, len);
len = Mmsg(msg, _(" Files Examined=%s\n"),
- edit_uint64_with_commas(njcr->impl->num_files_examined, b1));
+ edit_uint64_with_commas(njcr->fd_impl->num_files_examined, b1));
sp->send(msg, len);
if (njcr->JobFiles > 0) {
njcr->lock();
- len = Mmsg(msg, _(" Processing file: %s\n"), njcr->impl->last_fname);
+ len = Mmsg(msg, _(" Processing file: %s\n"),
+ njcr->fd_impl->last_fname);
njcr->unlock();
sp->send(msg, len);
}
@@ -242,7 +243,7 @@ static void ListRunningJobsApi(StatusPacket* sp)
PoolMem msg(PM_MESSAGE);
char dt[MAX_TIME_LENGTH], b1[32], b2[32], b3[32], b4[32];
- // List running jobs for Bat/Bweb (simple to parse)
+ // List running jobs for Bat/Bweb (sfd_imple to parse)
foreach_jcr (njcr) {
bstrutime(dt, sizeof(dt), njcr->start_time);
if (njcr->JobId == 0) {
@@ -251,12 +252,12 @@ static void ListRunningJobsApi(StatusPacket* sp)
len = Mmsg(msg, "JobId=%d\n Job=%s\n", njcr->JobId, njcr->Job);
sp->send(msg, len);
#ifdef WIN32_VSS
- len = Mmsg(
- msg, " VSS=%d\n Level=%c\n JobType=%c\n JobStarted=%s\n",
- (njcr->impl->pVSSClient && njcr->impl->pVSSClient->IsInitialized())
- ? 1
- : 0,
- njcr->getJobLevel(), njcr->getJobType(), dt);
+ len = Mmsg(msg, " VSS=%d\n Level=%c\n JobType=%c\n JobStarted=%s\n",
+ (njcr->fd_impl->pVSSClient
+ && njcr->fd_impl->pVSSClient->IsInitialized())
+ ? 1
+ : 0,
+ njcr->getJobLevel(), njcr->getJobType(), dt);
#else
len = Mmsg(msg, " VSS=%d\n Level=%c\n JobType=%c\n JobStarted=%s\n", 0,
njcr->getJobLevel(), njcr->getJobType(), dt);
@@ -275,11 +276,11 @@ static void ListRunningJobsApi(StatusPacket* sp)
edit_int64(njcr->max_bandwidth, b4));
sp->send(msg, len);
len = Mmsg(msg, " Files Examined=%s\n",
- edit_uint64(njcr->impl->num_files_examined, b1));
+ edit_uint64(njcr->fd_impl->num_files_examined, b1));
sp->send(msg, len);
if (njcr->JobFiles > 0) {
njcr->lock();
- len = Mmsg(msg, " Processing file=%s\n", njcr->impl->last_fname);
+ len = Mmsg(msg, " Processing file=%s\n", njcr->fd_impl->last_fname);
njcr->unlock();
sp->send(msg, len);
}
@@ -440,7 +441,8 @@ bool QstatusCmd(JobControlRecord* jcr)
dir->fsend(OKqstatus, cmd);
foreach_jcr (njcr) {
if (njcr->JobId != 0) {
- dir->fsend(DotStatusJob, njcr->JobId, njcr->JobStatus, njcr->JobErrors);
+ dir->fsend(DotStatusJob, njcr->JobId, njcr->getJobStatus(),
+ njcr->JobErrors);
}
}
endeach_jcr(njcr);
diff --git a/core/src/filed/verify.cc b/core/src/filed/verify.cc
index 544010859..72dccfb96 100644
--- a/core/src/filed/verify.cc
+++ b/core/src/filed/verify.cc
@@ -27,7 +27,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "findlib/find.h"
#include "findlib/attribs.h"
#include "lib/attribs.h"
@@ -62,24 +62,24 @@ static bool calculate_file_chksum(JobControlRecord* jcr,
*/
void DoVerify(JobControlRecord* jcr)
{
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
jcr->buf_size = DEFAULT_NETWORK_BUFFER_SIZE;
- if ((jcr->impl->big_buf = (char*)malloc(jcr->buf_size)) == NULL) {
+ if ((jcr->fd_impl->big_buf = (char*)malloc(jcr->buf_size)) == NULL) {
Jmsg1(jcr, M_ABORT, 0, _("Cannot malloc %d network read buffer\n"),
DEFAULT_NETWORK_BUFFER_SIZE);
}
- 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);
Dmsg0(10, "Start find files\n");
/* Subroutine VerifyFile() is called for each file */
- FindFiles(jcr, (FindFilesPacket*)jcr->impl->ff, VerifyFile, NULL);
+ FindFiles(jcr, (FindFilesPacket*)jcr->fd_impl->ff, VerifyFile, NULL);
Dmsg0(10, "End find files\n");
- 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;
}
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
}
/**
@@ -96,7 +96,7 @@ static int VerifyFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
if (JobCanceled(jcr)) { return 0; }
dir = jcr->dir_bsock;
- 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 */
@@ -112,8 +112,8 @@ static int VerifyFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
Dmsg2(30, "FT_LNK saving: %s -> %s\n", ff_pkt->fname, ff_pkt->link);
break;
case FT_DIRBEGIN:
- jcr->impl->num_files_examined--; /* correct file count */
- return 1; /* ignored */
+ jcr->fd_impl->num_files_examined--; /* correct file count */
+ return 1; /* ignored */
case FT_REPARSE:
case FT_JUNCTION:
case FT_DIREND:
@@ -197,7 +197,7 @@ static int VerifyFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool)
jcr->lock();
jcr->JobFiles++; /* increment number of files sent */
- PmStrcpy(jcr->impl->last_fname, ff_pkt->fname);
+ PmStrcpy(jcr->fd_impl->last_fname, ff_pkt->fname);
jcr->unlock();
/*
@@ -330,7 +330,7 @@ static int ReadDigest(BareosWinFilePacket* bfd,
char buf[DEFAULT_NETWORK_BUFFER_SIZE];
int64_t n;
int64_t bufsiz = (int64_t)sizeof(buf);
- FindFilesPacket* ff_pkt = (FindFilesPacket*)jcr->impl->ff;
+ FindFilesPacket* ff_pkt = (FindFilesPacket*)jcr->fd_impl->ff;
uint64_t fileAddr = 0; /* file address */
@@ -360,10 +360,10 @@ static int ReadDigest(BareosWinFilePacket* bfd,
if (n < 0) {
BErrNo be;
be.SetErrno(bfd->BErrNo);
- Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->impl->last_fname,
+ Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->fd_impl->last_fname,
be.bstrerror());
Jmsg(jcr, M_ERROR, 1, _("Error reading file %s: ERR=%s\n"),
- jcr->impl->last_fname, be.bstrerror());
+ jcr->fd_impl->last_fname, be.bstrerror());
jcr->JobErrors++;
return -1;
}
diff --git a/core/src/filed/verify_vol.cc b/core/src/filed/verify_vol.cc
index adb2b0c6b..a3d731f68 100644
--- a/core/src/filed/verify_vol.cc
+++ b/core/src/filed/verify_vol.cc
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2002-2010 Free Software Foundation Europe e.V.
- Copyright (C) 2016-2020 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -29,7 +29,7 @@
#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
-#include "filed/jcr_private.h"
+#include "filed/filed_jcr_impl.h"
#include "lib/bsock.h"
#include "lib/bget_msg.h"
#include "lib/bnet.h"
@@ -62,11 +62,11 @@ void DoVerifyVolume(JobControlRecord* jcr)
sd = jcr->store_bsock;
if (!sd) {
Jmsg(jcr, M_FATAL, 0, _("Storage command not issued before Verify.\n"));
- jcr->setJobStatus(JS_FatalError);
+ jcr->setJobStatusWithPriorityCheck(JS_FatalError);
return;
}
dir = jcr->dir_bsock;
- jcr->setJobStatus(JS_Running);
+ jcr->setJobStatusWithPriorityCheck(JS_Running);
LockRes(my_config);
ClientResource* client
@@ -79,7 +79,7 @@ void DoVerifyVolume(JobControlRecord* jcr)
buf_size = 0; /* use default */
}
if (!BnetSetBufferSize(sd, buf_size, BNET_SETBUF_WRITE)) {
- jcr->setJobStatus(JS_FatalError);
+ jcr->setJobStatusWithPriorityCheck(JS_FatalError);
return;
}
jcr->buf_size = sd->message_length;
@@ -166,8 +166,8 @@ void DoVerifyVolume(JobControlRecord* jcr)
}
jcr->lock();
jcr->JobFiles++;
- jcr->impl->num_files_examined++;
- PmStrcpy(jcr->impl->last_fname, fname); /* last file examined */
+ jcr->fd_impl->num_files_examined++;
+ PmStrcpy(jcr->fd_impl->last_fname, fname); /* last file examined */
jcr->unlock();
/*
@@ -249,7 +249,7 @@ void DoVerifyVolume(JobControlRecord* jcr)
case STREAM_RESTORE_OBJECT:
jcr->lock();
jcr->JobFiles++;
- jcr->impl->num_files_examined++;
+ jcr->fd_impl->num_files_examined++;
jcr->unlock();
Dmsg2(400, "send inx=%d STREAM_RESTORE_OBJECT-%d\n", jcr->JobFiles,
@@ -264,11 +264,11 @@ void DoVerifyVolume(JobControlRecord* jcr)
} /* end switch */
} /* end while bnet_get */
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
goto ok_out;
bail_out:
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
ok_out:
CleanupCompression(jcr);
diff --git a/core/src/findlib/attribs.cc b/core/src/findlib/attribs.cc
index 97f9fb544..dc94b0a56 100644
--- a/core/src/findlib/attribs.cc
+++ b/core/src/findlib/attribs.cc
@@ -600,12 +600,10 @@ int encode_attribsEx(JobControlRecord* jcr,
}
// Do casting according to unknown type to keep compiler happy
-# ifdef HAVE_TYPEOF
-# define plug(st, val) st = (typeof st)val
-# else
-// Use templates to do the casting
-template <class T> void plug(T& st, uint64_t val) { st = static_cast<T>(val); }
-# endif
+template <typename T> static void plug(T& st, uint64_t val)
+{
+ st = static_cast<T>(val);
+}
/**
* Set Extended File Attributes for Win32
diff --git a/core/src/include/config.h.in b/core/src/include/config.h.in
index 93b4b58b9..d2b4f99ab 100644
--- a/core/src/include/config.h.in
+++ b/core/src/include/config.h.in
@@ -487,9 +487,6 @@ extern char win_os[];
// Define to 1 if TLS support should be enabled
#cmakedefine HAVE_TLS @HAVE_TLS@
-// Define to 1 if compiler has typeof
-#cmakedefine HAVE_TYPEOF @HAVE_TYPEOF@
-
// Define to 1 if you have the <ucontext.h> header file
#cmakedefine HAVE_UCONTEXT_H @HAVE_UCONTEXT_H@
diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h
index 2594353df..f140e399f 100644
--- a/core/src/include/jcr.h
+++ b/core/src/include/jcr.h
@@ -45,8 +45,9 @@
#include "lib/breg.h"
#include "lib/dlink.h"
#include "lib/path_list.h"
-#include <unordered_set>
+#include <unordered_set>
+#include <atomic>
struct job_callback_item;
class BareosDb;
@@ -56,7 +57,9 @@ class JobControlRecord;
struct AttributesDbRecord;
struct PluginContext;
-struct JobControlRecordPrivate;
+struct DirectorJcrImpl;
+struct StoredJcrImpl;
+struct FiledJcrImpl;
struct VolumeSessionInfo;
#ifdef HAVE_WIN32
@@ -66,11 +69,12 @@ struct CopyThreadContext;
typedef void(JCR_free_HANDLER)(JobControlRecord* jcr);
#define JobTerminatedSuccessfully(jcr) \
- (jcr->JobStatus == JS_Terminated || jcr->JobStatus == JS_Warnings)
+ (jcr->getJobStatus() == JS_Terminated || jcr->getJobStatus() == JS_Warnings)
-#define JobCanceled(jcr) \
- (jcr->JobStatus == JS_Canceled || jcr->JobStatus == JS_ErrorTerminated \
- || jcr->JobStatus == JS_FatalError)
+#define JobCanceled(jcr) \
+ (jcr->getJobStatus() == JS_Canceled \
+ || jcr->getJobStatus() == JS_ErrorTerminated \
+ || jcr->getJobStatus() == JS_FatalError)
#define foreach_jcr(jcr) \
for (jcr = jcr_walk_start(); jcr; (jcr = jcr_walk_next(jcr)))
@@ -81,7 +85,8 @@ typedef void(JCR_free_HANDLER)(JobControlRecord* jcr);
class JobControlRecord {
private:
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /**< Jcr mutex */
- volatile int32_t _use_count{}; /**< Use count */
+ std::atomic<int32_t> _use_count{}; /**< Use count */
+ std::atomic<int32_t> JobStatus{}; /**< ready, running, blocked, terminated */
int32_t JobType_{}; /**< Backup, restore, verify ... */
int32_t JobLevel_{}; /**< Job level */
int32_t Protocol_{}; /**< Backup Protocol */
@@ -98,15 +103,11 @@ class JobControlRecord {
void unlock() { unlock_mutex(mutex); }
void IncUseCount(void)
{
- lock();
- _use_count++;
- unlock();
+ ++_use_count;
}
void DecUseCount(void)
{
- lock();
- _use_count--;
- unlock();
+ --_use_count;
}
int32_t UseCount() const { return _use_count; }
void InitMutex(void) { pthread_mutex_init(&mutex, NULL); }
@@ -121,7 +122,7 @@ class JobControlRecord {
void setJobLevel(int32_t JobLevel) { JobLevel_ = JobLevel; }
void setJobType(int32_t JobType) { JobType_ = JobType; }
void setJobProtocol(int32_t JobProtocol) { Protocol_ = JobProtocol; }
- void forceJobStatus(int32_t aJobStatus) { JobStatus = aJobStatus; }
+ void setJobStatus(int32_t aJobStatus) { JobStatus = aJobStatus; }
void setJobStarted();
int32_t getJobType() const { return JobType_; }
int32_t getJobLevel() const { return JobLevel_; }
@@ -135,8 +136,7 @@ class JobControlRecord {
bool IsPlugin() const { return (cmd_plugin || opt_plugin); }
const char* get_OperationName(); /**< in lib/jcr.c */
const char* get_ActionName(bool past = false); /**< in lib/jcr.c */
- void setJobStatus(int newJobStatus); /**< in lib/jcr.c */
- void resetJobStatus(int newJobStatus); /**< in lib/jcr.c */
+ void setJobStatusWithPriorityCheck(int newJobStatus); /**< in lib/jcr.c */
bool sendJobStatus(); /**< in lib/jcr.c */
bool sendJobStatus(int newJobStatus); /**< in lib/jcr.c */
bool JobReads(); /**< in lib/jcr.c */
@@ -169,7 +169,6 @@ class JobControlRecord {
uint64_t LastJobBytes{}; /**< Last sample number bytes */
uint64_t ReadBytes{}; /**< Bytes read -- before compression */
FileId_t FileId{}; /**< Last FileId used */
- volatile int32_t JobStatus{}; /**< ready, running, blocked, terminated */
int32_t JobPriority{}; /**< Job priority */
time_t sched_time{}; /**< Job schedule time, i.e. when it should start */
time_t initial_sched_time{}; /**< Original sched time before any reschedules are done */
@@ -233,7 +232,12 @@ class JobControlRecord {
PathList* path_list{}; /**< Directory list (used by findlib) */
bool is_passive_client_connection_probing{}; /**< Set if director probes a passive client connection */
- JobControlRecordPrivate* impl{nullptr}; /* Pointer to implementation of each daemon */
+ union {
+ DirectorJcrImpl* dir_impl;
+ StoredJcrImpl* sd_impl;
+ FiledJcrImpl* fd_impl;
+ };
+
};
/* clang-format on */
diff --git a/core/src/lib/alist.h b/core/src/lib/alist.h
index f6d83dfec..45a3b3f94 100644
--- a/core/src/lib/alist.h
+++ b/core/src/lib/alist.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2003-2012 Free Software Foundation Europe e.V.
- Copyright (C) 2016-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -35,48 +35,18 @@
* Loop var through each member of list using an increasing index.
* Loop var through each member of list using an decreasing index.
*/
-#ifdef HAVE_TYPEOF
-# define foreach_alist(var, list) \
- for ((var) = list ? (typeof((var)))(list)->first() : 0; (var); \
- (var) = (typeof(var))(list)->next())
-
-# define foreach_alist_null(var, list) \
- for ((var) = list ? (typeof((var)))(list)->first() : nullptr; (var); \
- (var) = (typeof(var))(list)->next())
-
-# define foreach_alist_index(inx, var, list) \
- for ((inx) = 0; \
- (list != nullptr) ? ((var) = (typeof((var)))(list)->get((inx))) : 0; \
- (inx)++)
-
-# define foreach_alist_rindex(inx, var, list) \
- for ((list != nullptr) ? (inx) = ((list)->size() - 1) : 0; \
- (list != nullptr) ? ((var) = (typeof((var)))(list)->get((inx))) : 0; \
- (inx)--)
-
-#else
-# define foreach_alist(var, list) \
- for ((void)(list ? (*((void**)&(var)) = (void*)((list)->first())) : 0); \
- (var); (*((void**)&(var)) = (void*)((list)->next())))
-
-# define foreach_alist_null(var, list) \
- for ((void)(list ? (*((void**)&(var)) = (void*)((list)->first())) \
- : nullptr); \
- (var); (*((void**)&(var)) = (void*)((list)->next())))
-
-# define foreach_alist_index(inx, var, list) \
- for ((inx) = 0; (list != nullptr) \
- ? ((*((void**)&(var)) = (void*)((list)->get((inx))))) \
- : 0; \
- (inx)++)
-
-# define foreach_alist_rindex(inx, var, list) \
- for ((list != nullptr) ? (inx) = ((list)->size() - 1) : 0; \
- (list != nullptr) \
- ? ((*((void**)&(var)) = (void*)((list)->get((inx))))) \
- : 0; \
- (inx)--)
-#endif
+#define foreach_alist(var, list) \
+ for ((var) = list ? (list)->first() : 0; (var); (var) = (list)->next())
+
+#define foreach_alist_null(var, list) \
+ for ((var) = list ? (list)->first() : nullptr; (var); (var) = (list)->next())
+
+#define foreach_alist_index(inx, var, list) \
+ for ((inx) = 0; (list != nullptr) ? ((var) = (list)->get((inx))) : 0; (inx)++)
+
+#define foreach_alist_rindex(inx, var, list) \
+ for ((list != nullptr) ? (inx) = ((list)->size() - 1) : 0; \
+ (list != nullptr) ? ((var) = (list)->get((inx))) : 0; (inx)--)
#include <string>
diff --git a/core/src/lib/attribs.cc b/core/src/lib/attribs.cc
index a624e7397..b84733035 100644
--- a/core/src/lib/attribs.cc
+++ b/core/src/lib/attribs.cc
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2002-2011 Free Software Foundation Europe e.V.
- Copyright (C) 2016-2018 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -107,23 +107,10 @@ void EncodeStat(char* buf,
}
/* Do casting according to unknown type to keep compiler happy */
-#ifdef HAVE_TYPEOF
-# define plug(st, val) st = (typeof st)val
-#else
-# if !HAVE_GCC & HAVE_SUN_OS
-/* Sun compiler does not handle templates correctly */
-# define plug(st, val) st = val
-# elif __sgi
-# define plug(st, val) st = val
-# else
-/* Use templates to do the casting */
-template <class T>
-void plug(T& st, uint64_t val)
+template <typename T> static void plug(T& st, uint64_t val)
{
st = static_cast<T>(val);
}
-# endif
-#endif
// Decode a stat packet from base64 characters
int DecodeStat(char* buf, struct stat* statp, int stat_size, int32_t* LinkFI)
diff --git a/core/src/lib/bareos_resource.cc b/core/src/lib/bareos_resource.cc
index 648405e54..b042c9153 100644
--- a/core/src/lib/bareos_resource.cc
+++ b/core/src/lib/bareos_resource.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2020 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -23,9 +23,9 @@
#include "lib/bareos_resource.h"
-const char* GetResourceName(void* resource)
+const char* GetResourceName(const void* resource)
{
- return ((BareosResource*)resource)->resource_name_;
+ return static_cast<const BareosResource*>(resource)->resource_name_;
}
BareosResource::BareosResource()
diff --git a/core/src/lib/bareos_resource.h b/core/src/lib/bareos_resource.h
index 2830c98c1..288695012 100644
--- a/core/src/lib/bareos_resource.h
+++ b/core/src/lib/bareos_resource.h
@@ -3,7 +3,7 @@
Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -64,6 +64,6 @@ class BareosResource {
bool verbose);
};
-const char* GetResourceName(void* resource);
+const char* GetResourceName(const void* resource);
#endif // BAREOS_LIB_BAREOS_RESOURCE_H_
diff --git a/core/src/lib/bsock.cc b/core/src/lib/bsock.cc
index 5eadb5d09..a4817059a 100644
--- a/core/src/lib/bsock.cc
+++ b/core/src/lib/bsock.cc
@@ -97,11 +97,11 @@ BareosSocket::BareosSocket(const BareosSocket& other)
in_msg_no = other.in_msg_no;
out_msg_no = other.out_msg_no;
message_length = other.message_length;
- timer_start = other.timer_start;
+ timer_start = other.timer_start.load();
b_errno = other.b_errno;
blocking_ = other.blocking_;
- errors = other.errors;
- suppress_error_msgs_ = other.suppress_error_msgs_;
+ errors = other.errors.load();
+ suppress_error_msgs_ = other.suppress_error_msgs_.load();
sleep_time_after_authentication_error
= other.sleep_time_after_authentication_error;
client_addr = other.client_addr;
diff --git a/core/src/lib/bsock.h b/core/src/lib/bsock.h
index 859c57983..5a2632047 100644
--- a/core/src/lib/bsock.h
+++ b/core/src/lib/bsock.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
- Copyright (C) 2016-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -37,9 +37,6 @@
#define BAREOS_LIB_BSOCK_H_
#include <include/bareos.h>
-#include <mutex>
-#include <functional>
-#include <cassert>
#include "lib/address_conf.h"
#include "lib/bnet_network_dump.h"
#include "lib/tls.h"
@@ -47,6 +44,11 @@
#include "lib/tls_conf.h"
#include "include/version_numbers.h"
+#include <mutex>
+#include <functional>
+#include <cassert>
+#include <atomic>
+
struct btimer_t; /* forward reference */
class BareosSocket;
class Tls;
@@ -62,20 +64,20 @@ class BareosSocket {
* bat breaks on some systems such as RedHat.
*/
public:
- int fd_; /* Socket file descriptor */
- uint64_t read_seqno; /* Read sequence number */
- POOLMEM* msg; /* Message pool buffer */
- POOLMEM* errmsg; /* Edited error message */
- int spool_fd_; /* Spooling file */
- IPADDR* src_addr; /* IP address to source connections from */
- uint32_t in_msg_no; /* Input message number */
- uint32_t out_msg_no; /* Output message number */
- int32_t message_length; /* Message length */
- volatile time_t timer_start; /* Time started read/write */
- int b_errno; /* BareosSocket errno */
- int blocking_; /* Blocking state (0 = nonblocking, 1 = blocking) */
- volatile int errors; /* Incremented for each error on socket */
- volatile bool suppress_error_msgs_; /* Set to suppress error messages */
+ int fd_; /* Socket file descriptor */
+ uint64_t read_seqno; /* Read sequence number */
+ POOLMEM* msg; /* Message pool buffer */
+ POOLMEM* errmsg; /* Edited error message */
+ int spool_fd_; /* Spooling file */
+ IPADDR* src_addr; /* IP address to source connections from */
+ uint32_t in_msg_no; /* Input message number */
+ uint32_t out_msg_no; /* Output message number */
+ int32_t message_length; /* Message length */
+ std::atomic<time_t> timer_start; /* Time started read/write */
+ int b_errno; /* BareosSocket errno */
+ int blocking_; /* Blocking state (0 = nonblocking, 1 = blocking) */
+ std::atomic<int> errors; /* Incremented for each error on socket */
+ std::atomic<bool> suppress_error_msgs_; /* Set to suppress error messages */
int sleep_time_after_authentication_error;
struct sockaddr client_addr; /* Client's IP address */
diff --git a/core/src/lib/bsock_tcp.cc b/core/src/lib/bsock_tcp.cc
index bc92dbd46..84571e9e5 100644
--- a/core/src/lib/bsock_tcp.cc
+++ b/core/src/lib/bsock_tcp.cc
@@ -396,7 +396,7 @@ bool BareosSocketTCP::SendPacket(int32_t* hdr, int32_t pktsiz)
rc = write_nbytes((char*)hdr, pktsiz);
timer_start = 0; /* clear timer */
if (rc != pktsiz) {
- errors++;
+ ++errors;
if (errno == 0) {
b_errno = EIO;
} else {
@@ -451,7 +451,7 @@ bool BareosSocketTCP::send()
if (errors) {
if (!suppress_error_msgs_) {
Qmsg4(jcr_, M_ERROR, 0, _("Socket has errors=%d on call to %s:%s:%d\n"),
- errors, who_, host_, port_);
+ errors.load(), who_, host_, port_);
}
return false;
}
@@ -544,13 +544,13 @@ int32_t BareosSocketTCP::recv()
} else {
b_errno = errno;
}
- errors++;
+ ++errors;
nbytes = BNET_HARDEOF; /* assume hard EOF received */
goto get_out;
}
timer_start = 0; /* clear timer */
if (nbytes != header_length) {
- errors++;
+ ++errors;
b_errno = EIO;
Qmsg5(jcr_, M_ERROR, 0, _("Read expected %d got %d from %s:%s:%d\n"),
header_length, nbytes, who_, host_, port_);
@@ -600,7 +600,7 @@ int32_t BareosSocketTCP::recv()
} else {
b_errno = errno;
}
- errors++;
+ ++errors;
Qmsg4(jcr_, M_ERROR, 0, _("Read error from %s:%s:%d: ERR=%s\n"), who_,
host_, port_, this->bstrerror());
nbytes = BNET_ERROR;
@@ -611,7 +611,7 @@ int32_t BareosSocketTCP::recv()
message_length = nbytes;
if (nbytes != pktsiz) {
b_errno = EIO;
- errors++;
+ ++errors;
Qmsg5(jcr_, M_ERROR, 0, _("Read expected %d got %d from %s:%s:%d\n"),
pktsiz, nbytes, who_, host_, port_);
nbytes = BNET_ERROR;
diff --git a/core/src/lib/compression.cc b/core/src/lib/compression.cc
index e6ef413c1..ab507793d 100644
--- a/core/src/lib/compression.cc
+++ b/core/src/lib/compression.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -304,7 +304,7 @@ static bool compress_with_zlib(JobControlRecord* jcr,
if ((zstat = deflate(pZlibStream, Z_FINISH)) != Z_STREAM_END) {
Jmsg(jcr, M_FATAL, 0, _("Compression deflate error: %d\n"), zstat);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -313,7 +313,7 @@ static bool compress_with_zlib(JobControlRecord* jcr,
// Reset zlib stream to be able to begin from scratch again
if ((zstat = deflateReset(pZlibStream)) != Z_OK) {
Jmsg(jcr, M_FATAL, 0, _("Compression deflateReset error: %d\n"), zstat);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -344,7 +344,7 @@ static bool compress_with_lzo(JobControlRecord* jcr,
if (lzores != LZO_E_OK || *compress_len > max_compress_len) {
// This should NEVER happen
Jmsg(jcr, M_FATAL, 0, _("Compression LZO error: %d\n"), lzores);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -376,7 +376,7 @@ static bool compress_with_fastlz(JobControlRecord* jcr,
if ((zstat = fastlzlibCompress(pZfastStream, Z_FINISH)) != Z_STREAM_END) {
Jmsg(jcr, M_FATAL, 0, _("Compression fastlzlibCompress error: %d\n"),
zstat);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -386,7 +386,7 @@ static bool compress_with_fastlz(JobControlRecord* jcr,
if ((zstat = fastlzlibCompressReset(pZfastStream)) != Z_OK) {
Jmsg(jcr, M_FATAL, 0, _("Compression fastlzlibCompressReset error: %d\n"),
zstat);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
diff --git a/core/src/lib/connection_pool.h b/core/src/lib/connection_pool.h
index 64414fcd1..d37f1b269 100644
--- a/core/src/lib/connection_pool.h
+++ b/core/src/lib/connection_pool.h
@@ -28,6 +28,8 @@
#ifndef BAREOS_LIB_CONNECTION_POOL_H_
#define BAREOS_LIB_CONNECTION_POOL_H_
+#include <atomic>
+
template <typename T> class alist;
class BareosSocket;
@@ -57,7 +59,7 @@ class Connection {
char name_[MAX_NAME_LENGTH];
int protocol_version_;
bool authenticated_;
- volatile bool in_use_;
+ std::atomic<bool> in_use_;
time_t connect_time_;
pthread_mutex_t mutex_;
};
diff --git a/core/src/lib/dlist.h b/core/src/lib/dlist.h
index ddb8d5890..0d2333333 100644
--- a/core/src/lib/dlist.h
+++ b/core/src/lib/dlist.h
@@ -34,24 +34,9 @@
#include "lib/message.h"
#include "lib/message_severity.h"
-/**
- * There is a lot of extra casting here to work around the fact
- * that some compilers (Sun and Visual C++) do not accept
- * (void *) as an lvalue on the left side of an equal.
- *
- * Loop var through each member of list
- */
-#ifdef HAVE_TYPEOF
-# define foreach_dlist(var, list) \
- for ((var) = nullptr; \
- (list ? ((var) = (typeof(var))(list)->next(var)) : nullptr) \
- != nullptr;)
-#else
-# define foreach_dlist(var, list) \
- for ((var) = nullptr; \
- (list ? (*((void**)&(var)) = (void*)((list)->next(var))) : nullptr) \
- != nullptr;)
-#endif
+#define foreach_dlist(var, list) \
+ for ((var) = nullptr; \
+ (list ? ((var) = (list)->next(var)) : nullptr) != nullptr;)
template <typename T> class dlist {
T* head{nullptr};
diff --git a/core/src/lib/htable.h b/core/src/lib/htable.h
index 6f2cd1c38..ebe653e9c 100644
--- a/core/src/lib/htable.h
+++ b/core/src/lib/htable.h
@@ -28,17 +28,8 @@
#ifndef BAREOS_LIB_HTABLE_H_
#define BAREOS_LIB_HTABLE_H_
-// Loop var through each member of table
-#ifdef HAVE_TYPEOF
-# define foreach_htable(var, tbl) \
- for ((var) = (typeof(var))((tbl)->first()); (var); \
- (var) = (typeof(var))((tbl)->next()))
-#else
-# define foreach_htable(var, tbl) \
- for ((*((void**)&(var)) = (void*)((tbl)->first())); (var); \
- (*((void**)&(var)) = (void*)((tbl)->next())))
-#endif
-
+#define foreach_htable(var, tbl) \
+ for ((var) = (tbl)->first(); (var); (var) = (tbl)->next())
#include "include/config.h"
#include "monotonic_buffer.h"
diff --git a/core/src/lib/implementation_factory.h b/core/src/lib/implementation_factory.h
new file mode 100644
index 000000000..727f0e6b5
--- /dev/null
+++ b/core/src/lib/implementation_factory.h
@@ -0,0 +1,67 @@
+/*
+ BAREOSĀ® - Backup Archiving REcovery Open Sourced
+
+ Copyright (C) 2022-2022 Bareos GmbH & Co. KG
+
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version three of the GNU Affero General Public
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+
+/*
+ * generic registry where you can register factory functions based on a name.
+ * The registry is templated on the implementation's interface, thus the
+ * names will be per interface.
+ */
+
+#ifndef BAREOS_LIB_IMPLEMENTATION_FACTORY_H_
+#define BAREOS_LIB_IMPLEMENTATION_FACTORY_H_
+
+#include <memory>
+#include <functional>
+#include <unordered_map>
+
+template <typename Interface> class ImplementationFactory {
+ using Factory = std::function<Interface*()>;
+ using Map = std::unordered_map<std::string, Factory>;
+
+ static Map& GetMap()
+ {
+ // this ensures thread-safe initialization (Meyers' singleton)
+ static Map factory_map;
+ return factory_map;
+ }
+
+ public:
+ // this retuns a bool, so you can initialize a global static variable from it
+ // to register your plugin when the program starts or during dl_open()
+ static bool Add(const std::string& implementation_name, Factory factory)
+ {
+ GetMap().insert({implementation_name, factory});
+ return true;
+ }
+
+ static bool IsRegistered(const std::string& implementation_name)
+ {
+ auto m = GetMap();
+ return m.find(implementation_name) != m.end();
+ }
+
+ static Interface* Create(const std::string& implementation_name)
+ {
+ Dmsg0(100, "Creating Instance for '%s'\n", implementation_name.c_str());
+ return GetMap().at(implementation_name)();
+ }
+};
+#endif // BAREOS_LIB_IMPLEMENTATION_FACTORY_H_
diff --git a/core/src/lib/jcr.cc b/core/src/lib/jcr.cc
index 7927ad127..cd983b894 100644
--- a/core/src/lib/jcr.cc
+++ b/core/src/lib/jcr.cc
@@ -217,7 +217,7 @@ JobControlRecord::JobControlRecord()
JobId = 0;
setJobType(JT_SYSTEM); /* internal job until defined */
setJobLevel(L_NONE);
- setJobStatus(JS_Created); /* ready to run */
+ setJobStatusWithPriorityCheck(JS_Created); /* ready to run */
SetTimeoutHandler();
}
@@ -660,7 +660,7 @@ TlsPolicy JcrGetTlsPolicy(const char* unified_job_name)
static void UpdateWaitTime(JobControlRecord* jcr, int newJobStatus)
{
bool enter_in_waittime;
- int oldJobStatus = jcr->JobStatus;
+ int oldJobStatus = jcr->getJobStatus();
switch (newJobStatus) {
case JS_WaitFD:
@@ -734,7 +734,7 @@ static int GetStatusPriority(int JobStatus)
// Send Job status to Director
bool JobControlRecord::sendJobStatus()
{
- if (dir_bsock) { return dir_bsock->fsend(Job_status, Job, JobStatus); }
+ if (dir_bsock) { return dir_bsock->fsend(Job_status, Job, getJobStatus()); }
return true;
}
@@ -743,8 +743,8 @@ bool JobControlRecord::sendJobStatus()
bool JobControlRecord::sendJobStatus(int newJobStatus)
{
if (!is_JobStatus(newJobStatus)) {
- setJobStatus(newJobStatus);
- if (dir_bsock) { return dir_bsock->fsend(Job_status, Job, JobStatus); }
+ setJobStatusWithPriorityCheck(newJobStatus);
+ if (dir_bsock) { return dir_bsock->fsend(Job_status, Job, getJobStatus()); }
}
return true;
@@ -756,21 +756,12 @@ void JobControlRecord::setJobStarted()
job_started_time = time(nullptr);
}
-void JobControlRecord::resetJobStatus(int newJobStatus)
-{
- JobStatus = newJobStatus;
-}
-
-void JobControlRecord::setJobStatus(int newJobStatus)
+void JobControlRecord::setJobStatusWithPriorityCheck(int newJobStatus)
{
int priority;
- int old_priority = 0;
- int oldJobStatus = ' ';
+ int oldJobStatus = JobStatus;
+ int old_priority = GetStatusPriority(oldJobStatus);
- if (JobStatus) {
- oldJobStatus = JobStatus;
- old_priority = GetStatusPriority(oldJobStatus);
- }
priority = GetStatusPriority(newJobStatus);
Dmsg2(800, "setJobStatus(%s, %c)\n", Job, newJobStatus);
@@ -794,7 +785,7 @@ void JobControlRecord::setJobStatus(int newJobStatus)
if (priority > old_priority || (priority == 0 && old_priority == 0)) {
Dmsg4(800, "Set new stat. old: %c,%d new: %c,%d\n", oldJobStatus,
old_priority, newJobStatus, priority);
- JobStatus = newJobStatus; /* replace with new status */
+ JobStatus.compare_exchange_strong(oldJobStatus, newJobStatus);
}
if (oldJobStatus != JobStatus) {
@@ -1047,11 +1038,11 @@ void DbgPrintJcr(FILE* fp)
jcr; jcr = (JobControlRecord*)job_control_record_chain->next(jcr)) {
fprintf(fp, "threadid=%s JobId=%d JobStatus=%c jcr=%p name=%s\n",
edit_pthread(jcr->my_thread_id, ed1, sizeof(ed1)), (int)jcr->JobId,
- jcr->JobStatus, jcr, jcr->Job);
- fprintf(fp,
- "threadid=%s killable=%d JobId=%d JobStatus=%c jcr=%p name=%s\n",
- edit_pthread(jcr->my_thread_id, ed1, sizeof(ed1)),
- jcr->IsKillable(), (int)jcr->JobId, jcr->JobStatus, jcr, jcr->Job);
+ jcr->getJobStatus(), jcr, jcr->Job);
+ fprintf(
+ fp, "threadid=%s killable=%d JobId=%d JobStatus=%c jcr=%p name=%s\n",
+ edit_pthread(jcr->my_thread_id, ed1, sizeof(ed1)), jcr->IsKillable(),
+ (int)jcr->JobId, jcr->getJobStatus(), jcr, jcr->Job);
fprintf(fp, "\tUseCount=%i\n", jcr->UseCount());
fprintf(fp, "\tJobType=%c JobLevel=%c\n", jcr->getJobType(),
jcr->getJobLevel());
diff --git a/core/src/lib/message.cc b/core/src/lib/message.cc
index ed45a30aa..27b0fc4f2 100644
--- a/core/src/lib/message.cc
+++ b/core/src/lib/message.cc
@@ -370,7 +370,7 @@ void CloseMsg(JobControlRecord* jcr)
switch (d->dest_code_) {
case MessageDestinationCode::KMailOnError:
if (jcr) {
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
case JS_Warnings:
goto rem_temp_file;
@@ -381,7 +381,7 @@ void CloseMsg(JobControlRecord* jcr)
break;
case MessageDestinationCode::kMailOnSuccess:
if (jcr) {
- switch (jcr->JobStatus) {
+ switch (jcr->getJobStatus()) {
case JS_Terminated:
case JS_Warnings:
break;
@@ -1291,7 +1291,7 @@ void Jmsg(JobControlRecord* jcr, int type, utime_t mtime, const char* fmt, ...)
break;
case M_FATAL:
Mmsg(buf, _("%s JobId %u: Fatal error: "), my_name, JobId);
- if (jcr) { jcr->setJobStatus(JS_FatalError); }
+ if (jcr) { jcr->setJobStatusWithPriorityCheck(JS_FatalError); }
if (jcr && jcr->JobErrors == 0) { jcr->JobErrors = 1; }
break;
case M_ERROR:
diff --git a/core/src/lib/output_formatter_resource.cc b/core/src/lib/output_formatter_resource.cc
index 1729f84c6..a0bc047fe 100644
--- a/core/src/lib/output_formatter_resource.cc
+++ b/core/src/lib/output_formatter_resource.cc
@@ -26,7 +26,7 @@
#include "lib/util.h"
#include "lib/output_formatter_resource.h"
-const char* GetAsCString(void* item) { return (const char*)item; }
+const char* GetAsCString(const void* item) { return (const char*)item; }
OutputFormatterResource::OutputFormatterResource(OutputFormatter* send,
int indent_level)
@@ -199,13 +199,13 @@ void OutputFormatterResource::KeyUnquotedString(const char* name,
void OutputFormatterResource::KeyMultipleStringsInOneLine(
const char* key,
alist<const char*>* list,
- std::function<const char*(void* item)> GetValue,
+ std::function<const char*(const void* item)> GetValue,
bool as_comment,
bool quoted_strings)
{
// Each member of the list is comma-separated
int cnt = 0;
- char* item = nullptr;
+ const char* item = nullptr;
std::string format = "%s";
if (quoted_strings) { format = "\"%s\""; }
@@ -255,13 +255,13 @@ void OutputFormatterResource::KeyMultipleStringsOnePerLineAddItem(
void OutputFormatterResource::KeyMultipleStringsOnePerLine(
const char* key,
alist<const char*>* list,
- std::function<const char*(void* item)> GetValue,
+ std::function<const char*(const void* item)> GetValue,
bool as_comment,
bool quoted_strings,
bool escape_strings)
{
// One line for each member of the list
- char* item = nullptr;
+ const char* item = nullptr;
if ((list == NULL) or (list->empty())) {
if (as_comment) {
diff --git a/core/src/lib/output_formatter_resource.h b/core/src/lib/output_formatter_resource.h
index 6820e894b..ee893b51d 100644
--- a/core/src/lib/output_formatter_resource.h
+++ b/core/src/lib/output_formatter_resource.h
@@ -1,7 +1,7 @@
/*
BAREOSĀ® - Backup Archiving REcovery Open Sourced
- Copyright (C) 2020-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2020-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -107,7 +107,7 @@ class OutputFormatterResource {
void KeyMultipleStringsInOneLine(
const char* key,
alist<const char*>* list,
- std::function<const char*(void* item)> GetValue,
+ std::function<const char*(const void* item)> GetValue,
bool as_comment = false,
bool quoted_strings = true);
@@ -117,12 +117,13 @@ class OutputFormatterResource {
bool quoted_strings = true,
bool escape_strings = false);
- void KeyMultipleStringsOnePerLine(const char* key,
- alist<const char*>* list,
- std::function<const char*(void*)> GetValue,
- bool as_comment = false,
- bool quoted_strings = true,
- bool escape_strings = false);
+ void KeyMultipleStringsOnePerLine(
+ const char* key,
+ alist<const char*>* list,
+ std::function<const char*(const void*)> GetValue,
+ bool as_comment = false,
+ bool quoted_strings = true,
+ bool escape_strings = false);
void KeyMultipleStringsOnePerLine(const char* key,
const std::vector<std::string>&,
diff --git a/core/src/lib/parse_conf.h b/core/src/lib/parse_conf.h
index 317098f52..9a0507df5 100644
--- a/core/src/lib/parse_conf.h
+++ b/core/src/lib/parse_conf.h
@@ -166,7 +166,7 @@ enum
CFG_TYPE_META = 91, /* Meta tag */
// Storage daemon resource types
- CFG_TYPE_DEVTYPE = 201, /* Device Type */
+ // CFG_TYPE_DEVTYPE = 201, /* Device Type */
CFG_TYPE_MAXBLOCKSIZE = 202, /* Maximum Blocksize */
CFG_TYPE_IODIRECTION = 203, /* AutoXflateMode IO Direction */
CFG_TYPE_CMPRSALGO = 204, /* Compression Algorithm */
@@ -475,16 +475,22 @@ void IndentConfigItem(PoolMem& cfg_str,
const char* config_item,
bool inherited = false);
+/* this function is used as an initializer in foreach_res, so we can null
+ * the pointer passed into and also get a reference to the configuration that
+ * we then keep for the lifetime of the loop.
+ */
+inline std::shared_ptr<ConfigResourcesContainer> _init_foreach_res_(
+ ConfigurationParser* my_config,
+ void* var)
+{
+ memset(var, 0, sizeof(void*));
+ return my_config->GetResourcesContainer();
+}
// Loop through each resource of type, returning in var
-#ifdef HAVE_TYPEOF
-# define foreach_res(var, type) \
- for ((var) = NULL; ((var) = (typeof(var))my_config->GetNextRes( \
- (type), (BareosResource*)var));)
-#else
-# define foreach_res(var, type) \
- for (var = NULL; (*((void**)&(var)) = (void*)my_config->GetNextRes( \
- (type), (BareosResource*)var));)
-#endif
+#define foreach_res(var, type) \
+ for (auto _config_table_ = _init_foreach_res_(my_config, &var); \
+ ((var) \
+ = static_cast<decltype(var)>(my_config->GetNextRes((type), var)));)
#define LockRes(x) (x)->b_LockRes(__FILE__, __LINE__)
#define UnlockRes(x) (x)->b_UnlockRes(__FILE__, __LINE__)
diff --git a/core/src/lib/plugins.cc b/core/src/lib/plugins.cc
index a68e23b69..6eee9c858 100644
--- a/core/src/lib/plugins.cc
+++ b/core/src/lib/plugins.cc
@@ -3,7 +3,7 @@
Copyright (C) 2007-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -215,7 +215,7 @@ bool LoadPlugins(void* bareos_plugin_interface_version,
* type.
*/
if (plugin_names && plugin_names->size()) {
- char* name = nullptr;
+ const char* name = nullptr;
PoolMem plugin_name(PM_FNAME);
foreach_alist (name, plugin_names) {
diff --git a/core/src/lib/rblist.h b/core/src/lib/rblist.h
index fb2655aea..3a161e3e9 100644
--- a/core/src/lib/rblist.h
+++ b/core/src/lib/rblist.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2005-2007 Free Software Foundation Europe e.V.
- Copyright (C) 2016-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -30,22 +30,9 @@
#define M_ABORT 1
-/**
- * There is a lot of extra casting here to work around the fact
- * that some compilers (Sun and Visual C++) do not accept
- * (bnode *) as an lvalue on the left side of an equal.
- *
- * Loop var through each member of list
- */
-#ifdef HAVE_TYPEOF
-# define foreach_rblist(var, tree) \
- for (((var) = (typeof(var))(tree)->first()); (var); \
- ((var) = (typeof(var))(tree)->next(var)))
-#else
-# define foreach_rblist(var, tree) \
- for ((*((void**)&(var)) = (void*)((tree)->first())); (var); \
- (*((void**)&(var)) = (void*)((tree)->next(var))))
-#endif
+#define foreach_rblist(var, tree) \
+ for (((var) = static_cast<decltype(var)>((tree)->first())); (var); \
+ ((var) = static_cast<decltype(var)>((tree)->next(var))))
struct rblink {
void* parent = nullptr;
diff --git a/core/src/lib/recent_job_results_list.cc b/core/src/lib/recent_job_results_list.cc
index 3165c1af0..18724ba18 100644
--- a/core/src/lib/recent_job_results_list.cc
+++ b/core/src/lib/recent_job_results_list.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2019-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2019-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -128,7 +128,7 @@ void RecentJobResultsList::Append(JobControlRecord* jcr)
bstrncpy(je.Job, jcr->Job, sizeof(je.Job));
je.JobFiles = jcr->JobFiles;
je.JobBytes = jcr->JobBytes;
- je.JobStatus = jcr->JobStatus;
+ je.JobStatus = jcr->getJobStatus();
je.JobLevel = jcr->getJobLevel();
je.start_time = jcr->start_time;
je.end_time = time(nullptr);
diff --git a/core/src/lib/res.cc b/core/src/lib/res.cc
index 54c7d05f1..1279b6e50 100644
--- a/core/src/lib/res.cc
+++ b/core/src/lib/res.cc
@@ -2205,7 +2205,7 @@ static DatatypeName datatype_names[] = {
{CFG_TYPE_META, "META_TAG", "Meta tag"},
// Storage daemon resource types
- {CFG_TYPE_DEVTYPE, "DEVICE_TYPE", "Device Type"},
+ //{CFG_TYPE_DEVTYPE, "DEVICE_TYPE", "Device Type"},
{CFG_TYPE_MAXBLOCKSIZE, "MAX_BLOCKSIZE", "Maximum Blocksize"},
{CFG_TYPE_IODIRECTION, "IO_DIRECTION", "IO Direction"},
{CFG_TYPE_CMPRSALGO, "COMPRESSION_ALGORITHM", "Compression Algorithm"},
diff --git a/core/src/lib/runscript.cc b/core/src/lib/runscript.cc
index 6b55de1c9..57ab1a2f3 100644
--- a/core/src/lib/runscript.cc
+++ b/core/src/lib/runscript.cc
@@ -61,7 +61,7 @@ static bool ScriptDirAllowed(JobControlRecord*,
RunScript* script,
alist<const char*>* allowed_script_dirs)
{
- char *bp, *allowed_script_dir = nullptr;
+ const char* allowed_script_dir = nullptr;
bool allowed = false;
PoolMem script_dir(PM_FNAME);
@@ -70,7 +70,9 @@ static bool ScriptDirAllowed(JobControlRecord*,
// Determine the dir the script is in.
PmStrcpy(script_dir, script->command.c_str());
- if ((bp = strrchr(script_dir.c_str(), '/'))) { *bp = '\0'; }
+ if (char* bp = strrchr(script_dir.c_str(), '/'); bp != nullptr) {
+ *bp = '\0';
+ }
/*
* Make sure there are no relative path elements in script dir by which the
@@ -111,7 +113,7 @@ int RunScripts(JobControlRecord* jcr,
int when;
Dmsg2(200, "runscript: running all RunScript object (%s) JobStatus=%c\n",
- label, jcr->JobStatus);
+ label, jcr->getJobStatus());
if (strstr(label, NT_("Before"))) {
when = SCRIPT_Before;
@@ -131,7 +133,7 @@ int RunScripts(JobControlRecord* jcr,
"runscript: try to run (Target=%s, OnSuccess=%i, OnFailure=%i, "
"CurrentJobStatus=%c, command=%s)\n",
NSTDPRNT(script->target), script->on_success, script->on_failure,
- jcr->JobStatus, NSTDPRNT(script->command));
+ jcr->getJobStatus(), NSTDPRNT(script->command));
runit = false;
if (!script->IsLocal()) {
@@ -144,23 +146,25 @@ int RunScripts(JobControlRecord* jcr,
} else {
if ((script->when & SCRIPT_Before) && (when & SCRIPT_Before)) {
if ((script->on_success
- && (jcr->JobStatus == JS_Running || jcr->JobStatus == JS_Created))
+ && (jcr->getJobStatus() == JS_Running
+ || jcr->getJobStatus() == JS_Created))
|| (script->on_failure
- && (JobCanceled(jcr) || jcr->JobStatus == JS_Differences))) {
+ && (JobCanceled(jcr)
+ || jcr->getJobStatus() == JS_Differences))) {
Dmsg4(200, "runscript: Run it because SCRIPT_Before (%s,%i,%i,%c)\n",
script->command.c_str(), script->on_success, script->on_failure,
- jcr->JobStatus);
+ jcr->getJobStatus());
runit = true;
}
}
if ((script->when & SCRIPT_AfterVSS) && (when & SCRIPT_AfterVSS)) {
- if ((script->on_success && (jcr->JobStatus == JS_Blocked))
+ if ((script->on_success && (jcr->getJobStatus() == JS_Blocked))
|| (script->on_failure && JobCanceled(jcr))) {
Dmsg4(200,
"runscript: Run it because SCRIPT_AfterVSS (%s,%i,%i,%c)\n",
script->command.c_str(), script->on_success, script->on_failure,
- jcr->JobStatus);
+ jcr->getJobStatus());
runit = true;
}
}
@@ -168,10 +172,11 @@ int RunScripts(JobControlRecord* jcr,
if ((script->when & SCRIPT_After) && (when & SCRIPT_After)) {
if ((script->on_success && jcr->IsTerminatedOk())
|| (script->on_failure
- && (JobCanceled(jcr) || jcr->JobStatus == JS_Differences))) {
+ && (JobCanceled(jcr)
+ || jcr->getJobStatus() == JS_Differences))) {
Dmsg4(200, "runscript: Run it because SCRIPT_After (%s,%i,%i,%c)\n",
script->command.c_str(), script->on_success, script->on_failure,
- jcr->JobStatus);
+ jcr->getJobStatus());
runit = true;
}
}
@@ -188,7 +193,7 @@ int RunScripts(JobControlRecord* jcr,
_("Runscript: run %s \"%s\" could not execute, "
"not in one of the allowed scripts dirs\n"),
label, script->command.c_str());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
goto bail_out;
}
@@ -272,7 +277,7 @@ bool RunScript::Run(JobControlRecord* jcr, const char* name)
bail_out:
/* cancel running job properly */
- if (fail_on_error) { jcr->setJobStatus(JS_ErrorTerminated); }
+ if (fail_on_error) { jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated); }
Dmsg1(100, "runscript failed. fail_on_error=%d\n", fail_on_error);
return false;
}
diff --git a/core/src/lib/util.cc b/core/src/lib/util.cc
index 1cb6191b5..3f7231491 100644
--- a/core/src/lib/util.cc
+++ b/core/src/lib/util.cc
@@ -35,6 +35,7 @@
#include "include/allow_deprecated.h"
#include <algorithm>
+#include <cctype>
#include <sstream>
#include <string>
#include <vector>
@@ -962,7 +963,7 @@ POOLMEM* edit_job_codes(JobControlRecord* jcr,
break;
case 'e': /* Job Exit code */
if (jcr) {
- str = job_status_to_str(jcr->JobStatus);
+ str = job_status_to_str(jcr->getJobStatus());
} else {
str = _("*None*");
}
@@ -1182,3 +1183,9 @@ regex_t* StringToRegex(const char* input)
}
return output;
}
+
+void to_lower(std::string& s)
+{
+ std::transform(s.begin(), s.end(), s.begin(),
+ [](unsigned char c) { return std::tolower(c); });
+}
diff --git a/core/src/lib/util.h b/core/src/lib/util.h
index fdaa58b1a..d0d62c3f1 100644
--- a/core/src/lib/util.h
+++ b/core/src/lib/util.h
@@ -91,5 +91,6 @@ std::string CreateDelimitedStringForSqlQueries(
std::string TPAsString(const std::chrono::system_clock::time_point& tp);
regex_t* StringToRegex(const char* input);
+void to_lower(std::string& s);
#endif // BAREOS_LIB_UTIL_H_
diff --git a/core/src/plugins/filed/python/CMakeLists.txt b/core/src/plugins/filed/python/CMakeLists.txt
index 08af03d73..f81513766 100644
--- a/core/src/plugins/filed/python/CMakeLists.txt
+++ b/core/src/plugins/filed/python/CMakeLists.txt
@@ -116,6 +116,7 @@ if(Python2_FOUND)
LINK_FLAGS "${Python2_BLDSHARED_FLAGS}"
LINKER_LANGUAGE CXX
INCLUDE_DIRECTORIES "${pymod2_include_dirs}"
+ CXX_STANDARD 17
)
target_compile_options(bareosfd-python2-module PUBLIC -fno-strict-aliasing)
if(NOT "${Python2_CCSHARED}" STREQUAL "")
@@ -154,6 +155,7 @@ if(Python3_FOUND)
LINK_FLAGS "${Python3_BLDSHARED_FLAGS}"
LINKER_LANGUAGE CXX
INCLUDE_DIRECTORIES "${pymod3_include_dirs}"
+ CXX_STANDARD 17
)
target_compile_options(bareosfd-python3-module PUBLIC -fno-strict-aliasing)
if(NOT "${Python3_CCSHARED}" STREQUAL "")
diff --git a/core/src/plugins/stored/autoxflate/autoxflate-sd.cc b/core/src/plugins/stored/autoxflate/autoxflate-sd.cc
index d7c198a71..9dbe6d0ef 100644
--- a/core/src/plugins/stored/autoxflate/autoxflate-sd.cc
+++ b/core/src/plugins/stored/autoxflate/autoxflate-sd.cc
@@ -481,7 +481,7 @@ static bool SetupAutoDeflation(PluginContext* ctx, DeviceControlRecord* dcr)
!= Z_OK) {
Jmsg(ctx, M_FATAL,
_("autoxflate-sd: Compression deflateParams error: %d\n"), zstat);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
goto bail_out;
}
break;
@@ -517,7 +517,7 @@ static bool SetupAutoDeflation(PluginContext* ctx, DeviceControlRecord* dcr)
_("autoxflate-sd: Compression fastlzlibSetCompressor error: "
"%d\n"),
zstat);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
goto bail_out;
}
break;
diff --git a/core/src/plugins/stored/scsicrypto/scsicrypto-sd.cc b/core/src/plugins/stored/scsicrypto/scsicrypto-sd.cc
index 972b197be..7b6dc8867 100644
--- a/core/src/plugins/stored/scsicrypto/scsicrypto-sd.cc
+++ b/core/src/plugins/stored/scsicrypto/scsicrypto-sd.cc
@@ -60,7 +60,7 @@
#include "include/bareos.h"
#include "stored/device_control_record.h"
#include "stored/device_status_information.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/stored.h"
#include "lib/berrno.h"
#include "lib/crypto_wrap.h"
@@ -343,8 +343,8 @@ static bRC do_set_scsi_encryption_key(void* value)
* has been wrapped using RFC3394 key wrapping. We first copy the current
* wrapped key into a temporary variable for unwrapping.
*/
- if (dcr->jcr && dcr->jcr->impl->director) {
- director = dcr->jcr->impl->director;
+ if (dcr->jcr && dcr->jcr->sd_impl->director) {
+ director = dcr->jcr->sd_impl->director;
if (director->keyencrkey.value) {
char WrappedVolEncrKey[MAX_NAME_LENGTH];
diff --git a/core/src/qt-tray-monitor/CMakeLists.txt b/core/src/qt-tray-monitor/CMakeLists.txt
index 2562aace7..a4be2cf60 100644
--- a/core/src/qt-tray-monitor/CMakeLists.txt
+++ b/core/src/qt-tray-monitor/CMakeLists.txt
@@ -18,9 +18,6 @@
# 02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
-cmake_minimum_required(VERSION 3.0)
-# (for AUTOUIC)
-
if(HAVE_WIN32)
add_definitions(-D_STAT_DEFINED=1)
endif()
diff --git a/core/src/stored/CMakeLists.txt b/core/src/stored/CMakeLists.txt
index 97bc92ef1..60f5d284c 100644
--- a/core/src/stored/CMakeLists.txt
+++ b/core/src/stored/CMakeLists.txt
@@ -44,34 +44,6 @@ if(NOT build_client_only)
message("Backends are now ${BACKENDS}")
endif()
-if(NOT ${HAVE_DYNAMIC_SD_BACKENDS})
- set(AVAILABLE_DEVICE_API_SRCS backends/generic_tape_device.cc)
-
- if(HAVE_WIN32)
- list(
- APPEND
- AVAILABLE_DEVICE_API_SRCS
- ${PROJECT_SOURCE_DIR}/src/win32/stored/backends/win32_fifo_device.cc
- ${PROJECT_SOURCE_DIR}/src/win32/stored/backends/win32_file_device.cc
- ${PROJECT_SOURCE_DIR}/src/win32/stored/backends/win32_tape_device.cc
- )
- else()
- list(APPEND AVAILABLE_DEVICE_API_SRCS backends/unix_fifo_device.cc
- # backends/droplet_device.cc
- backends/unix_tape_device.cc backends/unix_file_device.cc
- )
- endif()
-
- if(${HAVE_GFAPI})
- list(APPEND AVAILABLE_DEVICE_API_SRCS backends/gfapi_device.cc)
- endif()
-
- if(TARGET droplet)
- list(APPEND AVAILABLE_DEVICE_API_SRCS backends/droplet_device.cc)
- list(APPEND AVAILABLE_DEVICE_API_SRCS backends/chunked_device.cc)
- endif()
-endif()
-
set(LIBBAREOSSD_SRCS
acquire.cc
ansi_label.cc
@@ -94,7 +66,6 @@ set(LIBBAREOSSD_SRCS
record.cc
reserve.cc
scan.cc
- sd_backends.cc
sd_device_control_record.cc
sd_plugins.cc
sd_stats.cc
@@ -103,7 +74,6 @@ set(LIBBAREOSSD_SRCS
stored_conf.cc
vol_mgr.cc
wait.cc
- ${AVAILABLE_DEVICE_API_SRCS}
)
set(SDSRCS
@@ -177,10 +147,6 @@ else()
message(STATUS "LIBBAREOSSD_LIBRARIES ARE ${LIBBAREOSSD_LIBRARIES}")
endif()
-if(${HAVE_DYNAMIC_SD_BACKENDS})
- list(APPEND LIBBAREOSSD_SRCS backends/unix_file_device.cc)
-endif()
-
add_library(bareossd SHARED ${LIBBAREOSSD_SRCS})
target_link_libraries(bareossd PRIVATE bareos Threads::Threads)
set_target_properties(
@@ -188,7 +154,9 @@ set_target_properties(
SOVERSION "${BAREOS_VERSION_MAJOR}"
)
-if(NOT ${HAVE_DYNAMIC_SD_BACKENDS})
+if(${HAVE_DYNAMIC_SD_BACKENDS})
+ target_sources(bareossd PRIVATE sd_backends_dynamic.cc)
+else()
target_link_libraries(bareossd PRIVATE ${LIBBAREOSSD_LIBRARIES})
endif()
@@ -240,9 +208,7 @@ install(SCRIPT ${PROJECT_SOURCE_DIR}/cmake/install-stored-configfiles.cmake)
install(DIRECTORY DESTINATION "${archivedir}")
-if(${HAVE_DYNAMIC_SD_BACKENDS})
- add_subdirectory(backends)
-endif()
+add_subdirectory(backends)
if(TARGET droplet)
target_compile_definitions(bareossd PRIVATE HAVE_BAREOSSD_DROPLET_DEVICE)
diff --git a/core/src/stored/acquire.cc b/core/src/stored/acquire.cc
index cd4e266de..e8bba8874 100644
--- a/core/src/stored/acquire.cc
+++ b/core/src/stored/acquire.cc
@@ -43,7 +43,7 @@
#include "lib/berrno.h"
#include "include/jcr.h"
#include "stored/block.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include <algorithm>
@@ -115,7 +115,7 @@ bool AcquireDeviceForRead(DeviceControlRecord* dcr)
}
/* Find next Volume, if any */
- vol = jcr->impl->VolList;
+ vol = jcr->sd_impl->VolList;
if (!vol) {
char ed1[50];
Jmsg(jcr, M_FATAL, 0,
@@ -123,12 +123,12 @@ bool AcquireDeviceForRead(DeviceControlRecord* dcr)
edit_int64(jcr->JobId, ed1));
goto get_out;
}
- jcr->impl->CurReadVolume++;
- for (i = 1; i < jcr->impl->CurReadVolume; i++) { vol = vol->next; }
+ jcr->sd_impl->CurReadVolume++;
+ for (i = 1; i < jcr->sd_impl->CurReadVolume; i++) { vol = vol->next; }
if (!vol) {
Jmsg(jcr, M_FATAL, 0,
_("Logic error: no next volume to read. Numvol=%d Curvol=%d\n"),
- jcr->impl->NumReadVolumes, jcr->impl->CurReadVolume);
+ jcr->sd_impl->NumReadVolumes, jcr->sd_impl->CurReadVolume);
goto get_out; /* should not happen */
}
SetDcrFromVol(dcr, vol);
@@ -169,8 +169,8 @@ bool AcquireDeviceForRead(DeviceControlRecord* dcr)
LockReservations();
memset(&rctx, 0, sizeof(ReserveContext));
rctx.jcr = jcr;
- jcr->impl->read_dcr = dcr;
- jcr->impl->reserve_msgs = new alist<const char*>(10, not_owned_by_alist);
+ jcr->sd_impl->read_dcr = dcr;
+ jcr->sd_impl->reserve_msgs = new alist<const char*>(10, not_owned_by_alist);
rctx.any_drive = true;
rctx.device_name = vol->device;
store = new DirectorStorage;
@@ -437,7 +437,7 @@ DeviceControlRecord* AcquireDeviceForAppend(DeviceControlRecord* dcr)
dev->Lock_acquire(); /* only one job at a time */
dev->Lock();
- Dmsg1(100, "acquire_append device is %s\n", dev->IsTape() ? "tape" : "disk");
+ Dmsg1(100, "acquire_append device is %s\n", dev->type().c_str());
// With the reservation system, this should not happen
if (dev->CanRead()) {
@@ -492,7 +492,7 @@ DeviceControlRecord* AcquireDeviceForAppend(DeviceControlRecord* dcr)
}
dev->num_writers++; /* we are now a writer */
- if (jcr->impl->NumWriteVolumes == 0) { jcr->impl->NumWriteVolumes = 1; }
+ if (jcr->sd_impl->NumWriteVolumes == 0) { jcr->sd_impl->NumWriteVolumes = 1; }
dev->VolCatInfo.VolCatJobs++; /* increment number of jobs on vol */
Dmsg4(100, "=== nwriters=%d nres=%d vcatjob=%d dev=%s\n", dev->num_writers,
dev->NumReserved(), dev->VolCatInfo.VolCatJobs, dev->print_name());
@@ -738,8 +738,8 @@ void SetupNewDcrDevice(JobControlRecord* jcr,
if (dcr->attached_to_dev) { DetachDcrFromDev(dcr); }
// Use job spoolsize prior to device spoolsize
- if (jcr && jcr->impl->spool_size) {
- dcr->max_job_spool_size = jcr->impl->spool_size;
+ if (jcr && jcr->sd_impl->spool_size) {
+ dcr->max_job_spool_size = jcr->sd_impl->spool_size;
} else {
dcr->max_job_spool_size = dev->device_resource->max_job_spool_size;
}
@@ -833,9 +833,9 @@ void FreeDeviceControlRecord(DeviceControlRecord* dcr)
if (dcr->rec) { FreeRecord(dcr->rec); }
- if (jcr && jcr->impl->dcr == dcr) { jcr->impl->dcr = NULL; }
+ if (jcr && jcr->sd_impl->dcr == dcr) { jcr->sd_impl->dcr = NULL; }
- if (jcr && jcr->impl->read_dcr == dcr) { jcr->impl->read_dcr = NULL; }
+ if (jcr && jcr->sd_impl->read_dcr == dcr) { jcr->sd_impl->read_dcr = NULL; }
unlock_mutex(dcr->mutex_);
diff --git a/core/src/stored/ansi_label.cc b/core/src/stored/ansi_label.cc
index c0927ab0c..7ce5c3827 100644
--- a/core/src/stored/ansi_label.cc
+++ b/core/src/stored/ansi_label.cc
@@ -3,7 +3,7 @@
Copyright (C) 2005-2009 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -57,7 +57,6 @@ static bool SameLabelNames(char* bareos_name, char* ansi_name);
*/
int ReadAnsiIbmLabel(DeviceControlRecord* dcr)
{
- Device* volatile dev = dcr->dev;
JobControlRecord* jcr = dcr->jcr;
char label[80]; /* tape label */
int status, i;
@@ -69,36 +68,36 @@ int ReadAnsiIbmLabel(DeviceControlRecord* dcr)
* If tape read the following EOF mark, on disk do not read.
*/
Dmsg0(100, "Read ansi label.\n");
- if (!dev->IsTape()) { return VOL_OK; }
+ if (!dcr->dev->IsTape()) { return VOL_OK; }
- dev->label_type = B_BAREOS_LABEL; /* assume Bareos label */
+ dcr->dev->label_type = B_BAREOS_LABEL; /* assume Bareos label */
// Read a maximum of 5 records VOL1, HDR1, ... HDR4
for (i = 0; i < 6; i++) {
do {
- status = dev->read(label, sizeof(label));
+ status = dcr->dev->read(label, sizeof(label));
} while (status == -1 && errno == EINTR);
if (status < 0) {
BErrNo be;
- dev->clrerror(-1);
+ dcr->dev->clrerror(-1);
Dmsg1(100, "Read device got: ERR=%s\n", be.bstrerror());
Mmsg2(jcr->errmsg, _("Read error on device %s in ANSI label. ERR=%s\n"),
- dev->archive_device_string, be.bstrerror());
- Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
- dev->VolCatInfo.VolCatErrors++;
+ dcr->dev->archive_device_string, be.bstrerror());
+ Jmsg(jcr, M_ERROR, 0, "%s", dcr->dev->errmsg);
+ dcr->dev->VolCatInfo.VolCatErrors++;
return VOL_IO_ERROR;
}
if (status == 0) {
- if (dev->AtEof()) {
- dev->SetEot(); /* second eof, set eot bit */
+ if (dcr->dev->AtEof()) {
+ dcr->dev->SetEot(); /* second eof, set eot bit */
Dmsg0(100, "EOM on ANSI label\n");
Mmsg0(jcr->errmsg,
_("Insane! End of tape while reading ANSI label.\n"));
return VOL_LABEL_ERROR; /* at EOM this shouldn't happen */
} else {
- dev->SetAteof(); /* set eof state */
+ dcr->dev->SetAteof(); /* set eof state */
}
}
@@ -107,7 +106,7 @@ int ReadAnsiIbmLabel(DeviceControlRecord* dcr)
if (status == 80) {
if (bstrncmp("VOL1", label, 4)) {
ok = true;
- dev->label_type = B_ANSI_LABEL;
+ dcr->dev->label_type = B_ANSI_LABEL;
Dmsg0(100, "Got ANSI VOL1 label\n");
} else {
// Try EBCDIC
@@ -115,7 +114,7 @@ int ReadAnsiIbmLabel(DeviceControlRecord* dcr)
if (bstrncmp("VOL1", label, 4)) {
ok = true;
;
- dev->label_type = B_IBM_LABEL;
+ dcr->dev->label_type = B_IBM_LABEL;
Dmsg0(100, "Found IBM label.\n");
Dmsg0(100, "Got IBM VOL1 label\n");
}
@@ -135,26 +134,26 @@ int ReadAnsiIbmLabel(DeviceControlRecord* dcr)
char* p = &label[4];
char* q;
- FreeVolume(dev);
+ FreeVolume(dcr->dev);
// Store new Volume name
- q = dev->VolHdr.VolumeName;
+ q = dcr->dev->VolHdr.VolumeName;
for (int i = 0; *p != ' ' && i < 6; i++) { *q++ = *p++; }
*q = 0;
Dmsg0(100, "Call reserve_volume\n");
// why is this reserve_volume() needed???? KES
- reserve_volume(dcr, dev->VolHdr.VolumeName);
- dev = dcr->dev; /* may have changed in reserve_volume */
+ reserve_volume(dcr, dcr->dev->VolHdr.VolumeName);
+ dcr->dev = dcr->dev; /* may have changed in reserve_volume */
Dmsg2(100, "Wanted ANSI Vol %s got %6s\n", VolName,
- dev->VolHdr.VolumeName);
+ dcr->dev->VolHdr.VolumeName);
Mmsg2(jcr->errmsg, _("Wanted ANSI Volume \"%s\" got \"%s\"\n"),
- VolName, dev->VolHdr.VolumeName);
+ VolName, dcr->dev->VolHdr.VolumeName);
return VOL_NAME_ERROR;
}
}
break;
case 1:
- if (dev->label_type == B_IBM_LABEL) {
+ if (dcr->dev->label_type == B_IBM_LABEL) {
EbcdicToAscii(label, label, sizeof(label));
}
@@ -173,7 +172,7 @@ int ReadAnsiIbmLabel(DeviceControlRecord* dcr)
&label[4]);
Mmsg1(jcr->errmsg,
_("ANSI/IBM Volume \"%s\" does not belong to Bareos.\n"),
- dev->VolHdr.VolumeName);
+ dcr->dev->VolHdr.VolumeName);
return VOL_NAME_ERROR; /* Not a Bareos label */
}
} else {
@@ -182,14 +181,14 @@ int ReadAnsiIbmLabel(DeviceControlRecord* dcr)
&label[4]);
Mmsg1(jcr->errmsg,
_("ANSI/IBM Volume \"%s\" does not belong to Bareos.\n"),
- dev->VolHdr.VolumeName);
+ dcr->dev->VolHdr.VolumeName);
return VOL_NAME_ERROR; /* Not a Bareos label */
}
}
Dmsg0(100, "Got HDR1 label\n");
break;
case 2:
- if (dev->label_type == B_IBM_LABEL) {
+ if (dcr->dev->label_type == B_IBM_LABEL) {
EbcdicToAscii(label, label, sizeof(label));
}
@@ -207,7 +206,7 @@ int ReadAnsiIbmLabel(DeviceControlRecord* dcr)
return VOL_OK;
}
- if (dev->label_type == B_IBM_LABEL) {
+ if (dcr->dev->label_type == B_IBM_LABEL) {
EbcdicToAscii(label, label, sizeof(label));
}
diff --git a/core/src/stored/append.cc b/core/src/stored/append.cc
index 1c3336ec4..808891245 100644
--- a/core/src/stored/append.cc
+++ b/core/src/stored/append.cc
@@ -30,7 +30,7 @@
#include "stored/acquire.h"
#include "stored/fd_cmds.h"
#include "stored/stored_globals.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/label.h"
#include "stored/spool.h"
#include "lib/bget_msg.h"
@@ -101,20 +101,20 @@ bool IsAttribute(DeviceRecord* record)
static void UpdateFileList(JobControlRecord* jcr)
{
Dmsg0(100, _("... update file list\n"));
- jcr->impl->dcr->DirAskToUpdateFileList();
+ jcr->sd_impl->dcr->DirAskToUpdateFileList();
}
static void UpdateJobmediaRecord(JobControlRecord* jcr)
{
Dmsg0(100, _("... create job media record\n"));
- jcr->impl->dcr->DirCreateJobmediaRecord(false);
+ jcr->sd_impl->dcr->DirCreateJobmediaRecord(false);
}
static void UpdateJobrecord(JobControlRecord* jcr)
{
Dmsg2(100, _("... update job record: %llu bytes %lu files\n"), jcr->JobBytes,
jcr->JobFiles);
- jcr->impl->dcr->DirAskToUpdateJobRecord();
+ jcr->sd_impl->dcr->DirAskToUpdateJobRecord();
}
void DoBackupCheckpoint(JobControlRecord* jcr)
@@ -165,11 +165,11 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
POOLMEM* rec_data;
char ec[50];
- if (!jcr->impl->dcr) {
+ if (!jcr->sd_impl->dcr) {
Jmsg0(jcr, M_FATAL, 0, _("DeviceControlRecord is NULL!!!\n"));
return false;
}
- dev = jcr->impl->dcr->dev;
+ dev = jcr->sd_impl->dcr->dev;
if (!dev) {
Jmsg0(jcr, M_FATAL, 0, _("Device is NULL!!!\n"));
return false;
@@ -178,21 +178,22 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
Dmsg1(100, "Start append data. res=%d\n", dev->NumReserved());
if (!bs->SetBufferSize(
- jcr->impl->dcr->device_resource->max_network_buffer_size,
+ jcr->sd_impl->dcr->device_resource->max_network_buffer_size,
BNET_SETBUF_WRITE)) {
Jmsg0(jcr, M_FATAL, 0, _("Unable to set network buffer size.\n"));
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
- if (!AcquireDeviceForAppend(jcr->impl->dcr)) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ if (!AcquireDeviceForAppend(jcr->sd_impl->dcr)) {
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
- if (GeneratePluginEvent(jcr, bSdEventSetupRecordTranslation, jcr->impl->dcr)
+ if (GeneratePluginEvent(jcr, bSdEventSetupRecordTranslation,
+ jcr->sd_impl->dcr)
!= bRC_OK) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -203,14 +204,14 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
}
Dmsg1(50, "Begin append device=%s\n", dev->print_name());
- if (!BeginDataSpool(jcr->impl->dcr)) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ if (!BeginDataSpool(jcr->sd_impl->dcr)) {
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
if (!BeginAttributeSpool(jcr)) {
- DiscardDataSpool(jcr->impl->dcr);
- jcr->setJobStatus(JS_ErrorTerminated);
+ DiscardDataSpool(jcr->sd_impl->dcr);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -220,10 +221,10 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
}
// Write Begin Session Record
- if (!WriteSessionLabel(jcr->impl->dcr, SOS_LABEL)) {
+ if (!WriteSessionLabel(jcr->sd_impl->dcr, SOS_LABEL)) {
Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"),
dev->bstrerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
ok = false;
}
if (dev->VolCatInfo.VolCatName[0] == 0) {
@@ -255,7 +256,7 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
* file. 1. for the Attributes, 2. for the file data if any,
* and 3. for the MD5 if any.
*/
- jcr->impl->dcr->VolFirstIndex = jcr->impl->dcr->VolLastIndex = 0;
+ jcr->sd_impl->dcr->VolFirstIndex = jcr->sd_impl->dcr->VolLastIndex = 0;
jcr->run_time = time(NULL); /* start counting time for rates */
auto now
@@ -263,10 +264,10 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
time_t next_checkpoint_time = now + me->checkpoint_interval;
std::vector<ProcessedFile> processed_files{};
- int64_t current_volumeid = jcr->impl->dcr->VolMediaId;
+ int64_t current_volumeid = jcr->sd_impl->dcr->VolMediaId;
ProcessedFile file_currently_processed;
- uint32_t current_block_number = jcr->impl->dcr->block->BlockNumber;
+ uint32_t current_block_number = jcr->sd_impl->dcr->block->BlockNumber;
for (last_file_index = 0; ok && !jcr->IsJobCanceled();) {
/*
@@ -333,47 +334,48 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
* We save the original data pointer from the record so we can restore
* that after the loop ends.
*/
- rec_data = jcr->impl->dcr->rec->data;
+ rec_data = jcr->sd_impl->dcr->rec->data;
while ((n = BgetMsg(bs)) > 0 && !jcr->IsJobCanceled()) {
- jcr->impl->dcr->rec->VolSessionId = jcr->VolSessionId;
- jcr->impl->dcr->rec->VolSessionTime = jcr->VolSessionTime;
- jcr->impl->dcr->rec->FileIndex = file_index;
- jcr->impl->dcr->rec->Stream = stream;
- jcr->impl->dcr->rec->maskedStream
+ jcr->sd_impl->dcr->rec->VolSessionId = jcr->VolSessionId;
+ jcr->sd_impl->dcr->rec->VolSessionTime = jcr->VolSessionTime;
+ jcr->sd_impl->dcr->rec->FileIndex = file_index;
+ jcr->sd_impl->dcr->rec->Stream = stream;
+ jcr->sd_impl->dcr->rec->maskedStream
= stream & STREAMMASK_TYPE; /* strip high bits */
- jcr->impl->dcr->rec->data_len = bs->message_length;
- jcr->impl->dcr->rec->data = bs->msg; /* use message buffer */
+ jcr->sd_impl->dcr->rec->data_len = bs->message_length;
+ jcr->sd_impl->dcr->rec->data = bs->msg; /* use message buffer */
Dmsg4(850, "before writ_rec FI=%d SessId=%d Strm=%s len=%d\n",
- jcr->impl->dcr->rec->FileIndex, jcr->impl->dcr->rec->VolSessionId,
- stream_to_ascii(buf1, jcr->impl->dcr->rec->Stream,
- jcr->impl->dcr->rec->FileIndex),
- jcr->impl->dcr->rec->data_len);
+ jcr->sd_impl->dcr->rec->FileIndex,
+ jcr->sd_impl->dcr->rec->VolSessionId,
+ stream_to_ascii(buf1, jcr->sd_impl->dcr->rec->Stream,
+ jcr->sd_impl->dcr->rec->FileIndex),
+ jcr->sd_impl->dcr->rec->data_len);
- ok = jcr->impl->dcr->WriteRecord();
+ ok = jcr->sd_impl->dcr->WriteRecord();
if (!ok) {
Dmsg2(90, "Got WriteBlockToDev error on device %s. %s\n",
- jcr->impl->dcr->dev->print_name(),
- jcr->impl->dcr->dev->bstrerror());
+ jcr->sd_impl->dcr->dev->print_name(),
+ jcr->sd_impl->dcr->dev->bstrerror());
break;
}
- if (IsAttribute(jcr->impl->dcr->rec)) {
- file_currently_processed.AddAttribute(jcr->impl->dcr->rec);
+ if (IsAttribute(jcr->sd_impl->dcr->rec)) {
+ file_currently_processed.AddAttribute(jcr->sd_impl->dcr->rec);
}
if (AttributesAreSpooled(jcr)) {
SaveFullyProcessedFiles(jcr, processed_files);
} else {
- if (current_block_number != jcr->impl->dcr->block->BlockNumber) {
- current_block_number = jcr->impl->dcr->block->BlockNumber;
+ if (current_block_number != jcr->sd_impl->dcr->block->BlockNumber) {
+ current_block_number = jcr->sd_impl->dcr->block->BlockNumber;
SaveFullyProcessedFiles(jcr, processed_files);
}
if (me->checkpoint_interval) {
- if (jcr->impl->dcr->VolMediaId != current_volumeid) {
+ if (jcr->sd_impl->dcr->VolMediaId != current_volumeid) {
Jmsg0(jcr, M_INFO, 0, _("Volume changed, doing checkpoint:\n"));
DoBackupCheckpoint(jcr);
- current_volumeid = jcr->impl->dcr->VolMediaId;
+ current_volumeid = jcr->sd_impl->dcr->VolMediaId;
} else {
next_checkpoint_time = DoTimedCheckpoint(jcr, next_checkpoint_time,
me->checkpoint_interval);
@@ -387,7 +389,7 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
Dmsg2(650, "End read loop with %s. Stat=%d\n", what, n);
// Restore the original data pointer.
- jcr->impl->dcr->rec->data = rec_data;
+ jcr->sd_impl->dcr->rec->data = rec_data;
if (bs->IsError()) {
if (!jcr->IsJobCanceled()) {
@@ -403,7 +405,7 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
}
// Create Job status for end of session label
- jcr->setJobStatus(ok ? JS_Terminated : JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(ok ? JS_Terminated : JS_ErrorTerminated);
if (ok && bs == jcr->file_bsock) {
// Terminate connection with FD
@@ -415,27 +417,27 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
bs->fsend("3999 Failed append\n");
}
- Dmsg1(200, "Write EOS label JobStatus=%c\n", jcr->JobStatus);
+ Dmsg1(200, "Write EOS label JobStatus=%c\n", jcr->getJobStatus());
/*
* Check if we can still write. This may not be the case
* if we are at the end of the tape or we got a fatal I/O error.
*/
if (ok || dev->CanWrite()) {
- if (!WriteSessionLabel(jcr->impl->dcr, EOS_LABEL)) {
+ if (!WriteSessionLabel(jcr->sd_impl->dcr, EOS_LABEL)) {
// Print only if ok and not cancelled to avoid spurious messages
if (ok && !jcr->IsJobCanceled()) {
Jmsg1(jcr, M_FATAL, 0, _("Error writing end session label. ERR=%s\n"),
dev->bstrerror());
PossibleIncompleteJob(jcr, last_file_index);
}
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
ok = false;
}
Dmsg0(90, "back from write_end_session_label()\n");
// Flush out final partial block of this session
- if (!jcr->impl->dcr->WriteBlockToDevice()) {
+ if (!jcr->sd_impl->dcr->WriteBlockToDevice()) {
// Print only if ok and not cancelled to avoid spurious messages
if (ok && !jcr->IsJobCanceled()) {
Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"),
@@ -443,7 +445,7 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
Dmsg0(100, _("Set ok=FALSE after WriteBlockToDevice.\n"));
PossibleIncompleteJob(jcr, last_file_index);
}
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
ok = false;
} else if (ok && !jcr->IsJobCanceled()) {
// Send attributes of the final partial block of the session
@@ -455,14 +457,14 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
}
if (!ok && !jcr->is_JobStatus(JS_Incomplete)) {
- DiscardDataSpool(jcr->impl->dcr);
+ DiscardDataSpool(jcr->sd_impl->dcr);
} else {
// Note: if commit is OK, the device will remain blocked
- CommitDataSpool(jcr->impl->dcr);
+ CommitDataSpool(jcr->sd_impl->dcr);
}
// Release the device -- and send final Vol info to DIR and unlock it.
- ReleaseDevice(jcr->impl->dcr);
+ ReleaseDevice(jcr->sd_impl->dcr);
/*
* Don't use time_t for job_elapsed as time_t can be 32 or 64 bits,
@@ -491,11 +493,11 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what)
// Send attributes and digest to Director for Catalog
bool SendAttrsToDir(JobControlRecord* jcr, DeviceRecord* rec)
{
- if (!jcr->impl->no_attributes) {
+ if (!jcr->sd_impl->no_attributes) {
BareosSocket* dir = jcr->dir_bsock;
if (AttributesAreSpooled(jcr)) { dir->SetSpooling(); }
Dmsg0(850, "Send attributes to dir.\n");
- if (!jcr->impl->dcr->DirUpdateFileAttributes(rec)) {
+ if (!jcr->sd_impl->dcr->DirUpdateFileAttributes(rec)) {
Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"),
dir->bstrerror());
dir->ClearSpooling();
diff --git a/core/src/stored/authenticate.cc b/core/src/stored/authenticate.cc
index edf0473a6..0c5bed967 100644
--- a/core/src/stored/authenticate.cc
+++ b/core/src/stored/authenticate.cc
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
- Copyright (C) 2013-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -28,7 +28,7 @@
#include "include/bareos.h"
#include "stored/stored.h"
#include "stored/stored_globals.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "lib/parse_conf.h"
#include "lib/bsock.h"
#include "lib/bnet_network_dump.h"
@@ -85,7 +85,7 @@ bool AuthenticateDirector(JobControlRecord* jcr)
UnbashSpaces(dirname);
director = (DirectorResource*)my_config->GetResWithName(R_DIRECTOR, dirname);
- jcr->impl->director = director;
+ jcr->sd_impl->director = director;
if (!director) {
Dmsg2(debuglevel, "Connection from unknown Director %s at %s rejected.\n",
diff --git a/core/src/stored/autochanger.cc b/core/src/stored/autochanger.cc
index 7e8674e7a..4c70f78b0 100644
--- a/core/src/stored/autochanger.cc
+++ b/core/src/stored/autochanger.cc
@@ -3,7 +3,7 @@
Copyright (C) 2002-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -123,11 +123,10 @@ int AutoloadDevice(DeviceControlRecord* dcr, int writing, BareosSocket* dir)
slot_number_t wanted_slot;
JobControlRecord* jcr = dcr->jcr;
drive_number_t drive;
- Device* volatile dev = dcr->dev;
- if (!dev->AttachedToAutochanger()) {
+ if (!dcr->dev->AttachedToAutochanger()) {
Dmsg1(100, "Device %s is not attached to an autochanger\n",
- dev->print_name());
+ dcr->dev->print_name());
return 0;
}
@@ -138,7 +137,7 @@ int AutoloadDevice(DeviceControlRecord* dcr, int writing, BareosSocket* dir)
return 1; /* nothing to load */
}
- drive = dev->drive_index;
+ drive = dcr->dev->drive_index;
wanted_slot = dcr->VolCatInfo.InChanger ? dcr->VolCatInfo.Slot : 0;
Dmsg3(100, "autoload: slot=%hd InChgr=%d Vol=%s\n", dcr->VolCatInfo.Slot,
dcr->VolCatInfo.InChanger, dcr->getVolCatName());
@@ -162,31 +161,31 @@ int AutoloadDevice(DeviceControlRecord* dcr, int writing, BareosSocket* dir)
changer = GetPoolMemory(PM_FNAME);
if (!IsSlotNumberValid(wanted_slot)) {
// Suppress info when polling
- if (!dev->poll) {
+ if (!dcr->dev->poll) {
Jmsg(
jcr, M_INFO, 0,
_("No slot defined in catalog (slot=%hd) for Volume \"%s\" on %s.\n"),
- wanted_slot, dcr->getVolCatName(), dev->print_name());
+ wanted_slot, dcr->getVolCatName(), dcr->dev->print_name());
Jmsg(jcr, M_INFO, 0,
_("Cartridge change or \"update slots\" may be required.\n"));
}
rtn_stat = 0;
} else if (!dcr->device_resource->changer_name) {
// Suppress info when polling
- if (!dev->poll) {
+ if (!dcr->dev->poll) {
Jmsg(jcr, M_INFO, 0,
_("No \"Changer Device\" for %s. Manual load of Volume may be "
"required.\n"),
- dev->print_name());
+ dcr->dev->print_name());
}
rtn_stat = 0;
} else if (!dcr->device_resource->changer_command) {
// Suppress info when polling
- if (!dev->poll) {
+ if (!dcr->dev->poll) {
Jmsg(jcr, M_INFO, 0,
_("No \"Changer Command\" for %s. Manual load of Volume may be "
"required.\n"),
- dev->print_name());
+ dcr->dev->print_name());
}
rtn_stat = 0;
} else {
@@ -218,7 +217,7 @@ int AutoloadDevice(DeviceControlRecord* dcr, int writing, BareosSocket* dir)
// Load the desired volume.
Dmsg2(100, "Doing changer load slot %hd %s\n", wanted_slot,
- dev->print_name());
+ dcr->dev->print_name());
Jmsg(
jcr, M_INFO, 0,
_("3304 Issuing autochanger \"load slot %hd, drive %hd\" command.\n"),
@@ -226,7 +225,7 @@ int AutoloadDevice(DeviceControlRecord* dcr, int writing, BareosSocket* dir)
dcr->VolCatInfo.Slot = wanted_slot; /* slot to be loaded */
changer = edit_device_codes(
dcr, changer, dcr->device_resource->changer_command, "load");
- dev->close(dcr);
+ dcr->dev->close(dcr);
Dmsg1(200, "Run program=%s\n", changer);
status = RunProgramFullOutput(changer, timeout, results.addr());
if (status == 0) {
@@ -236,10 +235,10 @@ int AutoloadDevice(DeviceControlRecord* dcr, int writing, BareosSocket* dir)
wanted_slot, drive);
Dmsg2(100, "load slot %hd, drive %hd, status is OK.\n", wanted_slot,
drive);
- dev->SetSlotNumber(wanted_slot); /* set currently loaded slot */
- if (dev->vol) {
+ dcr->dev->SetSlotNumber(wanted_slot); /* set currently loaded slot */
+ if (dcr->dev->vol) {
// We just swapped this Volume so it cannot be swapping any more
- dev->vol->ClearSwapping();
+ dcr->dev->vol->ClearSwapping();
}
} else {
BErrNo be;
@@ -257,13 +256,13 @@ int AutoloadDevice(DeviceControlRecord* dcr, int writing, BareosSocket* dir)
_("3992 Bad autochanger \"load slot %hd, drive %hd\": "
"ERR=%s.\nResults=%s\n"),
wanted_slot, drive, be.bstrerror(), results.c_str());
- dev->SetSlotNumber(-1); /* mark unknown */
+ dcr->dev->SetSlotNumber(-1); /* mark unknown */
}
Dmsg2(100, "load slot %hd status=%d\n", wanted_slot, status);
UnlockChanger(dcr);
} else {
- status = 0; /* we got what we want */
- dev->SetSlotNumber(wanted_slot); /* set currently loaded slot */
+ status = 0; /* we got what we want */
+ dcr->dev->SetSlotNumber(wanted_slot); /* set currently loaded slot */
}
Dmsg1(100, "After changer, status=%d\n", status);
diff --git a/core/src/stored/backends/CMakeLists.txt b/core/src/stored/backends/CMakeLists.txt
index fa870ac0e..57fa560af 100644
--- a/core/src/stored/backends/CMakeLists.txt
+++ b/core/src/stored/backends/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOSĀ® - Backup Archiving REcovery Open Sourced
#
-# Copyright (C) 2017-2022 Bareos GmbH & Co. KG
+# Copyright (C) 2022-2022 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
@@ -16,40 +16,54 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
+
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
list(APPEND CMAKE_INSTALL_RPATH ${backenddir})
+macro(add_sd_backend backend_name)
+ if(HAVE_DYNAMIC_SD_BACKENDS)
+ add_library(${backend_name} MODULE)
+ install(TARGETS ${backend_name} DESTINATION ${backenddir})
+ else()
+ add_library(${backend_name} OBJECT)
+ target_link_libraries(bareossd PRIVATE ${backend_name})
+ endif()
+ set_property(TARGET ${backend_name} PROPERTY POSITION_INDEPENDENT_CODE ON)
+endmacro()
+
if(${HAVE_GLUSTERFS})
- add_library(bareossd-gfapi MODULE gfapi_device.cc)
- install(TARGETS bareossd-gfapi DESTINATION ${backenddir})
+ add_sd_backend(bareossd-gfapi)
+ target_sources(bareossd-gfapi PRIVATE gfapi_device.cc)
target_include_directories(bareossd-gfapi PUBLIC ${GFAPI_INCLUDE_DIRS})
target_link_libraries(bareossd-gfapi ${GFAPI_LIBRARIES})
endif()
if(TARGET droplet)
- add_library(bareossd-chunked SHARED ordered_cbuf.cc chunked_device.cc)
- target_link_libraries(bareossd-chunked droplet)
- install(TARGETS bareossd-chunked DESTINATION ${backenddir})
-
- add_library(bareossd-droplet MODULE droplet_device.cc)
- target_link_libraries(bareossd-droplet bareossd-chunked droplet)
- install(TARGETS bareossd-droplet DESTINATION ${backenddir})
+ add_sd_backend(bareossd-droplet)
+ target_sources(
+ bareossd-droplet PRIVATE droplet_device.cc ordered_cbuf.cc
+ chunked_device.cc
+ )
+ target_link_libraries(bareossd-droplet PRIVATE droplet)
endif()
-add_library(bareossd-fifo MODULE unix_fifo_device.cc)
-install(TARGETS bareossd-fifo DESTINATION ${backenddir})
-if(HAVE_DARWIN_OS)
- target_link_libraries(bareossd-fifo bareos bareossd)
+add_sd_backend(bareossd-file)
+add_sd_backend(bareossd-fifo)
+add_sd_backend(bareossd-tape)
+target_sources(bareossd-tape PRIVATE generic_tape_device.cc)
+if(HAVE_WIN32)
+ target_sources(bareossd-file PRIVATE win32_file_device.cc)
+ target_sources(bareossd-fifo PRIVATE win32_fifo_device.cc)
+ target_sources(bareossd-tape PRIVATE win32_tape_device.cc)
+ target_link_libraries(bareossd-file PRIVATE bareos)
+else()
+ target_sources(bareossd-file PRIVATE unix_file_device.cc)
+ target_sources(bareossd-fifo PRIVATE unix_fifo_device.cc)
+ target_sources(bareossd-tape PRIVATE unix_tape_device.cc)
endif()
-add_library(bareossd-gentape SHARED generic_tape_device.cc)
-install(TARGETS bareossd-gentape DESTINATION ${backenddir})
if(HAVE_DARWIN_OS)
+ target_link_libraries(bareossd-fifo bareos bareossd)
target_link_libraries(bareossd-gentape bareos bareossd)
endif()
-
-add_library(bareossd-tape MODULE unix_tape_device.cc)
-install(TARGETS bareossd-tape DESTINATION ${backenddir})
-
-target_link_libraries(bareossd-tape bareossd-gentape)
diff --git a/core/src/stored/backends/cephfs_device.h b/core/src/stored/backends/cephfs_device.h
deleted file mode 100644
index ff3ff5bc9..000000000
--- a/core/src/stored/backends/cephfs_device.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- BAREOSĀ® - Backup Archiving REcovery Open Sourced
-
- Copyright (C) 2014-2014 Planets Communications B.V.
- Copyright (C) 2014-2021 Bareos GmbH & Co. KG
-
- This program is Free Software; you can redistribute it and/or
- modify it under the terms of version three of the GNU Affero General Public
- License as published by the Free Software Foundation, which is
- listed in the file LICENSE.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-*/
-/*
- * CEPHFS API device abstraction.
- *
- * Marco van Wieringen, May 2014
- */
-
-#ifndef BAREOS_STORED_BACKENDS_CEPHFS_DEVICE_H_
-#define BAREOS_STORED_BACKENDS_CEPHFS_DEVICE_H_
-
-#include <cephfs/libcephfs.h>
-
-namespace storagedaemon {
-
-class cephfs_device : public Device {
- private:
- char* cephfs_configstring_;
- char* cephfs_conffile_;
- char* basedir_;
- struct ceph_mount_info* cmount_;
- POOLMEM* virtual_filename_;
-
- public:
- cephfs_device();
- ~cephfs_device();
-
- // Interface from Device
- int d_close(int) override;
- int d_open(const char* pathname, int flags, int mode) override;
- int d_ioctl(int fd, ioctl_req_t request, char* mt = NULL) override;
- boffset_t d_lseek(DeviceControlRecord* dcr,
- boffset_t offset,
- int whence) override;
- ssize_t d_read(int fd, void* buffer, size_t count) override;
- ssize_t d_write(int fd, const void* buffer, size_t count) override;
- bool d_truncate(DeviceControlRecord* dcr) override;
-};
-
-} /* namespace storagedaemon */
-
-#endif // BAREOS_STORED_BACKENDS_CEPHFS_DEVICE_H_
diff --git a/core/src/stored/backends/droplet_device.cc b/core/src/stored/backends/droplet_device.cc
index 6bf1923a0..0aaf6beaf 100644
--- a/core/src/stored/backends/droplet_device.cc
+++ b/core/src/stored/backends/droplet_device.cc
@@ -1027,23 +1027,6 @@ DropletDevice::~DropletDevice()
unlock_mutex(mutex);
}
-class Backend : public BackendInterface {
- public:
- Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) override
- {
- switch (device_type) {
- case DeviceType::B_DROPLET_DEV:
- return new DropletDevice;
- default:
- Jmsg(jcr, M_FATAL, 0, _("Request for unknown devicetype: %d\n"),
- device_type);
- return nullptr;
- }
- }
- void FlushDevice(void) override {}
-};
+REGISTER_SD_BACKEND(droplet, DropletDevice)
-#ifdef HAVE_DYNAMIC_SD_BACKENDS
-extern "C" BackendInterface* GetBackend(void) { return new Backend; }
-#endif
} /* namespace storagedaemon */
diff --git a/core/src/stored/backends/droplet_device.h b/core/src/stored/backends/droplet_device.h
index 3c63dfed2..1eaae6506 100644
--- a/core/src/stored/backends/droplet_device.h
+++ b/core/src/stored/backends/droplet_device.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2014-2017 Planets Communications B.V.
- Copyright (C) 2014-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2014-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -80,6 +80,8 @@ class DropletDevice : public ChunkedDevice {
~DropletDevice();
// Interface from Device
+ SeekMode GetSeekMode() const override { return SeekMode::BYTES; }
+ bool CanReadConcurrently() const override { return true; }
int d_close(int fd) override;
int d_open(const char* pathname, int flags, int mode) override;
int d_ioctl(int fd, ioctl_req_t request, char* mt = NULL) override;
diff --git a/core/src/stored/backends/generic_tape_device.h b/core/src/stored/backends/generic_tape_device.h
index 65c2a5b80..c6924e25b 100644
--- a/core/src/stored/backends/generic_tape_device.h
+++ b/core/src/stored/backends/generic_tape_device.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2014-2014 Planets Communications B.V.
- Copyright (C) 2014-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2014-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -38,6 +38,7 @@ class generic_tape_device : public Device {
virtual ~generic_tape_device() { close(nullptr); }
// Interface from Device
+ virtual SeekMode GetSeekMode() const override { return SeekMode::FILE_BLOCK; }
virtual void OpenDevice(DeviceControlRecord* dcr, DeviceMode omode) override;
virtual char* StatusDev() override;
virtual bool eod(DeviceControlRecord* dcr) override;
diff --git a/core/src/stored/backends/gfapi_device.cc b/core/src/stored/backends/gfapi_device.cc
index b2a74a1b7..0497c9278 100644
--- a/core/src/stored/backends/gfapi_device.cc
+++ b/core/src/stored/backends/gfapi_device.cc
@@ -575,26 +575,7 @@ gfapi_device::gfapi_device()
virtual_filename_ = GetPoolMemory(PM_FNAME);
}
-class Backend : public BackendInterface {
- public:
- Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) override
- {
- switch (device_type) {
- case DeviceType::B_GFAPI_DEV:
- return new gfapi_device;
- default:
- Jmsg(jcr, M_FATAL, 0, _("Request for unknown devicetype: %d\n"),
- device_type);
- return nullptr;
- }
- }
- void FlushDevice(void) override {}
-};
-
-# ifdef HAVE_DYNAMIC_SD_BACKENDS
-extern "C" BackendInterface* GetBackend(void) { return new Backend; }
-# endif
-
+REGISTER_SD_BACKEND(gfapi, gfapi_device);
} /* namespace storagedaemon */
#endif /* HAVE_GFAPI */
diff --git a/core/src/stored/backends/gfapi_device.h b/core/src/stored/backends/gfapi_device.h
index 282865f42..049cfaeb8 100644
--- a/core/src/stored/backends/gfapi_device.h
+++ b/core/src/stored/backends/gfapi_device.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2014-2014 Planets Communications B.V.
- Copyright (C) 2014-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2014-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -56,6 +56,8 @@ class gfapi_device : public Device {
~gfapi_device();
// Interface from Device
+ SeekMode GetSeekMode() const override { return SeekMode::BYTES; }
+ bool CanReadConcurrently() const override { return true; }
int d_close(int) override;
int d_open(const char* pathname, int flags, int mode) override;
int d_ioctl(int fd, ioctl_req_t request, char* mt = NULL) override;
@@ -65,6 +67,6 @@ class gfapi_device : public Device {
ssize_t d_read(int fd, void* buffer, size_t count) override;
ssize_t d_write(int fd, const void* buffer, size_t count) override;
bool d_truncate(DeviceControlRecord* dcr) override;
-} override;
+};
} /* namespace storagedaemon */
#endif // BAREOS_STORED_BACKENDS_GFAPI_DEVICE_H_
diff --git a/core/src/stored/backends/unix_fifo_device.cc b/core/src/stored/backends/unix_fifo_device.cc
index 60e8a7ef3..558d1e56d 100644
--- a/core/src/stored/backends/unix_fifo_device.cc
+++ b/core/src/stored/backends/unix_fifo_device.cc
@@ -315,25 +315,6 @@ boffset_t unix_fifo_device::d_lseek(DeviceControlRecord*, boffset_t, int)
bool unix_fifo_device::d_truncate(DeviceControlRecord*) { return true; }
-class Backend : public BackendInterface {
- public:
- Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) override
- {
- switch (device_type) {
- case DeviceType::B_FIFO_DEV:
- return new unix_fifo_device;
- default:
- Jmsg(jcr, M_FATAL, 0, _("Request for unknown devicetype: %d\n"),
- device_type);
- return nullptr;
- }
- }
- void FlushDevice(void) override {}
-};
-
-#ifdef HAVE_DYNAMIC_SD_BACKENDS
-extern "C" BackendInterface* GetBackend(void) { return new Backend; }
-#endif
-
+REGISTER_SD_BACKEND(fifo, unix_fifo_device);
} /* namespace storagedaemon */
diff --git a/core/src/stored/backends/unix_fifo_device.h b/core/src/stored/backends/unix_fifo_device.h
index 6e6d31bbf..078795db7 100644
--- a/core/src/stored/backends/unix_fifo_device.h
+++ b/core/src/stored/backends/unix_fifo_device.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2013-2013 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -40,6 +40,7 @@ class unix_fifo_device : public Device {
~unix_fifo_device() { close(nullptr); }
// Interface from Device
+ SeekMode GetSeekMode() const override { return SeekMode::NOSEEK; }
void OpenDevice(DeviceControlRecord* dcr, DeviceMode omode) override;
bool eod(DeviceControlRecord* dcr) override;
bool MountBackend(DeviceControlRecord* dcr, int timeout) override;
diff --git a/core/src/stored/backends/unix_file_device.cc b/core/src/stored/backends/unix_file_device.cc
index 363762c77..3d7b4e160 100644
--- a/core/src/stored/backends/unix_file_device.cc
+++ b/core/src/stored/backends/unix_file_device.cc
@@ -32,6 +32,7 @@
#include "include/bareos.h"
#include "stored/stored.h"
#include "stored/stored_globals.h"
+#include "stored/sd_backends.h"
#include "stored/device_control_record.h"
#include "unix_file_device.h"
#include "lib/berrno.h"
@@ -205,6 +206,11 @@ bool unix_file_device::UnmountBackend(DeviceControlRecord* dcr, int timeout)
return retval;
}
+bool unix_file_device::ScanForVolumeImpl(DeviceControlRecord* dcr)
+{
+ return ScanDirectoryForVolume(dcr);
+}
+
int unix_file_device::d_open(const char* pathname, int flags, int mode)
{
return ::open(pathname, flags, mode);
@@ -310,4 +316,6 @@ bail_out:
return true;
}
+REGISTER_SD_BACKEND(file, unix_file_device);
+
} /* namespace storagedaemon */
diff --git a/core/src/stored/backends/unix_file_device.h b/core/src/stored/backends/unix_file_device.h
index 51eb5aaa2..9b4847c5f 100644
--- a/core/src/stored/backends/unix_file_device.h
+++ b/core/src/stored/backends/unix_file_device.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2013-2013 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -28,6 +28,8 @@
#ifndef BAREOS_STORED_BACKENDS_UNIX_FILE_DEVICE_H_
#define BAREOS_STORED_BACKENDS_UNIX_FILE_DEVICE_H_
+#include "stored/dev.h"
+
namespace storagedaemon {
class unix_file_device : public Device {
@@ -36,8 +38,11 @@ class unix_file_device : public Device {
~unix_file_device() { close(nullptr); }
// Interface from Device
+ SeekMode GetSeekMode() const override { return SeekMode::BYTES; }
+ bool CanReadConcurrently() const override { return true; }
bool MountBackend(DeviceControlRecord* dcr, int timeout) override;
bool UnmountBackend(DeviceControlRecord* dcr, int timeout) override;
+ bool ScanForVolumeImpl(DeviceControlRecord* dcr) override;
int d_close(int) override;
int d_open(const char* pathname, int flags, int mode) override;
int d_ioctl(int fd, ioctl_req_t request, char* mt = NULL) override;
diff --git a/core/src/stored/backends/unix_tape_device.cc b/core/src/stored/backends/unix_tape_device.cc
index 042443470..b196b0f09 100644
--- a/core/src/stored/backends/unix_tape_device.cc
+++ b/core/src/stored/backends/unix_tape_device.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2013-2013 Planets Communications B.V.
- Copyright (C) 2013-2020 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -59,24 +59,6 @@ unix_tape_device::unix_tape_device()
SetCap(CAP_ADJWRITESIZE); /* Adjust write size to min/max */
}
-class Backend : public BackendInterface {
- public:
- Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) override
- {
- switch (device_type) {
- case DeviceType::B_TAPE_DEV:
- return new unix_tape_device;
- default:
- Jmsg(jcr, M_FATAL, 0, _("Request for unknown devicetype: %d\n"),
- device_type);
- return nullptr;
- }
- }
- void FlushDevice(void) override {}
-};
-
-#ifdef HAVE_DYNAMIC_SD_BACKENDS
-extern "C" BackendInterface* GetBackend(void) { return new Backend; }
-#endif
+REGISTER_SD_BACKEND(tape, unix_tape_device)
} /* namespace storagedaemon */
diff --git a/core/src/win32/stored/backends/win32_fifo_device.cc b/core/src/stored/backends/win32_fifo_device.cc
index 373ea5224..cb4ad27fa 100644
--- a/core/src/win32/stored/backends/win32_fifo_device.cc
+++ b/core/src/stored/backends/win32_fifo_device.cc
@@ -36,6 +36,7 @@
#include "stored/device_control_record.h"
#include "stored/stored.h"
#include "stored/autochanger.h"
+#include "stored/sd_backends.h"
namespace storagedaemon {
@@ -318,4 +319,6 @@ boffset_t win32_fifo_device::d_lseek(DeviceControlRecord*, boffset_t, int)
bool win32_fifo_device::d_truncate(DeviceControlRecord*) { return true; }
+REGISTER_SD_BACKEND(fifo, win32_fifo_device);
+
} /* namespace storagedaemon */
diff --git a/core/src/win32/stored/backends/win32_fifo_device.h b/core/src/stored/backends/win32_fifo_device.h
index 744cb06f8..080e0489f 100644
--- a/core/src/win32/stored/backends/win32_fifo_device.h
+++ b/core/src/stored/backends/win32_fifo_device.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2015-2015 Planets Communications B.V.
- Copyright (C) 2015-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2015-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -25,8 +25,8 @@
* Marco van Wieringen, June 2014
*/
-#ifndef BAREOS_WIN32_STORED_BACKENDS_WIN32_FIFO_DEVICE_H_
-#define BAREOS_WIN32_STORED_BACKENDS_WIN32_FIFO_DEVICE_H_
+#ifndef BAREOS_STORED_BACKENDS_WIN32_FIFO_DEVICE_H_
+#define BAREOS_STORED_BACKENDS_WIN32_FIFO_DEVICE_H_
#include "stored/dev.h"
#include "lib/btimers.h"
@@ -42,6 +42,7 @@ class win32_fifo_device : public Device {
~win32_fifo_device() { close(nullptr); }
// Interface from Device
+ SeekMode GetSeekMode() const override { return SeekMode::NOSEEK; }
void OpenDevice(DeviceControlRecord* dcr, DeviceMode omode) override;
bool eod(DeviceControlRecord* dcr) override;
bool MountBackend(DeviceControlRecord* dcr, int timeout) override;
@@ -61,4 +62,4 @@ class win32_fifo_device : public Device {
};
} /* namespace storagedaemon */
-#endif // BAREOS_WIN32_STORED_BACKENDS_WIN32_FIFO_DEVICE_H_
+#endif // BAREOS_STORED_BACKENDS_WIN32_FIFO_DEVICE_H_
diff --git a/core/src/win32/stored/backends/win32_file_device.cc b/core/src/stored/backends/win32_file_device.cc
index e0b8bd1e2..e75fbf880 100644
--- a/core/src/win32/stored/backends/win32_file_device.cc
+++ b/core/src/stored/backends/win32_file_device.cc
@@ -30,6 +30,7 @@
#include "lib/berrno.h"
#include "stored/device_control_record.h"
#include "stored/stored.h"
+#include "stored/sd_backends.h"
#include "win32_file_device.h"
namespace storagedaemon {
@@ -195,6 +196,11 @@ bool win32_file_device::UnmountBackend(DeviceControlRecord* dcr, int timeout)
return retval;
}
+bool win32_file_device::ScanForVolumeImpl(DeviceControlRecord* dcr)
+{
+ return ScanDirectoryForVolume(dcr);
+}
+
int win32_file_device::d_open(const char* pathname, int flags, int mode)
{
return ::open(pathname, flags, mode);
@@ -290,4 +296,6 @@ bool win32_file_device::d_truncate(DeviceControlRecord* dcr)
win32_file_device::win32_file_device() {}
+REGISTER_SD_BACKEND(file, win32_file_device);
+
} /* namespace storagedaemon */
diff --git a/core/src/win32/stored/backends/win32_file_device.h b/core/src/stored/backends/win32_file_device.h
index 07ac30049..ba2655438 100644
--- a/core/src/win32/stored/backends/win32_file_device.h
+++ b/core/src/stored/backends/win32_file_device.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2013-2014 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -25,8 +25,8 @@
* Marco van Wieringen, December 2013
*/
-#ifndef BAREOS_WIN32_STORED_BACKENDS_WIN32_FILE_DEVICE_H_
-#define BAREOS_WIN32_STORED_BACKENDS_WIN32_FILE_DEVICE_H_
+#ifndef BAREOS_STORED_BACKENDS_WIN32_FILE_DEVICE_H_
+#define BAREOS_STORED_BACKENDS_WIN32_FILE_DEVICE_H_
#include "lib/util.h"
namespace storagedaemon {
@@ -37,8 +37,11 @@ class win32_file_device : public Device {
~win32_file_device() { close(nullptr); }
// Interface from Device
+ SeekMode GetSeekMode() const override { return SeekMode::BYTES; }
+ bool CanReadConcurrently() const override { return true; }
bool MountBackend(DeviceControlRecord* dcr, int timeout) override;
bool UnmountBackend(DeviceControlRecord* dcr, int timeout) override;
+ bool ScanForVolumeImpl(DeviceControlRecord* dcr) override;
int d_close(int) override;
int d_open(const char* pathname, int flags, int mode) override;
int d_ioctl(int fd, ioctl_req_t request, char* mt = NULL) override;
@@ -51,4 +54,4 @@ class win32_file_device : public Device {
};
} /* namespace storagedaemon */
-#endif // BAREOS_WIN32_STORED_BACKENDS_WIN32_FILE_DEVICE_H_
+#endif // BAREOS_STORED_BACKENDS_WIN32_FILE_DEVICE_H_
diff --git a/core/src/win32/stored/backends/win32_tape_device.cc b/core/src/stored/backends/win32_tape_device.cc
index 35e6954a2..6f666217e 100644
--- a/core/src/win32/stored/backends/win32_tape_device.cc
+++ b/core/src/stored/backends/win32_tape_device.cc
@@ -43,6 +43,7 @@
#include "include/bareos.h"
#include "stored/stored.h"
+#include "stored/sd_backends.h"
#include "generic_tape_device.h"
#include "win32_tape_device.h"
@@ -1110,4 +1111,6 @@ win32_tape_device::win32_tape_device()
SetCap(CAP_ADJWRITESIZE); /* Adjust write size to min/max */
}
+REGISTER_SD_BACKEND(tape, win32_tape_device)
+
} /* namespace storagedaemon */
diff --git a/core/src/win32/stored/backends/win32_tape_device.h b/core/src/stored/backends/win32_tape_device.h
index a62d07dce..b5aad9609 100644
--- a/core/src/win32/stored/backends/win32_tape_device.h
+++ b/core/src/stored/backends/win32_tape_device.h
@@ -1,7 +1,7 @@
/*
BAREOSĀ® - Backup Archiving REcovery Open Sourced
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
Copyright (C) 2013-2014 Planets Communications B.V.
This program is Free Software; you can redistribute it and/or
@@ -25,8 +25,8 @@
* Marco van Wieringen, December 2013
*/
-#ifndef BAREOS_WIN32_STORED_BACKENDS_WIN32_TAPE_DEVICE_H_
-#define BAREOS_WIN32_STORED_BACKENDS_WIN32_TAPE_DEVICE_H_
+#ifndef BAREOS_STORED_BACKENDS_WIN32_TAPE_DEVICE_H_
+#define BAREOS_STORED_BACKENDS_WIN32_TAPE_DEVICE_H_
namespace storagedaemon {
@@ -46,4 +46,4 @@ class win32_tape_device : public generic_tape_device {
};
} /* namespace storagedaemon */
-#endif // BAREOS_WIN32_STORED_BACKENDS_WIN32_TAPE_DEVICE_H_
+#endif // BAREOS_STORED_BACKENDS_WIN32_TAPE_DEVICE_H_
diff --git a/core/src/stored/bcopy.cc b/core/src/stored/bcopy.cc
index d6d610587..3ebfe9e23 100644
--- a/core/src/stored/bcopy.cc
+++ b/core/src/stored/bcopy.cc
@@ -33,7 +33,7 @@
#include "lib/crypto_cache.h"
#include "stored/acquire.h"
#include "stored/butil.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/label.h"
#include "stored/mount.h"
#include "stored/read_record.h"
@@ -195,9 +195,9 @@ int main(int argc, char* argv[])
inputVolumes, true); /* read device */
if (!in_jcr) { exit(1); }
- in_jcr->impl->ignore_label_errors = ignore_label_errors;
+ in_jcr->sd_impl->ignore_label_errors = ignore_label_errors;
- in_dev = in_jcr->impl->dcr->dev;
+ in_dev = in_jcr->sd_impl->dcr->dev;
if (!in_dev) { exit(1); }
// Setup output device for writing
@@ -208,29 +208,29 @@ int main(int argc, char* argv[])
outputVolumes, false); /* write device */
if (!out_jcr) { exit(1); }
- out_dev = out_jcr->impl->dcr->dev;
+ out_dev = out_jcr->sd_impl->dcr->dev;
if (!out_dev) { exit(1); }
Dmsg0(100, "About to acquire device for writing\n");
// For we must now acquire the device for writing
out_dev->rLock(false);
- if (!out_dev->open(out_jcr->impl->dcr, DeviceMode::OPEN_READ_WRITE)) {
+ if (!out_dev->open(out_jcr->sd_impl->dcr, DeviceMode::OPEN_READ_WRITE)) {
Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), out_dev->errmsg);
out_dev->Unlock();
exit(1);
}
out_dev->Unlock();
- if (!AcquireDeviceForAppend(out_jcr->impl->dcr)) {
+ if (!AcquireDeviceForAppend(out_jcr->sd_impl->dcr)) {
FreeJcr(in_jcr);
exit(1);
}
- out_block = out_jcr->impl->dcr->block;
+ out_block = out_jcr->sd_impl->dcr->block;
- bool ok = ReadRecords(in_jcr->impl->dcr, RecordCb, MountNextReadVolume);
+ bool ok = ReadRecords(in_jcr->sd_impl->dcr, RecordCb, MountNextReadVolume);
if (ok || out_dev->CanWrite()) {
- if (!out_jcr->impl->dcr->WriteBlockToDevice()) {
+ if (!out_jcr->sd_impl->dcr->WriteBlockToDevice()) {
Pmsg0(000, _("Write of last block failed.\n"));
}
}
@@ -285,10 +285,10 @@ static bool RecordCb(DeviceControlRecord* in_dcr, DeviceRecord* rec)
/* Skipping record, because does not match BootStrapRecord filter */
return true;
}
- while (!WriteRecordToBlock(out_jcr->impl->dcr, rec)) {
+ while (!WriteRecordToBlock(out_jcr->sd_impl->dcr, rec)) {
Dmsg2(150, "!WriteRecordToBlock data_len=%d rem=%d\n", rec->data_len,
rec->remainder);
- if (!out_jcr->impl->dcr->WriteBlockToDevice()) {
+ if (!out_jcr->sd_impl->dcr->WriteBlockToDevice()) {
Dmsg2(90, "Got WriteBlockToDev error on device %s: ERR=%s\n",
out_dev->print_name(), out_dev->bstrerror());
Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
@@ -296,7 +296,7 @@ static bool RecordCb(DeviceControlRecord* in_dcr, DeviceRecord* rec)
return false;
}
}
- if (!out_jcr->impl->dcr->WriteBlockToDevice()) {
+ if (!out_jcr->sd_impl->dcr->WriteBlockToDevice()) {
Dmsg2(90, "Got WriteBlockToDev error on device %s: ERR=%s\n",
out_dev->print_name(), out_dev->bstrerror());
Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
@@ -321,10 +321,10 @@ static bool RecordCb(DeviceControlRecord* in_dcr, DeviceRecord* rec)
return true;
}
records++;
- while (!WriteRecordToBlock(out_jcr->impl->dcr, rec)) {
+ while (!WriteRecordToBlock(out_jcr->sd_impl->dcr, rec)) {
Dmsg2(150, "!WriteRecordToBlock data_len=%d rem=%d\n", rec->data_len,
rec->remainder);
- if (!out_jcr->impl->dcr->WriteBlockToDevice()) {
+ if (!out_jcr->sd_impl->dcr->WriteBlockToDevice()) {
Dmsg2(90, "Got WriteBlockToDev error on device %s: ERR=%s\n",
out_dev->print_name(), out_dev->bstrerror());
Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
diff --git a/core/src/stored/bextract.cc b/core/src/stored/bextract.cc
index 1017a27cb..95deeea38 100644
--- a/core/src/stored/bextract.cc
+++ b/core/src/stored/bextract.cc
@@ -33,7 +33,7 @@
#include "stored/acquire.h"
#include "stored/butil.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/mount.h"
#include "stored/read_record.h"
#include "findlib/find.h"
@@ -396,9 +396,9 @@ static void DoExtract(char* devname,
jcr = SetupJcr("bextract", devname, bsr, director, dcr, VolumeName,
true); /* read device */
if (!jcr) { exit(1); }
- dev = jcr->impl->read_dcr->dev;
+ dev = jcr->sd_impl->read_dcr->dev;
if (!dev) { exit(1); }
- dcr = jcr->impl->read_dcr;
+ dcr = jcr->sd_impl->read_dcr;
// Make sure where directory exists and that it is a directory
if (stat(where, &statp) < 0) {
@@ -445,7 +445,7 @@ static void DoExtract(char* devname,
CleanupCompression(jcr);
- CleanDevice(jcr->impl->dcr);
+ CleanDevice(jcr->sd_impl->dcr);
delete dev;
FreeDeviceControlRecord(dcr);
FreeJcr(jcr);
diff --git a/core/src/stored/bls.cc b/core/src/stored/bls.cc
index b2088afaa..ae65b4c82 100644
--- a/core/src/stored/bls.cc
+++ b/core/src/stored/bls.cc
@@ -35,7 +35,7 @@
#include "stored/acquire.h"
#include "stored/butil.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/label.h"
#include "stored/match_bsr.h"
#include "stored/mount.h"
@@ -238,10 +238,10 @@ int main(int argc, char* argv[])
jcr = SetupJcr("bls", device.data(), bsr, director, dcr, VolumeNames,
true); /* read device */
if (!jcr) { exit(1); }
- jcr->impl->ignore_label_errors = ignore_label_errors;
- dev = jcr->impl->dcr->dev;
+ jcr->sd_impl->ignore_label_errors = ignore_label_errors;
+ dev = jcr->sd_impl->dcr->dev;
if (!dev) { exit(1); }
- dcr = jcr->impl->dcr;
+ dcr = jcr->sd_impl->dcr;
rec = new_record();
attr = new_attr(jcr);
/*
@@ -274,9 +274,9 @@ static void do_close(JobControlRecord* jcr)
{
FreeAttr(attr);
FreeRecord(rec);
- CleanDevice(jcr->impl->dcr);
+ CleanDevice(jcr->sd_impl->dcr);
delete dev;
- FreeDeviceControlRecord(jcr->impl->dcr);
+ FreeDeviceControlRecord(jcr->sd_impl->dcr);
FreeJcr(jcr);
}
diff --git a/core/src/stored/bscan.cc b/core/src/stored/bscan.cc
index 041f0ee17..cfa8b4dc9 100644
--- a/core/src/stored/bscan.cc
+++ b/core/src/stored/bscan.cc
@@ -31,7 +31,7 @@
#include "include/bareos.h"
#include "stored/stored.h"
#include "stored/stored_globals.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "lib/crypto_cache.h"
#include "findlib/find.h"
#include "cats/cats.h"
@@ -304,7 +304,7 @@ int main(int argc, char* argv[])
bjcr = SetupJcr("bscan", device_name.data(), bsr, director, dcr, volumes,
true);
if (!bjcr) { exit(1); }
- dev = bjcr->impl->read_dcr->dev;
+ dev = bjcr->sd_impl->read_dcr->dev;
if (showProgress) {
char ed1[50];
@@ -349,9 +349,9 @@ int main(int argc, char* argv[])
db->CloseDatabase(bjcr);
DbFlushBackends();
- CleanDevice(bjcr->impl->dcr);
+ CleanDevice(bjcr->sd_impl->dcr);
delete dev;
- FreeDeviceControlRecord(bjcr->impl->dcr);
+ FreeDeviceControlRecord(bjcr->sd_impl->dcr);
FreeJcr(bjcr);
return 0;
@@ -378,8 +378,8 @@ static bool BscanMountNextReadVolume(DeviceControlRecord* dcr)
mdcr->EndBlock = dcr->EndBlock;
mdcr->EndFile = dcr->EndFile;
mdcr->VolMediaId = dcr->VolMediaId;
- mjcr->impl->read_dcr->VolLastIndex = dcr->VolLastIndex;
- if (mjcr->impl->insert_jobmedia_records) {
+ mjcr->sd_impl->read_dcr->VolLastIndex = dcr->VolLastIndex;
+ if (mjcr->sd_impl->insert_jobmedia_records) {
if (!CreateJobmediaRecord(db, mjcr)) {
Pmsg2(000, _("Could not create JobMedia record for Volume=%s Job=%s\n"),
dev->getVolCatName(), mjcr->Job);
@@ -424,7 +424,7 @@ static void do_scan()
fr = fr_empty;
// Detach bscan's jcr as we are not a real Job on the tape
- ReadRecords(bjcr->impl->read_dcr, RecordCb, BscanMountNextReadVolume);
+ ReadRecords(bjcr->sd_impl->read_dcr, RecordCb, BscanMountNextReadVolume);
if (update_db) {
db->WriteBatchFileRecords(bjcr); /* used by bulk batch file insert */
@@ -621,7 +621,7 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec)
// Process label, if Job record exists don't update db
mjcr = CreateJobRecord(db, &jr, &label, rec);
- dcr = mjcr->impl->read_dcr;
+ dcr = mjcr->sd_impl->read_dcr;
update_db = save_update_db;
jr.PoolId = pr.PoolId;
@@ -630,8 +630,8 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec)
mjcr->client_name = GetPoolMemory(PM_FNAME);
PmStrcpy(mjcr->client_name, label.ClientName);
- mjcr->impl->fileset_name = GetPoolMemory(PM_FNAME);
- PmStrcpy(mjcr->impl->fileset_name, label.FileSetName);
+ mjcr->sd_impl->fileset_name = GetPoolMemory(PM_FNAME);
+ PmStrcpy(mjcr->sd_impl->fileset_name, label.FileSetName);
bstrncpy(dcr->pool_type, label.PoolType, sizeof(dcr->pool_type));
bstrncpy(dcr->pool_name, label.PoolName, sizeof(dcr->pool_name));
@@ -645,9 +645,9 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec)
jr.JobId);
db->SqlQuery(sql_buffer.c_str(), db_int64_handler, &jmr_count);
if (jmr_count.value > 0) {
- mjcr->impl->insert_jobmedia_records = false;
+ mjcr->sd_impl->insert_jobmedia_records = false;
} else {
- mjcr->impl->insert_jobmedia_records = true;
+ mjcr->sd_impl->insert_jobmedia_records = true;
}
if (rec->VolSessionId != jr.VolSessionId) {
@@ -699,14 +699,14 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec)
UpdateJobRecord(db, &jr, &elabel, rec);
mjcr->end_time = jr.EndTime;
- mjcr->setJobStatus(JS_Terminated);
+ mjcr->setJobStatusWithPriorityCheck(JS_Terminated);
// Create JobMedia record
- mjcr->impl->read_dcr->VolLastIndex = dcr->VolLastIndex;
- if (mjcr->impl->insert_jobmedia_records) {
+ mjcr->sd_impl->read_dcr->VolLastIndex = dcr->VolLastIndex;
+ if (mjcr->sd_impl->insert_jobmedia_records) {
CreateJobmediaRecord(db, mjcr);
}
- FreeDeviceControlRecord(mjcr->impl->read_dcr);
+ FreeDeviceControlRecord(mjcr->sd_impl->read_dcr);
FreeJcr(mjcr);
}
break;
@@ -760,7 +760,7 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec)
}
return true;
}
- dcr = mjcr->impl->read_dcr;
+ dcr = mjcr->sd_impl->read_dcr;
if (dcr->VolFirstIndex == 0) { dcr->VolFirstIndex = block->FirstIndex; }
// File Attributes stream
@@ -993,19 +993,19 @@ static void BscanFreeJcr(JobControlRecord* jcr)
if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); }
- if (jcr->impl->dcr) {
- FreeDeviceControlRecord(jcr->impl->dcr);
- jcr->impl->dcr = nullptr;
+ if (jcr->sd_impl->dcr) {
+ FreeDeviceControlRecord(jcr->sd_impl->dcr);
+ jcr->sd_impl->dcr = nullptr;
}
- if (jcr->impl->read_dcr) {
- FreeDeviceControlRecord(jcr->impl->read_dcr);
- jcr->impl->read_dcr = nullptr;
+ if (jcr->sd_impl->read_dcr) {
+ FreeDeviceControlRecord(jcr->sd_impl->read_dcr);
+ jcr->sd_impl->read_dcr = nullptr;
}
- if (jcr->impl) {
- delete jcr->impl;
- jcr->impl = nullptr;
+ if (jcr->sd_impl) {
+ delete jcr->sd_impl;
+ jcr->sd_impl = nullptr;
}
Dmsg0(200, "End bscan FreeJcr\n");
@@ -1023,7 +1023,7 @@ static bool CreateFileAttributesRecord(BareosDb* db,
char* ap,
DeviceRecord* rec)
{
- DeviceControlRecord* dcr = mjcr->impl->read_dcr;
+ DeviceControlRecord* dcr = mjcr->sd_impl->read_dcr;
ar.fname = fname;
ar.link = lname;
ar.ClientId = mjcr->ClientId;
@@ -1258,7 +1258,7 @@ static bool UpdateJobRecord(BareosDb* db,
jr->JobId = mjcr->JobId;
jr->JobStatus = elabel->JobStatus;
- mjcr->JobStatus = elabel->JobStatus;
+ mjcr->setJobStatus(elabel->JobStatus);
jr->JobFiles = elabel->JobFiles;
if (jr->JobFiles > 0) { /* If we found files, force PurgedFiles */
jr->PurgedFiles = 0;
@@ -1294,7 +1294,7 @@ static bool UpdateJobRecord(BareosDb* db,
char sdt[50], edt[50];
char ec1[30], ec2[30], ec3[30];
- switch (mjcr->JobStatus) {
+ switch (mjcr->getJobStatus()) {
case JS_Terminated:
TermMsg = _("Backup OK");
break;
@@ -1310,7 +1310,7 @@ static bool UpdateJobRecord(BareosDb* db,
break;
default:
TermMsg = term_code;
- sprintf(term_code, _("Job Termination code: %d"), mjcr->JobStatus);
+ sprintf(term_code, _("Job Termination code: %d"), mjcr->getJobStatus());
break;
}
bstrftime(sdt, sizeof(sdt), mjcr->start_time);
@@ -1331,7 +1331,7 @@ static bool UpdateJobRecord(BareosDb* db,
"Last Volume Bytes: %s\n"
"Bareos binary info: %s\n"
"Termination: %s\n\n"),
- edt, mjcr->JobId, mjcr->Job, mjcr->impl->fileset_name,
+ edt, mjcr->JobId, mjcr->Job, mjcr->sd_impl->fileset_name,
job_level_to_str(mjcr->getJobLevel()), mjcr->client_name, sdt, edt,
edit_uint64_with_commas(mjcr->JobFiles, ec1),
edit_uint64_with_commas(mjcr->JobBytes, ec2), mjcr->VolSessionId,
@@ -1346,7 +1346,7 @@ static bool UpdateJobRecord(BareosDb* db,
static bool CreateJobmediaRecord(BareosDb* db, JobControlRecord* mjcr)
{
JobMediaDbRecord jmr;
- DeviceControlRecord* dcr = mjcr->impl->read_dcr;
+ DeviceControlRecord* dcr = mjcr->sd_impl->read_dcr;
dcr->EndBlock = dev->EndBlock;
dcr->EndFile = dev->EndFile;
@@ -1424,10 +1424,10 @@ static JobControlRecord* create_jcr(JobDbRecord* jr,
* the JobId and the ClientId.
*/
jobjcr = new_jcr(BscanFreeJcr);
- jobjcr->impl = new JobControlRecordPrivate;
+ jobjcr->sd_impl = new StoredJcrImpl;
jobjcr->setJobType(jr->JobType);
jobjcr->setJobLevel(jr->JobLevel);
- jobjcr->JobStatus = jr->JobStatus;
+ jobjcr->setJobStatus(jr->JobStatus);
bstrncpy(jobjcr->Job, jr->Job, sizeof(jobjcr->Job));
jobjcr->JobId = JobId; /* this is JobId on tape */
jobjcr->sched_time = jr->SchedTime;
@@ -1435,8 +1435,8 @@ static JobControlRecord* create_jcr(JobDbRecord* jr,
jobjcr->VolSessionId = rec->VolSessionId;
jobjcr->VolSessionTime = rec->VolSessionTime;
jobjcr->ClientId = jr->ClientId;
- jobjcr->impl->dcr = jobjcr->impl->read_dcr = new DeviceControlRecord;
- SetupNewDcrDevice(jobjcr, jobjcr->impl->dcr, dev, nullptr);
+ jobjcr->sd_impl->dcr = jobjcr->sd_impl->read_dcr = new DeviceControlRecord;
+ SetupNewDcrDevice(jobjcr, jobjcr->sd_impl->dcr, dev, nullptr);
return jobjcr;
}
diff --git a/core/src/stored/bsr.cc b/core/src/stored/bsr.cc
index 225cead36..2e39cdc1a 100644
--- a/core/src/stored/bsr.cc
+++ b/core/src/stored/bsr.cc
@@ -39,7 +39,7 @@
#include "include/bareos.h"
#include "stored/bsr.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/stored.h"
#include "include/jcr.h"
@@ -795,13 +795,13 @@ static VolumeList* new_restore_volume()
*/
static bool AddRestoreVolume(JobControlRecord* jcr, VolumeList* vol)
{
- VolumeList* next = jcr->impl->VolList;
+ VolumeList* next = jcr->sd_impl->VolList;
/* Add volume to volume manager's read list */
AddReadVolume(jcr, vol->VolumeName);
- if (!next) { /* list empty ? */
- jcr->impl->VolList = vol; /* yes, add volume */
+ if (!next) { /* list empty ? */
+ jcr->sd_impl->VolList = vol; /* yes, add volume */
} else {
/* Loop through all but last */
for (; next->next; next = next->next) {
@@ -835,10 +835,10 @@ void CreateRestoreVolumeList(JobControlRecord* jcr)
VolumeList* vol;
// Build a list of volumes to be processed
- jcr->impl->NumReadVolumes = 0;
- jcr->impl->CurReadVolume = 0;
- if (jcr->impl->read_session.bsr) {
- BootStrapRecord* bsr = jcr->impl->read_session.bsr;
+ jcr->sd_impl->NumReadVolumes = 0;
+ jcr->sd_impl->CurReadVolume = 0;
+ if (jcr->sd_impl->read_session.bsr) {
+ BootStrapRecord* bsr = jcr->sd_impl->read_session.bsr;
if (!bsr->volume || !bsr->volume->VolumeName[0]) { return; }
for (; bsr; bsr = bsr->next) {
BsrVolume* bsrvol;
@@ -858,7 +858,7 @@ void CreateRestoreVolumeList(JobControlRecord* jcr)
vol->Slot = bsrvol->Slot;
vol->start_file = sfile;
if (AddRestoreVolume(jcr, vol)) {
- jcr->impl->NumReadVolumes++;
+ jcr->sd_impl->NumReadVolumes++;
Dmsg2(400, "Added volume=%s mediatype=%s\n", vol->VolumeName,
vol->MediaType);
} else {
@@ -870,15 +870,15 @@ void CreateRestoreVolumeList(JobControlRecord* jcr)
}
} else {
/* This is the old way -- deprecated */
- for (p = jcr->impl->dcr->VolumeName; p && *p;) {
+ for (p = jcr->sd_impl->dcr->VolumeName; p && *p;) {
n = strchr(p, '|'); /* volume name separator */
if (n) { *n++ = 0; /* Terminate name */ }
vol = new_restore_volume();
bstrncpy(vol->VolumeName, p, sizeof(vol->VolumeName));
- bstrncpy(vol->MediaType, jcr->impl->dcr->media_type,
+ bstrncpy(vol->MediaType, jcr->sd_impl->dcr->media_type,
sizeof(vol->MediaType));
if (AddRestoreVolume(jcr, vol)) {
- jcr->impl->NumReadVolumes++;
+ jcr->sd_impl->NumReadVolumes++;
} else {
free((char*)vol);
}
@@ -889,7 +889,7 @@ void CreateRestoreVolumeList(JobControlRecord* jcr)
void FreeRestoreVolumeList(JobControlRecord* jcr)
{
- VolumeList* vol = jcr->impl->VolList;
+ VolumeList* vol = jcr->sd_impl->VolList;
VolumeList* tmp;
for (; vol;) {
@@ -898,7 +898,7 @@ void FreeRestoreVolumeList(JobControlRecord* jcr)
free(vol);
vol = tmp;
}
- jcr->impl->VolList = NULL;
+ jcr->sd_impl->VolList = NULL;
}
} /* namespace storagedaemon */
diff --git a/core/src/stored/btape.cc b/core/src/stored/btape.cc
index 5cacbf439..382c12343 100644
--- a/core/src/stored/btape.cc
+++ b/core/src/stored/btape.cc
@@ -42,7 +42,7 @@
#include "stored/btape_device_control_record.h"
#include "stored/butil.h"
#include "stored/device.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/label.h"
#include "stored/read_record.h"
#include "stored/sd_backends.h"
@@ -322,7 +322,7 @@ int main(int margc, char* margv[])
false); /* write device */
if (!jcr) { exit(1); }
- dev = jcr->impl->dcr->dev;
+ dev = jcr->sd_impl->dcr->dev;
if (!dev) { exit(1); }
if (!dev->IsTape()) {
@@ -359,10 +359,6 @@ static void TerminateBtape(int status)
if (dev) { delete dev; }
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
- FlushAndCloseBackendDevices();
-#endif
-
if (configfile) { free(configfile); }
if (my_config) {
@@ -2145,16 +2141,16 @@ static void fillcmd()
*/
Dmsg0(100, "just before acquire_device\n");
if (!AcquireDeviceForAppend(dcr)) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
exit_code = 1;
return;
}
- block = jcr->impl->dcr->block;
+ block = jcr->sd_impl->dcr->block;
Dmsg0(100, "Just after AcquireDeviceForAppend\n");
// Write Begin Session Record
if (!WriteSessionLabel(dcr, SOS_LABEL)) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"),
dev->bstrerror());
ok = false;
@@ -2169,7 +2165,7 @@ static void fillcmd()
FillBuffer(FILL_RANDOM, rec.data, rec.data_len);
// Generate data as if from File daemon, write to device
- jcr->impl->dcr->VolFirstIndex = 0;
+ jcr->sd_impl->dcr->VolFirstIndex = 0;
time(&jcr->run_time); /* start counting time for rates */
bstrftime(buf1, sizeof(buf1), jcr->run_time, "%H:%M:%S");
@@ -2255,10 +2251,10 @@ static void fillcmd()
Dmsg0(100, "Write_end_session_label()\n");
/* Create Job status for end of session label */
if (!JobCanceled(jcr) && ok) {
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
} else if (!ok) {
Pmsg0(000, _("Job canceled.\n"));
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
exit_code = 1;
}
if (!WriteSessionLabel(dcr, EOS_LABEL)) {
@@ -2313,15 +2309,17 @@ static void fillcmd()
Pmsg3(0,
_("\n\n%s Done filling tape at %d:%d. Now beginning re-read of "
"tape ...\n"),
- buf1, jcr->impl->dcr->dev->file, jcr->impl->dcr->dev->block_num);
+ buf1, jcr->sd_impl->dcr->dev->file,
+ jcr->sd_impl->dcr->dev->block_num);
} else {
Pmsg3(0,
_("\n\n%s Done filling tapes at %d:%d. Now beginning re-read of "
"first tape ...\n"),
- buf1, jcr->impl->dcr->dev->file, jcr->impl->dcr->dev->block_num);
+ buf1, jcr->sd_impl->dcr->dev->file,
+ jcr->sd_impl->dcr->dev->block_num);
}
- jcr->impl->dcr->block = block;
+ jcr->sd_impl->dcr->block = block;
if (!do_unfill()) {
Pmsg0(000, _("do_unfill failed.\n"));
exit_code = 1;
@@ -2414,13 +2412,13 @@ static bool do_unfill()
last_block = last_block1;
FreeRestoreVolumeList(jcr);
- jcr->impl->read_session.bsr = nullptr;
+ jcr->sd_impl->read_session.bsr = nullptr;
bstrncpy(dcr->VolumeName, "TestVolume1|TestVolume2", sizeof(dcr->VolumeName));
CreateRestoreVolumeList(jcr);
- if (jcr->impl->VolList != nullptr) {
- jcr->impl->VolList->Slot = 1;
- if (jcr->impl->VolList->next != nullptr) {
- jcr->impl->VolList->next->Slot = 2;
+ if (jcr->sd_impl->VolList != nullptr) {
+ jcr->sd_impl->VolList->Slot = 1;
+ if (jcr->sd_impl->VolList->next != nullptr) {
+ jcr->sd_impl->VolList->next->Slot = 2;
}
}
@@ -2441,7 +2439,7 @@ static bool do_unfill()
dev->close(dcr);
dev->num_writers = 0;
- jcr->impl->dcr->clear_will_write();
+ jcr->sd_impl->dcr->clear_will_write();
if (!AcquireDeviceForRead(dcr)) {
Pmsg1(-1, "%s", dev->errmsg);
@@ -2667,7 +2665,7 @@ static int FlushBlock(DeviceBlock* block)
stop = -1; /* stop, but do simplified test */
} else {
/* Full test in progress */
- if (!FixupDeviceBlockWriteError(jcr->impl->dcr)) {
+ if (!FixupDeviceBlockWriteError(jcr->sd_impl->dcr)) {
Pmsg1(000, _("Cannot fixup device error. %s\n"), dev->bstrerror());
ok = false;
dev->Unlock();
@@ -3011,7 +3009,7 @@ static bool MyMountNextReadVolume(DeviceControlRecord* dcr)
static void SetVolumeName(const char* VolName, int volnum)
{
- DeviceControlRecord* dcr = jcr->impl->dcr;
+ DeviceControlRecord* dcr = jcr->sd_impl->dcr;
volumename = VolName;
vol_num = volnum;
dev->setVolCatName(VolName);
diff --git a/core/src/stored/butil.cc b/core/src/stored/butil.cc
index feb6215e6..74f6311e2 100644
--- a/core/src/stored/butil.cc
+++ b/core/src/stored/butil.cc
@@ -39,7 +39,7 @@
#include "stored/device.h"
#include "stored/device_control_record.h"
#include "stored/bsr.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "lib/parse_bsr.h"
#include "lib/parse_conf.h"
#include "include/jcr.h"
@@ -62,28 +62,28 @@ JobControlRecord* SetupDummyJcr(const char* name,
DirectorResource* director)
{
JobControlRecord* jcr = new_jcr(MyFreeJcr);
- jcr->impl = new JobControlRecordPrivate;
+ jcr->sd_impl = new StoredJcrImpl;
- jcr->impl->read_session.bsr = bsr;
- jcr->impl->director = director;
+ jcr->sd_impl->read_session.bsr = bsr;
+ jcr->sd_impl->director = director;
jcr->VolSessionId = 1;
jcr->VolSessionTime = (uint32_t)time(NULL);
- jcr->impl->NumReadVolumes = 0;
- jcr->impl->NumWriteVolumes = 0;
+ jcr->sd_impl->NumReadVolumes = 0;
+ jcr->sd_impl->NumWriteVolumes = 0;
jcr->JobId = 0;
jcr->setJobType(JT_CONSOLE);
jcr->setJobLevel(L_FULL);
- jcr->JobStatus = JS_Terminated;
+ jcr->setJobStatus(JS_Terminated);
jcr->where = strdup("");
- jcr->impl->job_name = GetPoolMemory(PM_FNAME);
- PmStrcpy(jcr->impl->job_name, "Dummy.Job.Name");
+ jcr->sd_impl->job_name = GetPoolMemory(PM_FNAME);
+ PmStrcpy(jcr->sd_impl->job_name, "Dummy.Job.Name");
jcr->client_name = GetPoolMemory(PM_FNAME);
PmStrcpy(jcr->client_name, "Dummy.Client.Name");
bstrncpy(jcr->Job, name, sizeof(jcr->Job));
- jcr->impl->fileset_name = GetPoolMemory(PM_FNAME);
- PmStrcpy(jcr->impl->fileset_name, "Dummy.fileset.name");
- jcr->impl->fileset_md5 = GetPoolMemory(PM_FNAME);
- PmStrcpy(jcr->impl->fileset_md5, "Dummy.fileset.md5");
+ jcr->sd_impl->fileset_name = GetPoolMemory(PM_FNAME);
+ PmStrcpy(jcr->sd_impl->fileset_name, "Dummy.fileset.name");
+ jcr->sd_impl->fileset_md5 = GetPoolMemory(PM_FNAME);
+ PmStrcpy(jcr->sd_impl->fileset_md5, "Dummy.fileset.md5");
NewPlugins(jcr); /* instantiate plugins */
@@ -153,7 +153,7 @@ static bool setup_to_access_device(DeviceControlRecord* dcr,
} else {
VolName[0] = 0;
}
- if (!jcr->impl->read_session.bsr && VolName[0] == 0) {
+ if (!jcr->sd_impl->read_session.bsr && VolName[0] == 0) {
if (!bstrncmp(dev_name, "/dev/", 5)) {
/* Try stripping file part */
p = dev_name + strlen(dev_name);
@@ -178,7 +178,7 @@ static bool setup_to_access_device(DeviceControlRecord* dcr,
return false;
}
device_resource->dev = dev;
- jcr->impl->dcr = dcr;
+ jcr->sd_impl->dcr = dcr;
SetupNewDcrDevice(jcr, dcr, dev, NULL);
if (!readonly) { dcr->SetWillWrite(); }
@@ -193,7 +193,7 @@ static bool setup_to_access_device(DeviceControlRecord* dcr,
if (readonly) { /* read only access? */
Dmsg0(100, "Acquire device for read\n");
if (!AcquireDeviceForRead(dcr)) { return false; }
- jcr->impl->read_dcr = dcr;
+ jcr->sd_impl->read_dcr = dcr;
} else {
if (!FirstOpenDevice(dcr)) {
Jmsg1(jcr, M_FATAL, 0, _("Cannot open %s\n"), dev->print_name());
@@ -210,9 +210,9 @@ static bool setup_to_access_device(DeviceControlRecord* dcr,
*/
static void MyFreeJcr(JobControlRecord* jcr)
{
- if (jcr->impl->job_name) {
- FreePoolMemory(jcr->impl->job_name);
- jcr->impl->job_name = NULL;
+ if (jcr->sd_impl->job_name) {
+ FreePoolMemory(jcr->sd_impl->job_name);
+ jcr->sd_impl->job_name = NULL;
}
if (jcr->client_name) {
@@ -220,14 +220,14 @@ static void MyFreeJcr(JobControlRecord* jcr)
jcr->client_name = NULL;
}
- if (jcr->impl->fileset_name) {
- FreePoolMemory(jcr->impl->fileset_name);
- jcr->impl->fileset_name = NULL;
+ if (jcr->sd_impl->fileset_name) {
+ FreePoolMemory(jcr->sd_impl->fileset_name);
+ jcr->sd_impl->fileset_name = NULL;
}
- if (jcr->impl->fileset_md5) {
- FreePoolMemory(jcr->impl->fileset_md5);
- jcr->impl->fileset_md5 = NULL;
+ if (jcr->sd_impl->fileset_md5) {
+ FreePoolMemory(jcr->sd_impl->fileset_md5);
+ jcr->sd_impl->fileset_md5 = NULL;
}
if (jcr->comment) {
@@ -235,16 +235,16 @@ static void MyFreeJcr(JobControlRecord* jcr)
jcr->comment = NULL;
}
- if (jcr->impl->VolList) { FreeRestoreVolumeList(jcr); }
+ if (jcr->sd_impl->VolList) { FreeRestoreVolumeList(jcr); }
- if (jcr->impl->dcr) {
- FreeDeviceControlRecord(jcr->impl->dcr);
- jcr->impl->dcr = NULL;
+ if (jcr->sd_impl->dcr) {
+ FreeDeviceControlRecord(jcr->sd_impl->dcr);
+ jcr->sd_impl->dcr = NULL;
}
- if (jcr->impl) {
- delete jcr->impl;
- jcr->impl = nullptr;
+ if (jcr->sd_impl) {
+ delete jcr->sd_impl;
+ jcr->sd_impl = nullptr;
}
return;
diff --git a/core/src/stored/dev.cc b/core/src/stored/dev.cc
index 971a7ec18..5070c0bec 100644
--- a/core/src/stored/dev.cc
+++ b/core/src/stored/dev.cc
@@ -76,42 +76,20 @@
#include "stored/autochanger.h"
#include "stored/bsr.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/sd_backends.h"
#include "lib/btimers.h"
#include "include/jcr.h"
#include "lib/berrno.h"
-#ifndef HAVE_DYNAMIC_SD_BACKENDS
-# ifdef HAVE_GFAPI
-# include "backends/gfapi_device.h"
-# endif
-# ifdef HAVE_BAREOSSD_DROPLET_DEVICE
-# include "backends/chunked_device.h"
-# include "backends/droplet_device.h"
-# endif
-# include "backends/generic_tape_device.h"
-# ifdef HAVE_WIN32
-# include "backends/win32_tape_device.h"
-# include "backends/win32_fifo_device.h"
-# else
-# include "backends/unix_tape_device.h"
-# include "backends/unix_fifo_device.h"
-# endif
-#endif /* HAVE_DYNAMIC_SD_BACKENDS */
-
-#ifdef HAVE_WIN32
-# include "backends/win32_file_device.h"
-#else
-# include "backends/unix_file_device.h"
-#endif
-
#ifndef O_NONBLOCK
# define O_NONBLOCK 0
#endif
namespace storagedaemon {
+static void InitiateDevice(JobControlRecord* jcr, Device* dev);
+
const char* Device::mode_to_str(DeviceMode mode)
{
static const char* modes[] = {"CREATE_READ_WRITE", "OPEN_READ_WRITE",
@@ -144,162 +122,89 @@ Device* FactoryCreateDevice(JobControlRecord* jcr,
Dmsg1(400, "max_block_size in device_resource res is %u\n",
device_resource->max_block_size);
- // If no device type specified, try to guess
- if (device_resource->dev_type == DeviceType::B_UNKNOWN_DEV) {
- struct stat statp;
- // Check that device is available
- if (stat(device_resource->archive_device_string, &statp) < 0) {
- BErrNo be;
- Jmsg2(jcr, M_ERROR, 0, _("Unable to stat device %s: ERR=%s\n"),
- device_resource->archive_device_string, be.bstrerror());
- return nullptr;
- }
- if (S_ISDIR(statp.st_mode)) {
- device_resource->dev_type = DeviceType::B_FILE_DEV;
- } else if (S_ISCHR(statp.st_mode)) {
- device_resource->dev_type = DeviceType::B_TAPE_DEV;
- } else if (S_ISFIFO(statp.st_mode)) {
- device_resource->dev_type = DeviceType::B_FIFO_DEV;
- } else if (!BitIsSet(CAP_REQMOUNT, device_resource->cap_bits)) {
- Jmsg2(jcr, M_ERROR, 0,
- _("%s is an unknown device type. Must be tape or directory, "
- "st_mode=%04o\n"),
- device_resource->archive_device_string, (statp.st_mode & ~S_IFMT));
- return nullptr;
- }
+ if (!ImplementationFactory<Device>::IsRegistered(
+ device_resource->device_type)) {
+ Jmsg2(jcr, M_ERROR, 0, _("%s has an unsupported Device Type %s\n"),
+ device_resource->archive_device_string,
+ device_resource->device_type.c_str());
+ return nullptr;
}
- Device* dev = nullptr;
+ Device* dev
+ = ImplementationFactory<Device>::Create(device_resource->device_type);
- switch (device_resource->dev_type) {
- /*
- * When using dynamic loading use the InitBackendDevice() function
- * for any type of device not being of the type file.
- */
-#ifndef HAVE_DYNAMIC_SD_BACKENDS
-# ifdef HAVE_GFAPI
- case DeviceType::B_GFAPI_DEV:
- dev = new gfapi_device;
- break;
-# endif
-# ifdef HAVE_BAREOSSD_DROPLET_DEVICE
- case DeviceType::B_DROPLET_DEV:
- dev = new DropletDevice;
- break;
-# endif
-# ifdef HAVE_WIN32
- case DeviceType::B_TAPE_DEV:
- dev = new win32_tape_device;
- break;
- case DeviceType::B_FIFO_DEV:
- dev = new win32_fifo_device;
- break;
-# else
- case DeviceType::B_TAPE_DEV:
- dev = new unix_tape_device;
- break;
- case DeviceType::B_FIFO_DEV:
- dev = new unix_fifo_device;
- break;
-# endif
-#endif /* HAVE_DYNAMIC_SD_BACKENDS */
-#ifdef HAVE_WIN32
- case DeviceType::B_FILE_DEV:
- dev = new win32_file_device;
- break;
-#else
- case DeviceType::B_FILE_DEV:
- dev = new unix_file_device;
- break;
-#endif
- default:
-#ifdef HAVE_DYNAMIC_SD_BACKENDS
- dev = InitBackendDevice(jcr, device_resource->dev_type);
- if (!dev) {
- try {
- Jmsg2(jcr, M_ERROR, 0,
- _("Initialization of dynamic %s device \"%s\" with archive "
- "device \"%s\" failed. Backend "
- "library might be missing or backend directory incorrect.\n"),
- device_type_to_name_mapping.at(device_resource->dev_type),
- device_resource->resource_name_,
- device_resource->archive_device_string);
- } catch (const std::out_of_range&) {
- // device_resource->dev_type could exceed limits of map
- }
- return nullptr;
- }
-#endif
- break;
- }
+ dev->device_resource = device_resource;
+ device_resource->dev = dev;
- if (!dev) {
- Jmsg2(jcr, M_ERROR, 0, _("%s has an unknown device type %d\n"),
- device_resource->archive_device_string, device_resource->dev_type);
- return nullptr;
- }
+ InitiateDevice(jcr, dev);
+ return dev;
+}
+
+static void InitiateDevice(JobControlRecord* jcr, Device* dev)
+{
dev->InvalidateSlotNumber(); /* unknown */
// Copy user supplied device parameters from Resource
dev->archive_device_string
- = GetMemory(strlen(device_resource->archive_device_string) + 1);
- PmStrcpy(dev->archive_device_string, device_resource->archive_device_string);
- if (device_resource->device_options) {
- dev->dev_options = GetMemory(strlen(device_resource->device_options) + 1);
- PmStrcpy(dev->dev_options, device_resource->device_options);
+ = GetMemory(strlen(dev->device_resource->archive_device_string) + 1);
+ PmStrcpy(dev->archive_device_string,
+ dev->device_resource->archive_device_string);
+ if (dev->device_resource->device_options) {
+ dev->dev_options
+ = GetMemory(strlen(dev->device_resource->device_options) + 1);
+ PmStrcpy(dev->dev_options, dev->device_resource->device_options);
}
- dev->prt_name = GetMemory(strlen(device_resource->archive_device_string)
- + strlen(device_resource->resource_name_) + 20);
+ dev->prt_name
+ = GetMemory(strlen(dev->device_resource->archive_device_string)
+ + strlen(dev->device_resource->resource_name_) + 20);
- Mmsg(dev->prt_name, "\"%s\" (%s)", device_resource->resource_name_,
- device_resource->archive_device_string);
+ Mmsg(dev->prt_name, "\"%s\" (%s)", dev->device_resource->resource_name_,
+ dev->device_resource->archive_device_string);
Dmsg1(400, "Allocate dev=%s\n", dev->print_name());
- CopySetBits(CAP_MAX, device_resource->cap_bits, dev->capabilities);
+ CopySetBits(CAP_MAX, dev->device_resource->cap_bits, dev->capabilities);
- dev->min_block_size = device_resource->min_block_size;
- dev->max_block_size = device_resource->max_block_size;
+ dev->min_block_size = dev->device_resource->min_block_size;
+ dev->max_block_size = dev->device_resource->max_block_size;
dev->max_volume_size = 0;
- dev->max_file_size = device_resource->max_file_size;
- dev->max_concurrent_jobs = device_resource->max_concurrent_jobs;
- dev->volume_capacity = device_resource->volume_capacity;
- dev->max_rewind_wait = device_resource->max_rewind_wait;
- dev->max_open_wait = device_resource->max_open_wait;
- dev->max_open_vols = device_resource->max_open_vols;
- dev->vol_poll_interval = device_resource->vol_poll_interval;
- dev->max_spool_size = device_resource->max_spool_size;
- dev->drive = device_resource->drive;
- dev->drive_index = device_resource->drive_index;
- dev->autoselect = device_resource->autoselect;
- dev->norewindonclose = device_resource->norewindonclose;
- dev->dev_type = device_resource->dev_type;
- dev->device_resource = device_resource;
-
- device_resource->dev = dev;
+ dev->max_file_size = dev->device_resource->max_file_size;
+ dev->max_concurrent_jobs = dev->device_resource->max_concurrent_jobs;
+ dev->volume_capacity = dev->device_resource->volume_capacity;
+ dev->max_rewind_wait = dev->device_resource->max_rewind_wait;
+ dev->max_open_wait = dev->device_resource->max_open_wait;
+ dev->max_open_vols = dev->device_resource->max_open_vols;
+ dev->vol_poll_interval = dev->device_resource->vol_poll_interval;
+ dev->max_spool_size = dev->device_resource->max_spool_size;
+ dev->drive = dev->device_resource->drive;
+ dev->drive_index = dev->device_resource->drive_index;
+ dev->autoselect = dev->device_resource->autoselect;
+ dev->norewindonclose = dev->device_resource->norewindonclose;
+ dev->device_type = dev->device_resource->device_type;
if (dev->vol_poll_interval && dev->vol_poll_interval < 60) {
dev->vol_poll_interval = 60;
}
- if (dev->IsFifo()) { dev->SetCap(CAP_STREAM); }
+ if (dev->GetSeekMode() == SeekMode::NOSEEK) { dev->SetCap(CAP_STREAM); }
/*
* If the device requires mount :
* - Check that the mount point is available
* - Check that (un)mount commands are defined
*/
- if (dev->IsFile() && dev->RequiresMount()) {
+ if (dev->RequiresMount()) {
struct stat statp;
- if (!device_resource->mount_point
- || stat(device_resource->mount_point, &statp) < 0) {
+ if (!dev->device_resource->mount_point
+ || stat(dev->device_resource->mount_point, &statp) < 0) {
BErrNo be;
dev->dev_errno = errno;
Jmsg2(jcr, M_ERROR_TERM, 0, _("Unable to stat mount point %s: ERR=%s\n"),
- device_resource->mount_point, be.bstrerror());
+ dev->device_resource->mount_point, be.bstrerror());
}
- if (!device_resource->mount_command || !device_resource->unmount_command) {
+ if (!dev->device_resource->mount_command
+ || !dev->device_resource->unmount_command) {
Jmsg0(jcr, M_ERROR_TERM, 0,
_("Mount and unmount commands must defined for a device which "
"requires mount.\n"));
@@ -389,8 +294,6 @@ Device* FactoryCreateDevice(JobControlRecord* jcr,
dev->initiated = true;
Dmsg3(100, "dev=%s dev_max_bs=%u max_bs=%u\n", dev->archive_device_string,
dev->device_resource->max_block_size, dev->max_block_size);
-
- return dev;
}
// This routine initializes the device wait timers
@@ -408,27 +311,29 @@ void InitDeviceWaitTimers(DeviceControlRecord* dcr)
dev->num_wait = 0;
dev->poll = false;
- jcr->impl->device_wait_times.min_wait = 60 * 60;
- jcr->impl->device_wait_times.max_wait = 24 * 60 * 60;
- jcr->impl->device_wait_times.max_num_wait
+ jcr->sd_impl->device_wait_times.min_wait = 60 * 60;
+ jcr->sd_impl->device_wait_times.max_wait = 24 * 60 * 60;
+ jcr->sd_impl->device_wait_times.max_num_wait
= 9; /* 5 waits =~ 1 day, then 1 day at a time */
- jcr->impl->device_wait_times.wait_sec = jcr->impl->device_wait_times.min_wait;
- jcr->impl->device_wait_times.rem_wait_sec
- = jcr->impl->device_wait_times.wait_sec;
- jcr->impl->device_wait_times.num_wait = 0;
+ jcr->sd_impl->device_wait_times.wait_sec
+ = jcr->sd_impl->device_wait_times.min_wait;
+ jcr->sd_impl->device_wait_times.rem_wait_sec
+ = jcr->sd_impl->device_wait_times.wait_sec;
+ jcr->sd_impl->device_wait_times.num_wait = 0;
}
void InitJcrDeviceWaitTimers(JobControlRecord* jcr)
{
/* ******FIXME******* put these on config variables */
- jcr->impl->device_wait_times.min_wait = 60 * 60;
- jcr->impl->device_wait_times.max_wait = 24 * 60 * 60;
- jcr->impl->device_wait_times.max_num_wait
+ jcr->sd_impl->device_wait_times.min_wait = 60 * 60;
+ jcr->sd_impl->device_wait_times.max_wait = 24 * 60 * 60;
+ jcr->sd_impl->device_wait_times.max_num_wait
= 9; /* 5 waits =~ 1 day, then 1 day at a time */
- jcr->impl->device_wait_times.wait_sec = jcr->impl->device_wait_times.min_wait;
- jcr->impl->device_wait_times.rem_wait_sec
- = jcr->impl->device_wait_times.wait_sec;
- jcr->impl->device_wait_times.num_wait = 0;
+ jcr->sd_impl->device_wait_times.wait_sec
+ = jcr->sd_impl->device_wait_times.min_wait;
+ jcr->sd_impl->device_wait_times.rem_wait_sec
+ = jcr->sd_impl->device_wait_times.wait_sec;
+ jcr->sd_impl->device_wait_times.num_wait = 0;
}
/**
@@ -603,7 +508,7 @@ bool Device::open(DeviceControlRecord* dcr, DeviceMode omode)
}
Dmsg4(100, "open dev: type=%d archive_device_string=%s vol=%s mode=%s\n",
- dev_type, print_name(), getVolCatName(), mode_to_str(omode));
+ device_type.c_str(), print_name(), getVolCatName(), mode_to_str(omode));
ClearBit(ST_LABEL, state);
ClearBit(ST_APPENDREADY, state);
@@ -732,15 +637,25 @@ bool Device::rewind(DeviceControlRecord* dcr)
if (fd < 0) { return false; }
- if (IsFifo() || IsVtl()) { return true; }
-
- if (d_lseek(dcr, (boffset_t)0, SEEK_SET) < 0) {
- BErrNo be;
- dev_errno = errno;
- Mmsg2(errmsg, _("lseek error on %s. ERR=%s"), print_name(), be.bstrerror());
- return false;
+ switch (GetSeekMode()) {
+ case SeekMode::NOSEEK: {
+ return true;
+ } break;
+ case SeekMode::BYTES: {
+ if (d_lseek(dcr, (boffset_t)0, SEEK_SET) < 0) {
+ BErrNo be;
+ dev_errno = errno;
+ Mmsg2(errmsg, _("lseek error on %s. ERR=%s"), print_name(),
+ be.bstrerror());
+ return false;
+ }
+ } break;
+ case SeekMode::FILE_BLOCK: {
+ dev_errno = EINVAL;
+ Mmsg(errmsg, "Block addressed backends must override rewind().");
+ return false;
+ } break;
}
-
return true;
}
@@ -782,8 +697,6 @@ bool Device::eod(DeviceControlRecord* dcr)
return false;
}
- if (IsVtl()) { return true; }
-
Dmsg0(100, "Enter eod\n");
if (AtEot()) { return true; }
@@ -820,7 +733,6 @@ bool Device::eod(DeviceControlRecord* dcr)
bool Device::UpdatePos(DeviceControlRecord* dcr)
{
boffset_t pos;
- bool ok = true;
if (!IsOpen()) {
dev_errno = EBADF;
@@ -829,25 +741,34 @@ bool Device::UpdatePos(DeviceControlRecord* dcr)
return false;
}
- if (IsFifo() || IsVtl()) { return true; }
-
- file = 0;
- file_addr = 0;
- pos = d_lseek(dcr, (boffset_t)0, SEEK_CUR);
- if (pos < 0) {
- BErrNo be;
- dev_errno = errno;
- Pmsg1(000, _("Seek error: ERR=%s\n"), be.bstrerror());
- Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), print_name(),
- be.bstrerror());
- ok = false;
- } else {
- file_addr = pos;
- block_num = (uint32_t)pos;
- file = (uint32_t)(pos >> 32);
+ switch (GetSeekMode()) {
+ case SeekMode::NOSEEK: {
+ return true;
+ } break;
+ case SeekMode::BYTES: {
+ file = 0;
+ file_addr = 0;
+ pos = d_lseek(dcr, (boffset_t)0, SEEK_CUR);
+ if (pos < 0) {
+ BErrNo be;
+ dev_errno = errno;
+ Pmsg1(000, _("Seek error: ERR=%s\n"), be.bstrerror());
+ Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), print_name(),
+ be.bstrerror());
+ return false;
+ } else {
+ file_addr = pos;
+ block_num = (uint32_t)pos;
+ file = (uint32_t)(pos >> 32);
+ }
+ } break;
+ case SeekMode::FILE_BLOCK: {
+ dev_errno = EINVAL;
+ Mmsg(errmsg, "Block addressed backends must override UpdatePos().");
+ return false;
+ } break;
}
-
- return ok;
+ return true;
}
char* Device::StatusDev()
@@ -920,20 +841,30 @@ bool Device::Reposition(DeviceControlRecord* dcr,
return false;
}
- if (IsFifo() || IsVtl()) { return true; }
-
- boffset_t pos = (((boffset_t)rfile) << 32) | rblock;
- Dmsg1(100, "===== lseek to %d\n", (int)pos);
- if (d_lseek(dcr, pos, SEEK_SET) == (boffset_t)-1) {
- BErrNo be;
- dev_errno = errno;
- Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), print_name(),
- be.bstrerror());
- return false;
+ switch (GetSeekMode()) {
+ case SeekMode::NOSEEK: {
+ return true;
+ } break;
+ case SeekMode::BYTES: {
+ boffset_t pos = (((boffset_t)rfile) << 32) | rblock;
+ Dmsg1(100, "===== lseek to %d\n", (int)pos);
+ if (d_lseek(dcr, pos, SEEK_SET) == (boffset_t)-1) {
+ BErrNo be;
+ dev_errno = errno;
+ Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), print_name(),
+ be.bstrerror());
+ return false;
+ }
+ file = rfile;
+ block_num = rblock;
+ file_addr = pos;
+ } break;
+ case SeekMode::FILE_BLOCK: {
+ dev_errno = EINVAL;
+ Mmsg(errmsg, "Block addressed backends must override Reposition().");
+ return false;
+ } break;
}
- file = rfile;
- block_num = rblock;
- file_addr = pos;
return true;
}
@@ -971,22 +902,15 @@ bool Device::close(DeviceControlRecord* dcr)
if (!norewindonclose) { OfflineOrRewind(); }
- switch (dev_type) {
- case DeviceType::B_VTL_DEV:
- case DeviceType::B_TAPE_DEV:
- UnlockDoor();
- [[fallthrough]];
- default:
- status = d_close(fd);
- if (status < 0) {
- BErrNo be;
+ if (device_type == DeviceType::B_TAPE_DEV) { UnlockDoor(); }
+ status = d_close(fd);
+ if (status < 0) {
+ BErrNo be;
- Mmsg2(errmsg, _("Unable to close device %s. ERR=%s\n"), print_name(),
- be.bstrerror());
- dev_errno = errno;
- retval = false;
- }
- break;
+ Mmsg2(errmsg, _("Unable to close device %s. ERR=%s\n"), print_name(),
+ be.bstrerror());
+ dev_errno = errno;
+ retval = false;
}
unmount(dcr, 1); /* do unmount if required */
diff --git a/core/src/stored/dev.h b/core/src/stored/dev.h
index ef4225313..ad27ae7b1 100644
--- a/core/src/stored/dev.h
+++ b/core/src/stored/dev.h
@@ -65,6 +65,8 @@
#include "stored/volume_catalog_info.h"
#include <vector>
+#include <atomic>
+
template <typename T> class dlist;
namespace storagedaemon {
@@ -84,19 +86,6 @@ enum class DeviceMode : int
OPEN_WRITE_ONLY
};
-enum class DeviceType : int
-{
- B_UNKNOWN_DEV = 0,
- B_FILE_DEV = 1,
- B_TAPE_DEV,
- B_FIFO_DEV,
- B_VTL_DEV,
- B_GFAPI_DEV,
- B_DROPLET_DEV,
- B_RADOS_DEV,
- B_CEPHFS_DEV
-};
-
// Generic status bits returned from StatusDev()
enum
{
@@ -181,6 +170,22 @@ enum
// Make sure you have enough bits to store all above bit fields.
#define ST_BYTES NbytesForBits(ST_MAX + 1)
+enum class SeekMode
+{
+ NOSEEK, // device cannot be seeked (e.g. a FIFO)
+ FILE_BLOCK, // device works with file and blocknum (like a tape)
+ BYTES // device uses byte offsets (like a plain file)
+};
+
+// incomplete list of device types for GuessMissingDeviceTypes()
+struct DeviceType {
+ static constexpr std::string_view B_DROPLET_DEV = "droplet";
+ static constexpr std::string_view B_FIFO_DEV = "fifo";
+ static constexpr std::string_view B_FILE_DEV = "file";
+ static constexpr std::string_view B_TAPE_DEV = "tape";
+ static constexpr std::string_view B_UNKNOWN_DEV = "";
+};
+
/*
* Device structure definition.
*
@@ -203,7 +208,11 @@ class Device {
public:
Device() = default;
virtual ~Device();
- Device* volatile swap_dev{}; /**< Swap vol from this device */
+ Device(const Device&) = delete;
+ Device& operator=(const Device&) = delete;
+ Device(Device&&) = delete;
+ Device& operator=(Device&&) = delete;
+ Device* swap_dev{}; /**< Swap vol from this device */
std::vector<DeviceControlRecord*> attached_dcrs; /**< Attached DeviceControlRecords */
pthread_mutex_t mutex_ = PTHREAD_MUTEX_INITIALIZER; /**< Access control */
pthread_mutex_t spool_mutex = PTHREAD_MUTEX_INITIALIZER; /**< Mutex for updating spool_size */
@@ -220,7 +229,7 @@ class Device {
int dev_errno{}; /**< Our own errno */
int oflags{}; /**< Read/write flags */
DeviceMode open_mode{DeviceMode::kUndefined};
- DeviceType dev_type{DeviceType::B_UNKNOWN_DEV};
+ std::string device_type{};
bool autoselect{}; /**< Autoselect in autochanger */
bool norewindonclose{}; /**< Don't rewind tape drive on close */
bool initiated{}; /**< Set when FactoryCreateDevice() called */
@@ -289,20 +298,12 @@ class Device {
bool AttachedToAutochanger() const { return BitIsSet(CAP_ATTACHED_TO_AUTOCHANGER, capabilities); }
bool RequiresMount() const { return BitIsSet(CAP_REQMOUNT, capabilities); }
bool IsRemovable() const { return BitIsSet(CAP_REM, capabilities); }
- bool IsTape() const { return (dev_type == DeviceType::B_TAPE_DEV); }
- bool IsFile() const
- {
- return (dev_type == DeviceType::B_FILE_DEV || dev_type == DeviceType::B_GFAPI_DEV ||
- dev_type == DeviceType::B_DROPLET_DEV || dev_type == DeviceType::B_RADOS_DEV ||
- dev_type == DeviceType::B_CEPHFS_DEV);
- }
- bool IsFifo() const { return dev_type == DeviceType::B_FIFO_DEV; }
- bool IsVtl() const { return dev_type == DeviceType::B_VTL_DEV; }
+ bool IsTape() const { return (device_type == DeviceType::B_TAPE_DEV); }
bool IsOpen() const { return fd >= 0; }
bool IsOffline() const { return BitIsSet(ST_OFFLINE, state); }
bool IsLabeled() const { return BitIsSet(ST_LABEL, state); }
bool IsMounted() const { return BitIsSet(ST_MOUNTED, state); }
- bool IsUnmountable() const { return ((IsFile() && IsRemovable())); }
+ bool IsUnmountable() const { return (IsRemovable() && RequiresMount()); }
int NumReserved() const { return num_reserved_; }
bool is_part_spooled() const { return BitIsSet(ST_PART_SPOOLED, state); }
bool have_media() const { return BitIsSet(ST_MEDIA, state); }
@@ -334,6 +335,7 @@ class Device {
const char* strerror() const;
const char* archive_name() const;
const char* name() const;
+ const std::string& type() const { return device_type; }
const char* print_name() const; /**< Name for display purposes */
void SetEot() { SetBit(ST_EOT, state); }
void SetEof() { SetBit(ST_EOF, state); }
@@ -403,7 +405,11 @@ class Device {
bool unmount(DeviceControlRecord* dcr, int timeout);
void EditMountCodes(PoolMem& omsg, const char* imsg);
bool OfflineOrRewind();
- bool ScanDirForVolume(DeviceControlRecord* dcr);
+protected:
+ bool ScanDirectoryForVolume(DeviceControlRecord* dcr);
+ virtual bool ScanForVolumeImpl(DeviceControlRecord* dcr);
+public:
+ bool ScanForVolume(DeviceControlRecord* dcr);
void SetSlotNumber(slot_number_t slot);
void InvalidateSlotNumber();
@@ -447,6 +453,8 @@ class Device {
return true;
}
virtual bool DeviceStatus(DeviceStatusInformation*) { return false; }
+ virtual SeekMode GetSeekMode() const = 0;
+ virtual bool CanReadConcurrently() const { return false; }
// Low level operations
virtual int d_ioctl(int fd, ioctl_req_t request, char* mt_com = NULL) = 0;
@@ -493,14 +501,13 @@ class SpoolDevice :public Device
public:
SpoolDevice() = default;
~SpoolDevice() { close(nullptr); }
+ SeekMode GetSeekMode() const override { return SeekMode::NOSEEK; }
int d_ioctl(int, ioctl_req_t, char*) override {return -1;}
int d_open(const char*, int, int) override {return -1;}
int d_close(int) override {return -1;}
ssize_t d_read(int, void*, size_t) override { return 0;}
ssize_t d_write(int, const void*, size_t) override { return 0;}
- boffset_t d_lseek(DeviceControlRecord*,
- boffset_t,
- int) override { return 0;}
+ boffset_t d_lseek(DeviceControlRecord*, boffset_t, int) override { return 0;}
bool d_truncate(DeviceControlRecord*) override {return false;}
};
/* clang-format on */
diff --git a/core/src/stored/device.cc b/core/src/stored/device.cc
index a43f14fba..690d6ed94 100644
--- a/core/src/stored/device.cc
+++ b/core/src/stored/device.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2020 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -52,7 +52,7 @@
#include "stored/stored.h" /* pull in Storage Daemon headers */
#include "stored/device.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/match_bsr.h"
#include "lib/edit.h"
#include "include/jcr.h"
@@ -167,7 +167,7 @@ bool FixupDeviceBlockWriteError(DeviceControlRecord* dcr, int retries)
}
/* Clear NewVol now because DirGetVolumeInfo() already done */
- jcr->impl->dcr->NewVol = false;
+ jcr->sd_impl->dcr->NewVol = false;
SetNewVolumeParameters(dcr);
jcr->run_time += time(NULL) - wait_time; /* correct run time for mount wait */
@@ -225,7 +225,7 @@ void SetNewVolumeParameters(DeviceControlRecord* dcr)
Jmsg1(jcr, M_ERROR, 0, "%s", jcr->errmsg);
}
SetNewFileParameters(dcr);
- jcr->impl->NumWriteVolumes++;
+ jcr->sd_impl->NumWriteVolumes++;
dcr->NewVol = false;
}
@@ -305,9 +305,9 @@ BootStrapRecord* PositionDeviceToFirstFile(JobControlRecord* jcr,
* Now find and position to first file and block
* on this tape.
*/
- if (jcr->impl->read_session.bsr) {
- jcr->impl->read_session.bsr->Reposition = true;
- bsr = find_next_bsr(jcr->impl->read_session.bsr, dev);
+ if (jcr->sd_impl->read_session.bsr) {
+ jcr->sd_impl->read_session.bsr->Reposition = true;
+ bsr = find_next_bsr(jcr->sd_impl->read_session.bsr, dev);
if (GetBsrStartAddr(bsr, &file, &block) > 0) {
Jmsg(jcr, M_INFO, 0,
_("Forward spacing Volume \"%s\" to file:block %u:%u.\n"),
@@ -331,15 +331,15 @@ bool TryDeviceRepositioning(JobControlRecord* jcr,
BootStrapRecord* bsr;
Device* dev = dcr->dev;
- bsr = find_next_bsr(jcr->impl->read_session.bsr, dev);
- if (bsr == NULL && jcr->impl->read_session.bsr->mount_next_volume) {
+ bsr = find_next_bsr(jcr->sd_impl->read_session.bsr, dev);
+ if (bsr == NULL && jcr->sd_impl->read_session.bsr->mount_next_volume) {
Dmsg0(500, "Would mount next volume here\n");
Dmsg2(500, "Current position (file:block) %u:%u\n", dev->file,
dev->block_num);
- jcr->impl->read_session.bsr->mount_next_volume = false;
+ jcr->sd_impl->read_session.bsr->mount_next_volume = false;
if (!dev->AtEot()) {
/* Set EOT flag to force mount of next Volume */
- jcr->impl->read_session.mount_next_volume = true;
+ jcr->sd_impl->read_session.mount_next_volume = true;
dev->SetEot();
}
rec->Block = 0;
diff --git a/core/src/stored/device_control_record.h b/core/src/stored/device_control_record.h
index 9ae738d0c..b2c349656 100644
--- a/core/src/stored/device_control_record.h
+++ b/core/src/stored/device_control_record.h
@@ -72,7 +72,7 @@ class DeviceControlRecord {
JobControlRecord* jcr{}; /**< Pointer to JobControlRecord */
pthread_mutex_t mutex_ = PTHREAD_MUTEX_INITIALIZER; /**< Access control */
pthread_mutex_t r_mutex = PTHREAD_MUTEX_INITIALIZER; /**< rLock pre-mutex */
- Device* volatile dev{}; /**< Pointer to device */
+ Device* dev{}; /**< Pointer to device */
DeviceResource* device_resource{}; /**< Pointer to device resource */
DeviceBlock* block{}; /**< Pointer to current block */
DeviceRecord* rec{}; /**< Pointer to record being processed */
diff --git a/core/src/stored/device_resource.cc b/core/src/stored/device_resource.cc
index 35e1e861e..7fb59d7de 100644
--- a/core/src/stored/device_resource.cc
+++ b/core/src/stored/device_resource.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -38,7 +38,7 @@ DeviceResource::DeviceResource()
, changer_command(nullptr)
, alert_command(nullptr)
, spool_directory(nullptr)
- , dev_type(DeviceType::B_UNKNOWN_DEV)
+ , device_type(DeviceType::B_UNKNOWN_DEV)
, label_type(B_BAREOS_LABEL)
, autoselect(true)
, norewindonclose(true)
@@ -115,7 +115,7 @@ DeviceResource::DeviceResource(const DeviceResource& other)
if (other.spool_directory) {
spool_directory = strdup(other.spool_directory);
}
- dev_type = other.dev_type;
+ device_type = other.device_type;
label_type = other.label_type;
autoselect = other.autoselect;
norewindonclose = other.norewindonclose;
@@ -170,7 +170,7 @@ DeviceResource& DeviceResource::operator=(const DeviceResource& rhs)
changer_command = rhs.changer_command;
alert_command = rhs.alert_command;
spool_directory = rhs.spool_directory;
- dev_type = rhs.dev_type;
+ device_type = rhs.device_type;
label_type = rhs.label_type;
autoselect = rhs.autoselect;
norewindonclose = rhs.norewindonclose;
@@ -274,13 +274,10 @@ void DeviceResource::CreateAndAssignSerialNumber(uint16_t number)
bool DeviceResource::Validate()
{
- if (max_block_size > 0 && dev_type != DeviceType::B_TAPE_DEV) {
+ if (max_block_size > 0 && device_type != DeviceType::B_TAPE_DEV) {
my_config->AddWarning(
"Setting 'Maximum Block Size' on a non-tape device is unsupported");
}
- if (dev_type == DeviceType::B_RADOS_DEV) {
- my_config->AddWarning("The Rados Storage Backend Device is deprecated");
- }
return true;
}
diff --git a/core/src/stored/device_resource.h b/core/src/stored/device_resource.h
index 987cf2708..1a115ef0b 100644
--- a/core/src/stored/device_resource.h
+++ b/core/src/stored/device_resource.h
@@ -3,7 +3,7 @@
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -35,16 +35,16 @@ class AutochangerResource;
class DeviceResource : public BareosResource {
public:
- char* media_type; /**< User assigned media type */
- char* archive_device_string; /**< Archive device name */
- char* device_options; /**< Device specific option string */
- char* diag_device_name; /**< Diagnostic device name */
- char* changer_name; /**< Changer device name */
- char* changer_command; /**< Changer command -- external program */
- char* alert_command; /**< Alert command -- external program */
- char* spool_directory; /**< Spool file directory */
- DeviceType dev_type; /**< device type */
- uint32_t label_type; /**< label type */
+ char* media_type; /**< User assigned media type */
+ char* archive_device_string; /**< Archive device name */
+ char* device_options; /**< Device specific option string */
+ char* diag_device_name; /**< Diagnostic device name */
+ char* changer_name; /**< Changer device name */
+ char* changer_command; /**< Changer command -- external program */
+ char* alert_command; /**< Alert command -- external program */
+ char* spool_directory; /**< Spool file directory */
+ std::string device_type;
+ uint32_t label_type;
bool autoselect; /**< Automatically select from AutoChanger */
bool norewindonclose; /**< Don't rewind tape drive on close */
bool drive_tapealert_enabled; /**< Enable Tape Alert monitoring */
diff --git a/core/src/stored/dir_cmd.cc b/core/src/stored/dir_cmd.cc
index 078b21d1b..2047de07e 100644
--- a/core/src/stored/dir_cmd.cc
+++ b/core/src/stored/dir_cmd.cc
@@ -50,7 +50,7 @@
#include "stored/device_control_record.h"
#include "stored/sd_device_control_record.h"
#include "stored/fd_cmds.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/job.h"
#include "stored/label.h"
#include "stored/ndmp_tape.h"
@@ -259,7 +259,7 @@ void* HandleDirectorConnection(BareosSocket* dir)
jcr->dir_bsock->SetJcr(jcr);
// Initialize Start Job condition variable
- errstat = pthread_cond_init(&jcr->impl->job_start_wait, NULL);
+ errstat = pthread_cond_init(&jcr->sd_impl->job_start_wait, NULL);
if (errstat != 0) {
BErrNo be;
Jmsg1(jcr, M_FATAL, 0,
@@ -269,7 +269,7 @@ void* HandleDirectorConnection(BareosSocket* dir)
}
// Initialize End Job condition variable
- errstat = pthread_cond_init(&jcr->impl->job_end_wait, NULL);
+ errstat = pthread_cond_init(&jcr->sd_impl->job_end_wait, NULL);
if (errstat != 0) {
BErrNo be;
Jmsg1(jcr, M_FATAL, 0, _("Unable to init job end cond variable: ERR=%s\n"),
@@ -302,7 +302,7 @@ void* HandleDirectorConnection(BareosSocket* dir)
found = false;
for (i = 0; cmds[i].cmd; i++) {
if (bstrncmp(cmds[i].cmd, dir->msg, strlen(cmds[i].cmd))) {
- if ((!cmds[i].monitoraccess) && (jcr->impl->director->monitor)) {
+ if ((!cmds[i].monitoraccess) && (jcr->sd_impl->director->monitor)) {
Dmsg1(100, "Command \"%s\" is invalid.\n", cmds[i].cmd);
dir->fsend(invalid_cmd);
dir->signal(BNET_EOD);
@@ -517,13 +517,14 @@ static bool CancelCmd(JobControlRecord* cjcr)
}
}
- oldStatus = jcr->JobStatus;
- jcr->setJobStatus(status);
+ oldStatus = jcr->getJobStatus();
+ jcr->setJobStatusWithPriorityCheck(status);
Dmsg2(800, "Cancel JobId=%d %p\n", jcr->JobId, jcr);
if (!jcr->authenticated
&& (oldStatus == JS_WaitFD || oldStatus == JS_WaitSD)) {
- pthread_cond_signal(&jcr->impl->job_start_wait); /* wake waiting thread */
+ pthread_cond_signal(
+ &jcr->sd_impl->job_start_wait); /* wake waiting thread */
}
if (jcr->file_bsock) {
@@ -533,23 +534,23 @@ static bool CancelCmd(JobControlRecord* cjcr)
} else {
if (oldStatus != JS_WaitSD) {
// Still waiting for FD to connect, release it
- pthread_cond_signal(&jcr->impl->job_start_wait); /* wake waiting job */
+ pthread_cond_signal(&jcr->sd_impl->job_start_wait); /* wake waiting job */
Dmsg2(800, "Signal FD connect jid=%d %p\n", jcr->JobId, jcr);
}
}
// If thread waiting on mount, wake him
- if (jcr->impl->dcr && jcr->impl->dcr->dev
- && jcr->impl->dcr->dev->waiting_for_mount()) {
- pthread_cond_broadcast(&jcr->impl->dcr->dev->wait_next_vol);
+ if (jcr->sd_impl->dcr && jcr->sd_impl->dcr->dev
+ && jcr->sd_impl->dcr->dev->waiting_for_mount()) {
+ pthread_cond_broadcast(&jcr->sd_impl->dcr->dev->wait_next_vol);
Dmsg1(100, "JobId=%u broadcast wait_device_release\n",
(uint32_t)jcr->JobId);
ReleaseDeviceCond();
}
- if (jcr->impl->read_dcr && jcr->impl->read_dcr->dev
- && jcr->impl->read_dcr->dev->waiting_for_mount()) {
- pthread_cond_broadcast(&jcr->impl->read_dcr->dev->wait_next_vol);
+ if (jcr->sd_impl->read_dcr && jcr->sd_impl->read_dcr->dev
+ && jcr->sd_impl->read_dcr->dev->waiting_for_mount()) {
+ pthread_cond_broadcast(&jcr->sd_impl->read_dcr->dev->wait_next_vol);
Dmsg1(100, "JobId=%u broadcast wait_device_release\n",
(uint32_t)jcr->JobId);
ReleaseDeviceCond();
@@ -573,7 +574,7 @@ static bool CancelCmd(JobControlRecord* cjcr)
}
}
- pthread_cond_signal(&jcr->impl->job_end_wait); /* wake waiting job */
+ pthread_cond_signal(&jcr->sd_impl->job_end_wait); /* wake waiting job */
jcr->MyThreadSendSignal(TIMEOUT_SIGNAL);
dir->fsend(_("3000 JobId=%ld Job=\"%s\" marked to be %s.\n"), jcr->JobId,
@@ -1319,14 +1320,14 @@ static inline bool GetBootstrapFile(JobControlRecord* jcr, BareosSocket* sock)
}
fclose(bs);
Dmsg0(10, "=== end bootstrap file ===\n");
- jcr->impl->read_session.bsr
+ jcr->sd_impl->read_session.bsr
= libbareos::parse_bsr(jcr, jcr->RestoreBootstrap);
- if (!jcr->impl->read_session.bsr) {
+ if (!jcr->sd_impl->read_session.bsr) {
Jmsg(jcr, M_FATAL, 0, _("Error parsing bootstrap file.\n"));
goto bail_out;
}
if (debug_level >= 10) {
- libbareos::DumpBsr(jcr->impl->read_session.bsr, true);
+ libbareos::DumpBsr(jcr->sd_impl->read_session.bsr, true);
}
/* If we got a bootstrap, we are reading, so create read volume list */
CreateRestoreVolumeList(jcr);
@@ -1654,8 +1655,8 @@ static bool ReplicateCmd(JobControlRecord* jcr)
storage_daemon_socket->SetSourceAddress(me->SDsrc_addr);
if (!jcr->max_bandwidth) {
- if (jcr->impl->director->max_bandwidth_per_job) {
- jcr->max_bandwidth = jcr->impl->director->max_bandwidth_per_job;
+ if (jcr->sd_impl->director->max_bandwidth_per_job) {
+ jcr->max_bandwidth = jcr->sd_impl->director->max_bandwidth_per_job;
} else if (me->max_bandwidth_per_job) {
jcr->max_bandwidth = me->max_bandwidth_per_job;
}
@@ -1710,7 +1711,7 @@ static bool ReplicateCmd(JobControlRecord* jcr)
connect_state(ReplicateCmdState::kAuthenticated);
Dmsg0(110, "Authenticated with SD.\n");
- jcr->impl->remote_replicate = true;
+ jcr->sd_impl->remote_replicate = true;
storage_daemon_socket.release(); /* jcr->store_bsock */
return dir->fsend(OK_replicate);
@@ -1823,10 +1824,10 @@ static bool PluginoptionsCmd(JobControlRecord* jcr)
}
UnbashSpaces(plugin_options);
- if (!jcr->impl->plugin_options) {
- jcr->impl->plugin_options = new alist<const char*>(10, owned_by_alist);
+ if (!jcr->sd_impl->plugin_options) {
+ jcr->sd_impl->plugin_options = new alist<const char*>(10, owned_by_alist);
}
- jcr->impl->plugin_options->append(strdup(plugin_options));
+ jcr->sd_impl->plugin_options->append(strdup(plugin_options));
// Send OK to Director
return dir->fsend(OKpluginoptions);
diff --git a/core/src/stored/fd_cmds.cc b/core/src/stored/fd_cmds.cc
index 30e2ad4c6..f44a4bc64 100644
--- a/core/src/stored/fd_cmds.cc
+++ b/core/src/stored/fd_cmds.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -38,7 +38,7 @@
#include "stored/authenticate.h"
#include "stored/device_control_record.h"
#include "stored/fd_cmds.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/read.h"
#include "stored/sd_stats.h"
#include "lib/bnet.h"
@@ -134,7 +134,7 @@ void* HandleFiledConnection(BareosSocket* fd, char* job_name)
if (!AuthenticateFiledaemon(jcr)) {
Dmsg1(50, "Authentication failed Job %s\n", jcr->Job);
Jmsg(jcr, M_FATAL, 0, _("Unable to authenticate File daemon\n"));
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
} else {
utime_t now;
@@ -147,7 +147,7 @@ void* HandleFiledConnection(BareosSocket* fd, char* job_name)
UpdateJobStatistics(jcr, now);
}
- pthread_cond_signal(&jcr->impl->job_start_wait); /* wake waiting job */
+ pthread_cond_signal(&jcr->sd_impl->job_start_wait); /* wake waiting job */
FreeJcr(jcr);
return NULL;
@@ -177,11 +177,11 @@ void RunJob(JobControlRecord* jcr)
jcr->end_time = time(NULL);
DequeueMessages(jcr); /* send any queued messages */
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
GeneratePluginEvent(jcr, bSdEventJobEnd);
- dir->fsend(Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles,
+ dir->fsend(Job_end, jcr->Job, jcr->getJobStatus(), jcr->JobFiles,
edit_uint64(jcr->JobBytes, ec1), jcr->JobErrors);
dir->signal(BNET_EOD); /* send EOD to Director daemon */
@@ -220,7 +220,7 @@ void DoFdCommands(JobControlRecord* jcr)
} else {
Jmsg0(jcr, M_FATAL, 0, _("Command error with FD, hanging up.\n"));
}
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
quit = true;
}
@@ -250,7 +250,7 @@ static bool AppendDataCmd(JobControlRecord* jcr)
BareosSocket* fd = jcr->file_bsock;
Dmsg1(120, "Append data: %s", fd->msg);
- if (jcr->impl->session_opened) {
+ if (jcr->sd_impl->session_opened) {
Dmsg1(110, "<filed: %s", fd->msg);
jcr->setJobType(JT_BACKUP);
if (DoAppendData(jcr, fd, "FD")) {
@@ -272,7 +272,7 @@ static bool AppendEndSession(JobControlRecord* jcr)
BareosSocket* fd = jcr->file_bsock;
Dmsg1(120, "stored<filed: %s", fd->msg);
- if (!jcr->impl->session_opened) {
+ if (!jcr->sd_impl->session_opened) {
PmStrcpy(jcr->errmsg, _("Attempt to close non-open session.\n"));
fd->fsend(NOT_opened);
return false;
@@ -286,13 +286,13 @@ static bool AppendOpenSession(JobControlRecord* jcr)
BareosSocket* fd = jcr->file_bsock;
Dmsg1(120, "Append open session: %s", fd->msg);
- if (jcr->impl->session_opened) {
+ if (jcr->sd_impl->session_opened) {
PmStrcpy(jcr->errmsg, _("Attempt to open already open session.\n"));
fd->fsend(NO_open);
return false;
}
- jcr->impl->session_opened = true;
+ jcr->sd_impl->session_opened = true;
/* Send "Ticket" to File Daemon */
fd->fsend(OK_open, jcr->VolSessionId);
@@ -311,19 +311,19 @@ static bool AppendCloseSession(JobControlRecord* jcr)
BareosSocket* fd = jcr->file_bsock;
Dmsg1(120, "<filed: %s", fd->msg);
- if (!jcr->impl->session_opened) {
+ if (!jcr->sd_impl->session_opened) {
PmStrcpy(jcr->errmsg, _("Attempt to close non-open session.\n"));
fd->fsend(NOT_opened);
return false;
}
// Send final statistics to File daemon
- fd->fsend(OK_close, jcr->JobStatus);
+ fd->fsend(OK_close, jcr->getJobStatus());
Dmsg1(120, ">filed: %s", fd->msg);
fd->signal(BNET_EOD); /* send EOD to File daemon */
- jcr->impl->session_opened = false;
+ jcr->sd_impl->session_opened = false;
return true;
}
@@ -338,7 +338,7 @@ static bool ReadDataCmd(JobControlRecord* jcr)
BareosSocket* fd = jcr->file_bsock;
Dmsg1(120, "Read data: %s", fd->msg);
- if (jcr->impl->session_opened) {
+ if (jcr->sd_impl->session_opened) {
Dmsg1(120, "<filed: %s", fd->msg);
return DoReadData(jcr);
} else {
@@ -358,38 +358,38 @@ static bool ReadOpenSession(JobControlRecord* jcr)
BareosSocket* fd = jcr->file_bsock;
Dmsg1(120, "%s\n", fd->msg);
- if (jcr->impl->session_opened) {
+ if (jcr->sd_impl->session_opened) {
PmStrcpy(jcr->errmsg, _("Attempt to open read on non-open session.\n"));
fd->fsend(NO_open);
return false;
}
- if (sscanf(fd->msg, read_open, jcr->impl->read_dcr->VolumeName,
- &jcr->impl->read_session.read_VolSessionId,
- &jcr->impl->read_session.read_VolSessionTime,
- &jcr->impl->read_session.read_StartFile,
- &jcr->impl->read_session.read_EndFile,
- &jcr->impl->read_session.read_StartBlock,
- &jcr->impl->read_session.read_EndBlock)
+ if (sscanf(fd->msg, read_open, jcr->sd_impl->read_dcr->VolumeName,
+ &jcr->sd_impl->read_session.read_VolSessionId,
+ &jcr->sd_impl->read_session.read_VolSessionTime,
+ &jcr->sd_impl->read_session.read_StartFile,
+ &jcr->sd_impl->read_session.read_EndFile,
+ &jcr->sd_impl->read_session.read_StartBlock,
+ &jcr->sd_impl->read_session.read_EndBlock)
== 7) {
- if (jcr->impl->session_opened) {
+ if (jcr->sd_impl->session_opened) {
PmStrcpy(jcr->errmsg, _("Attempt to open read on non-open session.\n"));
fd->fsend(NOT_opened);
return false;
}
Dmsg4(100,
"ReadOpenSession got: JobId=%d Vol=%s VolSessId=%ld VolSessT=%ld\n",
- jcr->JobId, jcr->impl->read_dcr->VolumeName,
- jcr->impl->read_session.read_VolSessionId,
- jcr->impl->read_session.read_VolSessionTime);
+ jcr->JobId, jcr->sd_impl->read_dcr->VolumeName,
+ jcr->sd_impl->read_session.read_VolSessionId,
+ jcr->sd_impl->read_session.read_VolSessionTime);
Dmsg4(100, " StartF=%ld EndF=%ld StartB=%ld EndB=%ld\n",
- jcr->impl->read_session.read_StartFile,
- jcr->impl->read_session.read_EndFile,
- jcr->impl->read_session.read_StartBlock,
- jcr->impl->read_session.read_EndBlock);
+ jcr->sd_impl->read_session.read_StartFile,
+ jcr->sd_impl->read_session.read_EndFile,
+ jcr->sd_impl->read_session.read_StartBlock,
+ jcr->sd_impl->read_session.read_EndBlock);
}
- jcr->impl->session_opened = true;
+ jcr->sd_impl->session_opened = true;
jcr->setJobType(JT_RESTORE);
// Send "Ticket" to File Daemon
@@ -408,18 +408,18 @@ static bool ReadCloseSession(JobControlRecord* jcr)
BareosSocket* fd = jcr->file_bsock;
Dmsg1(120, "Read close session: %s\n", fd->msg);
- if (!jcr->impl->session_opened) {
+ if (!jcr->sd_impl->session_opened) {
fd->fsend(NOT_opened);
return false;
}
// Send final close msg to File daemon
- fd->fsend(OK_close, jcr->JobStatus);
+ fd->fsend(OK_close, jcr->getJobStatus());
Dmsg1(160, ">filed: %s", fd->msg);
fd->signal(BNET_EOD); /* send EOD to File daemon */
- jcr->impl->session_opened = false;
+ jcr->sd_impl->session_opened = false;
return true;
}
diff --git a/core/src/stored/job.cc b/core/src/stored/job.cc
index fd209fd79..931c3b2a6 100644
--- a/core/src/stored/job.cc
+++ b/core/src/stored/job.cc
@@ -31,7 +31,7 @@
#include "stored/bsr.h"
#include "stored/acquire.h"
#include "stored/fd_cmds.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/ndmp_tape.h"
#include "stored/read_record.h"
#include "stored/stored_globals.h"
@@ -98,7 +98,7 @@ bool job_cmd(JobControlRecord* jcr)
PmStrcpy(jcr->errmsg, dir->msg);
dir->fsend(BAD_job, status, jcr->errmsg);
Dmsg1(100, ">dird: %s", dir->msg);
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -132,27 +132,27 @@ bool job_cmd(JobControlRecord* jcr)
}
bstrncpy(jcr->Job, job, sizeof(jcr->Job));
UnbashSpaces(job_name);
- jcr->impl->job_name = GetPoolMemory(PM_NAME);
- PmStrcpy(jcr->impl->job_name, job_name);
+ jcr->sd_impl->job_name = GetPoolMemory(PM_NAME);
+ PmStrcpy(jcr->sd_impl->job_name, job_name);
UnbashSpaces(client_name);
jcr->client_name = GetPoolMemory(PM_NAME);
PmStrcpy(jcr->client_name, client_name);
UnbashSpaces(fileset_name);
- jcr->impl->fileset_name = GetPoolMemory(PM_NAME);
- PmStrcpy(jcr->impl->fileset_name, fileset_name);
+ jcr->sd_impl->fileset_name = GetPoolMemory(PM_NAME);
+ PmStrcpy(jcr->sd_impl->fileset_name, fileset_name);
jcr->setJobType(JobType);
jcr->setJobLevel(level);
- jcr->impl->no_attributes = no_attributes;
- jcr->impl->spool_attributes = spool_attributes;
- jcr->impl->spool_data = spool_data;
- jcr->impl->spool_size = str_to_int64(spool_size);
- jcr->impl->fileset_md5 = GetPoolMemory(PM_NAME);
- PmStrcpy(jcr->impl->fileset_md5, fileset_md5);
- jcr->impl->PreferMountedVols = PreferMountedVols;
- jcr->impl->RemainingQuota = quota;
+ jcr->sd_impl->no_attributes = no_attributes;
+ jcr->sd_impl->spool_attributes = spool_attributes;
+ jcr->sd_impl->spool_data = spool_data;
+ jcr->sd_impl->spool_size = str_to_int64(spool_size);
+ jcr->sd_impl->fileset_md5 = GetPoolMemory(PM_NAME);
+ PmStrcpy(jcr->sd_impl->fileset_md5, fileset_md5);
+ jcr->sd_impl->PreferMountedVols = PreferMountedVols;
+ jcr->sd_impl->RemainingQuota = quota;
UnbashSpaces(backup_format);
- jcr->impl->backup_format = GetPoolMemory(PM_NAME);
- PmStrcpy(jcr->impl->backup_format, backup_format);
+ jcr->sd_impl->backup_format = GetPoolMemory(PM_NAME);
+ PmStrcpy(jcr->sd_impl->backup_format, backup_format);
jcr->authenticated = false;
Dmsg1(50, "Quota set as %llu\n", quota);
@@ -195,8 +195,8 @@ bool DoJobRun(JobControlRecord* jcr)
*/
lock_mutex(mutex);
while (!jcr->authenticated && !JobCanceled(jcr)) {
- errstat
- = pthread_cond_timedwait(&jcr->impl->job_start_wait, &mutex, &timeout);
+ errstat = pthread_cond_timedwait(&jcr->sd_impl->job_start_wait, &mutex,
+ &timeout);
if (errstat == ETIMEDOUT || errstat == EINVAL || errstat == EPERM) {
break;
}
@@ -222,7 +222,7 @@ bool DoJobRun(JobControlRecord* jcr)
*/
Dmsg2(800, "Wait for end job jid=%d %p\n", jcr->JobId, jcr);
lock_mutex(mutex);
- pthread_cond_wait(&jcr->impl->job_end_wait, &mutex);
+ pthread_cond_wait(&jcr->sd_impl->job_end_wait, &mutex);
unlock_mutex(mutex);
}
Dmsg2(800, "Done jid=%d %p\n", jcr->JobId, jcr);
@@ -287,7 +287,7 @@ bool nextRunCmd(JobControlRecord* jcr)
lock_mutex(mutex);
while (!jcr->authenticated && !JobCanceled(jcr)) {
- errstat = pthread_cond_timedwait(&jcr->impl->job_start_wait, &mutex,
+ errstat = pthread_cond_timedwait(&jcr->sd_impl->job_start_wait, &mutex,
&timeout);
if (errstat == ETIMEDOUT || errstat == EINVAL || errstat == EPERM) {
break;
@@ -311,7 +311,7 @@ bool nextRunCmd(JobControlRecord* jcr)
*/
Dmsg2(800, "Wait for end job jid=%d %p\n", jcr->JobId, jcr);
lock_mutex(mutex);
- pthread_cond_wait(&jcr->impl->job_end_wait, &mutex);
+ pthread_cond_wait(&jcr->sd_impl->job_end_wait, &mutex);
unlock_mutex(mutex);
}
Dmsg2(800, "Done jid=%d %p\n", jcr->JobId, jcr);
@@ -346,7 +346,7 @@ bool FinishCmd(JobControlRecord* jcr)
jcr->end_time = time(NULL);
DequeueMessages(jcr); /* send any queued messages */
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
switch (jcr->getJobType()) {
case JT_BACKUP:
@@ -361,7 +361,7 @@ bool FinishCmd(JobControlRecord* jcr)
GeneratePluginEvent(jcr, bSdEventJobEnd);
- dir->fsend(Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles,
+ dir->fsend(Job_end, jcr->Job, jcr->getJobStatus(), jcr->JobFiles,
edit_uint64(jcr->JobBytes, ec1), jcr->JobErrors);
dir->signal(BNET_EOD); /* send EOD to Director daemon */
@@ -407,27 +407,27 @@ void StoredFreeJcr(JobControlRecord* jcr)
jcr->file_bsock = NULL;
}
- if (jcr->impl->job_name) { FreePoolMemory(jcr->impl->job_name); }
+ if (jcr->sd_impl->job_name) { FreePoolMemory(jcr->sd_impl->job_name); }
if (jcr->client_name) {
FreeMemory(jcr->client_name);
jcr->client_name = NULL;
}
- if (jcr->impl->fileset_name) { FreeMemory(jcr->impl->fileset_name); }
+ if (jcr->sd_impl->fileset_name) { FreeMemory(jcr->sd_impl->fileset_name); }
- if (jcr->impl->fileset_md5) { FreeMemory(jcr->impl->fileset_md5); }
+ if (jcr->sd_impl->fileset_md5) { FreeMemory(jcr->sd_impl->fileset_md5); }
- if (jcr->impl->backup_format) { FreeMemory(jcr->impl->backup_format); }
+ if (jcr->sd_impl->backup_format) { FreeMemory(jcr->sd_impl->backup_format); }
- if (jcr->impl->read_session.bsr) {
- libbareos::FreeBsr(jcr->impl->read_session.bsr);
- jcr->impl->read_session.bsr = NULL;
+ if (jcr->sd_impl->read_session.bsr) {
+ libbareos::FreeBsr(jcr->sd_impl->read_session.bsr);
+ jcr->sd_impl->read_session.bsr = NULL;
}
- if (jcr->impl->read_session.rctx) {
- FreeReadContext(jcr->impl->read_session.rctx);
- jcr->impl->read_session.rctx = NULL;
+ if (jcr->sd_impl->read_session.rctx) {
+ FreeReadContext(jcr->sd_impl->read_session.rctx);
+ jcr->sd_impl->read_session.rctx = NULL;
}
if (jcr->compress.deflate_buffer || jcr->compress.inflate_buffer) {
@@ -442,46 +442,48 @@ void StoredFreeJcr(JobControlRecord* jcr)
jcr->RestoreBootstrap = NULL;
}
- if (jcr->impl->next_dev || jcr->impl->prev_dev) {
+ if (jcr->sd_impl->next_dev || jcr->sd_impl->prev_dev) {
Emsg0(M_FATAL, 0, _("In FreeJcr(), but still attached to device!!!!\n"));
}
- pthread_cond_destroy(&jcr->impl->job_start_wait);
- pthread_cond_destroy(&jcr->impl->job_end_wait);
+ pthread_cond_destroy(&jcr->sd_impl->job_start_wait);
+ pthread_cond_destroy(&jcr->sd_impl->job_end_wait);
// Avoid a double free
- if (jcr->impl->dcr == jcr->impl->read_dcr) { jcr->impl->read_dcr = NULL; }
+ if (jcr->sd_impl->dcr == jcr->sd_impl->read_dcr) {
+ jcr->sd_impl->read_dcr = NULL;
+ }
- if (jcr->impl->dcr) {
- FreeDeviceControlRecord(jcr->impl->dcr);
- jcr->impl->dcr = NULL;
+ if (jcr->sd_impl->dcr) {
+ FreeDeviceControlRecord(jcr->sd_impl->dcr);
+ jcr->sd_impl->dcr = NULL;
}
- if (jcr->impl->read_dcr) {
- FreeDeviceControlRecord(jcr->impl->read_dcr);
- jcr->impl->read_dcr = NULL;
+ if (jcr->sd_impl->read_dcr) {
+ FreeDeviceControlRecord(jcr->sd_impl->read_dcr);
+ jcr->sd_impl->read_dcr = NULL;
}
- if (jcr->impl->plugin_options) { delete jcr->impl->plugin_options; }
+ if (jcr->sd_impl->plugin_options) { delete jcr->sd_impl->plugin_options; }
- if (jcr->impl->read_store) {
+ if (jcr->sd_impl->read_store) {
DirectorStorage* store = nullptr;
- foreach_alist (store, jcr->impl->read_store) {
+ foreach_alist (store, jcr->sd_impl->read_store) {
delete store->device;
delete store;
}
- delete jcr->impl->read_store;
- jcr->impl->read_store = NULL;
+ delete jcr->sd_impl->read_store;
+ jcr->sd_impl->read_store = NULL;
}
- if (jcr->impl->write_store) {
+ if (jcr->sd_impl->write_store) {
DirectorStorage* store = nullptr;
- foreach_alist (store, jcr->impl->write_store) {
+ foreach_alist (store, jcr->sd_impl->write_store) {
delete store->device;
delete store;
}
- delete jcr->impl->write_store;
- jcr->impl->write_store = NULL;
+ delete jcr->sd_impl->write_store;
+ jcr->sd_impl->write_store = NULL;
}
FreePlugins(jcr); /* release instantiated plugins */
@@ -492,9 +494,9 @@ void StoredFreeJcr(JobControlRecord* jcr)
GetFirstPortHostOrder(me->SDaddrs));
}
- if (jcr->impl) {
- delete jcr->impl;
- jcr->impl = nullptr;
+ if (jcr->sd_impl) {
+ delete jcr->sd_impl;
+ jcr->sd_impl = nullptr;
}
Dmsg0(200, "End stored FreeJcr\n");
@@ -505,7 +507,7 @@ void StoredFreeJcr(JobControlRecord* jcr)
JobControlRecord* NewStoredJcr()
{
JobControlRecord* jcr = new_jcr(StoredFreeJcr);
- jcr->impl = new JobControlRecordPrivate;
+ jcr->sd_impl = new StoredJcrImpl;
return jcr;
}
diff --git a/core/src/stored/label.cc b/core/src/stored/label.cc
index 1906d9cd7..141140cab 100644
--- a/core/src/stored/label.cc
+++ b/core/src/stored/label.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -32,7 +32,7 @@
#include "stored/dev.h"
#include "stored/device.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/label.h"
#include "lib/edit.h"
#include "include/jcr.h"
@@ -69,7 +69,6 @@ static void CreateVolumeLabelRecord(DeviceControlRecord* dcr,
int ReadDevVolumeLabel(DeviceControlRecord* dcr)
{
JobControlRecord* jcr = dcr->jcr;
- Device* volatile dev = dcr->dev;
char* VolName = dcr->VolumeName;
DeviceRecord* record;
bool ok = false;
@@ -81,31 +80,33 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr)
* We always write the label in an 64512 byte / 63k block.
* so we never have problems reading the volume label.
*/
- dev->SetLabelBlocksize(dcr);
+ dcr->dev->SetLabelBlocksize(dcr);
Dmsg5(100,
"Enter ReadVolumeLabel res=%d device=%s vol=%s dev_Vol=%s "
"max_blocksize=%u\n",
- dev->NumReserved(), dev->print_name(), VolName,
- dev->VolHdr.VolumeName[0] ? dev->VolHdr.VolumeName : "*NULL*",
- dev->max_block_size);
+ dcr->dev->NumReserved(), dcr->dev->print_name(), VolName,
+ dcr->dev->VolHdr.VolumeName[0] ? dcr->dev->VolHdr.VolumeName : "*NULL*",
+ dcr->dev->max_block_size);
- if (!dev->IsOpen()) {
- if (!dev->open(dcr, DeviceMode::OPEN_READ_ONLY)) { return VOL_IO_ERROR; }
+ if (!dcr->dev->IsOpen()) {
+ if (!dcr->dev->open(dcr, DeviceMode::OPEN_READ_ONLY)) {
+ return VOL_IO_ERROR;
+ }
}
- dev->ClearLabeled();
- dev->ClearAppend();
- dev->ClearRead();
- dev->label_type = B_BAREOS_LABEL;
+ dcr->dev->ClearLabeled();
+ dcr->dev->ClearAppend();
+ dcr->dev->ClearRead();
+ dcr->dev->label_type = B_BAREOS_LABEL;
- if (!dev->rewind(dcr)) {
+ if (!dcr->dev->rewind(dcr)) {
Mmsg(jcr->errmsg, _("Couldn't rewind device %s: ERR=%s\n"),
- dev->print_name(), dev->print_errmsg());
+ dcr->dev->print_name(), dcr->dev->print_errmsg());
Dmsg1(130, "return VOL_NO_MEDIA: %s", jcr->errmsg);
return VOL_NO_MEDIA;
}
- bstrncpy(dev->VolHdr.Id, "**error**", sizeof(dev->VolHdr.Id));
+ bstrncpy(dcr->dev->VolHdr.Id, "**error**", sizeof(dcr->dev->VolHdr.Id));
/*
* The stored plugin handling the bSdEventLabelRead event can abort
@@ -119,21 +120,21 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr)
// Read ANSI/IBM label if so requested
want_ansi_label = dcr->VolCatInfo.LabelType != B_BAREOS_LABEL
|| dcr->device_resource->label_type != B_BAREOS_LABEL;
- if (want_ansi_label || dev->HasCap(CAP_CHECKLABELS)) {
+ if (want_ansi_label || dcr->dev->HasCap(CAP_CHECKLABELS)) {
status = ReadAnsiIbmLabel(dcr);
// If we want a label and didn't find it, return error
if (want_ansi_label && status != VOL_OK) { goto bail_out; }
if (status == VOL_NAME_ERROR || status == VOL_LABEL_ERROR) {
Mmsg(jcr->errmsg,
_("Wrong Volume mounted on device %s: Wanted %s have %s\n"),
- dev->print_name(), VolName, dev->VolHdr.VolumeName);
- if (!dev->poll && jcr->impl->label_errors++ > 100) {
+ dcr->dev->print_name(), VolName, dcr->dev->VolHdr.VolumeName);
+ if (!dcr->dev->poll && jcr->sd_impl->label_errors++ > 100) {
Jmsg(jcr, M_FATAL, 0, _("Too many tries: %s"), jcr->errmsg);
}
goto bail_out;
}
if (status != VOL_OK) { /* Not an ANSI/IBM label, so re-read */
- dev->rewind(dcr);
+ dcr->dev->rewind(dcr);
} else {
have_ansi_label = true;
}
@@ -149,30 +150,30 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr)
Mmsg(jcr->errmsg,
_("Requested Volume \"%s\" on %s is not a Bareos "
"labeled Volume, because: ERR=%s"),
- NPRT(VolName), dev->print_name(), dev->print_errmsg());
+ NPRT(VolName), dcr->dev->print_name(), dcr->dev->print_errmsg());
Dmsg1(130, "%s", jcr->errmsg);
} else if (!ReadRecordFromBlock(dcr, record)) {
Mmsg(jcr->errmsg, _("Could not read Volume label from block.\n"));
Dmsg1(130, "%s", jcr->errmsg);
- } else if (!UnserVolumeLabel(dev, record)) {
+ } else if (!UnserVolumeLabel(dcr->dev, record)) {
Mmsg(jcr->errmsg, _("Could not UnSerialize Volume label: ERR=%s\n"),
- dev->print_errmsg());
+ dcr->dev->print_errmsg());
Dmsg1(130, "%s", jcr->errmsg);
- } else if (!bstrcmp(dev->VolHdr.Id, BareosId)
- && !bstrcmp(dev->VolHdr.Id, OldBaculaId)
- && !bstrcmp(dev->VolHdr.Id, OlderBaculaId)) {
- Mmsg(jcr->errmsg, _("Volume Header Id bad: %s\n"), dev->VolHdr.Id);
+ } else if (!bstrcmp(dcr->dev->VolHdr.Id, BareosId)
+ && !bstrcmp(dcr->dev->VolHdr.Id, OldBaculaId)
+ && !bstrcmp(dcr->dev->VolHdr.Id, OlderBaculaId)) {
+ Mmsg(jcr->errmsg, _("Volume Header Id bad: %s\n"), dcr->dev->VolHdr.Id);
Dmsg1(130, "%s", jcr->errmsg);
} else {
ok = true;
}
FreeRecord(record); /* finished reading Volume record */
- if (!dev->IsVolumeToUnload()) { dev->ClearUnload(); }
+ if (!dcr->dev->IsVolumeToUnload()) { dcr->dev->ClearUnload(); }
if (!ok) {
- if (forge_on || jcr->impl->ignore_label_errors) {
- dev->SetLabeled(); /* set has Bareos label */
+ if (forge_on || jcr->sd_impl->ignore_label_errors) {
+ dcr->dev->SetLabeled(); /* set has Bareos label */
Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
goto ok_out;
}
@@ -186,11 +187,11 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr)
* then read the Bareos Volume label. Now we need to
* make sure we have the right Volume.
*/
- if (dev->VolHdr.VerNum != BareosTapeVersion
- && dev->VolHdr.VerNum != OldCompatibleBareosTapeVersion1) {
+ if (dcr->dev->VolHdr.VerNum != BareosTapeVersion
+ && dcr->dev->VolHdr.VerNum != OldCompatibleBareosTapeVersion1) {
Mmsg(jcr->errmsg,
_("Volume on %s has wrong Bareos version. Wanted %d got %d\n"),
- dev->print_name(), BareosTapeVersion, dev->VolHdr.VerNum);
+ dcr->dev->print_name(), BareosTapeVersion, dcr->dev->VolHdr.VerNum);
Dmsg1(130, "VOL_VERSION_ERROR: %s", jcr->errmsg);
status = VOL_VERSION_ERROR;
goto bail_out;
@@ -200,12 +201,12 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr)
* We are looking for either an unused Bareos tape (PRE_LABEL) or
* a Bareos volume label (VOL_LABEL)
*/
- if (dev->VolHdr.LabelType != PRE_LABEL
- && dev->VolHdr.LabelType != VOL_LABEL) {
+ if (dcr->dev->VolHdr.LabelType != PRE_LABEL
+ && dcr->dev->VolHdr.LabelType != VOL_LABEL) {
Mmsg(jcr->errmsg, _("Volume on %s has bad Bareos label type: %x\n"),
- dev->print_name(), dev->VolHdr.LabelType);
+ dcr->dev->print_name(), dcr->dev->VolHdr.LabelType);
Dmsg1(130, "%s", jcr->errmsg);
- if (!dev->poll && jcr->impl->label_errors++ > 100) {
+ if (!dcr->dev->poll && jcr->sd_impl->label_errors++ > 100) {
Jmsg(jcr, M_FATAL, 0, _("Too many tries: %s"), jcr->errmsg);
}
Dmsg0(150, "return VOL_LABEL_ERROR\n");
@@ -213,22 +214,22 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr)
goto bail_out;
}
- dev->SetLabeled(); /* set has Bareos label */
+ dcr->dev->SetLabeled(); /* set has Bareos label */
/* Compare Volume Names */
Dmsg2(130, "Compare Vol names: VolName=%s hdr=%s\n", VolName ? VolName : "*",
- dev->VolHdr.VolumeName);
+ dcr->dev->VolHdr.VolumeName);
if (VolName && *VolName && *VolName != '*'
- && !bstrcmp(dev->VolHdr.VolumeName, VolName)) {
+ && !bstrcmp(dcr->dev->VolHdr.VolumeName, VolName)) {
Mmsg(jcr->errmsg,
_("Wrong Volume mounted on device %s: Wanted %s have %s\n"),
- dev->print_name(), VolName, dev->VolHdr.VolumeName);
+ dcr->dev->print_name(), VolName, dcr->dev->VolHdr.VolumeName);
Dmsg1(130, "%s", jcr->errmsg);
/*
* Cancel Job if too many label errors
* => we are in a loop
*/
- if (!dev->poll && jcr->impl->label_errors++ > 100) {
+ if (!dcr->dev->poll && jcr->sd_impl->label_errors++ > 100) {
Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg);
}
Dmsg0(150, "return VOL_NAME_ERROR\n");
@@ -236,12 +237,12 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr)
goto bail_out;
}
- if (debug_level >= 200) { DumpVolumeLabel(dev); }
+ if (debug_level >= 200) { DumpVolumeLabel(dcr->dev); }
Dmsg0(130, "Leave ReadVolumeLabel() VOL_OK\n");
// If we are a streaming device, we only get one chance to read
- if (!dev->HasCap(CAP_STREAM)) {
- dev->rewind(dcr);
+ if (!dcr->dev->HasCap(CAP_STREAM)) {
+ dcr->dev->rewind(dcr);
if (have_ansi_label) {
status = ReadAnsiIbmLabel(dcr);
// If we want a label and didn't find it, return error
@@ -249,12 +250,12 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr)
}
}
- Dmsg1(100, "Call reserve_volume=%s\n", dev->VolHdr.VolumeName);
- if (reserve_volume(dcr, dev->VolHdr.VolumeName) == NULL) {
+ Dmsg1(100, "Call reserve_volume=%s\n", dcr->dev->VolHdr.VolumeName);
+ if (reserve_volume(dcr, dcr->dev->VolHdr.VolumeName) == NULL) {
Mmsg2(jcr->errmsg, _("Could not reserve volume %s on %s\n"),
- dev->VolHdr.VolumeName, dev->print_name());
- Dmsg2(150, "Could not reserve volume %s on %s\n", dev->VolHdr.VolumeName,
- dev->print_name());
+ dcr->dev->VolHdr.VolumeName, dcr->dev->print_name());
+ Dmsg2(150, "Could not reserve volume %s on %s\n",
+ dcr->dev->VolHdr.VolumeName, dcr->dev->print_name());
status = VOL_NAME_ERROR;
goto bail_out;
}
@@ -279,13 +280,13 @@ ok_out:
* Reset blocksizes from volinfo to device as we set blocksize to
* DEFAULT_BLOCK_SIZE to read the label
*/
- dev->SetBlocksizes(dcr);
+ dcr->dev->SetBlocksizes(dcr);
return VOL_OK;
bail_out:
EmptyBlock(dcr->block);
- dev->rewind(dcr);
+ dcr->dev->rewind(dcr);
Dmsg1(150, "return %d\n", status);
return status;
}
@@ -519,8 +520,8 @@ static void CreateVolumeLabelRecord(DeviceControlRecord* dcr,
rec->FileIndex = dev->VolHdr.LabelType;
rec->VolSessionId = jcr->VolSessionId;
rec->VolSessionTime = jcr->VolSessionTime;
- rec->Stream = jcr->impl->NumWriteVolumes;
- rec->maskedStream = jcr->impl->NumWriteVolumes;
+ rec->Stream = jcr->sd_impl->NumWriteVolumes;
+ rec->maskedStream = jcr->sd_impl->NumWriteVolumes;
Dmsg2(150, "Created Vol label rec: FI=%s len=%d\n",
FI_to_ascii(buf, rec->FileIndex), rec->data_len);
}
@@ -602,16 +603,16 @@ static void CreateSessionLabel(DeviceControlRecord* dcr,
SerString(dcr->pool_name);
SerString(dcr->pool_type);
- SerString(jcr->impl->job_name); /* base Job name */
+ SerString(jcr->sd_impl->job_name); /* base Job name */
SerString(jcr->client_name);
/* Added in VerNum 10 */
SerString(jcr->Job); /* Unique name of this Job */
- SerString(jcr->impl->fileset_name);
+ SerString(jcr->sd_impl->fileset_name);
ser_uint32(jcr->getJobType());
ser_uint32(jcr->getJobLevel());
/* Added in VerNum 11 */
- SerString(jcr->impl->fileset_md5);
+ SerString(jcr->sd_impl->fileset_md5);
if (label == EOS_LABEL) {
ser_uint32(jcr->JobFiles);
@@ -623,7 +624,7 @@ static void CreateSessionLabel(DeviceControlRecord* dcr,
ser_uint32(jcr->JobErrors);
/* Added in VerNum 11 */
- ser_uint32(jcr->JobStatus);
+ ser_uint32(jcr->getJobStatus());
}
SerEnd(rec->data, SER_LENGTH_Session_Label);
rec->data_len = SerLength(rec->data);
diff --git a/core/src/stored/mac.cc b/core/src/stored/mac.cc
index 38b952eff..0d68bbb4f 100644
--- a/core/src/stored/mac.cc
+++ b/core/src/stored/mac.cc
@@ -35,7 +35,7 @@
#include "stored/append.h"
#include "stored/device.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/label.h"
#include "stored/mount.h"
#include "stored/read_record.h"
@@ -113,7 +113,7 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec)
bool retval = false;
bool translated_record = false;
JobControlRecord* jcr = dcr->jcr;
- Device* dev = jcr->impl->dcr->dev;
+ Device* dev = jcr->sd_impl->dcr->dev;
char buf1[100], buf2[100];
/*
@@ -139,10 +139,10 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec)
if (jcr->is_JobType(JT_MIGRATE) || jcr->is_JobType(JT_COPY)) {
bstrncpy(jcr->Job, label->Job, sizeof(jcr->Job));
- PmStrcpy(jcr->impl->job_name, label->JobName);
+ PmStrcpy(jcr->sd_impl->job_name, label->JobName);
PmStrcpy(jcr->client_name, label->ClientName);
- PmStrcpy(jcr->impl->fileset_name, label->FileSetName);
- PmStrcpy(jcr->impl->fileset_md5, label->FileSetMD5);
+ PmStrcpy(jcr->sd_impl->fileset_name, label->FileSetName);
+ PmStrcpy(jcr->sd_impl->fileset_md5, label->FileSetMD5);
}
jcr->setJobType(label->JobType);
jcr->setJobLevel(label->JobLevel);
@@ -155,10 +155,10 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec)
jcr->start_time = jcr->sched_time;
/* write the SOS Label with the existing timestamp infos */
- if (!WriteSessionLabel(jcr->impl->dcr, SOS_LABEL)) {
+ if (!WriteSessionLabel(jcr->sd_impl->dcr, SOS_LABEL)) {
Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"),
dev->bstrerror());
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
retval = false;
goto bail_out;
}
@@ -201,9 +201,10 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec)
stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);
// Perform record translations.
- jcr->impl->dcr->before_rec = rec;
- jcr->impl->dcr->after_rec = NULL;
- if (GeneratePluginEvent(jcr, bSdEventWriteRecordTranslation, jcr->impl->dcr)
+ jcr->sd_impl->dcr->before_rec = rec;
+ jcr->sd_impl->dcr->after_rec = NULL;
+ if (GeneratePluginEvent(jcr, bSdEventWriteRecordTranslation,
+ jcr->sd_impl->dcr)
!= bRC_OK) {
goto bail_out;
}
@@ -214,17 +215,17 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec)
* taken place we just point the after_rec pointer to same DeviceRecord as in
* the before_rec pointer.
*/
- if (!jcr->impl->dcr->after_rec) {
- jcr->impl->dcr->after_rec = jcr->impl->dcr->before_rec;
+ if (!jcr->sd_impl->dcr->after_rec) {
+ jcr->sd_impl->dcr->after_rec = jcr->sd_impl->dcr->before_rec;
} else {
translated_record = true;
}
- while (!WriteRecordToBlock(jcr->impl->dcr, jcr->impl->dcr->after_rec)) {
+ while (!WriteRecordToBlock(jcr->sd_impl->dcr, jcr->sd_impl->dcr->after_rec)) {
Dmsg4(200, "!WriteRecordToBlock blkpos=%u:%u len=%d rem=%d\n", dev->file,
- dev->block_num, jcr->impl->dcr->after_rec->data_len,
- jcr->impl->dcr->after_rec->remainder);
- if (!jcr->impl->dcr->WriteBlockToDevice()) {
+ dev->block_num, jcr->sd_impl->dcr->after_rec->data_len,
+ jcr->sd_impl->dcr->after_rec->remainder);
+ if (!jcr->sd_impl->dcr->WriteBlockToDevice()) {
Dmsg2(90, "Got WriteBlockToDev error on device %s. %s\n",
dev->print_name(), dev->bstrerror());
Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"),
@@ -235,36 +236,36 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec)
}
// Restore packet
- jcr->impl->dcr->after_rec->VolSessionId
- = jcr->impl->dcr->after_rec->last_VolSessionId;
- jcr->impl->dcr->after_rec->VolSessionTime
- = jcr->impl->dcr->after_rec->last_VolSessionTime;
+ jcr->sd_impl->dcr->after_rec->VolSessionId
+ = jcr->sd_impl->dcr->after_rec->last_VolSessionId;
+ jcr->sd_impl->dcr->after_rec->VolSessionTime
+ = jcr->sd_impl->dcr->after_rec->last_VolSessionTime;
- if (jcr->impl->dcr->after_rec->FileIndex < 0) {
+ if (jcr->sd_impl->dcr->after_rec->FileIndex < 0) {
retval = true; /* don't send LABELs to Dir */
goto bail_out;
}
- jcr->JobBytes
- += jcr->impl->dcr->after_rec->data_len; /* increment bytes of this job */
+ jcr->JobBytes += jcr->sd_impl->dcr->after_rec
+ ->data_len; /* increment bytes of this job */
Dmsg5(500, "wrote_record JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
- jcr->JobId, FI_to_ascii(buf1, jcr->impl->dcr->after_rec->FileIndex),
- jcr->impl->dcr->after_rec->VolSessionId,
- stream_to_ascii(buf2, jcr->impl->dcr->after_rec->Stream,
- jcr->impl->dcr->after_rec->FileIndex),
- jcr->impl->dcr->after_rec->data_len);
-
- if (IsAttribute(jcr->impl->dcr->after_rec)) {
- SendAttrsToDir(jcr, jcr->impl->dcr->after_rec);
+ jcr->JobId, FI_to_ascii(buf1, jcr->sd_impl->dcr->after_rec->FileIndex),
+ jcr->sd_impl->dcr->after_rec->VolSessionId,
+ stream_to_ascii(buf2, jcr->sd_impl->dcr->after_rec->Stream,
+ jcr->sd_impl->dcr->after_rec->FileIndex),
+ jcr->sd_impl->dcr->after_rec->data_len);
+
+ if (IsAttribute(jcr->sd_impl->dcr->after_rec)) {
+ SendAttrsToDir(jcr, jcr->sd_impl->dcr->after_rec);
}
retval = true;
bail_out:
if (translated_record) {
- FreeRecord(jcr->impl->dcr->after_rec);
- jcr->impl->dcr->after_rec = NULL;
+ FreeRecord(jcr->sd_impl->dcr->after_rec);
+ jcr->sd_impl->dcr->after_rec = NULL;
}
return retval;
@@ -393,22 +394,22 @@ static inline void CheckAutoXflation(JobControlRecord* jcr)
if (me->autoxflateonreplication) { return; }
// Check autodeflation.
- switch (jcr->impl->read_dcr->autodeflate) {
+ switch (jcr->sd_impl->read_dcr->autodeflate) {
case AutoXflateMode::IO_DIRECTION_IN:
case AutoXflateMode::IO_DIRECTION_INOUT:
Dmsg0(200, "Clearing autodeflate on read_dcr\n");
- jcr->impl->read_dcr->autodeflate = AutoXflateMode::IO_DIRECTION_NONE;
+ jcr->sd_impl->read_dcr->autodeflate = AutoXflateMode::IO_DIRECTION_NONE;
break;
default:
break;
}
- if (jcr->impl->dcr) {
- switch (jcr->impl->dcr->autodeflate) {
+ if (jcr->sd_impl->dcr) {
+ switch (jcr->sd_impl->dcr->autodeflate) {
case AutoXflateMode::IO_DIRECTION_OUT:
case AutoXflateMode::IO_DIRECTION_INOUT:
Dmsg0(200, "Clearing autodeflate on write dcr\n");
- jcr->impl->dcr->autodeflate = AutoXflateMode::IO_DIRECTION_NONE;
+ jcr->sd_impl->dcr->autodeflate = AutoXflateMode::IO_DIRECTION_NONE;
break;
default:
break;
@@ -416,22 +417,22 @@ static inline void CheckAutoXflation(JobControlRecord* jcr)
}
// Check autoinflation.
- switch (jcr->impl->read_dcr->autoinflate) {
+ switch (jcr->sd_impl->read_dcr->autoinflate) {
case AutoXflateMode::IO_DIRECTION_IN:
case AutoXflateMode::IO_DIRECTION_INOUT:
Dmsg0(200, "Clearing autoinflate on read_dcr\n");
- jcr->impl->read_dcr->autoinflate = AutoXflateMode::IO_DIRECTION_NONE;
+ jcr->sd_impl->read_dcr->autoinflate = AutoXflateMode::IO_DIRECTION_NONE;
break;
default:
break;
}
- if (jcr->impl->dcr) {
- switch (jcr->impl->dcr->autoinflate) {
+ if (jcr->sd_impl->dcr) {
+ switch (jcr->sd_impl->dcr->autoinflate) {
case AutoXflateMode::IO_DIRECTION_OUT:
case AutoXflateMode::IO_DIRECTION_INOUT:
Dmsg0(200, "Clearing autoinflate on write dcr\n");
- jcr->impl->dcr->autoinflate = AutoXflateMode::IO_DIRECTION_NONE;
+ jcr->sd_impl->dcr->autoinflate = AutoXflateMode::IO_DIRECTION_NONE;
break;
default:
break;
@@ -448,7 +449,7 @@ bool DoMacRun(JobControlRecord* jcr)
bool ok = true;
bool acquire_fail = false;
BareosSocket* dir = jcr->dir_bsock;
- Device* dev = jcr->impl->dcr->dev;
+ Device* dev = jcr->sd_impl->dcr->dev;
switch (jcr->getJobType()) {
case JT_MIGRATE:
@@ -470,7 +471,7 @@ bool DoMacRun(JobControlRecord* jcr)
Dmsg0(20, "Start read data.\n");
- if (jcr->impl->NumReadVolumes == 0) {
+ if (jcr->sd_impl->NumReadVolumes == 0) {
Jmsg(jcr, M_FATAL, 0, _("No Volume names found for %s.\n"), Type);
goto bail_out;
}
@@ -479,27 +480,29 @@ bool DoMacRun(JobControlRecord* jcr)
CheckAutoXflation(jcr);
// See if we perform both read and write or read only.
- if (jcr->impl->remote_replicate) {
+ if (jcr->sd_impl->remote_replicate) {
BareosSocket* sd;
- if (!jcr->impl->read_dcr) {
+ if (!jcr->sd_impl->read_dcr) {
Jmsg(jcr, M_FATAL, 0, _("Read device not properly initialized.\n"));
goto bail_out;
}
- Dmsg1(100, "read_dcr=%p\n", jcr->impl->read_dcr);
+ Dmsg1(100, "read_dcr=%p\n", jcr->sd_impl->read_dcr);
Dmsg3(200, "Found %d volumes names for %s. First=%s\n",
- jcr->impl->NumReadVolumes, Type, jcr->impl->VolList->VolumeName);
+ jcr->sd_impl->NumReadVolumes, Type,
+ jcr->sd_impl->VolList->VolumeName);
// Ready devices for reading.
- if (!AcquireDeviceForRead(jcr->impl->read_dcr)) {
+ if (!AcquireDeviceForRead(jcr->sd_impl->read_dcr)) {
ok = false;
acquire_fail = true;
goto bail_out;
}
Dmsg2(200, "===== After acquire pos %u:%u\n",
- jcr->impl->read_dcr->dev->file, jcr->impl->read_dcr->dev->block_num);
+ jcr->sd_impl->read_dcr->dev->file,
+ jcr->sd_impl->read_dcr->dev->block_num);
jcr->sendJobStatus(JS_Running);
@@ -518,12 +521,12 @@ bool DoMacRun(JobControlRecord* jcr)
// Expect to receive back the Ticket number.
if (BgetMsg(sd) >= 0) {
Dmsg1(110, "<stored: %s", sd->msg);
- if (sscanf(sd->msg, OK_start_replicate, &jcr->impl->Ticket) != 1) {
+ if (sscanf(sd->msg, OK_start_replicate, &jcr->sd_impl->Ticket) != 1) {
Jmsg(jcr, M_FATAL, 0, _("Bad response to start replicate: %s\n"),
sd->msg);
goto bail_out;
}
- Dmsg1(110, "Got Ticket=%d\n", jcr->impl->Ticket);
+ Dmsg1(110, "Got Ticket=%d\n", jcr->sd_impl->Ticket);
} else {
Jmsg(jcr, M_FATAL, 0,
_("Bad response from stored to start replicate command\n"));
@@ -531,7 +534,7 @@ bool DoMacRun(JobControlRecord* jcr)
}
// Let the remote SD know we are now really going to send the data.
- sd->fsend(ReplicateData, jcr->impl->Ticket);
+ sd->fsend(ReplicateData, jcr->sd_impl->Ticket);
Dmsg1(110, ">stored: %s", sd->msg);
// Expect to get response to the replicate data cmd from Storage daemon
@@ -545,7 +548,7 @@ bool DoMacRun(JobControlRecord* jcr)
UpdateJobStatistics(jcr, now);
// Read all data and send it to remote SD.
- ok = ReadRecords(jcr->impl->read_dcr, CloneRecordToRemoteSd,
+ ok = ReadRecords(jcr->sd_impl->read_dcr, CloneRecordToRemoteSd,
MountNextReadVolume);
/*
@@ -579,26 +582,27 @@ bool DoMacRun(JobControlRecord* jcr)
/* Inform Storage daemon that we are done */
sd->signal(BNET_TERMINATE);
} else {
- if (!jcr->impl->read_dcr) {
+ if (!jcr->sd_impl->read_dcr) {
Jmsg(jcr, M_FATAL, 0, _("Read device not properly initialized.\n"));
goto bail_out;
}
- Dmsg2(100, "read_dcr=%p write_dcr=%p\n", jcr->impl->read_dcr,
- jcr->impl->dcr);
+ Dmsg2(100, "read_dcr=%p write_dcr=%p\n", jcr->sd_impl->read_dcr,
+ jcr->sd_impl->dcr);
Dmsg3(200, "Found %d volumes names for %s. First=%s\n",
- jcr->impl->NumReadVolumes, Type, jcr->impl->VolList->VolumeName);
+ jcr->sd_impl->NumReadVolumes, Type,
+ jcr->sd_impl->VolList->VolumeName);
// Ready devices for reading and writing.
- if (!AcquireDeviceForAppend(jcr->impl->dcr)
- || !AcquireDeviceForRead(jcr->impl->read_dcr)) {
+ if (!AcquireDeviceForAppend(jcr->sd_impl->dcr)
+ || !AcquireDeviceForRead(jcr->sd_impl->read_dcr)) {
ok = false;
acquire_fail = true;
goto bail_out;
}
- Dmsg2(200, "===== After acquire pos %u:%u\n", jcr->impl->dcr->dev->file,
- jcr->impl->dcr->dev->block_num);
+ Dmsg2(200, "===== After acquire pos %u:%u\n", jcr->sd_impl->dcr->dev->file,
+ jcr->sd_impl->dcr->dev->block_num);
jcr->sendJobStatus(JS_Running);
@@ -606,7 +610,7 @@ bool DoMacRun(JobControlRecord* jcr)
now = (utime_t)time(NULL);
UpdateJobStatistics(jcr, now);
- if (!BeginDataSpool(jcr->impl->dcr)) {
+ if (!BeginDataSpool(jcr->sd_impl->dcr)) {
ok = false;
goto bail_out;
}
@@ -616,20 +620,20 @@ bool DoMacRun(JobControlRecord* jcr)
goto bail_out;
}
- jcr->impl->dcr->VolFirstIndex = jcr->impl->dcr->VolLastIndex = 0;
+ jcr->sd_impl->dcr->VolFirstIndex = jcr->sd_impl->dcr->VolLastIndex = 0;
jcr->run_time = time(NULL);
- SetStartVolPosition(jcr->impl->dcr);
+ SetStartVolPosition(jcr->sd_impl->dcr);
jcr->JobFiles = 0;
// Read all data and make a local clone of it.
- ok = ReadRecords(jcr->impl->read_dcr, CloneRecordInternally,
+ ok = ReadRecords(jcr->sd_impl->read_dcr, CloneRecordInternally,
MountNextReadVolume);
}
bail_out:
- if (!ok) { jcr->setJobStatus(JS_ErrorTerminated); }
+ if (!ok) { jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated); }
- if (!acquire_fail && !jcr->impl->remote_replicate && jcr->impl->dcr) {
+ if (!acquire_fail && !jcr->sd_impl->remote_replicate && jcr->sd_impl->dcr) {
/*
* Don't use time_t for job_elapsed as time_t can be 32 or 64 bits,
* and the subsequent Jmsg() editing will break
@@ -643,11 +647,11 @@ bail_out:
memorize current JobStatus and set to
JS_Terminated to write into EOS_LABEL
*/
- char currentJobStatus = jcr->JobStatus;
- jcr->setJobStatus(JS_Terminated);
+ char currentJobStatus = jcr->getJobStatus();
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
// Write End Of Session Label
- DeviceControlRecord* dcr = jcr->impl->dcr;
+ DeviceControlRecord* dcr = jcr->sd_impl->dcr;
if (!WriteSessionLabel(dcr, EOS_LABEL)) {
// Print only if ok and not cancelled to avoid spurious messages
@@ -655,14 +659,14 @@ bail_out:
Jmsg1(jcr, M_FATAL, 0, _("Error writing end session label. ERR=%s\n"),
dev->bstrerror());
}
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
ok = false;
} else {
/* restore JobStatus */
- jcr->setJobStatus(currentJobStatus);
+ jcr->setJobStatusWithPriorityCheck(currentJobStatus);
}
// Flush out final partial block of this session
- if (!jcr->impl->dcr->WriteBlockToDevice()) {
+ if (!jcr->sd_impl->dcr->WriteBlockToDevice()) {
Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"),
dev->print_name(), dev->bstrerror());
Dmsg0(100, _("Set ok=FALSE after WriteBlockToDevice.\n"));
@@ -674,10 +678,10 @@ bail_out:
if (!ok) {
- DiscardDataSpool(jcr->impl->dcr);
+ DiscardDataSpool(jcr->sd_impl->dcr);
} else {
// Note: if commit is OK, the device will remain blocked
- CommitDataSpool(jcr->impl->dcr);
+ CommitDataSpool(jcr->sd_impl->dcr);
}
job_elapsed = time(NULL) - jcr->run_time;
@@ -696,11 +700,11 @@ bail_out:
}
}
- if (!jcr->impl->remote_replicate && jcr->impl->dcr) {
- if (!ReleaseDevice(jcr->impl->dcr)) { ok = false; }
+ if (!jcr->sd_impl->remote_replicate && jcr->sd_impl->dcr) {
+ if (!ReleaseDevice(jcr->sd_impl->dcr)) { ok = false; }
}
- if (jcr->impl->read_dcr) {
- if (!ReleaseDevice(jcr->impl->read_dcr)) { ok = false; }
+ if (jcr->sd_impl->read_dcr) {
+ if (!ReleaseDevice(jcr->sd_impl->read_dcr)) { ok = false; }
}
jcr->sendJobStatus(); /* update director */
@@ -708,12 +712,12 @@ bail_out:
Dmsg0(30, "Done reading.\n");
jcr->end_time = time(NULL);
DequeueMessages(jcr); /* send any queued messages */
- if (ok) { jcr->setJobStatus(JS_Terminated); }
+ if (ok) { jcr->setJobStatusWithPriorityCheck(JS_Terminated); }
GeneratePluginEvent(jcr, bSdEventJobEnd);
- dir->fsend(Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles,
+ dir->fsend(Job_end, jcr->Job, jcr->getJobStatus(), jcr->JobFiles,
edit_uint64(jcr->JobBytes, ec1), jcr->JobErrors);
- Dmsg4(100, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles, ec1);
+ Dmsg4(100, Job_end, jcr->Job, jcr->getJobStatus(), jcr->JobFiles, ec1);
dir->signal(BNET_EOD); /* send EOD to Director daemon */
FreePlugins(jcr); /* release instantiated plugins */
diff --git a/core/src/stored/mount.cc b/core/src/stored/mount.cc
index 73d2de8b4..c2785ee82 100644
--- a/core/src/stored/mount.cc
+++ b/core/src/stored/mount.cc
@@ -31,7 +31,7 @@
#include "stored/acquire.h"
#include "stored/autochanger.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/label.h"
#include "lib/edit.h"
#include "include/jcr.h"
@@ -244,11 +244,10 @@ mount_next_vol:
while (!dev->open(dcr, mode)) {
Dmsg1(150, "OpenDevice failed: ERR=%s\n", dev->bstrerror());
- if (dev->IsFile() && dev->IsRemovable()) {
- bool ok = true;
- Dmsg0(150, "call scan_dir_for_vol\n");
- if (ok && dev->ScanDirForVolume(dcr)) {
- if (dev->open(dcr, mode)) { break; /* got a valid volume */ }
+ if (dev->IsRemovable()) {
+ Dmsg0(150, "call ScanForVolume\n");
+ if (dev->ScanForVolume(dcr) && dev->open(dcr, mode)) {
+ break; /* got a valid volume */
}
}
if (TryAutolabel(false) == try_read_vol) {
@@ -654,85 +653,78 @@ void DeviceControlRecord::DoSwapping(bool)
*/
bool DeviceControlRecord::is_eod_valid()
{
- DeviceControlRecord* dcr = this;
-
- if (dev->IsTape()) {
- /*
- * Check if we are positioned on the tape at the same place
- * that the database says we should be.
- */
- if (dev->VolCatInfo.VolCatFiles == dev->GetFile()) {
- Jmsg(jcr, M_INFO, 0,
- _("Ready to append to end of Volume \"%s\" at file=%d.\n"),
- VolumeName, dev->GetFile());
- } else if (dev->GetFile() > dev->VolCatInfo.VolCatFiles) {
- Jmsg(jcr, M_WARNING, 0,
- _("For Volume \"%s\":\n"
- "The number of files mismatch! Volume=%u Catalog=%u\n"
- "Correcting Catalog\n"),
- VolumeName, dev->GetFile(), dev->VolCatInfo.VolCatFiles);
- dev->VolCatInfo.VolCatFiles = dev->GetFile();
- dev->VolCatInfo.VolCatBlocks = dev->GetBlockNum();
- if (!dcr->DirUpdateVolumeInfo(false, true)) {
- Jmsg(jcr, M_WARNING, 0, _("Error updating Catalog\n"));
+ switch (dev->GetSeekMode()) {
+ case SeekMode::FILE_BLOCK: {
+ /*
+ * Check if we are positioned on the tape at the same place
+ * that the database says we should be.
+ */
+ if (dev->VolCatInfo.VolCatFiles == dev->GetFile()) {
+ Jmsg(jcr, M_INFO, 0,
+ _("Ready to append to end of Volume \"%s\" at file=%d.\n"),
+ VolumeName, dev->GetFile());
+ } else if (dev->GetFile() > dev->VolCatInfo.VolCatFiles) {
+ Jmsg(jcr, M_WARNING, 0,
+ _("For Volume \"%s\":\n"
+ "The number of files mismatch! Volume=%u Catalog=%u\n"
+ "Correcting Catalog\n"),
+ VolumeName, dev->GetFile(), dev->VolCatInfo.VolCatFiles);
+ dev->VolCatInfo.VolCatFiles = dev->GetFile();
+ dev->VolCatInfo.VolCatBlocks = dev->GetBlockNum();
+ if (!DirUpdateVolumeInfo(false, true)) {
+ Jmsg(jcr, M_WARNING, 0, _("Error updating Catalog\n"));
+ MarkVolumeInError();
+ return false;
+ }
+ } else {
+ Jmsg(jcr, M_ERROR, 0,
+ _("Bareos cannot write on tape Volume \"%s\" because:\n"
+ "The number of files mismatch! Volume=%u Catalog=%u\n"),
+ VolumeName, dev->GetFile(), dev->VolCatInfo.VolCatFiles);
MarkVolumeInError();
return false;
}
- } else {
- Jmsg(jcr, M_ERROR, 0,
- _("Bareos cannot write on tape Volume \"%s\" because:\n"
- "The number of files mismatch! Volume=%u Catalog=%u\n"),
- VolumeName, dev->GetFile(), dev->VolCatInfo.VolCatFiles);
- MarkVolumeInError();
- return false;
- }
- } else if (dev->IsFile()) {
- char ed1[50], ed2[50];
-
- boffset_t pos;
- pos = dev->d_lseek(dcr, (boffset_t)0, SEEK_CUR);
- if (dev->VolCatInfo.VolCatBytes == (uint64_t)pos) {
- Jmsg(jcr, M_INFO, 0,
- _("Ready to append to end of Volume \"%s\""
- " size=%s\n"),
- VolumeName, edit_uint64(dev->VolCatInfo.VolCatBytes, ed1));
- } else if ((uint64_t)pos > dev->VolCatInfo.VolCatBytes) {
- Jmsg(jcr, M_WARNING, 0,
- _("For Volume \"%s\":\n"
- "The sizes do not match! Volume=%s Catalog=%s\n"
- "Correcting Catalog\n"),
- VolumeName, edit_uint64(pos, ed1),
- edit_uint64(dev->VolCatInfo.VolCatBytes, ed2));
- dev->VolCatInfo.VolCatBytes = (uint64_t)pos;
- dev->VolCatInfo.VolCatFiles = (uint32_t)(pos >> 32);
- if (!dcr->DirUpdateVolumeInfo(false, true)) {
- Jmsg(jcr, M_WARNING, 0, _("Error updating Catalog\n"));
+ } break;
+ case SeekMode::BYTES: {
+ char ed1[50], ed2[50];
+
+ boffset_t pos;
+ pos = dev->d_lseek(this, (boffset_t)0, SEEK_CUR);
+ if (dev->VolCatInfo.VolCatBytes == (uint64_t)pos) {
+ Jmsg(jcr, M_INFO, 0,
+ _("Ready to append to end of Volume \"%s\""
+ " size=%s\n"),
+ VolumeName, edit_uint64(dev->VolCatInfo.VolCatBytes, ed1));
+ } else if ((uint64_t)pos > dev->VolCatInfo.VolCatBytes) {
+ Jmsg(jcr, M_WARNING, 0,
+ _("For Volume \"%s\":\n"
+ "The sizes do not match! Volume=%s Catalog=%s\n"
+ "Correcting Catalog\n"),
+ VolumeName, edit_uint64(pos, ed1),
+ edit_uint64(dev->VolCatInfo.VolCatBytes, ed2));
+ dev->VolCatInfo.VolCatBytes = (uint64_t)pos;
+ dev->VolCatInfo.VolCatFiles = (uint32_t)(pos >> 32);
+ if (!DirUpdateVolumeInfo(false, true)) {
+ Jmsg(jcr, M_WARNING, 0, _("Error updating Catalog\n"));
+ MarkVolumeInError();
+ return false;
+ }
+ } else {
+ Mmsg(jcr->errmsg,
+ _("Bareos cannot write on disk Volume \"%s\" because: "
+ "The sizes do not match! Volume=%s Catalog=%s\n"),
+ VolumeName, edit_uint64(pos, ed1),
+ edit_uint64(dev->VolCatInfo.VolCatBytes, ed2));
+ Jmsg(jcr, M_ERROR, 0, jcr->errmsg);
+ Dmsg0(050, jcr->errmsg);
MarkVolumeInError();
return false;
}
- } else {
- Mmsg(jcr->errmsg,
- _("Bareos cannot write on disk Volume \"%s\" because: "
- "The sizes do not match! Volume=%s Catalog=%s\n"),
- VolumeName, edit_uint64(pos, ed1),
- edit_uint64(dev->VolCatInfo.VolCatBytes, ed2));
- Jmsg(jcr, M_ERROR, 0, jcr->errmsg);
- Dmsg0(050, jcr->errmsg);
- MarkVolumeInError();
- return false;
- }
- } else if (dev->IsFifo() || dev->IsVtl()) {
- return true;
- } else {
- Mmsg1(
- jcr->errmsg,
- _("Don't know how to check if EOD is valid for a device of type %d\n"),
- dev->dev_type);
- Jmsg(jcr, M_ERROR, 0, jcr->errmsg);
- Dmsg0(050, jcr->errmsg);
- return false;
+ } break;
+ case SeekMode::NOSEEK: {
+ return true;
+ } break;
}
-
return true;
}
@@ -919,13 +911,13 @@ bool MountNextReadVolume(DeviceControlRecord* dcr)
{
Device* dev = dcr->dev;
JobControlRecord* jcr = dcr->jcr;
- Dmsg2(90, "NumReadVolumes=%d CurReadVolume=%d\n", jcr->impl->NumReadVolumes,
- jcr->impl->CurReadVolume);
+ Dmsg2(90, "NumReadVolumes=%d CurReadVolume=%d\n",
+ jcr->sd_impl->NumReadVolumes, jcr->sd_impl->CurReadVolume);
VolumeUnused(dcr); /* release current volume */
// End Of Tape -- mount next Volume (if another specified)
- if (jcr->impl->NumReadVolumes > 1
- && jcr->impl->CurReadVolume < jcr->impl->NumReadVolumes) {
+ if (jcr->sd_impl->NumReadVolumes > 1
+ && jcr->sd_impl->CurReadVolume < jcr->sd_impl->NumReadVolumes) {
dev->Lock();
dev->close(dcr);
dev->SetRead();
diff --git a/core/src/stored/ndmp_tape.cc b/core/src/stored/ndmp_tape.cc
index 5e0f15447..b08f1a2a6 100644
--- a/core/src/stored/ndmp_tape.cc
+++ b/core/src/stored/ndmp_tape.cc
@@ -45,7 +45,7 @@
# include "stored/bsr.h"
# include "stored/device.h"
# include "stored/device_control_record.h"
-# include "stored/jcr_private.h"
+# include "stored/stored_jcr_impl.h"
# include "stored/label.h"
# include "stored/mount.h"
# include "stored/read_record.h"
@@ -293,7 +293,7 @@ static inline bool bndmp_write_data_to_block(JobControlRecord* jcr,
uint32_t data_length)
{
bool retval = false;
- DeviceControlRecord* dcr = jcr->impl->dcr;
+ DeviceControlRecord* dcr = jcr->sd_impl->dcr;
POOLMEM* rec_data;
if (!dcr) {
@@ -341,8 +341,8 @@ static inline bool bndmp_read_data_from_block(JobControlRecord* jcr,
uint32_t wanted_data_length,
uint32_t* data_length)
{
- DeviceControlRecord* dcr = jcr->impl->read_dcr;
- READ_CTX* rctx = jcr->impl->read_session.rctx;
+ DeviceControlRecord* dcr = jcr->sd_impl->read_dcr;
+ READ_CTX* rctx = jcr->sd_impl->read_session.rctx;
bool done = false;
bool ok = true;
@@ -446,7 +446,7 @@ static inline bool bndmp_read_data_from_block(JobControlRecord* jcr,
// Generate virtual file attributes for the whole NDMP stream.
static inline bool BndmpCreateVirtualFile(JobControlRecord* jcr, char* filename)
{
- DeviceControlRecord* dcr = jcr->impl->dcr;
+ DeviceControlRecord* dcr = jcr->sd_impl->dcr;
struct stat statp;
time_t now = time(NULL);
PoolMem attribs(PM_NAME), data(PM_NAME);
@@ -544,7 +544,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess,
/* There is a native storage daemon session waiting for the FD to connect.
* In NDMP terms this is the same as a FD connecting so wake any waiting
* threads. */
- pthread_cond_signal(&jcr->impl->job_start_wait);
+ pthread_cond_signal(&jcr->sd_impl->job_start_wait);
/* Save the JobControlRecord to ndm_session binding so everything furher
* knows which JobControlRecord belongs to which NDMP session. We have
@@ -568,9 +568,9 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess,
// Depending on the open mode select the right DeviceControlRecord.
if (will_write) {
- dcr = jcr->impl->dcr;
+ dcr = jcr->sd_impl->dcr;
} else {
- dcr = jcr->impl->read_dcr;
+ dcr = jcr->sd_impl->read_dcr;
}
if (!dcr) {
@@ -592,7 +592,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess,
/* One NDMP backup Job can be one or more save sessions so we keep
* track if we already acquired the storage. */
- if (!jcr->impl->acquired_storage) {
+ if (!jcr->sd_impl->acquired_storage) {
// Actually acquire the device which we reserved.
if (!AcquireDeviceForAppend(dcr)) { goto bail_out; }
@@ -603,7 +603,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess,
}
// Keep track that we acquired the storage.
- jcr->impl->acquired_storage = true;
+ jcr->sd_impl->acquired_storage = true;
Dmsg1(50, "Begin append device=%s\n", dcr->dev->print_name());
@@ -648,16 +648,16 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess,
READ_CTX* rctx;
// Setup internal system for reading data (if not done before).
- if (!jcr->impl->acquired_storage) {
+ if (!jcr->sd_impl->acquired_storage) {
Dmsg0(20, "Start read data.\n");
- if (jcr->impl->NumReadVolumes == 0) {
+ if (jcr->sd_impl->NumReadVolumes == 0) {
Jmsg(jcr, M_FATAL, 0, _("No Volume names found for restore.\n"));
goto bail_out;
}
Dmsg2(200, "Found %d volumes names to restore. First=%s\n",
- jcr->impl->NumReadVolumes, jcr->impl->VolList->VolumeName);
+ jcr->sd_impl->NumReadVolumes, jcr->sd_impl->VolList->VolumeName);
// Ready device for reading
if (!AcquireDeviceForRead(dcr)) { goto bail_out; }
@@ -669,7 +669,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess,
}
// Keep track that we acquired the storage.
- jcr->impl->acquired_storage = true;
+ jcr->sd_impl->acquired_storage = true;
// Change the Job to running state.
jcr->sendJobStatus(JS_Running);
@@ -677,11 +677,11 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess,
Dmsg1(50, "Begin reading device=%s\n", dcr->dev->print_name());
PositionDeviceToFirstFile(jcr, dcr);
- jcr->impl->read_session.mount_next_volume = false;
+ jcr->sd_impl->read_session.mount_next_volume = false;
// Allocate a new read context for this Job.
rctx = new_read_context();
- jcr->impl->read_session.rctx = rctx;
+ jcr->sd_impl->read_session.rctx = rctx;
// Read the first block and setup record processing.
if (!ReadNextBlockFromDevice(dcr, &rctx->sessrec, NULL,
@@ -716,7 +716,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess,
return NDMP9_NO_ERR;
bail_out:
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return NDMP9_NO_DEVICE_ERR;
}
@@ -751,7 +751,8 @@ extern "C" ndmp9_error BndmpTapeClose(struct ndm_session* sess)
}
}
- pthread_cond_signal(&jcr->impl->job_end_wait); /* wake any waiting thread */
+ pthread_cond_signal(
+ &jcr->sd_impl->job_end_wait); /* wake any waiting thread */
ndmos_tape_initialize(sess);
@@ -832,7 +833,7 @@ extern "C" ndmp9_error bndmp_tape_write(struct ndm_session* sess,
*done_count = count;
err = NDMP9_NO_ERR;
} else {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
err = NDMP9_IO_ERR;
}
@@ -886,7 +887,7 @@ extern "C" ndmp9_error bndmp_tape_read(struct ndm_session* sess,
err = NDMP9_NO_ERR;
}
} else {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
err = NDMP9_IO_ERR;
}
@@ -921,7 +922,7 @@ static inline void UnregisterCallbackHooks(struct ndm_session* sess)
void EndOfNdmpBackup(JobControlRecord* jcr)
{
- DeviceControlRecord* dcr = jcr->impl->dcr;
+ DeviceControlRecord* dcr = jcr->sd_impl->dcr;
char ec[50];
/* Don't use time_t for job_elapsed as time_t can be 32 or 64 bits,
@@ -939,7 +940,7 @@ void EndOfNdmpBackup(JobControlRecord* jcr)
/* Check if we can still write. This may not be the case
* if we are at the end of the tape or we got a fatal I/O error. */
if (dcr->dev && dcr->dev->CanWrite()) {
- Dmsg1(200, "Write EOS label JobStatus=%c\n", jcr->JobStatus);
+ Dmsg1(200, "Write EOS label JobStatus=%c\n", jcr->getJobStatus());
if (!WriteSessionLabel(dcr, EOS_LABEL)) {
/* Print only if JobStatus JS_Terminated and not cancelled to avoid
@@ -948,7 +949,7 @@ void EndOfNdmpBackup(JobControlRecord* jcr)
Jmsg1(jcr, M_FATAL, 0, _("Error writing end session label. ERR=%s\n"),
dcr->dev->bstrerror());
}
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
Dmsg0(90, "back from write_end_session_label()\n");
@@ -961,7 +962,7 @@ void EndOfNdmpBackup(JobControlRecord* jcr)
Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"),
dcr->dev->print_name(), dcr->dev->bstrerror());
}
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
}
@@ -973,9 +974,9 @@ void EndOfNdmpBackup(JobControlRecord* jcr)
}
// Release the device -- and send final Vol info to DIR and unlock it.
- if (jcr->impl->acquired_storage) {
+ if (jcr->sd_impl->acquired_storage) {
ReleaseDevice(dcr);
- jcr->impl->acquired_storage = false;
+ jcr->sd_impl->acquired_storage = false;
} else {
dcr->UnreserveDevice();
}
@@ -986,16 +987,16 @@ void EndOfNdmpBackup(JobControlRecord* jcr)
void EndOfNdmpRestore(JobControlRecord* jcr)
{
- if (jcr->impl->read_session.rctx) {
- FreeReadContext(jcr->impl->read_session.rctx);
- jcr->impl->read_session.rctx = NULL;
+ if (jcr->sd_impl->read_session.rctx) {
+ FreeReadContext(jcr->sd_impl->read_session.rctx);
+ jcr->sd_impl->read_session.rctx = NULL;
}
- if (jcr->impl->acquired_storage) {
- ReleaseDevice(jcr->impl->read_dcr);
- jcr->impl->acquired_storage = false;
+ if (jcr->sd_impl->acquired_storage) {
+ ReleaseDevice(jcr->sd_impl->read_dcr);
+ jcr->sd_impl->acquired_storage = false;
} else {
- jcr->impl->read_dcr->UnreserveDevice();
+ jcr->sd_impl->read_dcr->UnreserveDevice();
}
}
diff --git a/core/src/stored/read.cc b/core/src/stored/read.cc
index 3470ecac7..de0688d78 100644
--- a/core/src/stored/read.cc
+++ b/core/src/stored/read.cc
@@ -3,7 +3,7 @@
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2020 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -31,7 +31,7 @@
#include "stored/acquire.h"
#include "stored/bsr.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/mount.h"
#include "stored/read_record.h"
#include "lib/bnet.h"
@@ -57,7 +57,7 @@ static char rec_header[] = "rechdr %ld %ld %ld %ld %ld";
bool DoReadData(JobControlRecord* jcr)
{
BareosSocket* fd = jcr->file_bsock;
- DeviceControlRecord* dcr = jcr->impl->read_dcr;
+ DeviceControlRecord* dcr = jcr->sd_impl->read_dcr;
bool ok = true;
Dmsg0(20, "Start read data.\n");
@@ -67,14 +67,14 @@ bool DoReadData(JobControlRecord* jcr)
return false;
}
- if (jcr->impl->NumReadVolumes == 0) {
+ if (jcr->sd_impl->NumReadVolumes == 0) {
Jmsg(jcr, M_FATAL, 0, _("No Volume names found for restore.\n"));
fd->fsend(FD_error);
return false;
}
Dmsg2(200, "Found %d volumes names to restore. First=%s\n",
- jcr->impl->NumReadVolumes, jcr->impl->VolList->VolumeName);
+ jcr->sd_impl->NumReadVolumes, jcr->sd_impl->VolList->VolumeName);
// Ready device for reading
if (!AcquireDeviceForRead(dcr)) {
@@ -84,7 +84,7 @@ bool DoReadData(JobControlRecord* jcr)
// Let any SD plugin know now its time to setup the record translation infra.
if (GeneratePluginEvent(jcr, bSdEventSetupRecordTranslation, dcr) != bRC_OK) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
@@ -96,7 +96,7 @@ bool DoReadData(JobControlRecord* jcr)
// Send end of data to FD
fd->signal(BNET_EOD);
- if (!ReleaseDevice(jcr->impl->read_dcr)) { ok = false; }
+ if (!ReleaseDevice(jcr->sd_impl->read_dcr)) { ok = false; }
Dmsg0(30, "Done reading.\n");
return ok;
diff --git a/core/src/stored/read_record.cc b/core/src/stored/read_record.cc
index 84f0ceebb..97bc59e3c 100644
--- a/core/src/stored/read_record.cc
+++ b/core/src/stored/read_record.cc
@@ -38,7 +38,7 @@
#include "stored/butil.h"
#include "stored/device.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/label.h"
#include "stored/match_bsr.h"
#include "stored/read_ctx.h"
@@ -216,15 +216,15 @@ bool ReadNextBlockFromDevice(DeviceControlRecord* dcr,
trec->FileIndex = EOT_LABEL;
trec->File = dcr->dev->file;
*status = RecordCb(dcr, trec);
- if (jcr->impl->read_session.mount_next_volume) {
- jcr->impl->read_session.mount_next_volume = false;
+ if (jcr->sd_impl->read_session.mount_next_volume) {
+ jcr->sd_impl->read_session.mount_next_volume = false;
dcr->dev->ClearEot();
}
FreeRecord(trec);
}
return false;
}
- jcr->impl->read_session.mount_next_volume = false;
+ jcr->sd_impl->read_session.mount_next_volume = false;
/*
* We just have a new tape up, now read the label (first record)
@@ -253,7 +253,7 @@ bool ReadNextBlockFromDevice(DeviceControlRecord* dcr,
} else {
// I/O error or strange end of tape
DisplayTapeErrorStatus(jcr, dcr->dev);
- if (forge_on || jcr->impl->ignore_label_errors) {
+ if (forge_on || jcr->sd_impl->ignore_label_errors) {
dcr->dev->fsr(1); /* try skipping bad record */
Pmsg0(000, _("Did fsr in attemp to skip bad record.\n"));
continue;
@@ -317,10 +317,10 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr,
// Some sort of label?
if (rec->FileIndex < 0) {
HandleSessionRecord(dcr->dev, rec, &rctx->sessrec);
- if (jcr->impl->read_session.bsr) {
+ if (jcr->sd_impl->read_session.bsr) {
// We just check block FI and FT not FileIndex
rec->match_stat
- = MatchBsrBlock(jcr->impl->read_session.bsr, dcr->block);
+ = MatchBsrBlock(jcr->sd_impl->read_session.bsr, dcr->block);
} else {
rec->match_stat = 0;
}
@@ -329,9 +329,9 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr,
}
// Apply BootStrapRecord filter
- if (jcr->impl->read_session.bsr) {
- rec->match_stat = MatchBsr(jcr->impl->read_session.bsr, rec, &dev->VolHdr,
- &rctx->sessrec, jcr);
+ if (jcr->sd_impl->read_session.bsr) {
+ rec->match_stat = MatchBsr(jcr->sd_impl->read_session.bsr, rec,
+ &dev->VolHdr, &rctx->sessrec, jcr);
if (rec->match_stat == -1) { /* no more possible matches */
*done = true; /* all items found, stop */
Dmsg2(debuglevel, "All done=(file:block) %u:%u\n", dev->file,
@@ -362,7 +362,7 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr,
if (rctx->lastFileIndex != READ_NO_FILEINDEX
&& rctx->lastFileIndex != rec->FileIndex) {
- if (IsThisBsrDone(jcr->impl->read_session.bsr, rec)
+ if (IsThisBsrDone(jcr->sd_impl->read_session.bsr, rec)
&& TryDeviceRepositioning(jcr, rec, dcr)) {
Dmsg2(debuglevel, "This bsr done, break pos %u:%u\n", dev->file,
dev->block_num);
@@ -397,7 +397,7 @@ bool ReadRecords(DeviceControlRecord* dcr,
rctx = new_read_context();
PositionDeviceToFirstFile(jcr, dcr);
- jcr->impl->read_session.mount_next_volume = false;
+ jcr->sd_impl->read_session.mount_next_volume = false;
while (ok && !done) {
if (JobCanceled(jcr)) {
diff --git a/core/src/stored/record.cc b/core/src/stored/record.cc
index ed23db09b..ca5bcb034 100644
--- a/core/src/stored/record.cc
+++ b/core/src/stored/record.cc
@@ -29,7 +29,7 @@
*/
#include "include/bareos.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/stored.h"
#include "stored/device_control_record.h"
#include "lib/attribs.h"
@@ -670,7 +670,8 @@ bool DeviceControlRecord::WriteRecord()
}
jcr->JobBytes += after_rec->data_len; /* increment bytes this job */
- if (jcr->impl->RemainingQuota && jcr->JobBytes > jcr->impl->RemainingQuota) {
+ if (jcr->sd_impl->RemainingQuota
+ && jcr->JobBytes > jcr->sd_impl->RemainingQuota) {
Jmsg0(jcr, M_FATAL, 0, _("Quota Exceeded. Job Terminated.\n"));
goto bail_out;
}
diff --git a/core/src/stored/reserve.cc b/core/src/stored/reserve.cc
index edf0867f9..aee7c366a 100644
--- a/core/src/stored/reserve.cc
+++ b/core/src/stored/reserve.cc
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
- Copyright (C) 2016-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -35,7 +35,7 @@
#include "stored/sd_device_control_record.h"
#include "stored/acquire.h"
#include "stored/autochanger.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/wait.h"
#include "lib/berrno.h"
#include "lib/util.h"
@@ -80,7 +80,7 @@ bool use_cmd(JobControlRecord* jcr)
{
// Get the device, media, and pool information
if (!UseDeviceCmd(jcr)) {
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key));
return false;
}
@@ -201,7 +201,7 @@ static bool UseDeviceCmd(JobControlRecord* jcr)
* If there are multiple devices, the director sends us
* use_device for each device that it wants to use.
*/
- jcr->impl->reserve_msgs = new alist<const char*>(10, not_owned_by_alist);
+ jcr->sd_impl->reserve_msgs = new alist<const char*>(10, not_owned_by_alist);
do {
Dmsg1(debuglevel, "<dird: %s", dir->msg);
ok = sscanf(dir->msg, use_storage, StoreName.c_str(), media_type.c_str(),
@@ -211,9 +211,9 @@ static bool UseDeviceCmd(JobControlRecord* jcr)
alist<DirectorStorage*>* dirstore
= new alist<DirectorStorage*>(10, not_owned_by_alist);
if (append) {
- jcr->impl->write_store = dirstore;
+ jcr->sd_impl->write_store = dirstore;
} else {
- jcr->impl->read_store = dirstore;
+ jcr->sd_impl->read_store = dirstore;
}
rctx.append = append;
UnbashSpaces(StoreName);
@@ -241,11 +241,11 @@ static bool UseDeviceCmd(JobControlRecord* jcr)
} while (ok && dir->recv() >= 0);
InitJcrDeviceWaitTimers(jcr);
- jcr->impl->dcr = new StorageDaemonDeviceControlRecord;
- SetupNewDcrDevice(jcr, jcr->impl->dcr, NULL, NULL);
- if (rctx.append) { jcr->impl->dcr->SetWillWrite(); }
+ jcr->sd_impl->dcr = new StorageDaemonDeviceControlRecord;
+ SetupNewDcrDevice(jcr, jcr->sd_impl->dcr, NULL, NULL);
+ if (rctx.append) { jcr->sd_impl->dcr->SetWillWrite(); }
- if (!jcr->impl->dcr) {
+ if (!jcr->sd_impl->dcr) {
BareosSocket* dir = jcr->dir_bsock;
dir->fsend(_("3939 Could not get dcr\n"));
Dmsg1(debuglevel, ">dird: %s", dir->msg);
@@ -270,9 +270,9 @@ static bool UseDeviceCmd(JobControlRecord* jcr)
// Put new dcr in proper location
if (rctx.append) {
- rctx.jcr->impl->dcr = jcr->impl->dcr;
+ rctx.jcr->sd_impl->dcr = jcr->sd_impl->dcr;
} else {
- rctx.jcr->impl->read_dcr = jcr->impl->dcr;
+ rctx.jcr->sd_impl->read_dcr = jcr->sd_impl->dcr;
}
LockReservations();
@@ -282,7 +282,7 @@ static bool UseDeviceCmd(JobControlRecord* jcr)
rctx.have_volume = false;
rctx.VolumeName[0] = 0;
rctx.any_drive = false;
- if (!jcr->impl->PreferMountedVols) {
+ if (!jcr->sd_impl->PreferMountedVols) {
/*
* Here we try to find a drive that is not used.
* This will maximize the use of available drives.
@@ -405,14 +405,14 @@ bool FindSuitableDeviceForJob(JobControlRecord* jcr, ReserveContext& rctx)
{
bool ok = false;
DirectorStorage* store = nullptr;
- char* device_name = nullptr;
+ const char* device_name = nullptr;
alist<DirectorStorage*>* dirstore;
- DeviceControlRecord* dcr = jcr->impl->dcr;
+ DeviceControlRecord* dcr = jcr->sd_impl->dcr;
if (rctx.append) {
- dirstore = jcr->impl->write_store;
+ dirstore = jcr->sd_impl->write_store;
} else {
- dirstore = jcr->impl->read_store;
+ dirstore = jcr->sd_impl->read_store;
}
Dmsg5(debuglevel,
"Start find_suit_dev PrefMnt=%d exact=%d suitable=%d chgronly=%d "
@@ -565,11 +565,11 @@ int SearchResForDevice(ReserveContext& rctx)
if (rctx.store->append == SD_APPEND) {
Dmsg2(debuglevel, "Device %s reserved=%d for append.\n",
rctx.device_resource->resource_name_,
- rctx.jcr->impl->dcr->dev->NumReserved());
+ rctx.jcr->sd_impl->dcr->dev->NumReserved());
} else {
Dmsg2(debuglevel, "Device %s reserved=%d for read.\n",
rctx.device_resource->resource_name_,
- rctx.jcr->impl->read_dcr->dev->NumReserved());
+ rctx.jcr->sd_impl->read_dcr->dev->NumReserved());
}
return status;
}
@@ -592,11 +592,11 @@ int SearchResForDevice(ReserveContext& rctx)
if (rctx.store->append == SD_APPEND) {
Dmsg2(debuglevel, "Device %s reserved=%d for append.\n",
rctx.device_resource->resource_name_,
- rctx.jcr->impl->dcr->dev->NumReserved());
+ rctx.jcr->sd_impl->dcr->dev->NumReserved());
} else {
Dmsg2(debuglevel, "Device %s reserved=%d for read.\n",
rctx.device_resource->resource_name_,
- rctx.jcr->impl->read_dcr->dev->NumReserved());
+ rctx.jcr->sd_impl->read_dcr->dev->NumReserved());
}
return status;
}
@@ -624,11 +624,11 @@ int SearchResForDevice(ReserveContext& rctx)
if (rctx.store->append == SD_APPEND) {
Dmsg2(debuglevel, "Device %s reserved=%d for append.\n",
rctx.device_resource->resource_name_,
- rctx.jcr->impl->dcr->dev->NumReserved());
+ rctx.jcr->sd_impl->dcr->dev->NumReserved());
} else {
Dmsg2(debuglevel, "Device %s reserved=%d for read.\n",
rctx.device_resource->resource_name_,
- rctx.jcr->impl->read_dcr->dev->NumReserved());
+ rctx.jcr->sd_impl->read_dcr->dev->NumReserved());
}
return status;
}
@@ -685,13 +685,13 @@ static int ReserveDevice(ReserveContext& rctx)
Dmsg1(debuglevel, "try reserve %s\n", rctx.device_resource->resource_name_);
if (rctx.store->append) {
- SetupNewDcrDevice(rctx.jcr, rctx.jcr->impl->dcr, rctx.device_resource->dev,
- NULL);
- dcr = rctx.jcr->impl->dcr;
+ SetupNewDcrDevice(rctx.jcr, rctx.jcr->sd_impl->dcr,
+ rctx.device_resource->dev, NULL);
+ dcr = rctx.jcr->sd_impl->dcr;
} else {
- SetupNewDcrDevice(rctx.jcr, rctx.jcr->impl->read_dcr,
+ SetupNewDcrDevice(rctx.jcr, rctx.jcr->sd_impl->read_dcr,
rctx.device_resource->dev, NULL);
- dcr = rctx.jcr->impl->read_dcr;
+ dcr = rctx.jcr->sd_impl->read_dcr;
}
if (!dcr) {
@@ -714,7 +714,7 @@ static int ReserveDevice(ReserveContext& rctx)
ok = ReserveDeviceForAppend(dcr, rctx);
if (!ok) { goto bail_out; }
- rctx.jcr->impl->dcr = dcr;
+ rctx.jcr->sd_impl->dcr = dcr;
Dmsg5(debuglevel, "Reserved=%d dev_name=%s mediatype=%s pool=%s ok=%d\n",
dcr->dev->NumReserved(), dcr->dev_name, dcr->media_type,
dcr->pool_name, ok);
@@ -773,7 +773,7 @@ static int ReserveDevice(ReserveContext& rctx)
} else {
ok = ReserveDeviceForRead(dcr);
if (ok) {
- rctx.jcr->impl->read_dcr = dcr;
+ rctx.jcr->sd_impl->read_dcr = dcr;
Dmsg5(debuglevel,
"Read reserved=%d dev_name=%s mediatype=%s pool=%s ok=%d\n",
dcr->dev->NumReserved(), dcr->dev_name, dcr->media_type,
@@ -1139,7 +1139,7 @@ static void QueueReserveMessage(JobControlRecord* jcr)
jcr->lock();
- auto msgs = jcr->impl->reserve_msgs;
+ auto msgs = jcr->sd_impl->reserve_msgs;
if (!msgs) { goto bail_out; }
// Look for duplicate message. If found, do not insert
for (i = msgs->size() - 1; i >= 0; i--) {
@@ -1151,7 +1151,7 @@ static void QueueReserveMessage(JobControlRecord* jcr)
}
// Message unique, so insert it.
- jcr->impl->reserve_msgs->push(strdup(jcr->errmsg));
+ jcr->sd_impl->reserve_msgs->push(strdup(jcr->errmsg));
bail_out:
jcr->unlock();
@@ -1163,7 +1163,7 @@ static void PopReserveMessages(JobControlRecord* jcr)
char* msg;
jcr->lock();
- auto msgs = jcr->impl->reserve_msgs;
+ auto msgs = jcr->sd_impl->reserve_msgs;
if (!msgs) { goto bail_out; }
while ((msg = (char*)msgs->pop())) { free(msg); }
bail_out:
@@ -1175,9 +1175,9 @@ void ReleaseReserveMessages(JobControlRecord* jcr)
{
PopReserveMessages(jcr);
jcr->lock();
- if (!jcr->impl->reserve_msgs) { goto bail_out; }
- delete jcr->impl->reserve_msgs;
- jcr->impl->reserve_msgs = NULL;
+ if (!jcr->sd_impl->reserve_msgs) { goto bail_out; }
+ delete jcr->sd_impl->reserve_msgs;
+ jcr->sd_impl->reserve_msgs = NULL;
bail_out:
jcr->unlock();
diff --git a/core/src/stored/reserve.h b/core/src/stored/reserve.h
index 35ae84e93..6770a2b2c 100644
--- a/core/src/stored/reserve.h
+++ b/core/src/stored/reserve.h
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2006-2007 Free Software Foundation Europe e.V.
- Copyright (C) 2016-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -56,7 +56,7 @@ class DirectorStorage {
class ReserveContext {
public:
JobControlRecord* jcr;
- char* device_name;
+ const char* device_name;
DirectorStorage* store;
DeviceResource* device_resource;
Device* low_use_drive; /**< Low use drive candidate */
diff --git a/core/src/stored/scan.cc b/core/src/stored/scan.cc
index 4d6d271ce..857a877f2 100644
--- a/core/src/stored/scan.cc
+++ b/core/src/stored/scan.cc
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2006-2011 Free Software Foundation Europe e.V.
- Copyright (C) 2016-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -35,8 +35,15 @@ namespace storagedaemon {
/* Forward referenced functions */
static bool IsVolumeNameLegal(char* name);
+bool Device::ScanForVolume(DeviceControlRecord* dcr)
+{
+ return ScanForVolumeImpl(dcr); // call virtual implementation
+}
+
+/* default implementation: don't scan at all */
+bool Device::ScanForVolumeImpl(DeviceControlRecord*) { return false; }
-bool Device::ScanDirForVolume(DeviceControlRecord* dcr)
+bool Device::ScanDirectoryForVolume(DeviceControlRecord* dcr)
{
DIR* dp;
struct dirent* result;
diff --git a/core/src/stored/sd_backends.cc b/core/src/stored/sd_backends.cc
deleted file mode 100644
index 0c3916b25..000000000
--- a/core/src/stored/sd_backends.cc
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- BAREOSĀ® - Backup Archiving REcovery Open Sourced
-
- Copyright (C) 2014-2014 Planets Communications B.V.
- Copyright (C) 2014-2022 Bareos GmbH & Co. KG
-
- This program is Free Software; you can redistribute it and/or
- modify it under the terms of version three of the GNU Affero General Public
- License as published by the Free Software Foundation and included
- in the file LICENSE.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-*/
-// Marco van Wieringen, June 2014
-/**
- * @file
- * Dynamic loading of SD backend plugins.
- */
-
-#include "include/bareos.h"
-
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
-
-# include "stored/stored.h"
-# include "sd_backends.h"
-
-# include <cstdlib>
-# include <dlfcn.h>
-# include <map>
-# include <memory>
-# include <stdexcept>
-# include <vector>
-
-namespace storagedaemon {
-
-struct BackendDeviceLibraryDescriptor {
- public:
- DeviceType device_type{DeviceType::B_UNKNOWN_DEV};
-
- private:
- void* dynamic_library_handle{};
- BackendInterface* backend_interface{};
-
- public:
- BackendDeviceLibraryDescriptor(DeviceType t_device_type,
- void* t_dynamic_library_handle,
- BackendInterface* t_backend_interface)
- : device_type(t_device_type)
- , dynamic_library_handle(t_dynamic_library_handle)
- , backend_interface(t_backend_interface)
- {
- }
-
- ~BackendDeviceLibraryDescriptor()
- {
- FlushDevice();
- delete backend_interface;
- dlclose(dynamic_library_handle);
- }
-
- BackendDeviceLibraryDescriptor(const BackendDeviceLibraryDescriptor& other)
- = delete;
- BackendDeviceLibraryDescriptor& operator=(
- const BackendDeviceLibraryDescriptor& other)
- = delete;
- BackendDeviceLibraryDescriptor(BackendDeviceLibraryDescriptor&& other)
- {
- device_type = other.device_type;
- std::swap(dynamic_library_handle, other.dynamic_library_handle);
- std::swap(backend_interface, other.backend_interface);
- }
- BackendDeviceLibraryDescriptor& operator=(
- BackendDeviceLibraryDescriptor&& other)
- {
- device_type = other.device_type;
- std::swap(dynamic_library_handle, other.dynamic_library_handle);
- std::swap(backend_interface, other.backend_interface);
- return *this;
- }
-
- Device* GetDevice(JobControlRecord* jcr, DeviceType device_type)
- {
- return backend_interface->GetDevice(jcr, device_type);
- }
- void FlushDevice() { backend_interface->FlushDevice(); }
-};
-
-const std::map<DeviceType, const char*> device_type_to_name_mapping
- = {{DeviceType::B_FIFO_DEV, "fifo"},
- {DeviceType::B_TAPE_DEV, "tape"},
- {DeviceType::B_GFAPI_DEV, "gfapi"},
- {DeviceType::B_DROPLET_DEV, "droplet"},
- {DeviceType::B_UNKNOWN_DEV, nullptr}};
-
-static std::vector<std::unique_ptr<BackendDeviceLibraryDescriptor>>
- loaded_backends;
-static std::vector<std::string> backend_directories;
-
-void SetBackendDeviceDirectories(
- std::vector<std::string>&& new_backend_directories)
-{
- backend_directories = new_backend_directories;
-}
-
-static inline const char* get_dlerror()
-{
- const char* error = dlerror();
- return error != nullptr ? error : "";
-}
-
-Device* InitBackendDevice(JobControlRecord* jcr, DeviceType device_type)
-{
- if (backend_directories.empty()) {
- Jmsg(jcr, M_ERROR_TERM, 0, _("Catalog Backends Dir not configured.\n"));
- // does not return
- }
-
- const char* interface_name = nullptr;
-
- try {
- interface_name = device_type_to_name_mapping.at(device_type);
- } catch (const std::out_of_range&) {
- return nullptr;
- }
-
- for (const auto& b : loaded_backends) {
- if (b->device_type == device_type) {
- return b->GetDevice(jcr, device_type);
- }
- }
-
- t_backend_base GetBackend{nullptr};
- void* dynamic_library_handle{nullptr};
-
- for (const auto& backend_dir : backend_directories) {
- if (dynamic_library_handle != nullptr) { break; }
-
- std::string shared_library_name = backend_dir + "/libbareossd-";
- shared_library_name += interface_name;
- shared_library_name += DYN_LIB_EXTENSION;
-
- Dmsg3(100, "InitBackendDevice: checking backend %s/libbareossd-%s%s\n",
- backend_dir.c_str(), interface_name, DYN_LIB_EXTENSION);
-
- struct stat st;
- if (stat(shared_library_name.c_str(), &st) != 0) {
- Dmsg3(100,
- "InitBackendDevice: backend does not exist %s/libbareossd-%s%s\n",
- backend_dir.c_str(), interface_name, DYN_LIB_EXTENSION);
- return nullptr;
- }
-
- dynamic_library_handle = dlopen(shared_library_name.c_str(), RTLD_NOW);
-
- if (dynamic_library_handle == nullptr) {
- const char* error = get_dlerror();
- Jmsg(jcr, M_ERROR, 0, _("Unable to load shared library: %s ERR=%s\n"),
- shared_library_name.c_str(), error);
- Dmsg2(100, _("Unable to load shared library: %s ERR=%s\n"),
- shared_library_name.c_str(), error);
- continue;
- }
-
- GetBackend = reinterpret_cast<t_backend_base>(
- dlsym(dynamic_library_handle, "GetBackend"));
-
- if (GetBackend == nullptr) {
- const char* error = get_dlerror();
- Jmsg(jcr, M_ERROR, 0,
- _("Lookup of GetBackend in shared library %s failed: "
- "ERR=%s\n"),
- shared_library_name.c_str(), error);
- Dmsg2(100,
- _("Lookup of GetBackend in shared library %s failed: "
- "ERR=%s\n"),
- shared_library_name.c_str(), error);
- dlclose(dynamic_library_handle);
- dynamic_library_handle = nullptr;
- continue;
- }
- }
-
- if (dynamic_library_handle == nullptr) {
- Jmsg(jcr, M_ERROR_TERM, 0,
- _("Unable to load any shared library for libbareossd-%s%s\n"),
- interface_name, DYN_LIB_EXTENSION);
- return nullptr;
- }
- if (!GetBackend) {
- Jmsg(jcr, M_ERROR_TERM, 0,
- _("Unable to locate GetBackend() function in shared backend library "
- "for libbareossd-%s%s\n"),
- interface_name, DYN_LIB_EXTENSION);
- return nullptr;
- }
-
- auto b = std::make_unique<BackendDeviceLibraryDescriptor>(
- device_type, dynamic_library_handle, GetBackend());
-
- Device* d = b->GetDevice(jcr, device_type);
- loaded_backends.push_back(std::move(b));
- return d;
-}
-
-void FlushAndCloseBackendDevices() { loaded_backends.clear(); }
-
-} /* namespace storagedaemon */
-
-#endif /* HAVE_DYNAMIC_SD_BACKENDS */
diff --git a/core/src/stored/sd_backends.h b/core/src/stored/sd_backends.h
index 9ba9840b1..cb8b834d0 100644
--- a/core/src/stored/sd_backends.h
+++ b/core/src/stored/sd_backends.h
@@ -1,8 +1,7 @@
/*
BAREOSĀ® - Backup Archiving REcovery Open Sourced
- Copyright (C) 2014-2014 Planets Communications B.V.
- Copyright (C) 2014-2022 Bareos GmbH & Co. KG
+ Copyright (C) 2022-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -19,49 +18,27 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
-// Marco van Wieringen, June 2014
-/**
- * @file
- * Dynamic loading of SD backend plugins.
- */
#ifndef BAREOS_STORED_SD_BACKENDS_H_
#define BAREOS_STORED_SD_BACKENDS_H_
-namespace storagedaemon {
-
-class BackendInterface {
- public:
- virtual ~BackendInterface() {}
- virtual Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) = 0;
- virtual void FlushDevice(void) = 0;
-};
+#include <lib/implementation_factory.h>
+namespace storagedaemon {
-extern "C" {
-typedef BackendInterface* (*t_backend_base)(void);
-BackendInterface* GetBackend(void);
-}
+class Device;
+template <typename T> Device* DeviceFactory(void) { return new T(); }
-#if defined(HAVE_WIN32)
-# define DYN_LIB_EXTENSION ".dll"
-#elif defined(HAVE_DARWIN_OS)
-/* cmake MODULE creates a .so files; cmake SHARED creates .dylib */
-// #define DYN_LIB_EXTENSION ".dylib"
-# define DYN_LIB_EXTENSION ".so"
-#else
-# define DYN_LIB_EXTENSION ".so"
+#if defined(HAVE_DYNAMIC_SD_BACKENDS)
+bool LoadStorageBackend(const std::string& device_type,
+ const std::vector<std::string>& backend_directories);
#endif
+#define REGISTER_SD_BACKEND(backend_name, backend_class) \
+ [[maybe_unused]] static bool backend_name##_backend_ \
+ = ImplementationFactory<Device>::Add(#backend_name, \
+ DeviceFactory<backend_class>);
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
-# include <map>
-void SetBackendDeviceDirectories(std::vector<std::string>&& new_backend_dirs);
-Device* InitBackendDevice(JobControlRecord* jcr, DeviceType device_type);
-void FlushAndCloseBackendDevices();
-
-extern const std::map<DeviceType, const char*> device_type_to_name_mapping;
-#endif
-} /* namespace storagedaemon */
+} // namespace storagedaemon
#endif // BAREOS_STORED_SD_BACKENDS_H_
diff --git a/core/src/stored/sd_backends_dynamic.cc b/core/src/stored/sd_backends_dynamic.cc
new file mode 100644
index 000000000..2d4fcf9e6
--- /dev/null
+++ b/core/src/stored/sd_backends_dynamic.cc
@@ -0,0 +1,78 @@
+/*
+ BAREOSĀ® - Backup Archiving REcovery Open Sourced
+
+ Copyright (C) 2022-2022 Bareos GmbH & Co. KG
+
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version three of the GNU Affero General Public
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+/**
+ * @file
+ * Dynamic loading of SD backend plugins.
+ */
+
+#include "include/bareos.h"
+
+#include "stored/stored.h"
+#include "sd_backends.h"
+#include <dlfcn.h>
+
+namespace storagedaemon {
+
+#if defined(HAVE_WIN32)
+static const char* kDynLibExtension = ".dll";
+#else
+static const char* kDynLibExtension = ".so";
+#endif
+
+static bool LoadDynamicLibrary(
+ const std::string& library_file,
+ const std::vector<std::string>& library_directories)
+{
+ for (const auto& library_dir : library_directories) {
+ if (dlopen((library_dir + "/" + library_file).c_str(), RTLD_NOW)) {
+ Dmsg0(50, "Loaded dynamic library %s/%s\n", library_dir.c_str(),
+ library_file.c_str());
+ return true;
+ }
+ Dmsg0(50, "Could not load library %s/%s: %s\n", library_dir.c_str(),
+ library_file.c_str(), dlerror());
+ }
+ return false;
+}
+
+bool LoadStorageBackend(const std::string& device_type,
+ const std::vector<std::string>& backend_directories)
+{
+ using namespace std::string_literals;
+
+ if (device_type.empty() || backend_directories.empty()) { return false; }
+
+ if (!LoadDynamicLibrary("libbareossd-"s + device_type + kDynLibExtension,
+ backend_directories)) {
+ return false;
+ }
+
+ if (!ImplementationFactory<Device>::IsRegistered(device_type)) {
+ Jmsg(nullptr, M_ERROR_TERM, 0,
+ "Loaded backend library for %s did not register its backend. This is "
+ "probably a bug in the backend library.\n",
+ device_type.c_str());
+ }
+
+ return true;
+}
+
+} /* namespace storagedaemon */
diff --git a/core/src/stored/sd_cmds.cc b/core/src/stored/sd_cmds.cc
index 6761ad6fb..0cd00bbd3 100644
--- a/core/src/stored/sd_cmds.cc
+++ b/core/src/stored/sd_cmds.cc
@@ -36,7 +36,7 @@
#include "stored/stored_globals.h"
#include "stored/append.h"
#include "stored/authenticate.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/sd_stats.h"
#include "stored/sd_stats.h"
#include "lib/bnet.h"
@@ -134,9 +134,11 @@ void* handle_stored_connection(BareosSocket* sd, char* job_name)
jcr->Job);
}
- if (!jcr->authenticated) { jcr->setJobStatus(JS_ErrorTerminated); }
+ if (!jcr->authenticated) {
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
+ }
- pthread_cond_signal(&jcr->impl->job_start_wait); /* wake waiting job */
+ pthread_cond_signal(&jcr->sd_impl->job_start_wait); /* wake waiting job */
FreeJcr(jcr);
return NULL;
@@ -174,7 +176,7 @@ static void DoSdCommands(JobControlRecord* jcr)
} else {
Jmsg0(jcr, M_FATAL, 0, _("Command error with SD, hanging up.\n"));
}
- jcr->setJobStatus(JS_ErrorTerminated);
+ jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
}
quit = true;
}
@@ -223,7 +225,7 @@ bool DoListenRun(JobControlRecord* jcr)
*/
lock_mutex(mutex);
while (!jcr->authenticated && !JobCanceled(jcr)) {
- errstat = pthread_cond_wait(&jcr->impl->job_start_wait, &mutex);
+ errstat = pthread_cond_wait(&jcr->sd_impl->job_start_wait, &mutex);
if (errstat == EINVAL || errstat == EPERM) { break; }
Dmsg1(800, "=== Auth cond errstat=%d\n", errstat);
}
@@ -256,12 +258,12 @@ bool DoListenRun(JobControlRecord* jcr)
jcr->end_time = time(NULL);
DequeueMessages(jcr); /* send any queued messages */
- jcr->setJobStatus(JS_Terminated);
+ jcr->setJobStatusWithPriorityCheck(JS_Terminated);
cleanup:
GeneratePluginEvent(jcr, bSdEventJobEnd);
- dir->fsend(Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles,
+ dir->fsend(Job_end, jcr->Job, jcr->getJobStatus(), jcr->JobFiles,
edit_uint64(jcr->JobBytes, ec1), jcr->JobErrors);
dir->signal(BNET_EOD); /* send EOD to Director daemon */
@@ -278,13 +280,13 @@ static bool StartReplicationSession(JobControlRecord* jcr)
BareosSocket* sd = jcr->store_bsock;
Dmsg1(120, "Start replication session: %s", sd->msg);
- if (jcr->impl->session_opened) {
+ if (jcr->sd_impl->session_opened) {
PmStrcpy(jcr->errmsg, _("Attempt to open already open session.\n"));
sd->fsend(NO_open);
return false;
}
- jcr->impl->session_opened = true;
+ jcr->sd_impl->session_opened = true;
// Send "Ticket" to Storage Daemon
sd->fsend(OK_start_replicate, jcr->VolSessionId);
@@ -303,7 +305,7 @@ static bool ReplicateData(JobControlRecord* jcr)
BareosSocket* sd = jcr->store_bsock;
Dmsg1(120, "Replicate data: %s", sd->msg);
- if (jcr->impl->session_opened) {
+ if (jcr->sd_impl->session_opened) {
utime_t now;
// Update the initial Job Statistics.
@@ -332,7 +334,7 @@ static bool EndReplicationSession(JobControlRecord* jcr)
BareosSocket* sd = jcr->store_bsock;
Dmsg1(120, "stored<stored: %s", sd->msg);
- if (!jcr->impl->session_opened) {
+ if (!jcr->sd_impl->session_opened) {
PmStrcpy(jcr->errmsg, _("Attempt to close non-open session.\n"));
sd->fsend(NOT_opened);
return false;
diff --git a/core/src/stored/sd_plugins.cc b/core/src/stored/sd_plugins.cc
index 943ba9480..1077915dd 100644
--- a/core/src/stored/sd_plugins.cc
+++ b/core/src/stored/sd_plugins.cc
@@ -30,7 +30,7 @@
#include "stored/stored.h"
#include "stored/stored_globals.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "sd_plugins.h"
#include "lib/crypto_cache.h"
#include "stored/sd_stats.h"
@@ -501,7 +501,7 @@ static inline PluginContext* instantiate_plugin(JobControlRecord* jcr,
/**
* Send a bSdEventNewPluginOptions event to all plugins configured in
- * jcr->impl_->plugin_options.
+ * jcr->sd_impl_->plugin_options.
*/
void DispatchNewPluginOptions(JobControlRecord* jcr)
{
@@ -517,11 +517,11 @@ void DispatchNewPluginOptions(JobControlRecord* jcr)
if (!sd_plugin_list || sd_plugin_list->empty()) { return; }
- if (jcr->impl->plugin_options && jcr->impl->plugin_options->size()) {
+ if (jcr->sd_impl->plugin_options && jcr->sd_impl->plugin_options->size()) {
eventType = bSdEventNewPluginOptions;
event.eventType = eventType;
- foreach_alist_index (i, plugin_options, jcr->impl->plugin_options) {
+ foreach_alist_index (i, plugin_options, jcr->sd_impl->plugin_options) {
// Make a private copy of plugin options.
PmStrcpy(priv_plugin_options, plugin_options);
@@ -671,7 +671,7 @@ static bRC bareosGetValue(PluginContext* ctx, bsdrVariable var, void* value)
if (jcr) {
switch (var) {
case bsdVarJob:
- *((char**)value) = jcr->impl->job_name;
+ *((char**)value) = jcr->sd_impl->job_name;
Dmsg1(debuglevel, "sd-plugin: return bsdVarJobName=%s\n",
NPRT(*((char**)value)));
break;
@@ -695,8 +695,8 @@ static bRC bareosGetValue(PluginContext* ctx, bsdrVariable var, void* value)
NPRT(*((char**)value)));
break;
case bsdVarPool:
- if (jcr->impl->dcr) {
- *((char**)value) = jcr->impl->dcr->pool_name;
+ if (jcr->sd_impl->dcr) {
+ *((char**)value) = jcr->sd_impl->dcr->pool_name;
Dmsg1(debuglevel, "sd-plugin: return bsdVarPool=%s\n",
NPRT(*((char**)value)));
} else {
@@ -704,8 +704,8 @@ static bRC bareosGetValue(PluginContext* ctx, bsdrVariable var, void* value)
}
break;
case bsdVarPoolType:
- if (jcr->impl->dcr) {
- *((char**)value) = jcr->impl->dcr->pool_type;
+ if (jcr->sd_impl->dcr) {
+ *((char**)value) = jcr->sd_impl->dcr->pool_type;
Dmsg1(debuglevel, "sd-plugin: return bsdVarPoolType=%s\n",
NPRT(*((char**)value)));
} else {
@@ -713,8 +713,8 @@ static bRC bareosGetValue(PluginContext* ctx, bsdrVariable var, void* value)
}
break;
case bsdVarStorage:
- if (jcr->impl->dcr && jcr->impl->dcr->device_resource) {
- *((char**)value) = jcr->impl->dcr->device_resource->resource_name_;
+ if (jcr->sd_impl->dcr && jcr->sd_impl->dcr->device_resource) {
+ *((char**)value) = jcr->sd_impl->dcr->device_resource->resource_name_;
Dmsg1(debuglevel, "sd-plugin: return bsdVarStorage=%s\n",
NPRT(*((char**)value)));
} else {
@@ -722,8 +722,8 @@ static bRC bareosGetValue(PluginContext* ctx, bsdrVariable var, void* value)
}
break;
case bsdVarMediaType:
- if (jcr->impl->dcr) {
- *((char**)value) = jcr->impl->dcr->media_type;
+ if (jcr->sd_impl->dcr) {
+ *((char**)value) = jcr->sd_impl->dcr->media_type;
Dmsg1(debuglevel, "sd-plugin: return bsdVarMediaType=%s\n",
NPRT(*((char**)value)));
} else {
@@ -736,13 +736,13 @@ static bRC bareosGetValue(PluginContext* ctx, bsdrVariable var, void* value)
NPRT(*((char**)value)));
break;
case bsdVarJobStatus:
- *((int*)value) = jcr->JobStatus;
+ *((int*)value) = jcr->getJobStatus();
Dmsg1(debuglevel, "sd-plugin: return bsdVarJobStatus=%c\n",
- jcr->JobStatus);
+ jcr->getJobStatus());
break;
case bsdVarVolumeName:
- if (jcr->impl->dcr) {
- *((char**)value) = jcr->impl->dcr->VolumeName;
+ if (jcr->sd_impl->dcr) {
+ *((char**)value) = jcr->sd_impl->dcr->VolumeName;
Dmsg1(debuglevel, "sd-plugin: return bsdVarVolumeName=%s\n",
NPRT(*((char**)value)));
} else {
diff --git a/core/src/stored/sd_stats.cc b/core/src/stored/sd_stats.cc
index 0e0f8e6f8..96831d7ab 100644
--- a/core/src/stored/sd_stats.cc
+++ b/core/src/stored/sd_stats.cc
@@ -29,7 +29,7 @@
#include "stored/stored.h"
#include "stored/stored_globals.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "lib/util.h"
#include "include/jcr.h"
#include "lib/parse_conf.h"
@@ -294,8 +294,9 @@ void UpdateJobStatistics(JobControlRecord* jcr, utime_t now)
job_stat->timestamp = now;
job_stat->JobFiles = jcr->JobFiles;
job_stat->JobBytes = jcr->JobBytes;
- if (jcr->impl->dcr && jcr->impl->dcr->device_resource) {
- job_stat->DevName = strdup(jcr->impl->dcr->device_resource->resource_name_);
+ if (jcr->sd_impl->dcr && jcr->sd_impl->dcr->device_resource) {
+ job_stat->DevName
+ = strdup(jcr->sd_impl->dcr->device_resource->resource_name_);
} else {
job_stat->DevName = strdup("unknown");
}
diff --git a/core/src/stored/spool.cc b/core/src/stored/spool.cc
index 5b567eaca..cd66e8a4c 100644
--- a/core/src/stored/spool.cc
+++ b/core/src/stored/spool.cc
@@ -31,7 +31,7 @@
#include "stored/acquire.h"
#include "stored/device.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "lib/berrno.h"
#include "lib/bsock.h"
#include "lib/edit.h"
@@ -118,7 +118,7 @@ bool BeginDataSpool(DeviceControlRecord* dcr)
{
bool status = true;
- if (dcr->jcr->impl->spool_data) {
+ if (dcr->jcr->sd_impl->spool_data) {
Dmsg0(100, "Turning on data spooling\n");
dcr->spool_data = true;
status = OpenDataSpoolFile(dcr);
@@ -186,7 +186,7 @@ static bool OpenDataSpoolFile(DeviceControlRecord* dcr)
if ((spool_fd = open(name, O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0640))
>= 0) {
dcr->spool_fd = spool_fd;
- dcr->jcr->impl->spool_attributes = true;
+ dcr->jcr->sd_impl->spool_attributes = true;
} else {
BErrNo be;
@@ -249,7 +249,7 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit)
BareosSocket* dir = jcr->dir_bsock;
Dmsg0(100, "Despooling data\n");
- if (jcr->impl->dcr->job_spool_size == 0) {
+ if (jcr->sd_impl->dcr->job_spool_size == 0) {
Jmsg(jcr, M_WARNING, 0,
_("Despooling zero bytes. Your disk is probably FULL!\n"));
}
@@ -263,14 +263,14 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit)
Jmsg(jcr, M_INFO, 0,
_("Committing spooled data to Volume \"%s\". Despooling %s bytes "
"...\n"),
- jcr->impl->dcr->VolumeName,
- edit_uint64_with_commas(jcr->impl->dcr->job_spool_size, ec1));
- jcr->setJobStatus(JS_DataCommitting);
+ jcr->sd_impl->dcr->VolumeName,
+ edit_uint64_with_commas(jcr->sd_impl->dcr->job_spool_size, ec1));
+ jcr->setJobStatusWithPriorityCheck(JS_DataCommitting);
} else {
Jmsg(jcr, M_INFO, 0,
_("Writing spooled data to Volume. Despooling %s bytes ...\n"),
- edit_uint64_with_commas(jcr->impl->dcr->job_spool_size, ec1));
- jcr->setJobStatus(JS_DataDespooling);
+ edit_uint64_with_commas(jcr->sd_impl->dcr->job_spool_size, ec1));
+ jcr->setJobStatusWithPriorityCheck(JS_DataDespooling);
}
jcr->sendJobStatus(JS_DataDespooling);
dcr->despool_wait = true;
@@ -334,7 +334,7 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit)
Dmsg2(000, "Fatal append error on device %s: ERR=%s\n",
dcr->dev->print_name(), dcr->dev->bstrerror());
/* Force in case Incomplete set */
- jcr->forceJobStatus(JS_FatalError);
+ jcr->setJobStatus(JS_FatalError);
}
Dmsg3(800, "Write block ok=%d FI=%d LI=%d\n", ok, block->FirstIndex,
block->LastIndex);
@@ -354,7 +354,7 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit)
Jmsg2(jcr, M_FATAL, 0,
_("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
dcr->getVolCatName(), jcr->Job);
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
}
/* Set new file/block parameters for current dcr */
SetNewFileParameters(dcr);
@@ -373,8 +373,8 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit)
"Bytes/second\n"),
despool_elapsed / 3600, despool_elapsed % 3600 / 60,
despool_elapsed % 60,
- edit_uint64_with_suffix(jcr->impl->dcr->job_spool_size / despool_elapsed,
- ec1));
+ edit_uint64_with_suffix(
+ jcr->sd_impl->dcr->job_spool_size / despool_elapsed, ec1));
dcr->block = block; /* reset block */
@@ -458,7 +458,7 @@ static int ReadBlockFromSpoolFile(DeviceControlRecord* dcr)
_("Spool header read error. Wanted %u bytes, got %d\n"), rlen,
status);
}
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
return RB_ERROR;
}
rlen = hdr.len;
@@ -467,7 +467,7 @@ static int ReadBlockFromSpoolFile(DeviceControlRecord* dcr)
rlen);
Jmsg2(jcr, M_FATAL, 0, _("Spool block too big. Max %u bytes, got %u\n"),
block->buf_len, rlen);
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
return RB_ERROR;
}
status = read(dcr->spool_fd, (char*)block->buf, (size_t)rlen);
@@ -476,7 +476,7 @@ static int ReadBlockFromSpoolFile(DeviceControlRecord* dcr)
status);
Jmsg2(dcr->jcr, M_FATAL, 0,
_("Spool data read error. Wanted %u bytes, got %d\n"), rlen, status);
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
return RB_ERROR;
}
/* Setup write pointers */
@@ -582,7 +582,7 @@ static bool WriteSpoolHeader(DeviceControlRecord* dcr)
Jmsg(jcr, M_FATAL, 0, _("Error writing header to spool file. ERR=%s\n"),
be.bstrerror());
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
}
if (status != (ssize_t)sizeof(hdr)) {
Jmsg(jcr, M_ERROR, 0,
@@ -607,7 +607,7 @@ static bool WriteSpoolHeader(DeviceControlRecord* dcr)
}
if (!DespoolData(dcr, false)) {
Jmsg(jcr, M_FATAL, 0, _("Fatal despooling error.\n"));
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
return false;
}
continue; /* try again */
@@ -615,7 +615,7 @@ static bool WriteSpoolHeader(DeviceControlRecord* dcr)
return true;
}
Jmsg(jcr, M_FATAL, 0, _("Retrying after header spooling error failed.\n"));
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
return false;
}
@@ -633,7 +633,7 @@ static bool WriteSpoolData(DeviceControlRecord* dcr)
Jmsg(jcr, M_FATAL, 0, _("Error writing data to spool file. ERR=%s\n"),
be.bstrerror());
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
}
if (status != (ssize_t)block->binbuf) {
// If we wrote something, truncate it and the header, then despool
@@ -654,7 +654,7 @@ static bool WriteSpoolData(DeviceControlRecord* dcr)
if (!DespoolData(dcr, false)) {
Jmsg(jcr, M_FATAL, 0, _("Fatal despooling error.\n"));
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
return false;
}
@@ -667,14 +667,14 @@ static bool WriteSpoolData(DeviceControlRecord* dcr)
}
Jmsg(jcr, M_FATAL, 0, _("Retrying after data spooling error failed.\n"));
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
return false;
}
bool AttributesAreSpooled(JobControlRecord* jcr)
{
- return jcr->impl->spool_attributes && jcr->dir_bsock->spool_fd_ != -1;
+ return jcr->sd_impl->spool_attributes && jcr->dir_bsock->spool_fd_ != -1;
}
/**
@@ -686,7 +686,7 @@ bool AttributesAreSpooled(JobControlRecord* jcr)
*/
bool BeginAttributeSpool(JobControlRecord* jcr)
{
- if (!jcr->impl->no_attributes && jcr->impl->spool_attributes) {
+ if (!jcr->sd_impl->no_attributes && jcr->sd_impl->spool_attributes) {
return OpenAttrSpoolFile(jcr, jcr->dir_bsock);
}
return true;
@@ -739,7 +739,7 @@ static bool BlastAttrSpoolFile(JobControlRecord* jcr, boffset_t)
if (jcr->dir_bsock->recv() <= 0) {
Jmsg(jcr, M_FATAL, 0, _("Network error on BlastAttributes.\n"));
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
return false;
}
@@ -764,7 +764,7 @@ bool CommitAttributeSpool(JobControlRecord* jcr)
Jmsg(jcr, M_FATAL, 0, _("lseek on attributes file failed: ERR=%s\n"),
be.bstrerror());
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
goto bail_out;
}
@@ -779,7 +779,7 @@ bool CommitAttributeSpool(JobControlRecord* jcr)
Jmsg(jcr, M_FATAL, 0,
_("Truncate on attributes file failed: ERR=%s\n"),
be.bstrerror());
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
goto bail_out;
}
Dmsg2(100, "=== Attrib spool truncated from %lld to %lld\n", size,
@@ -793,7 +793,7 @@ bool CommitAttributeSpool(JobControlRecord* jcr)
Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"),
be.bstrerror());
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
goto bail_out;
}
@@ -835,7 +835,7 @@ static bool OpenAttrSpoolFile(JobControlRecord* jcr, BareosSocket* bs)
Jmsg(jcr, M_FATAL, 0, _("fopen attr spool file %s failed: ERR=%s\n"), name,
be.bstrerror());
- jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */
+ jcr->setJobStatus(JS_FatalError); /* override any Incomplete */
FreePoolMemory(name);
return false;
}
diff --git a/core/src/stored/status.cc b/core/src/stored/status.cc
index 27dd18f67..5432af94e 100644
--- a/core/src/stored/status.cc
+++ b/core/src/stored/status.cc
@@ -31,7 +31,7 @@
#include "stored/stored.h"
#include "stored/stored_globals.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/spool.h"
#include "stored/status.h"
#include "lib/status_packet.h"
@@ -519,7 +519,7 @@ static void SendBlockedStatus(Device* dev, StatusPacket* sp)
bool found_jcr = false;
dev->Lock();
for (auto dcr : dev->attached_dcrs) {
- if (dcr->jcr->JobStatus == JS_WaitMount) {
+ if (dcr->jcr->getJobStatus() == JS_WaitMount) {
len = Mmsg(
msg,
_(" Device is BLOCKED waiting for mount of volume \"%s\",\n"
@@ -528,7 +528,7 @@ static void SendBlockedStatus(Device* dev, StatusPacket* sp)
dcr->VolumeName, dcr->pool_name, dcr->media_type);
sp->send(msg, len);
found_jcr = true;
- } else if (dcr->jcr->JobStatus == JS_WaitMedia) {
+ } else if (dcr->jcr->getJobStatus() == JS_WaitMedia) {
len = Mmsg(msg,
_(" Device is BLOCKED waiting to create a volume for:\n"
" Pool: %s\n"
@@ -597,18 +597,17 @@ static void SendDeviceStatus(Device* dev, StatusPacket* sp)
len = Mmsg(msg, _("Device state:\n"));
sp->send(msg, len);
- len = Mmsg(
- msg,
- " %sOPENED %sTAPE %sLABEL %sMALLOC %sAPPEND %sREAD %sEOT %sWEOT %sEOF "
- "%sNEXTVOL %sSHORT %sMOUNTED\n",
- dev->IsOpen() ? "" : "!", dev->IsTape() ? "" : "!",
- dev->IsLabeled() ? "" : "!",
- BitIsSet(ST_ALLOCATED, dev->state) ? "" : "!",
- dev->CanAppend() ? "" : "!", dev->CanRead() ? "" : "!",
- dev->AtEot() ? "" : "!", BitIsSet(ST_WEOT, dev->state) ? "" : "!",
- dev->AtEof() ? "" : "!", BitIsSet(ST_NEXTVOL, dev->state) ? "" : "!",
- BitIsSet(ST_SHORT, dev->state) ? "" : "!",
- BitIsSet(ST_MOUNTED, dev->state) ? "" : "!");
+ len = Mmsg(msg,
+ " %sOPENED %sLABEL %sMALLOC %sAPPEND %sREAD %sEOT %sWEOT %sEOF "
+ "%sNEXTVOL %sSHORT %sMOUNTED\n",
+ dev->IsOpen() ? "" : "!", dev->IsLabeled() ? "" : "!",
+ BitIsSet(ST_ALLOCATED, dev->state) ? "" : "!",
+ dev->CanAppend() ? "" : "!", dev->CanRead() ? "" : "!",
+ dev->AtEot() ? "" : "!", BitIsSet(ST_WEOT, dev->state) ? "" : "!",
+ dev->AtEof() ? "" : "!",
+ BitIsSet(ST_NEXTVOL, dev->state) ? "" : "!",
+ BitIsSet(ST_SHORT, dev->state) ? "" : "!",
+ BitIsSet(ST_MOUNTED, dev->state) ? "" : "!");
sp->send(msg, len);
len = Mmsg(msg, _(" num_writers=%d reserves=%d block=%d\n"),
@@ -634,8 +633,8 @@ static void SendDeviceStatus(Device* dev, StatusPacket* sp)
len = Mmsg(msg, _("Device parameters:\n"));
sp->send(msg, len);
- len = Mmsg(msg, _(" Archive name: %s Device name: %s\n"),
- dev->archive_name(), dev->name());
+ len = Mmsg(msg, _(" Archive name: %s\nDevice name: %s\nDevice Type: %s\n"),
+ dev->archive_name(), dev->name(), dev->type().c_str());
sp->send(msg, len);
len = Mmsg(msg, _(" File=%u block=%u\n"), dev->file, dev->block_num);
sp->send(msg, len);
@@ -663,13 +662,13 @@ static void ListRunningJobs(StatusPacket* sp)
}
foreach_jcr (jcr) {
- if (jcr->JobStatus == JS_WaitFD) {
+ if (jcr->getJobStatus() == JS_WaitFD) {
len = Mmsg(msg, _("%s Job %s waiting for Client connection.\n"),
job_type_to_str(jcr->getJobType()), jcr->Job);
sp->send(msg, len);
}
- dcr = jcr->impl->dcr;
- rdcr = jcr->impl->read_dcr;
+ dcr = jcr->sd_impl->dcr;
+ rdcr = jcr->sd_impl->read_dcr;
if ((dcr && dcr->device_resource) || (rdcr && rdcr->device_resource)) {
bstrncpy(JobName, jcr->Job, sizeof(JobName));
/* There are three periods after the Job name */
@@ -755,7 +754,7 @@ static inline void SendDriveReserveMessages(JobControlRecord* jcr,
char* msg;
jcr->lock();
- msgs = jcr->impl->reserve_msgs;
+ msgs = jcr->sd_impl->reserve_msgs;
if (!msgs || msgs->size() == 0) { goto bail_out; }
for (i = msgs->size() - 1; i >= 0; i--) {
msg = (char*)msgs->get(i);
@@ -783,7 +782,7 @@ static void ListJobsWaitingOnReservation(StatusPacket* sp)
}
foreach_jcr (jcr) {
- if (!jcr->impl->reserve_msgs) { continue; }
+ if (!jcr->sd_impl->reserve_msgs) { continue; }
SendDriveReserveMessages(jcr, sp);
}
endeach_jcr(jcr);
@@ -985,7 +984,8 @@ bool DotstatusCmd(JobControlRecord* jcr)
dir->fsend(OKdotstatus, cmd.c_str());
foreach_jcr (njcr) {
if (njcr->JobId != 0) {
- dir->fsend(DotStatusJob, njcr->JobId, njcr->JobStatus, njcr->JobErrors);
+ dir->fsend(DotStatusJob, njcr->JobId, njcr->getJobStatus(),
+ njcr->JobErrors);
}
}
endeach_jcr(njcr);
diff --git a/core/src/stored/stored.cc b/core/src/stored/stored.cc
index 25371c15d..efd17e9c8 100644
--- a/core/src/stored/stored.cc
+++ b/core/src/stored/stored.cc
@@ -38,7 +38,7 @@
#include "stored/autochanger.h"
#include "stored/bsr.h"
#include "stored/device.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/job.h"
#include "stored/label.h"
#include "stored/ndmp_tape.h"
@@ -505,7 +505,7 @@ extern "C" void* device_initialization(void*)
jcr->setJobType(JT_SYSTEM);
// Initialize job start condition variable
- errstat = pthread_cond_init(&jcr->impl->job_start_wait, nullptr);
+ errstat = pthread_cond_init(&jcr->sd_impl->job_start_wait, nullptr);
if (errstat != 0) {
BErrNo be;
Jmsg1(jcr, M_ABORT, 0,
@@ -514,7 +514,7 @@ extern "C" void* device_initialization(void*)
}
// Initialize job end condition variable
- errstat = pthread_cond_init(&jcr->impl->job_end_wait, nullptr);
+ errstat = pthread_cond_init(&jcr->sd_impl->job_end_wait, nullptr);
if (errstat != 0) {
BErrNo be;
Jmsg1(jcr, M_ABORT, 0,
@@ -534,9 +534,9 @@ extern "C" void* device_initialization(void*)
}
dcr = new StorageDaemonDeviceControlRecord;
- jcr->impl->dcr = dcr;
+ jcr->sd_impl->dcr = dcr;
SetupNewDcrDevice(jcr, dcr, dev, nullptr);
- jcr->impl->dcr->SetWillWrite();
+ jcr->sd_impl->dcr->SetWillWrite();
GeneratePluginEvent(jcr, bSdEventDeviceInit, dcr);
if (dev->AttachedToAutochanger()) {
// If autochanger set slot in dev structure
@@ -550,7 +550,7 @@ extern "C" void* device_initialization(void*)
dev->print_name());
Dmsg1(20, "Could not open device %s\n", dev->print_name());
FreeDeviceControlRecord(dcr);
- jcr->impl->dcr = nullptr;
+ jcr->sd_impl->dcr = nullptr;
continue;
}
}
@@ -568,7 +568,7 @@ extern "C" void* device_initialization(void*)
}
}
FreeDeviceControlRecord(dcr);
- jcr->impl->dcr = nullptr;
+ jcr->sd_impl->dcr = nullptr;
}
FreeJcr(jcr);
init_done = true;
@@ -613,23 +613,23 @@ static
foreach_jcr (jcr) {
BareosSocket* fd;
if (jcr->JobId == 0) { continue; /* ignore console */ }
- jcr->setJobStatus(JS_Canceled);
+ jcr->setJobStatusWithPriorityCheck(JS_Canceled);
fd = jcr->file_bsock;
if (fd) {
fd->SetTimedOut();
jcr->MyThreadSendSignal(TIMEOUT_SIGNAL);
Dmsg1(100, "term_stored killing JobId=%d\n", jcr->JobId);
/* ***FIXME*** wiffle through all dcrs */
- if (jcr->impl->dcr && jcr->impl->dcr->dev
- && jcr->impl->dcr->dev->blocked()) {
- pthread_cond_broadcast(&jcr->impl->dcr->dev->wait_next_vol);
+ if (jcr->sd_impl->dcr && jcr->sd_impl->dcr->dev
+ && jcr->sd_impl->dcr->dev->blocked()) {
+ pthread_cond_broadcast(&jcr->sd_impl->dcr->dev->wait_next_vol);
Dmsg1(100, "JobId=%u broadcast wait_device_release\n",
(uint32_t)jcr->JobId);
ReleaseDeviceCond();
}
- if (jcr->impl->read_dcr && jcr->impl->read_dcr->dev
- && jcr->impl->read_dcr->dev->blocked()) {
- pthread_cond_broadcast(&jcr->impl->read_dcr->dev->wait_next_vol);
+ if (jcr->sd_impl->read_dcr && jcr->sd_impl->read_dcr->dev
+ && jcr->sd_impl->read_dcr->dev->blocked()) {
+ pthread_cond_broadcast(&jcr->sd_impl->read_dcr->dev->wait_next_vol);
Dmsg1(100, "JobId=%u broadcast wait_device_release\n",
(uint32_t)jcr->JobId);
ReleaseDeviceCond();
@@ -663,10 +663,6 @@ static
}
}
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
- FlushAndCloseBackendDevices();
-#endif
-
if (configfile) {
free(configfile);
configfile = nullptr;
diff --git a/core/src/stored/stored_conf.cc b/core/src/stored/stored_conf.cc
index 736cf00f4..6ef9e1d40 100644
--- a/core/src/stored/stored_conf.cc
+++ b/core/src/stored/stored_conf.cc
@@ -43,6 +43,7 @@
#define NEED_JANSSON_NAMESPACE 1
#include "lib/output_formatter.h"
#include "lib/output_formatter_resource.h"
+#include "lib/implementation_factory.h"
#include "include/auth_types.h"
#include "include/jcr.h"
@@ -147,7 +148,7 @@ static ResourceItem dev_items[] = {
{"Description", CFG_TYPE_STR, ITEM(res_dev, description_), 0, 0, NULL, NULL,
"The Description directive provides easier human recognition, but is not used by Bareos directly."},
{"MediaType", CFG_TYPE_STRNAME, ITEM(res_dev, media_type), 0, CFG_ITEM_REQUIRED, NULL, NULL, NULL},
- {"DeviceType", CFG_TYPE_DEVTYPE, ITEM(res_dev, dev_type), 0, 0, NULL, NULL, NULL},
+ {"DeviceType", CFG_TYPE_STDSTR, ITEM(res_dev, device_type), 0, CFG_ITEM_DEFAULT, "", NULL, NULL},
{"ArchiveDevice", CFG_TYPE_STRNAME, ITEM(res_dev, archive_device_string), 0, CFG_ITEM_REQUIRED, NULL, NULL, NULL},
{"DeviceOptions", CFG_TYPE_STR, ITEM(res_dev, device_options), 0, 0, NULL, "15.2.0-", NULL},
{"DiagnosticDevice", CFG_TYPE_STRNAME, ITEM(res_dev, diag_device_name), 0, 0, NULL, NULL, NULL},
@@ -247,22 +248,6 @@ static ResourceTable resources[] = {
static struct s_kw authentication_methods[]
= {{"None", AT_NONE}, {"Clear", AT_CLEAR}, {"MD5", AT_MD5}, {NULL, 0}};
-struct s_dvt_kw {
- const char* name;
- DeviceType token;
-};
-
-static s_dvt_kw device_types[]
- = {{"file", DeviceType::B_FILE_DEV},
- {"tape", DeviceType::B_TAPE_DEV},
- {"fifo", DeviceType::B_FIFO_DEV},
- {"vtl", DeviceType::B_VTL_DEV},
- {"gfapi", DeviceType::B_GFAPI_DEV},
- /* compatibility: object have been renamed to droplet */
- {"object", DeviceType::B_DROPLET_DEV},
- {"droplet", DeviceType::B_DROPLET_DEV},
- {nullptr, DeviceType::B_UNKNOWN_DEV}};
-
struct s_io_kw {
const char* name;
AutoXflateMode token;
@@ -329,27 +314,6 @@ static void StoreAutopassword(LEX* lc, ResourceItem* item, int index, int pass)
}
}
-static void StoreDeviceType(LEX* lc, ResourceItem* item, int index, int)
-{
- int i;
-
- LexGetToken(lc, BCT_NAME);
- // Store the label pass 2 so that type is defined
- for (i = 0; device_types[i].name; i++) {
- if (Bstrcasecmp(lc->str, device_types[i].name)) {
- SetItemVariable<DeviceType>(*item, device_types[i].token);
- i = 0;
- break;
- }
- }
- if (i != 0) {
- scan_err1(lc, _("Expected a Device Type keyword, got: %s"), lc->str);
- }
- ScanToEol(lc);
- SetBit(index, (*item->allocated_resource)->item_present_);
- ClearBit(index, (*item->allocated_resource)->inherit_content_);
-}
-
// Store Maximum Block Size, and check it is not greater than MAX_BLOCK_LENGTH
static void StoreMaxblocksize(LEX* lc, ResourceItem* item, int index, int pass)
{
@@ -448,9 +412,6 @@ static void ParseConfigCb(LEX* lc,
case CFG_TYPE_AUTHTYPE:
StoreAuthenticationType(lc, item, index, pass);
break;
- case CFG_TYPE_DEVTYPE:
- StoreDeviceType(lc, item, index, pass);
- break;
case CFG_TYPE_MAXBLOCKSIZE:
StoreMaxblocksize(lc, item, index, pass);
break;
@@ -528,11 +489,11 @@ static void CheckDropletDevices(ConfigurationParser& my_config)
while ((p = my_config.GetNextRes(R_DEVICE, p)) != nullptr) {
DeviceResource* d = dynamic_cast<DeviceResource*>(p);
- if (d && d->dev_type == DeviceType::B_DROPLET_DEV) {
+ if (d && d->device_type == DeviceType::B_DROPLET_DEV) {
if (d->max_concurrent_jobs == 0) {
/*
- * 0 is the general default. However, for this dev_type, only 1 works.
- * So we set it to this value.
+ * 0 is the general default. However, for this device_type, only 1
+ * works. So we set it to this value.
*/
Jmsg1(nullptr, M_WARNING, 0,
_("device %s is set to the default 'Maximum Concurrent Jobs' = "
@@ -549,9 +510,81 @@ static void CheckDropletDevices(ConfigurationParser& my_config)
}
}
+static void GuessMissingDeviceTypes(ConfigurationParser& my_config)
+{
+ BareosResource* p = nullptr;
+
+ while ((p = my_config.GetNextRes(R_DEVICE, p)) != nullptr) {
+ DeviceResource* d = dynamic_cast<DeviceResource*>(p);
+ if (d && d->device_type == DeviceType::B_UNKNOWN_DEV) {
+ struct stat statp;
+ // Check that device is available
+ if (stat(d->archive_device_string, &statp) < 0) {
+ BErrNo be;
+ Jmsg2(nullptr, M_ERROR_TERM, 0,
+ _("Unable to stat path '%s' for device %s: ERR=%s\n"
+ "Consider setting Device Type if device is not available when "
+ "daemon starts.\n"),
+ d->archive_device_string, d->resource_name_, be.bstrerror());
+ return;
+ }
+ if (S_ISDIR(statp.st_mode)) {
+ d->device_type = DeviceType::B_FILE_DEV;
+ } else if (S_ISCHR(statp.st_mode)) {
+ d->device_type = DeviceType::B_TAPE_DEV;
+ } else if (S_ISFIFO(statp.st_mode)) {
+ d->device_type = DeviceType::B_FIFO_DEV;
+ } else if (!BitIsSet(CAP_REQMOUNT, d->cap_bits)) {
+ Jmsg2(nullptr, M_ERROR_TERM, 0,
+ "cannot deduce Device Type from '%s'. Must be tape or directory, "
+ "st_mode=%04o\n",
+ d->archive_device_string, (statp.st_mode & ~S_IFMT));
+ return;
+ }
+ }
+ }
+}
+
+static void CheckAndLoadDeviceBackends(ConfigurationParser& my_config)
+{
+#if defined(HAVE_DYNAMIC_SD_BACKENDS)
+ auto storage_res
+ = dynamic_cast<StorageResource*>(my_config.GetNextRes(R_STORAGE, NULL));
+#endif
+
+ BareosResource* p = nullptr;
+ while ((p = my_config.GetNextRes(R_DEVICE, p)) != nullptr) {
+ DeviceResource* d = dynamic_cast<DeviceResource*>(p);
+ if (d) {
+ to_lower(d->device_type);
+ if (!ImplementationFactory<Device>::IsRegistered(d->device_type)) {
+#if defined(HAVE_DYNAMIC_SD_BACKENDS)
+ if (!storage_res || storage_res->backend_directories.empty()) {
+ Jmsg2(nullptr, M_ERROR_TERM, 0,
+ "Backend Directory not set. Cannot load dynamic backend %s\n",
+ d->device_type.c_str());
+ }
+ if (!LoadStorageBackend(d->device_type,
+ storage_res->backend_directories)) {
+ Jmsg2(nullptr, M_ERROR_TERM, 0,
+ "Could not load storage backend %s for device %s.\n",
+ d->device_type.c_str(), d->resource_name_);
+ }
+#else
+ Jmsg2(nullptr, M_ERROR_TERM, 0,
+ "Backend %s for device %s not available.\n",
+ d->device_type.c_str(), d->resource_name_);
+#endif
+ }
+ }
+ }
+}
+
static void ConfigReadyCallback(ConfigurationParser& my_config)
{
MultiplyConfiguredDevices(my_config);
+ GuessMissingDeviceTypes(my_config);
+ CheckAndLoadDeviceBackends(my_config);
CheckDropletDevices(my_config);
}
@@ -581,10 +614,6 @@ bool ParseSdConfig(const char* configfile, int exit_code)
configfile);
return retval;
}
-
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
- SetBackendDeviceDirectories(std::move(me->backend_directories));
-#endif
}
return retval;
diff --git a/core/src/stored/jcr_private.h b/core/src/stored/stored_jcr_impl.h
index 485ad3273..fb459b210 100644
--- a/core/src/stored/jcr_private.h
+++ b/core/src/stored/stored_jcr_impl.h
@@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
- Copyright (C) 2013-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -21,8 +21,8 @@
02110-1301, USA.
*/
-#ifndef BAREOS_STORED_JCR_PRIVATE_H_
-#define BAREOS_STORED_JCR_PRIVATE_H_
+#ifndef BAREOS_STORED_STORED_JCR_IMPL_H_
+#define BAREOS_STORED_STORED_JCR_IMPL_H_
#include "stored/read_ctx.h"
#include "stored/stored_conf.h"
@@ -65,7 +65,7 @@ struct DeviceWaitTimes {
/* clang-format off */
-struct JobControlRecordPrivate {
+struct StoredJcrImpl {
JobControlRecord* next_dev{}; /**< Next JobControlRecord attached to device */
JobControlRecord* prev_dev{}; /**< Previous JobControlRecord attached to device */
pthread_cond_t job_start_wait = PTHREAD_COND_INITIALIZER; /**< Wait for FD to start Job */
@@ -104,4 +104,4 @@ struct JobControlRecordPrivate {
};
/* clang-format on */
-#endif // BAREOS_STORED_JCR_PRIVATE_H_
+#endif // BAREOS_STORED_STORED_JCR_IMPL_H_
diff --git a/core/src/stored/vol_mgr.cc b/core/src/stored/vol_mgr.cc
index e0b60245b..0d4b69516 100644
--- a/core/src/stored/vol_mgr.cc
+++ b/core/src/stored/vol_mgr.cc
@@ -51,7 +51,6 @@ static int read_vol_list_lock_count = 0;
/* Forward referenced functions */
static void FreeVolItem(VolumeReservationItem* vol);
-static void FreeReadVolItem(VolumeReservationItem* vol);
static VolumeReservationItem* new_vol_item(DeviceControlRecord* dcr,
const char* VolumeName);
static void DebugListVolumes(const char* imsg);
@@ -163,7 +162,7 @@ void AddReadVolume(JobControlRecord* jcr, const char* VolumeName)
LockReadVolumes();
vol = (VolumeReservationItem*)read_vol_list->binary_insert(nvol, ReadCompare);
if (vol != nvol) {
- FreeReadVolItem(nvol);
+ FreeVolItem(nvol);
Dmsg2(debuglevel, "read_vol=%s JobId=%d already in list.\n", VolumeName,
jcr->JobId);
} else {
@@ -191,7 +190,7 @@ void RemoveReadVolume(JobControlRecord* jcr, const char* VolumeName)
}
if (fvol) {
read_vol_list->remove(fvol);
- FreeReadVolItem(fvol);
+ FreeVolItem(fvol);
}
UnlockReadVolumes();
// pthread_cond_broadcast(&wait_next_vol);
@@ -261,10 +260,10 @@ static VolumeReservationItem* new_vol_item(DeviceControlRecord* dcr,
const char* VolumeName)
{
VolumeReservationItem* vol;
- VolumeReservationItem emptyVol;
vol = (VolumeReservationItem*)malloc(sizeof(VolumeReservationItem));
- *vol = emptyVol;
+ vol = new (vol) VolumeReservationItem();
+
vol->vol_name = strdup(VolumeName);
if (dcr) {
vol->dev = dcr->dev;
@@ -279,7 +278,7 @@ static VolumeReservationItem* new_vol_item(DeviceControlRecord* dcr,
static void FreeVolItem(VolumeReservationItem* vol)
{
- Device* dev = NULL;
+ Device* dev = nullptr;
vol->DecUseCount();
vol->Lock();
@@ -292,25 +291,7 @@ static void FreeVolItem(VolumeReservationItem* vol)
if (vol->dev) { dev = vol->dev; }
vol->DestroyMutex();
free(vol);
- if (dev) { dev->vol = NULL; }
-}
-
-static void FreeReadVolItem(VolumeReservationItem* vol)
-{
- Device* dev = NULL;
-
- vol->DecUseCount();
- vol->Lock();
- if (vol->UseCount() > 0) {
- vol->Unlock();
- return;
- }
- vol->Unlock();
- free(vol->vol_name);
- if (vol->dev) { dev = vol->dev; }
- vol->DestroyMutex();
- free(vol);
- if (dev) { dev->vol = NULL; }
+ if (dev) { dev->vol = nullptr; }
}
/**
@@ -368,10 +349,9 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
const char* VolumeName)
{
VolumeReservationItem *vol, *nvol;
- Device* volatile dev = dcr->dev;
if (JobCanceled(dcr->jcr)) { return NULL; }
- ASSERT(dev != NULL);
+ ASSERT(dcr->dev != NULL);
Dmsg2(debuglevel, "enter reserve_volume=%s drive=%s\n", VolumeName,
dcr->dev->print_name());
@@ -382,7 +362,7 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
Mmsg(dcr->jcr->errmsg,
_("Could not reserve volume \"%s\" for append, because it is read by "
"another Job.\n"),
- dev->VolHdr.VolumeName);
+ dcr->dev->VolHdr.VolumeName);
return NULL;
}
@@ -397,10 +377,10 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
* First, remove any old volume attached to this device as it is no longer
* used.
*/
- if (dev->vol) {
- vol = dev->vol;
+ if (dcr->dev->vol) {
+ vol = dcr->dev->vol;
Dmsg4(debuglevel, "Vol attached=%s, newvol=%s volinuse=%d on %s\n",
- vol->vol_name, VolumeName, vol->IsInUse(), dev->print_name());
+ vol->vol_name, VolumeName, vol->IsInUse(), dcr->dev->print_name());
/*
* Make sure we don't remove the current volume we are inserting
* because it was probably inserted by another job, or it
@@ -422,11 +402,11 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
vol->vol_name);
// If old Volume is still mounted, must unload it
- if (bstrcmp(vol->vol_name, dev->VolHdr.VolumeName)) {
+ if (bstrcmp(vol->vol_name, dcr->dev->VolHdr.VolumeName)) {
Dmsg0(50, "SetUnload\n");
- dev->SetUnload(); /* have to unload current volume */
+ dcr->dev->SetUnload(); /* have to unload current volume */
}
- FreeVolume(dev); /* Release old volume entry */
+ FreeVolume(dcr->dev); /* Release old volume entry */
if (debug_level >= debuglevel) { DebugListVolumes("reserve_vol free"); }
}
@@ -439,11 +419,12 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
* See if this is a request for reading a file type device which can be
* accesses by multiple readers at once without disturbing each other.
*/
- if (me->filedevice_concurrent_read && !dcr->IsWriting() && dev->IsFile()) {
+ if (me->filedevice_concurrent_read && !dcr->IsWriting()
+ && dcr->dev->CanReadConcurrently()) {
nvol->SetJobid(dcr->jcr->JobId);
nvol->SetReading();
vol = nvol;
- dev->vol = vol;
+ dcr->dev->vol = vol;
/*
* Read volumes on file based devices are not inserted into the write volume
@@ -458,7 +439,7 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
if (vol != nvol) {
Dmsg2(debuglevel, "Found vol=%s dev-same=%d\n", vol->vol_name,
- dev == vol->dev);
+ dcr->dev == vol->dev);
/*
* At this point, a Volume with this name already is in the list,
@@ -473,7 +454,7 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
FreeVolItem(nvol);
if (vol->dev) {
- Dmsg2(debuglevel, "dev=%s vol->dev=%s\n", dev->print_name(),
+ Dmsg2(debuglevel, "dev=%s vol->dev=%s\n", dcr->dev->print_name(),
vol->dev->print_name());
}
@@ -481,35 +462,35 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
* Check if we are trying to use the Volume on a different drive dev is our
* device vol->dev is where the Volume we want is
*/
- if (dev != vol->dev) {
+ if (dcr->dev != vol->dev) {
// Caller wants to switch Volume to another device
// should be different devices with different names
- if (bstrcmp(dev->print_name(), vol->dev->print_name())) {
+ if (bstrcmp(dcr->dev->print_name(), vol->dev->print_name())) {
// names are same
Dmsg1(100, "device pointers are different but have same name %s\n",
- dev->print_name());
+ dcr->dev->print_name());
}
if (!vol->dev->IsBusy() && !vol->IsSwapping()) {
slot_number_t slot;
Dmsg3(debuglevel, "==== Swap vol=%s from dev=%s to %s\n", VolumeName,
- vol->dev->print_name(), dev->print_name());
- FreeVolume(dev); /* free any volume attached to our drive */
- Dmsg1(50, "SetUnload dev=%s\n", dev->print_name());
- dev->SetUnload(); /* Unload any volume that is on our drive */
+ vol->dev->print_name(), dcr->dev->print_name());
+ FreeVolume(dcr->dev); /* free any volume attached to our drive */
+ Dmsg1(50, "SetUnload dev=%s\n", dcr->dev->print_name());
+ dcr->dev->SetUnload(); /* Unload any volume that is on our drive */
dcr->SetDev(vol->dev); /* temp point to other dev */
slot = GetAutochangerLoadedSlot(dcr); /* get slot on other drive */
- dcr->SetDev(dev); /* restore dev */
+ dcr->SetDev(dcr->dev); /* restore dev */
vol->SetSlotNumber(slot); /* save slot */
vol->dev->SetUnload(); /* unload the other drive */
vol->SetSwapping(); /* swap from other drive */
- dev->swap_dev = vol->dev; /* remember to get this vol */
- dev->SetLoad(); /* then reload on our drive */
+ dcr->dev->swap_dev = vol->dev; /* remember to get this vol */
+ dcr->dev->SetLoad(); /* then reload on our drive */
vol->dev->vol = NULL; /* remove volume from other drive */
- vol->dev = dev; /* point the Volume at our drive */
- dev->vol = vol; /* point our drive at the Volume */
+ vol->dev = dcr->dev; /* point the Volume at our drive */
+ dcr->dev->vol = vol; /* point our drive at the Volume */
} else {
Jmsg7(dcr->jcr, M_WARNING, 0,
"Need volume from other drive, but swap not possible. "
@@ -517,13 +498,14 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
"vol=%s from dev=%s to %s\n",
vol->dev->CanRead(), vol->dev->num_writers,
vol->dev->NumReserved(), vol->IsSwapping(), VolumeName,
- vol->dev->print_name(), dev->print_name());
- if (vol->IsSwapping() && dev->swap_dev) {
+ vol->dev->print_name(), dcr->dev->print_name());
+ if (vol->IsSwapping() && dcr->dev->swap_dev) {
Dmsg3(debuglevel, "Swap failed vol=%s from=%s to dev=%s\n",
- vol->vol_name, dev->swap_dev->print_name(), dev->print_name());
+ vol->vol_name, dcr->dev->swap_dev->print_name(),
+ dcr->dev->print_name());
} else {
Dmsg3(debuglevel, "Swap failed vol=%s from=%p to dev=%s\n",
- vol->vol_name, dev->swap_dev, dev->print_name());
+ vol->vol_name, dcr->dev->swap_dev, dcr->dev->print_name());
}
if (debug_level >= debuglevel) { DebugListVolumes("failed swap"); }
@@ -532,10 +514,10 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
goto get_out;
}
} else {
- dev->vol = vol;
+ dcr->dev->vol = vol;
}
} else {
- dev->vol = vol; /* point to newly inserted volume */
+ dcr->dev->vol = vol; /* point to newly inserted volume */
}
get_out:
@@ -655,7 +637,7 @@ VolumeReservationItem* ReadVolWalkNext(VolumeReservationItem* prev_vol)
Dmsg2(debuglevel, "Inc walk_next UseCount=%d volname=%s\n", vol->UseCount(),
vol->vol_name);
}
- if (prev_vol) { FreeReadVolItem(prev_vol); }
+ if (prev_vol) { FreeVolItem(prev_vol); }
UnlockReadVolumes();
return vol;
@@ -668,7 +650,7 @@ void ReadVolWalkEnd(VolumeReservationItem* vol)
LockReadVolumes();
Dmsg2(debuglevel, "Free walk_end UseCount=%d volname=%s\n", vol->UseCount(),
vol->vol_name);
- FreeReadVolItem(vol);
+ FreeVolItem(vol);
UnlockReadVolumes();
}
}
@@ -779,7 +761,8 @@ bool FreeVolume(Device* dev)
* - Config option filedevice_concurrent_read is not on.
* - The device is not of type File.
*/
- if (vol->IsWriting() || !me->filedevice_concurrent_read || !dev->IsFile()) {
+ if (vol->IsWriting() || !me->filedevice_concurrent_read
+ || !dev->CanReadConcurrently()) {
vol_list->remove(vol);
}
Dmsg2(debuglevel, "=== remove volume %s dev=%s\n", vol->vol_name,
diff --git a/core/src/stored/vol_mgr.h b/core/src/stored/vol_mgr.h
index 61f0c887b..b954b39d1 100644
--- a/core/src/stored/vol_mgr.h
+++ b/core/src/stored/vol_mgr.h
@@ -46,6 +46,8 @@
#ifndef BAREOS_STORED_VOL_MGR_H_
#define BAREOS_STORED_VOL_MGR_H_
+#include <atomic>
+
template <typename T> class dlist;
namespace storagedaemon {
@@ -60,12 +62,12 @@ void ReadVolWalkEnd(VolumeReservationItem* vol);
// Volume reservation class -- see vol_mgr.c and reserve.c
class VolumeReservationItem {
- bool swapping_{false}; /**< set when swapping to another drive */
- bool in_use_{false}; /**< set when volume reserved or in use */
- bool reading_{false}; /**< set when reading */
- slot_number_t slot_{0}; /**< slot of swapping volume */
- uint32_t JobId_{0}; /**< JobId for read volumes */
- volatile int32_t use_count_{0}; /**< Use count */
+ bool swapping_{false}; /**< set when swapping to another drive */
+ bool in_use_{false}; /**< set when volume reserved or in use */
+ bool reading_{false}; /**< set when reading */
+ slot_number_t slot_{0}; /**< slot of swapping volume */
+ uint32_t JobId_{0}; /**< JobId for read volumes */
+ std::atomic<int32_t> use_count_{0}; /**< Use count */
pthread_mutex_t mutex_ = PTHREAD_MUTEX_INITIALIZER; /**< Vol muntex */
public:
dlink<VolumeReservationItem> link;
@@ -76,18 +78,8 @@ class VolumeReservationItem {
void DestroyMutex() { pthread_mutex_destroy(&mutex_); }
void Lock() { lock_mutex(mutex_); }
void Unlock() { unlock_mutex(mutex_); }
- void IncUseCount(void)
- {
- lock_mutex(mutex_);
- use_count_++;
- unlock_mutex(mutex_);
- }
- void DecUseCount(void)
- {
- lock_mutex(mutex_);
- use_count_--;
- unlock_mutex(mutex_);
- }
+ void IncUseCount(void) { ++use_count_; }
+ void DecUseCount(void) { --use_count_; }
int32_t UseCount() const { return use_count_; }
bool IsSwapping() const { return swapping_; }
bool is_reading() const { return reading_; }
diff --git a/core/src/tests/CMakeLists.txt b/core/src/tests/CMakeLists.txt
index ccd063f8a..80b6f2836 100644
--- a/core/src/tests/CMakeLists.txt
+++ b/core/src/tests/CMakeLists.txt
@@ -249,7 +249,7 @@ if(NOT client-only)
)
bareos_add_test(sd_backend LINK_LIBRARIES ${LINK_LIBRARIES})
if(TARGET droplet)
- target_compile_definitions(sd_backend PRIVATE HAVE_DROPLET)
+ bareos_add_test(droplet_backend LINK_LIBRARIES ${LINK_LIBRARIES})
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") # disable on solaris
set(disable "DISABLE")
diff --git a/core/src/tests/alist_test.cc b/core/src/tests/alist_test.cc
index 9869a1f90..a95b9962a 100644
--- a/core/src/tests/alist_test.cc
+++ b/core/src/tests/alist_test.cc
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2003-2011 Free Software Foundation Europe e.V.
- Copyright (C) 2015-2021 Bareos GmbH & Co. KG
+ Copyright (C) 2015-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -66,7 +66,7 @@ void AlistFill(alist<const char*>* list, int max)
// we expect, that the list is filled with strings of numbers from 0 to n.
void TestForeachAlist(alist<const char*>* list)
{
- char* str = NULL;
+ const char* str = NULL;
char buf[30];
int i = 0;
diff --git a/core/src/tests/catalog.cc b/core/src/tests/catalog.cc
index 48024395b..07bd57658 100644
--- a/core/src/tests/catalog.cc
+++ b/core/src/tests/catalog.cc
@@ -26,7 +26,7 @@
#include "dird/get_database_connection.h"
#include "dird/dird_conf.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -99,11 +99,11 @@ void CatalogTest::SetUp()
// connect to database
{
jcr = directordaemon::NewDirectorJcr(directordaemon::DirdFreeJcr);
- jcr->impl->res.catalog
+ jcr->dir_impl->res.catalog
= (directordaemon::CatalogResource*)my_config->GetResWithName(
directordaemon::R_CATALOG, catalog_backend_name.c_str());
- ASSERT_NE(jcr->impl->res.catalog, nullptr);
+ ASSERT_NE(jcr->dir_impl->res.catalog, nullptr);
auto backenddir = std::vector<std::string>{backend_dir};
DbSetBackendDirs(backenddir);
diff --git a/core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/device/FileStorage.conf b/core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/device/FileStorage.conf
index 88c5391b4..d967bc4d6 100644
--- a/core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/device/FileStorage.conf
+++ b/core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/device/FileStorage.conf
@@ -2,6 +2,7 @@ Device {
Name = FileStorage
Media Type = File
Archive Device = /tmp/tests/backup-bareos-test/storage
+ Device Type = File
LabelMedia = yes; # lets Bareos label unlabeled media
Random Access = yes;
AutomaticMount = yes; # when device opened, read it
diff --git a/core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/storage/bareos-sd.conf b/core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/storage/bareos-sd.conf.in
index 9f4f96c31..c0174978b 100644
--- a/core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/storage/bareos-sd.conf
+++ b/core/src/tests/configs/bareos-configparser-tests/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,6 @@ Storage {
# Plugin Names = ""
Working Directory = "/tmp/tests/backup-bareos-test/working"
SD Port = 42003
+
+ @UNCOMMENT_SD_BACKEND_DIRECTORY@Backend Directory = @PROJECT_BINARY_DIR@/src/stored/backends
}
diff --git a/core/src/tests/configs/sd_backend/bareos-sd.d/device/droplet.conf.in b/core/src/tests/configs/droplet_backend/bareos-sd.d/device/droplet.conf.in
index b93c0b119..9fb80a40c 100644
--- a/core/src/tests/configs/sd_backend/bareos-sd.d/device/droplet.conf.in
+++ b/core/src/tests/configs/droplet_backend/bareos-sd.d/device/droplet.conf.in
@@ -2,7 +2,7 @@ Device {
Name = droplet
Media Type = S3
Device Type = droplet
- Device Options = "profile=@CMAKE_CURRENT_SOURCE_DIR@/src/tests/configs/sd_backend/droplet.profile,bucket=bareos-test,chunksize=10M"
+ Device Options = "profile=@CMAKE_CURRENT_SOURCE_DIR@/src/tests/configs/droplet_backend/droplet.profile,bucket=bareos-test,chunksize=10M"
Maximum Concurrent Jobs = 1
Archive Device = "Cloud Storage"
LabelMedia = yes
diff --git a/core/src/tests/configs/droplet_backend/bareos-sd.d/storage/myself.conf.in b/core/src/tests/configs/droplet_backend/bareos-sd.d/storage/myself.conf.in
new file mode 100644
index 000000000..bc16b3bda
--- /dev/null
+++ b/core/src/tests/configs/droplet_backend/bareos-sd.d/storage/myself.conf.in
@@ -0,0 +1,5 @@
+Storage {
+ Name = test-sd
+ @UNCOMMENT_SD_BACKEND_DIRECTORY@Backend Directory = @PROJECT_BINARY_DIR@/src/stored/backends
+ Working Directory = @PROJECT_BINARY_DIR@/
+}
diff --git a/core/src/tests/configs/sd_backend/droplet.profile.in b/core/src/tests/configs/droplet_backend/droplet.profile.in
index 9d161c8cf..9d161c8cf 100644
--- a/core/src/tests/configs/sd_backend/droplet.profile.in
+++ b/core/src/tests/configs/droplet_backend/droplet.profile.in
diff --git a/core/src/tests/configs/sd_reservation/bareos-sd.d/device/auto1.conf b/core/src/tests/configs/sd_reservation/bareos-sd.d/device/auto1.conf
index 97a2b3d71..117532956 100644
--- a/core/src/tests/configs/sd_reservation/bareos-sd.d/device/auto1.conf
+++ b/core/src/tests/configs/sd_reservation/bareos-sd.d/device/auto1.conf
@@ -14,8 +14,9 @@ Device {
Device {
Name = auto1dev1
- Media Type = File
+ Media Type = NonMatchingMediaType
Archive Device = ./non-existent
+ Device Type = File
LabelMedia = yes
Random Access = yes
Autochanger = yes
diff --git a/core/src/tests/configs/sd_reservation/bareos-sd.d/device/auto2.conf b/core/src/tests/configs/sd_reservation/bareos-sd.d/device/auto2.conf
index d5a748805..ff6296683 100644
--- a/core/src/tests/configs/sd_reservation/bareos-sd.d/device/auto2.conf
+++ b/core/src/tests/configs/sd_reservation/bareos-sd.d/device/auto2.conf
@@ -1,6 +1,7 @@
Device {
Name = auto2dev0
Media Type = NotFile
+ Device Type = File
Archive Device = .
LabelMedia = yes
Random Access = yes
@@ -14,6 +15,7 @@ Device {
Device {
Name = auto2dev1
Media Type = NotFile
+ Device Type = File
Archive Device = ./non-existent
LabelMedia = yes
Random Access = yes
@@ -26,6 +28,7 @@ Device {
Device {
Name = auto2dev2
Media Type = NotFile
+ Device Type = File
Archive Device = .
LabelMedia = yes
Random Access = yes
@@ -38,6 +41,7 @@ Device {
Device {
Name = auto2dev3
Media Type = NotFile
+ Device Type = File
Archive Device = .
LabelMedia = yes
Random Access = yes
@@ -50,6 +54,7 @@ Device {
Device {
Name = auto2dev4
Media Type = NotFile
+ Device Type = File
Archive Device = .
LabelMedia = yes
Random Access = yes
diff --git a/core/src/tests/configs/sd_reservation/bareos-sd.d/device/single2.conf b/core/src/tests/configs/sd_reservation/bareos-sd.d/device/single2.conf
index eab446cc2..2ec9006a7 100644
--- a/core/src/tests/configs/sd_reservation/bareos-sd.d/device/single2.conf
+++ b/core/src/tests/configs/sd_reservation/bareos-sd.d/device/single2.conf
@@ -2,4 +2,5 @@ Device {
Name = single2
Media Type = NotFile
Archive Device = .
+ Device Type = tape
}
diff --git a/core/src/tests/configs/statistics_thread/sd_statistics_thread/default_config/bareos-sd.d/storage/myself.conf b/core/src/tests/configs/statistics_thread/sd_statistics_thread/default_config/bareos-sd.d/storage/myself.conf
deleted file mode 100644
index b791506cf..000000000
--- a/core/src/tests/configs/statistics_thread/sd_statistics_thread/default_config/bareos-sd.d/storage/myself.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-Storage {
- Name = test-sd
-}
diff --git a/core/src/tests/configs/statistics_thread/sd_statistics_thread/default_config/bareos-sd.d/storage/myself.conf.in b/core/src/tests/configs/statistics_thread/sd_statistics_thread/default_config/bareos-sd.d/storage/myself.conf.in
new file mode 100644
index 000000000..394794a44
--- /dev/null
+++ b/core/src/tests/configs/statistics_thread/sd_statistics_thread/default_config/bareos-sd.d/storage/myself.conf.in
@@ -0,0 +1,4 @@
+Storage {
+ Name = test-sd
+ @UNCOMMENT_SD_BACKEND_DIRECTORY@Backend Directory = @PROJECT_BINARY_DIR@/src/stored/backends
+}
diff --git a/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_collect_set/bareos-sd.d/storage/myself.conf b/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_collect_set/bareos-sd.d/storage/myself.conf
deleted file mode 100644
index d952a4d5d..000000000
--- a/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_collect_set/bareos-sd.d/storage/myself.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-Storage {
- Name = test-sd
- Collect Device Statistics = yes
-}
diff --git a/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_collect_set/bareos-sd.d/storage/myself.conf.in b/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_collect_set/bareos-sd.d/storage/myself.conf.in
new file mode 100644
index 000000000..5e5be67f4
--- /dev/null
+++ b/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_collect_set/bareos-sd.d/storage/myself.conf.in
@@ -0,0 +1,5 @@
+Storage {
+ Name = test-sd
+ Collect Device Statistics = yes
+ @UNCOMMENT_SD_BACKEND_DIRECTORY@Backend Directory = @PROJECT_BINARY_DIR@/src/stored/backends
+}
diff --git a/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_interval_set/bareos-sd.d/storage/myself.conf b/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_interval_set/bareos-sd.d/storage/myself.conf
deleted file mode 100644
index 45e845000..000000000
--- a/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_interval_set/bareos-sd.d/storage/myself.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-Storage {
- Name = test-sd
- Statistics Collect Interval = 150
-}
diff --git a/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_interval_set/bareos-sd.d/storage/myself.conf.in b/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_interval_set/bareos-sd.d/storage/myself.conf.in
new file mode 100644
index 000000000..db56afcad
--- /dev/null
+++ b/core/src/tests/configs/statistics_thread/sd_statistics_thread/only_interval_set/bareos-sd.d/storage/myself.conf.in
@@ -0,0 +1,5 @@
+Storage {
+ Name = test-sd
+ Statistics Collect Interval = 150
+ @UNCOMMENT_SD_BACKEND_DIRECTORY@Backend Directory = @PROJECT_BINARY_DIR@/src/stored/backends
+}
diff --git a/core/src/tests/configs/stored_multiplied_device/bareos-sd.d/device/FileStorage.conf b/core/src/tests/configs/stored_multiplied_device/bareos-sd.d/device/FileStorage.conf
index d05993e6c..41776e110 100644
--- a/core/src/tests/configs/stored_multiplied_device/bareos-sd.d/device/FileStorage.conf
+++ b/core/src/tests/configs/stored_multiplied_device/bareos-sd.d/device/FileStorage.conf
@@ -1,7 +1,8 @@
Device {
Name = MultipliedDeviceResource
Media Type = File
- Archive Device = /dev/null/
+ Archive Device = /dev/null
+ Device Type = File
LabelMedia = yes; # lets Bareos label unlabeled media
Random Access = yes;
AutomaticMount = yes; # when device opened, read it
@@ -14,7 +15,8 @@ Device {
Device {
Name = AnotherMultipliedDeviceResource
Media Type = File
- Archive Device = /dev/null/
+ Archive Device = /dev/null
+ Device Type = File
LabelMedia = yes; # lets Bareos label unlabeled media
Random Access = yes;
AutomaticMount = yes; # when device opened, read it
@@ -27,7 +29,8 @@ Device {
Device {
Name = JustADeviceResource
Media Type = File
- Archive Device = /dev/null/
+ Archive Device = /dev/null
+ Device Type = File
LabelMedia = yes; # lets Bareos label unlabeled media
Random Access = yes;
AutomaticMount = yes; # when device opened, read it
diff --git a/core/src/tests/configs/stored_multiplied_device/bareos-sd.d/storage/bareos-sd.conf b/core/src/tests/configs/stored_multiplied_device/bareos-sd.d/storage/bareos-sd.conf
deleted file mode 100644
index e73e2417f..000000000
--- a/core/src/tests/configs/stored_multiplied_device/bareos-sd.d/storage/bareos-sd.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-Storage {
- Name = bareos-sd
- Maximum Concurrent Jobs = 20
-
- # remove comment from "Plugin Directory" to load plugins from specified directory.
- # if "Plugin Names" is defined, only the specified plugins will be loaded,
- # otherwise all storage plugins (*-sd.so) from the "Plugin Directory".
- #
- # Plugin Directory = "/dev/null"
- # Plugin Names = ""
-}
diff --git a/core/src/tests/configs/stored_multiplied_device/bareos-sd.d/storage/bareos-sd.conf.in b/core/src/tests/configs/stored_multiplied_device/bareos-sd.d/storage/bareos-sd.conf.in
new file mode 100644
index 000000000..ee02d180e
--- /dev/null
+++ b/core/src/tests/configs/stored_multiplied_device/bareos-sd.d/storage/bareos-sd.conf.in
@@ -0,0 +1,4 @@
+Storage {
+ Name = bareos-sd
+ @UNCOMMENT_SD_BACKEND_DIRECTORY@Backend Directory = @PROJECT_BINARY_DIR@/src/stored/backends
+}
diff --git a/core/src/tests/dir_fd_connection.cc b/core/src/tests/dir_fd_connection.cc
index 04d15f035..c19132c34 100644
--- a/core/src/tests/dir_fd_connection.cc
+++ b/core/src/tests/dir_fd_connection.cc
@@ -39,7 +39,7 @@ TEST(DirectorToClientConnection, DoesNotConnectWhenDisabled)
JobControlRecord* jcr
= directordaemon::NewDirectorJcr(directordaemon::DirdFreeJcr);
- jcr->impl->res.client = static_cast<directordaemon::ClientResource*>(
+ jcr->dir_impl->res.client = static_cast<directordaemon::ClientResource*>(
directordaemon::my_config->GetResWithName(directordaemon::R_CLIENT,
"fd-no-connection"));
directordaemon::UaContext* ua = nullptr;
diff --git a/core/src/tests/droplet_backend.cc b/core/src/tests/droplet_backend.cc
new file mode 100644
index 000000000..261e12a0d
--- /dev/null
+++ b/core/src/tests/droplet_backend.cc
@@ -0,0 +1,192 @@
+/*
+ BAREOSĀ® - Backup Archiving REcovery Open Sourced
+
+ Copyright (C) 2021-2022 Bareos GmbH & Co. KG
+
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version three of the GNU Affero General Public
+ License as published by the Free Software Foundation, which is
+ listed in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+
+#if defined(HAVE_MINGW)
+# include "include/bareos.h"
+# include "gtest/gtest.h"
+#else
+# include "gtest/gtest.h"
+# include "include/bareos.h"
+#endif
+
+
+#include <chrono>
+#include <future>
+
+#define STORAGE_DAEMON 1
+#include "include/jcr.h"
+#include "lib/crypto_cache.h"
+#include "lib/edit.h"
+#include "lib/parse_conf.h"
+#include "stored/butil.h"
+#include "stored/device_control_record.h"
+#include "stored/jcr_private.h"
+#include "stored/job.h"
+#include "stored/sd_plugins.h"
+#include "stored/sd_stats.h"
+#include "stored/stored.h"
+#include "stored/stored_globals.h"
+#include "stored/wait.h"
+#include "stored/sd_backends.h"
+
+#define CONFIG_SUBDIR "droplet_backend"
+#include "sd_backend_tests.h"
+
+using namespace storagedaemon;
+
+void droplet_write_reread_testdata(std::vector<std::vector<char>>& test_data)
+{
+ const char* name = "sd_backend_test";
+ const char* dev_name = "droplet";
+ const char* volname
+ = ::testing::UnitTest::GetInstance()->current_test_info()->name();
+
+ JobControlRecord* jcr = SetupDummyJcr(name, nullptr, nullptr);
+ ASSERT_TRUE(jcr);
+
+ DeviceResource* device_resource
+ = (DeviceResource*)my_config->GetResWithName(R_DEVICE, dev_name);
+
+ Device* dev = FactoryCreateDevice(jcr, device_resource);
+ ASSERT_TRUE(dev);
+
+ // write to device
+ {
+ dev->setVolCatName(volname);
+ auto fd = dev->d_open(volname, O_CREAT | O_RDWR | O_BINARY, 0640);
+ dev->d_truncate(
+ nullptr); // dcr parameter is unused, so nullptr should be fine
+
+ for (auto& buf : test_data) { dev->d_write(fd, buf.data(), buf.size()); }
+ dev->d_close(fd);
+ }
+
+ // read from device
+ {
+ dev->setVolCatName(volname);
+ auto fd = dev->d_open(volname, O_CREAT | O_RDWR | O_BINARY, 0640);
+
+ for (auto& buf : test_data) {
+ std::vector<char> tmp(buf.size());
+ dev->d_read(fd, tmp.data(), buf.size());
+ ASSERT_EQ(buf, tmp);
+ }
+ dev->d_close(fd);
+ }
+ delete dev;
+ FreeJcr(jcr);
+}
+
+// write-request writing 1 byte to this chunk and rest to next chunk
+TEST_F(sd, droplet_off_by_one_short)
+{
+ using namespace std::string_literals;
+ std::vector<std::vector<char>> test_data;
+
+ {
+ std::vector<char> tmp(1024 * 1024 - 1);
+ std::fill(tmp.begin(), tmp.end(), '0');
+ test_data.push_back(tmp);
+ }
+ for (char& c : "123456789abcdefghijklmnopqrstuvwxyz"s) {
+ std::vector<char> tmp(1024 * 1024);
+ std::fill(tmp.begin(), tmp.end(), c);
+ test_data.push_back(tmp);
+ }
+
+ droplet_write_reread_testdata(test_data);
+}
+
+// write-request crossing the chunk-border by exactly 1 byte
+TEST_F(sd, droplet_off_by_one_long)
+{
+ using namespace std::string_literals;
+ std::vector<std::vector<char>> test_data;
+
+ {
+ std::vector<char> tmp(1024 * 1024 + 1);
+ std::fill(tmp.begin(), tmp.end(), '0');
+ test_data.push_back(tmp);
+ }
+ for (char& c : "123456789abcdefghijklmnopqrstuvwxyz"s) {
+ std::vector<char> tmp(1024 * 1024);
+ std::fill(tmp.begin(), tmp.end(), c);
+ test_data.push_back(tmp);
+ }
+
+ droplet_write_reread_testdata(test_data);
+}
+
+// write-request hitting chunk-border exactly
+TEST_F(sd, droplet_aligned)
+{
+ using namespace std::string_literals;
+ std::vector<std::vector<char>> test_data;
+ for (char& c : "0123456789abcdefghijklmnopqrstuvwxyz"s) {
+ std::vector<char> tmp(1024 * 1024);
+ std::fill(tmp.begin(), tmp.end(), c);
+ test_data.push_back(tmp);
+ }
+
+ droplet_write_reread_testdata(test_data);
+}
+
+// write-request same size as chunk
+TEST_F(sd, droplet_fullchunk)
+{
+ using namespace std::string_literals;
+ std::vector<std::vector<char>> test_data;
+ for (char& c : "0123"s) {
+ std::vector<char> tmp(10 * 1024 * 1024);
+ std::fill(tmp.begin(), tmp.end(), c);
+ test_data.push_back(tmp);
+ }
+
+ droplet_write_reread_testdata(test_data);
+}
+
+// write-request larger than chunk
+TEST_F(sd, droplet_oversized_write)
+{
+ using namespace std::string_literals;
+ std::vector<std::vector<char>> test_data;
+ for (char& c : "0123"s) {
+ std::vector<char> tmp(11 * 1024 * 1024);
+ std::fill(tmp.begin(), tmp.end(), c);
+ test_data.push_back(tmp);
+ }
+
+ droplet_write_reread_testdata(test_data);
+}
+
+// write-request larger than two chunks
+TEST_F(sd, droplet_double_oversized_write)
+{
+ using namespace std::string_literals;
+ std::vector<std::vector<char>> test_data;
+ for (char& c : "0123"s) {
+ std::vector<char> tmp(21 * 1024 * 1024);
+ std::fill(tmp.begin(), tmp.end(), c);
+ test_data.push_back(tmp);
+ }
+
+ droplet_write_reread_testdata(test_data);
+}
diff --git a/core/src/tests/messages_resource.cc b/core/src/tests/messages_resource.cc
index e87dee44f..bff646252 100644
--- a/core/src/tests/messages_resource.cc
+++ b/core/src/tests/messages_resource.cc
@@ -31,7 +31,7 @@
#include "dird/dird_globals.h"
#include "dird/get_database_connection.h"
#include "dird/job.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "lib/messages_resource.h"
#include "lib/parse_conf.h"
#include "lib/util.h"
diff --git a/core/src/tests/run_on_incoming_connect_interval.cc b/core/src/tests/run_on_incoming_connect_interval.cc
index 0ee6573ce..fa41fa5e6 100644
--- a/core/src/tests/run_on_incoming_connect_interval.cc
+++ b/core/src/tests/run_on_incoming_connect_interval.cc
@@ -33,7 +33,7 @@
#include "cats/cats.h"
#include "dird/dird_conf.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/job.h"
#include "dird/run_on_incoming_connect_interval.h"
#include "dird/scheduler.h"
@@ -145,7 +145,7 @@ static void SchedulerJobCallback(JobControlRecord* jcr)
++test_results.job_counter;
// add job-name to map
- test_results.job_names[jcr->impl->res.job->resource_name_]++;
+ test_results.job_names[jcr->dir_impl->res.job->resource_name_]++;
FreeJcr(jcr);
}
diff --git a/core/src/tests/scheduler.cc b/core/src/tests/scheduler.cc
index 07b97bc63..bc44beea8 100644
--- a/core/src/tests/scheduler.cc
+++ b/core/src/tests/scheduler.cc
@@ -29,7 +29,7 @@
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/scheduler.h"
#include "dird/dird_conf.h"
#define DIRECTOR_DAEMON
@@ -144,7 +144,9 @@ void SimulatedTimeSource::ExecuteJob(JobControlRecord* jcr)
list_of_job_execution_time_stamps.emplace_back(
time_adapter->time_source_->SystemTime());
- if (debug) { std::cout << jcr->impl->res.job->resource_name_ << std::endl; }
+ if (debug) {
+ std::cout << jcr->dir_impl->res.job->resource_name_ << std::endl;
+ }
if (counter_of_number_of_jobs_run == maximum_number_of_jobs_run) {
scheduler->Terminate();
diff --git a/core/src/tests/sd_backend.cc b/core/src/tests/sd_backend.cc
index 701382b04..8d1755903 100644
--- a/core/src/tests/sd_backend.cc
+++ b/core/src/tests/sd_backend.cc
@@ -38,70 +38,20 @@
#include "lib/parse_conf.h"
#include "stored/butil.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/job.h"
#include "stored/sd_plugins.h"
#include "stored/sd_stats.h"
#include "stored/stored.h"
#include "stored/stored_globals.h"
#include "stored/wait.h"
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
-# include "stored/sd_backends.h"
-#endif
-
-using namespace storagedaemon;
-
-namespace storagedaemon {
-/* import this to parse the config */
-extern bool ParseSdConfig(const char* configfile, int exit_code);
-} // namespace storagedaemon
-
-class sd : public ::testing::Test {
- protected:
- void SetUp() override;
- void TearDown() override;
-};
+#include "stored/sd_backends.h"
-void sd::SetUp()
-{
- OSDependentInit();
-
- debug_level = 900;
+#define CONFIG_SUBDIR "sd_backend"
+#include "sd_backend_tests.h"
- /* configfile is a global char* from stored_globals.h */
- configfile = strdup(RELATIVE_PROJECT_SOURCE_DIR "/configs/sd_backend/");
- my_config = InitSdConfig(configfile, M_ERROR_TERM);
- ParseSdConfig(configfile, M_ERROR_TERM);
- /*
- * we do not run CheckResources() here, so take care the test configration
- * is not broken. Also autochangers will not work.
- */
-}
-void sd::TearDown()
-{
- Dmsg0(100, "TearDown start\n");
-
- {
- DeviceResource* d = nullptr;
- foreach_res (d, R_DEVICE) {
- Dmsg1(10, "Term device %s (%s)\n", d->resource_name_,
- d->archive_device_string);
- if (d->dev) {
- d->dev->ClearVolhdr();
- delete d->dev;
- d->dev = nullptr;
- }
- }
- }
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
- FlushAndCloseBackendDevices();
-#endif
+using namespace storagedaemon;
- if (configfile) { free(configfile); }
- if (my_config) { delete my_config; }
-
- TermReservationsLock();
-}
// Test that load and unloads a tape device.
TEST_F(sd, backend_load_unload)
@@ -140,178 +90,3 @@ TEST_F(sd, backend_load_unload)
Dmsg0(100, "cleanup\n");
FreeJcr(jcr);
}
-
-void droplet_write_reread_testdata(std::vector<std::vector<char>>& test_data)
-{
- const char* name = "sd_backend_test";
- const char* dev_name = "droplet";
- const char* volname
- = ::testing::UnitTest::GetInstance()->current_test_info()->name();
-
- JobControlRecord* jcr = SetupDummyJcr(name, nullptr, nullptr);
- ASSERT_TRUE(jcr);
-
- DeviceResource* device_resource
- = (DeviceResource*)my_config->GetResWithName(R_DEVICE, dev_name);
-
- Device* dev = FactoryCreateDevice(jcr, device_resource);
- ASSERT_TRUE(dev);
-
- // write to device
- {
- dev->setVolCatName(volname);
- auto fd = dev->d_open(volname, O_CREAT | O_RDWR | O_BINARY, 0640);
- dev->d_truncate(
- nullptr); // dcr parameter is unused, so nullptr should be fine
-
- for (auto& buf : test_data) { dev->d_write(fd, buf.data(), buf.size()); }
- dev->d_close(fd);
- }
-
- // read from device
- {
- dev->setVolCatName(volname);
- auto fd = dev->d_open(volname, O_CREAT | O_RDWR | O_BINARY, 0640);
-
- for (auto& buf : test_data) {
- std::vector<char> tmp(buf.size());
- dev->d_read(fd, tmp.data(), buf.size());
- ASSERT_EQ(buf, tmp);
- }
- dev->d_close(fd);
- }
- delete dev;
- FreeJcr(jcr);
-}
-
-// write-request writing 1 byte to this chunk and rest to next chunk
-TEST_F(sd, droplet_off_by_one_short)
-{
-#if !defined HAVE_DROPLET
- std::cerr << "\nThis test requires droplet backend, which has not been "
- "built. Skipping.\n";
- exit(77);
-#else
- using namespace std::string_literals;
- std::vector<std::vector<char>> test_data;
-
- {
- std::vector<char> tmp(1024 * 1024 - 1);
- std::fill(tmp.begin(), tmp.end(), '0');
- test_data.push_back(tmp);
- }
- for (char& c : "123456789abcdefghijklmnopqrstuvwxyz"s) {
- std::vector<char> tmp(1024 * 1024);
- std::fill(tmp.begin(), tmp.end(), c);
- test_data.push_back(tmp);
- }
-
- droplet_write_reread_testdata(test_data);
-#endif
-}
-
-// write-request crossing the chunk-border by exactly 1 byte
-TEST_F(sd, droplet_off_by_one_long)
-{
-#if !defined HAVE_DROPLET
- std::cerr << "\nThis test requires droplet backend, which has not been "
- "built. Skipping.\n";
- exit(77);
-#else
- using namespace std::string_literals;
- std::vector<std::vector<char>> test_data;
-
- {
- std::vector<char> tmp(1024 * 1024 + 1);
- std::fill(tmp.begin(), tmp.end(), '0');
- test_data.push_back(tmp);
- }
- for (char& c : "123456789abcdefghijklmnopqrstuvwxyz"s) {
- std::vector<char> tmp(1024 * 1024);
- std::fill(tmp.begin(), tmp.end(), c);
- test_data.push_back(tmp);
- }
-
- droplet_write_reread_testdata(test_data);
-#endif
-}
-
-// write-request hitting chunk-border exactly
-TEST_F(sd, droplet_aligned)
-{
-#if !defined HAVE_DROPLET
- std::cerr << "\nThis test requires droplet backend, which has not been "
- "built. Skipping.\n";
- exit(77);
-#else
- using namespace std::string_literals;
- std::vector<std::vector<char>> test_data;
- for (char& c : "0123456789abcdefghijklmnopqrstuvwxyz"s) {
- std::vector<char> tmp(1024 * 1024);
- std::fill(tmp.begin(), tmp.end(), c);
- test_data.push_back(tmp);
- }
-
- droplet_write_reread_testdata(test_data);
-#endif
-}
-
-// write-request same size as chunk
-TEST_F(sd, droplet_fullchunk)
-{
-#if !defined HAVE_DROPLET
- std::cerr << "\nThis test requires droplet backend, which has not been "
- "built. Skipping.\n";
- exit(77);
-#else
- using namespace std::string_literals;
- std::vector<std::vector<char>> test_data;
- for (char& c : "0123"s) {
- std::vector<char> tmp(10 * 1024 * 1024);
- std::fill(tmp.begin(), tmp.end(), c);
- test_data.push_back(tmp);
- }
-
- droplet_write_reread_testdata(test_data);
-#endif
-}
-
-// write-request larger than chunk
-TEST_F(sd, droplet_oversized_write)
-{
-#if !defined HAVE_DROPLET
- std::cerr << "\nThis test requires droplet backend, which has not been "
- "built. Skipping.\n";
- exit(77);
-#else
- using namespace std::string_literals;
- std::vector<std::vector<char>> test_data;
- for (char& c : "0123"s) {
- std::vector<char> tmp(11 * 1024 * 1024);
- std::fill(tmp.begin(), tmp.end(), c);
- test_data.push_back(tmp);
- }
-
- droplet_write_reread_testdata(test_data);
-#endif
-}
-
-// write-request larger than two chunks
-TEST_F(sd, droplet_double_oversized_write)
-{
-#if !defined HAVE_DROPLET
- std::cerr << "\nThis test requires droplet backend, which has not been "
- "built. Skipping.\n";
- exit(77);
-#else
- using namespace std::string_literals;
- std::vector<std::vector<char>> test_data;
- for (char& c : "0123"s) {
- std::vector<char> tmp(21 * 1024 * 1024);
- std::fill(tmp.begin(), tmp.end(), c);
- test_data.push_back(tmp);
- }
-
- droplet_write_reread_testdata(test_data);
-#endif
-}
diff --git a/core/src/tests/sd_backend_tests.h b/core/src/tests/sd_backend_tests.h
new file mode 100644
index 000000000..c47fe75f7
--- /dev/null
+++ b/core/src/tests/sd_backend_tests.h
@@ -0,0 +1,75 @@
+/*
+ BAREOSĀ® - Backup Archiving REcovery Open Sourced
+
+ Copyright (C) 2022-2022 Bareos GmbH & Co. KG
+
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version three of the GNU Affero General Public
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+
+#ifndef BAREOS_TESTS_SD_BACKEND_TESTS_H_
+#define BAREOS_TESTS_SD_BACKEND_TESTS_H_
+namespace storagedaemon {
+/* import this to parse the config */
+extern bool ParseSdConfig(const char* configfile, int exit_code);
+} // namespace storagedaemon
+
+class sd : public ::testing::Test {
+ protected:
+ void SetUp() override;
+ void TearDown() override;
+};
+
+void sd::SetUp()
+{
+ using namespace storagedaemon;
+ OSDependentInit();
+
+ debug_level = 900;
+
+ /* configfile is a global char* from stored_globals.h */
+ configfile
+ = strdup(RELATIVE_PROJECT_SOURCE_DIR "/configs/" CONFIG_SUBDIR "/");
+ my_config = InitSdConfig(configfile, M_ERROR_TERM);
+ ParseSdConfig(configfile, M_ERROR_TERM);
+ /*
+ * we do not run CheckResources() here, so take care the test configration
+ * is not broken. Also autochangers will not work.
+ */
+}
+void sd::TearDown()
+{
+ using namespace storagedaemon;
+ Dmsg0(100, "TearDown start\n");
+
+ {
+ DeviceResource* d = nullptr;
+ foreach_res (d, R_DEVICE) {
+ Dmsg1(10, "Term device %s (%s)\n", d->resource_name_,
+ d->archive_device_string);
+ if (d->dev) {
+ d->dev->ClearVolhdr();
+ delete d->dev;
+ d->dev = nullptr;
+ }
+ }
+ }
+
+ if (configfile) { free(configfile); }
+ if (my_config) { delete my_config; }
+
+ TermReservationsLock();
+}
+#endif // BAREOS_TESTS_SD_BACKEND_TESTS_H_
diff --git a/core/src/tests/sd_reservation.cc b/core/src/tests/sd_reservation.cc
index 1e651106c..38a9a0fb7 100644
--- a/core/src/tests/sd_reservation.cc
+++ b/core/src/tests/sd_reservation.cc
@@ -40,16 +40,14 @@
#include "lib/edit.h"
#include "lib/parse_conf.h"
#include "stored/device_control_record.h"
-#include "stored/jcr_private.h"
+#include "stored/stored_jcr_impl.h"
#include "stored/job.h"
#include "stored/sd_plugins.h"
#include "stored/sd_stats.h"
#include "stored/stored.h"
#include "stored/stored_globals.h"
#include "stored/wait.h"
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
-# include "stored/sd_backends.h"
-#endif
+#include "stored/sd_backends.h"
#include "bsock_mock.h"
@@ -99,9 +97,6 @@ void ReservationTest::TearDown()
}
}
}
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
- FlushAndCloseBackendDevices();
-#endif
if (configfile) { free(configfile); }
if (my_config) { delete my_config; }
@@ -140,7 +135,7 @@ void WaitThenUnreserve(std::unique_ptr<TestJob>&);
void WaitThenUnreserve(std::unique_ptr<TestJob>& job)
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
- job->jcr->impl->dcr->UnreserveDevice();
+ job->jcr->sd_impl->dcr->UnreserveDevice();
ReleaseDeviceCond();
}
diff --git a/core/src/tests/test_config_parser_dir.cc b/core/src/tests/test_config_parser_dir.cc
index ea716e49c..389c68ae0 100644
--- a/core/src/tests/test_config_parser_dir.cc
+++ b/core/src/tests/test_config_parser_dir.cc
@@ -31,6 +31,11 @@
#include "dird/dird_conf.h"
#include "lib/output_formatter_resource.h"
+#include <thread>
+#include <condition_variable>
+#include <chrono>
+using namespace std::chrono_literals;
+
namespace directordaemon {
static std::string sprintoutput{};
@@ -128,6 +133,63 @@ TEST(ConfigParser_Dir, bareos_configparser_tests)
delete my_config;
}
+TEST(ConfigParser_Dir, foreach_res_and_reload)
+{
+ OSDependentInit();
+ std::string path_to_config_file = std::string(
+ RELATIVE_PROJECT_SOURCE_DIR "/configs/bareos-configparser-tests");
+ my_config = InitDirConfig(path_to_config_file.c_str(), M_ERROR_TERM);
+ my_config->ParseConfig();
+
+ [[maybe_unused]] auto do_reload = [](bool keep_config) {
+ auto backup = my_config->BackupResourcesContainer();
+ my_config->ParseConfig();
+
+ me = (DirectorResource*)my_config->GetNextRes(R_DIRECTOR, nullptr);
+ my_config->own_resource_ = me;
+ ASSERT_NE(nullptr, me);
+ if (!keep_config) {
+ my_config->RestoreResourcesContainer(std::move(backup));
+ ASSERT_NE(nullptr, me);
+ }
+ };
+
+ std::mutex cv_m;
+ std::condition_variable cv;
+ bool done = false;
+
+ auto do_foreach_res = [&]() {
+ std::unique_lock lk(cv_m);
+ BareosResource* client;
+ client = (BareosResource*)0xfefe;
+ // auto handle = my_config->GetResourcesContainer();
+ foreach_res (client, R_CLIENT) {
+ cv.wait(lk);
+ printf("%p %s\n", client->resource_name_, client->resource_name_);
+ }
+ done = true;
+ return;
+ };
+
+ auto reload_loop = [&]() {
+ std::unique_lock<std::mutex> lk(cv_m);
+ while (!done) {
+ lk.unlock();
+ printf("Config reload\n");
+ do_reload(true);
+ cv.notify_one();
+ std::this_thread::sleep_for(10ms);
+ lk.lock();
+ }
+ };
+
+ std::thread t1{do_foreach_res}, t2{reload_loop};
+ t1.join();
+ t2.join();
+
+ delete my_config;
+} // namespace directordaemon
+
TEST(ConfigParser_Dir, runscript_test)
{
OSDependentInit();
@@ -173,7 +235,7 @@ void test_config_directive_type(
void test_CFG_TYPE_AUDIT(DirectorResource* me)
{
- char* val = nullptr;
+ const char* val = nullptr;
foreach_alist (val, me->audit_events) {
printf("AuditEvents = %s\n", val);
}
@@ -188,7 +250,7 @@ TEST(ConfigParser_Dir, CFG_TYPE_AUDIT)
void test_CFG_TYPE_PLUGIN_NAMES(DirectorResource* me)
{
- char* val = nullptr;
+ const char* val = nullptr;
foreach_alist (val, me->plugin_names) {
printf("PluginNames = %s\n", val);
}
diff --git a/core/src/tests/thread_list.cc b/core/src/tests/thread_list.cc
index 9e73c18aa..0c456893d 100644
--- a/core/src/tests/thread_list.cc
+++ b/core/src/tests/thread_list.cc
@@ -57,7 +57,8 @@ class WaitCondition {
{
std::unique_lock<std::mutex> ul(mutex_);
status_ = Status::kWaiting;
- bool success = cond_variable_.wait_for(ul, ms, [=]() { return notified; });
+ bool success
+ = cond_variable_.wait_for(ul, ms, [this]() { return notified; });
status_ = success ? Status::kSuccess : Status::kTimedOut;
}
void NotifyOne()
diff --git a/core/src/tests/version_strings.cc b/core/src/tests/version_strings.cc
index 43a30be95..981b557c0 100644
--- a/core/src/tests/version_strings.cc
+++ b/core/src/tests/version_strings.cc
@@ -1,7 +1,7 @@
/*
BAREOSĀ® - Backup Archiving REcovery Open Sourced
- Copyright (C) 2019-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2019-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -18,20 +18,15 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
-#include <algorithm>
-#include <vector>
-
-#if defined(HAVE_MINGW)
-# include "include/bareos.h"
-# include "gtest/gtest.h"
-#else
-# include "gtest/gtest.h"
-# include "include/bareos.h"
-#endif
+#include "include/bareos.h"
+#include "gtest/gtest.h"
#include "lib/version.h"
+#include <algorithm>
+#include <vector>
+
TEST(version_strings, version)
{
std::string ver_full{kBareosVersionStrings.Full};
diff --git a/core/src/vmware/CMakeLists.txt b/core/src/vmware/CMakeLists.txt
index 43ac195b9..407d69d16 100644
--- a/core/src/vmware/CMakeLists.txt
+++ b/core/src/vmware/CMakeLists.txt
@@ -1,7 +1,7 @@
#
# BAREOS - Backup Archiving REcovery Open Sourced
#
-# Copyright (C) 2017-2020 Bareos GmbH & Co. KG
+# Copyright (C) 2017-2022 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
@@ -19,6 +19,5 @@
# 02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
-cmake_minimum_required(VERSION 3.0)
add_subdirectory(vadp_dumper)
add_subdirectory(vmware_cbt_tool)
diff --git a/core/src/win32/filed/vss.cc b/core/src/win32/filed/vss.cc
index 8b68e24b2..ca626f77a 100644
--- a/core/src/win32/filed/vss.cc
+++ b/core/src/win32/filed/vss.cc
@@ -2,7 +2,7 @@
BAREOSĀ® - Backup Archiving REcovery Open Sourced
Copyright (C) 2005-2010 Free Software Foundation Europe e.V.
- Copyright (C) 2014-2019 Bareos GmbH & Co. KG
+ Copyright (C) 2014-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
@@ -33,7 +33,7 @@
# include "include/bareos.h"
# include "filed/filed.h"
-# include "filed/jcr_private.h"
+# include "filed/filed_jcr_impl.h"
# include "lib/thread_specific_data.h"
# include "ms_atl.h"
@@ -54,9 +54,9 @@ static bool VSSPathConvert(const char* szFilePath,
{
JobControlRecord* jcr = GetJcrFromThreadSpecificData();
- if (jcr && jcr->impl->pVSSClient) {
- return jcr->impl->pVSSClient->GetShadowPath(szFilePath, szShadowPath,
- nBuflen);
+ if (jcr && jcr->fd_impl->pVSSClient) {
+ return jcr->fd_impl->pVSSClient->GetShadowPath(szFilePath, szShadowPath,
+ nBuflen);
}
return false;
@@ -68,9 +68,9 @@ static bool VSSPathConvertW(const wchar_t* szFilePath,
{
JobControlRecord* jcr = GetJcrFromThreadSpecificData();
- if (jcr && jcr->impl->pVSSClient) {
- return jcr->impl->pVSSClient->GetShadowPathW(szFilePath, szShadowPath,
- nBuflen);
+ if (jcr && jcr->fd_impl->pVSSClient) {
+ return jcr->fd_impl->pVSSClient->GetShadowPathW(szFilePath, szShadowPath,
+ nBuflen);
}
return false;
@@ -82,15 +82,15 @@ void VSSInit(JobControlRecord* jcr)
if (g_MajorVersion == 5) {
switch (g_MinorVersion) {
case 1:
- jcr->impl->pVSSClient = new VSSClientXP();
+ jcr->fd_impl->pVSSClient = new VSSClientXP();
break;
case 2:
- jcr->impl->pVSSClient = new VSSClient2003();
+ jcr->fd_impl->pVSSClient = new VSSClient2003();
break;
}
// Vista or Longhorn or later
} else if (g_MajorVersion >= 6) {
- jcr->impl->pVSSClient = new VSSClientVista();
+ jcr->fd_impl->pVSSClient = new VSSClientVista();
}
// Setup the callback functions.
diff --git a/debian/bareos-storage-droplet.install.in b/debian/bareos-storage-droplet.install.in
index 84010ec30..1be86d8e8 100644
--- a/debian/bareos-storage-droplet.install.in
+++ b/debian/bareos-storage-droplet.install.in
@@ -1,5 +1,3 @@
-@libdir@/libbareosdroplet.so*
-@backenddir@/libbareossd-chunked.so*
@backenddir@/libbareossd-droplet.so*
@configtemplatedir@/bareos-dir.d/storage/S3_Object.conf.example
@configtemplatedir@/bareos-sd.d/device/S3_ObjectStorage.conf.example
diff --git a/debian/bareos-storage-tape.install.in b/debian/bareos-storage-tape.install.in
index cfa0d5e74..8f505071e 100644
--- a/debian/bareos-storage-tape.install.in
+++ b/debian/bareos-storage-tape.install.in
@@ -2,7 +2,6 @@
@configtemplatedir@/bareos-dir.d/storage/Tape.conf.example
@configtemplatedir@/bareos-sd.d/autochanger/autochanger-0.conf.example
@configtemplatedir@/bareos-sd.d/device/tapedrive-0.conf.example
-@backenddir@/libbareossd-gentape.so*
@backenddir@/libbareossd-tape.so*
@plugindir@/scsicrypto-sd.so
@plugindir@/scsitapealert-sd.so
diff --git a/debian/bareos-storage.install.in b/debian/bareos-storage.install.in
index 101deba2d..de1fa14d6 100644
--- a/debian/bareos-storage.install.in
+++ b/debian/bareos-storage.install.in
@@ -1,4 +1,5 @@
@plugindir@/autoxflate-sd.so
+@backenddir@/libbareossd-file.so*
@scriptdir@/disk-changer
@configtemplatedir@/bareos-sd.d/device/FileStorage.conf
@configtemplatedir@/bareos-sd.d/director/bareos-dir.conf
diff --git a/debian/control b/debian/control
index dc19efc08..fd2ea6e7a 100644
--- a/debian/control
+++ b/debian/control
@@ -21,7 +21,7 @@ Build-Depends: acl-dev,
apache2 | httpd,
bc,
chrpath,
- cmake (>= 3.12.0) | cmake-mozilla,
+ cmake (>= 3.17.0) | cmake-mozilla,
debhelper (>= 7.0.50~),
dpkg-dev (>= 1.13.19),
libacl1-dev,
diff --git a/debian/control.src b/debian/control.src
index 08f9b0d17..52e39a910 100644
--- a/debian/control.src
+++ b/debian/control.src
@@ -13,7 +13,7 @@ Build-Depends: acl-dev,
apache2 | httpd,
bc,
chrpath,
- cmake (>= 3.12.0) | cmake-mozilla,
+ cmake (>= 3.17.0) | cmake-mozilla,
debhelper (>= 7.0.50~),
dpkg-dev (>= 1.13.19),
libacl1-dev,
diff --git a/docs/manuals/CMakeLists.txt b/docs/manuals/CMakeLists.txt
index b36ef6c65..ae48cec74 100644
--- a/docs/manuals/CMakeLists.txt
+++ b/docs/manuals/CMakeLists.txt
@@ -17,8 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-cmake_minimum_required(VERSION 3.0)
-
project(bareos-docs NONE)
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)
diff --git a/docs/manuals/source/include/autogenerated/bareos-dir-config-schema.json b/docs/manuals/source/include/autogenerated/bareos-dir-config-schema.json
index 9e408c4d3..66cccf090 100644
--- a/docs/manuals/source/include/autogenerated/bareos-dir-config-schema.json
+++ b/docs/manuals/source/include/autogenerated/bareos-dir-config-schema.json
@@ -3393,10 +3393,6 @@
"number": 91,
"description": "Meta tag"
},
- "DEVICE_TYPE": {
- "number": 201,
- "description": "Device Type"
- },
"MAX_BLOCKSIZE": {
"number": 202,
"description": "Maximum Blocksize"
diff --git a/docs/manuals/source/include/autogenerated/bareos-sd-config-schema.json b/docs/manuals/source/include/autogenerated/bareos-sd-config-schema.json
index 41d3c8208..0275769df 100644
--- a/docs/manuals/source/include/autogenerated/bareos-sd-config-schema.json
+++ b/docs/manuals/source/include/autogenerated/bareos-sd-config-schema.json
@@ -505,8 +505,9 @@
"required": true
},
"DeviceType": {
- "datatype": "DEVICE_TYPE",
+ "datatype": "STRING",
"code": 0,
+ "default_value": "",
"equals": true
},
"ArchiveDevice": {
diff --git a/get_version.cmake b/get_version.cmake
index dc6bc98a4..3111fc751 100644
--- a/get_version.cmake
+++ b/get_version.cmake
@@ -1,6 +1,6 @@
# BAREOSĀ® - Backup Archiving REcovery Open Sourced
#
-# Copyright (C) 2019-2019 Bareos GmbH & Co. KG
+# Copyright (C) 2019-2022 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or modify it under
# the terms of version three of the GNU Affero General Public License as
@@ -15,7 +15,8 @@
# with this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.17)
+cmake_policy(VERSION 3.17...3.19)
if(NOT DEFINED VERSION_STRING)
set(CMAKE_MODULE_PATH
diff --git a/systemtests/CMakeLists.txt b/systemtests/CMakeLists.txt
index e49b7dff0..58d334fd1 100644
--- a/systemtests/CMakeLists.txt
+++ b/systemtests/CMakeLists.txt
@@ -19,7 +19,6 @@
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
-cmake_minimum_required(VERSION 3.3)
project(bareos-systemtests)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
diff --git a/systemtests/cmake/BareosSystemtestFunctions.cmake b/systemtests/cmake/BareosSystemtestFunctions.cmake
index 05862ff67..f7f6d93cb 100644
--- a/systemtests/cmake/BareosSystemtestFunctions.cmake
+++ b/systemtests/cmake/BareosSystemtestFunctions.cmake
@@ -17,10 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-cmake_policy(SET CMP0057 NEW) # IF(.. IN_LIST ..)
-cmake_policy(SET CMP0053 NEW)
-cmake_policy(SET CMP0064 NEW) # IF(TEST ...)
-
macro(create_systemtests_directory)
configurefilestosystemtest("systemtests" "data" "*.tgz" COPYONLY "")
configurefilestosystemtest("systemtests" "data" "*.gz" COPYONLY "")
@@ -347,6 +343,14 @@ macro(prepare_testdir_for_daemon_run)
set(backenddir ${BACKEND_DIR_TO_TEST})
set(sd_backenddir ${SD_BACKEND_DIR_TO_TEST})
+ # the SD will not suppot the BackendDirectory setting if it was not built with
+ # HAVE_DYNAMIC_SD_BACKENDS, thus we declare `sd_backend_config` that will
+ # evaluate to nothing if we don't have dynamic backends enabled.
+ if(HAVE_DYNAMIC_SD_BACKENDS)
+ set(sd_backend_config "BackendDirectory = \"${SD_BACKEND_DIR_TO_TEST}\"")
+ else()
+ set(sd_backend_config "")
+ endif()
set(BAREOS_WEBUI_PUBLIC_DIR ${WEBUI_PUBLIC_DIR_TO_TEST})
set(dbHost ${current_test_directory}/tmp)
diff --git a/systemtests/scripts/functions b/systemtests/scripts/functions
index 413684176..051035f2b 100644
--- a/systemtests/scripts/functions
+++ b/systemtests/scripts/functions
@@ -411,16 +411,19 @@ check_duration_lt()
}
start_dir() {
+ "${BAREOS_DIRECTOR_BINARY}" -c "${BAREOS_CONFIG_DIR}" -t </dev/null
"${BAREOS_DIRECTOR_BINARY}" -c "${BAREOS_CONFIG_DIR}" -f </dev/null &
dir_pid=$!
}
start_fd() {
+ "${BAREOS_FILEDAEMON_BINARY}" -c "${BAREOS_CONFIG_DIR}" -t </dev/null
"${BAREOS_FILEDAEMON_BINARY}" -c "${BAREOS_CONFIG_DIR}" -f </dev/null &
fd_pid=$!
}
start_sd() {
+ "${BAREOS_STORAGEDAEMON_BINARY}" -c "${BAREOS_CONFIG_DIR}" -t </dev/null
"${BAREOS_STORAGEDAEMON_BINARY}" -c "${BAREOS_CONFIG_DIR}" -f </dev/null &
sd_pid=$!
}
diff --git a/systemtests/scripts/start_bareos.sh b/systemtests/scripts/start_bareos.sh
index d04454a04..73b70c7ef 100755
--- a/systemtests/scripts/start_bareos.sh
+++ b/systemtests/scripts/start_bareos.sh
@@ -2,7 +2,7 @@
# BAREOSĀ® - Backup Archiving REcovery Open Sourced
#
-# Copyright (C) 2021-2021 Bareos GmbH & Co. KG
+# Copyright (C) 2021-2022 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
@@ -32,6 +32,7 @@ set -u
"${rscripts}"/setup
bin/bareos start
+bin/bareos status
# make sure, director is up and running.
print_debug "$(bin/bconsole <<< "status dir")"
diff --git a/systemtests/tests/acl/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/acl/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/acl/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/acl/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/always-incremental-consolidate/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/always-incremental-consolidate/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/always-incremental-consolidate/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/always-incremental-consolidate/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/autochanger/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/autochanger/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index 45c1fa0cf..14e2fd4eb 100644
--- a/systemtests/tests/autochanger/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/autochanger/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,5 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
- BackendDirectory = @sd_backenddir@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/autochanger/test-setup b/systemtests/tests/autochanger/test-setup
index bc74d296a..5d4579396 100755
--- a/systemtests/tests/autochanger/test-setup
+++ b/systemtests/tests/autochanger/test-setup
@@ -48,6 +48,7 @@ fi
setup_data
bin/bareos start
+bin/bareos status
# make sure, director is up and running.
print_debug "$(bin/bconsole <<< "status dir")"
diff --git a/systemtests/tests/bareos-acl/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/bareos-acl/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/bareos-acl/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/bareos-acl/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/bareos/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/bareos/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index 5dc406dca..ed2f80e4c 100644
--- a/systemtests/tests/bareos/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/bareos/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,6 @@ Storage {
Plugin Names = "autoxflate"
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
+ ## @sd_backend_config@ ##
}
diff --git a/systemtests/tests/bareos/test-setup b/systemtests/tests/bareos/test-setup
index 3b467ba11..824c7a1cc 100755
--- a/systemtests/tests/bareos/test-setup
+++ b/systemtests/tests/bareos/test-setup
@@ -2,7 +2,7 @@
# BAREOSĀ® - Backup Archiving REcovery Open Sourced
#
-# Copyright (C) 2021-2021 Bareos GmbH & Co. KG
+# Copyright (C) 2021-2022 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
@@ -35,6 +35,7 @@ set -u
setup_data
bin/bareos start
+bin/bareos status
# make sure, director is up and running.
print_debug "$(bin/bconsole <<< "status dir")"
diff --git a/systemtests/tests/bareos/testrunner-filesettext-is-updated b/systemtests/tests/bareos/testrunner-filesettext-is-updated
new file mode 100755
index 000000000..d3ec000bb
--- /dev/null
+++ b/systemtests/tests/bareos/testrunner-filesettext-is-updated
@@ -0,0 +1,68 @@
+#!/bin/bash
+set -e
+set -o pipefail
+set -u
+
+# Delete fileset text from database and check that it is readded
+# when estimate call uses the fileset
+TestName="$(basename "$(pwd)")"
+export TestName
+
+
+#shellcheck source=../environment.in
+. ./environment
+
+#shellcheck source=../scripts/functions
+. "${rscripts}"/functions
+
+start_test
+
+run_log=$tmp/run.out
+filesetwithtext=$tmp/fileset-with-filesettext
+filesetwithouttext=$tmp/fileset-without-filesettext
+JobName=backup-bareos-fd
+
+rm -f $run_log $filesetwithtext $filesetwithouttext
+
+
+cat <<END_OF_DATA >"$tmp/bconcmds"
+@$out /dev/null
+messages
+@$out $run_log
+@# first do an estimate to be sure the fileset db entry exists
+estimate listing job=$JobName
+
+@# remove filesettext from db entry
+sqlquery
+update fileset set filesettext='';
+
+@$out $filesetwithouttext
+@# display fileset entry (without filesettext)
+sqlquery
+select * from fileset;
+
+@# call estimate to update the fileset db entry and readd the filesettext
+estimate listing job=$JobName
+
+@#verify the fileset text is added again
+@$out $filesetwithtext
+sqlquery
+select * from fileset;
+END_OF_DATA
+
+run_bconsole
+
+run_bconsole
+
+# check that the fileset has not the fileset text after it was deleted
+expect_grep "| 1 | SelfTest | FileSet {" \
+ "$filesetwithtext" \
+ "The expected fileset text was not found."
+
+# check that the fileset has the fileset was added by the estimate call
+expect_grep "| 1 | SelfTest | |" \
+ "$filesetwithouttext" \
+ "The expected fileset without text was not found."
+
+
+end_test
diff --git a/systemtests/tests/bconsole/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/bconsole/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/bconsole/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/bconsole/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/bconsole/etc/bareos/bconsole.conf.in b/systemtests/tests/bconsole/etc/bareos/bconsole.conf.in
index 50b647c1d..df3050688 100644
--- a/systemtests/tests/bconsole/etc/bareos/bconsole.conf.in
+++ b/systemtests/tests/bconsole/etc/bareos/bconsole.conf.in
@@ -1,7 +1,6 @@
#
# Bareos User Agent (or Console) Configuration File
#
-
Director {
Name = @basename@-dir
DIRport = @dir_port@
diff --git a/systemtests/tests/block-size/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/block-size/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index 45c1fa0cf..14e2fd4eb 100644
--- a/systemtests/tests/block-size/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/block-size/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,5 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
- BackendDirectory = @sd_backenddir@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/bscan-bextract-bls-bcopy/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/bscan-bextract-bls-bcopy/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/bscan-bextract-bls-bcopy/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/bscan-bextract-bls-bcopy/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/checkpoints/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/checkpoints/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index 92656f4b5..f0d7f842d 100644
--- a/systemtests/tests/checkpoints/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/checkpoints/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -8,5 +8,6 @@ Storage {
#
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
Checkpoint Interval = 3
}
diff --git a/systemtests/tests/checkpoints/test-setup b/systemtests/tests/checkpoints/test-setup
index 9f7be3d9b..c48c83ec8 100755
--- a/systemtests/tests/checkpoints/test-setup
+++ b/systemtests/tests/checkpoints/test-setup
@@ -35,6 +35,7 @@ set -u
setup_data
bin/bareos start
+bin/bareos status
# make sure, director is up and running.
print_debug "$(bin/bconsole <<< "status dir")"
diff --git a/systemtests/tests/checkpoints/testrunner-checkpoints-on-stop b/systemtests/tests/checkpoints/testrunner-checkpoints-on-stop
index 96177339d..55c6fbe8f 100755
--- a/systemtests/tests/checkpoints/testrunner-checkpoints-on-stop
+++ b/systemtests/tests/checkpoints/testrunner-checkpoints-on-stop
@@ -63,6 +63,7 @@ fi
bin/bareos stop
bin/bareos start
+bin/bareos status
slowjobid=$(grep 'Job queued. JobId=' "$backup_log" | sed -n -e 's/^.*JobId=//p')
diff --git a/systemtests/tests/chflags/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/chflags/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/chflags/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/chflags/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/client-initiated/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/client-initiated/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/client-initiated/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/client-initiated/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/commandline-options/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/commandline-options/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index d555776e0..e8518885b 100644
--- a/systemtests/tests/commandline-options/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/commandline-options/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -8,4 +8,5 @@ Storage {
#
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/config-syntax-crash/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/config-syntax-crash/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/config-syntax-crash/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/config-syntax-crash/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/copy-archive-job/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/copy-archive-job/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index 622a6d444..ed481dae4 100644
--- a/systemtests/tests/copy-archive-job/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/copy-archive-job/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/copy-migrate/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/copy-migrate/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/copy-migrate/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/copy-migrate/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/copy-remote-bscan/etc/bareos-remote/bareos-sd.d/device/FileStorage.conf b/systemtests/tests/copy-remote-bscan/etc/bareos-remote/bareos-sd.d/device/FileStorage.conf
index 41d7a2ea8..c78922256 100644
--- a/systemtests/tests/copy-remote-bscan/etc/bareos-remote/bareos-sd.d/device/FileStorage.conf
+++ b/systemtests/tests/copy-remote-bscan/etc/bareos-remote/bareos-sd.d/device/FileStorage.conf
@@ -2,6 +2,7 @@ Device {
Name = RemoteFileStorage
Media Type = File
Archive Device = storage-remote
+ Device Type = File
LabelMedia = yes; # lets Bareos label unlabeled media
Random Access = yes;
AutomaticMount = yes; # when device opened, read it
@@ -13,6 +14,7 @@ Device {
Name = RemoteFileStorage2
Media Type = File
Archive Device = storage2-remote
+ Device Type = File
LabelMedia = yes; # lets Bareos label unlabeled media
Random Access = yes;
AutomaticMount = yes; # when device opened, read it
diff --git a/systemtests/tests/copy-remote-bscan/etc/bareos-remote/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/copy-remote-bscan/etc/bareos-remote/bareos-sd.d/storage/bareos-sd.conf.in
index 2fb2d6411..a16df7669 100644
--- a/systemtests/tests/copy-remote-bscan/etc/bareos-remote/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/copy-remote-bscan/etc/bareos-remote/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd2_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/copy-remote-bscan/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/copy-remote-bscan/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/copy-remote-bscan/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/copy-remote-bscan/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/dbcopy-mysql-postgresql/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/dbcopy-mysql-postgresql/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/dbcopy-mysql-postgresql/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/dbcopy-mysql-postgresql/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/deprecation/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/deprecation/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/deprecation/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/deprecation/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/droplet-s3/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/droplet-s3/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c2d9bfadd..14e2fd4eb 100644
--- a/systemtests/tests/droplet-s3/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/droplet-s3/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -8,7 +8,7 @@ Storage {
#
# Plugin Directory = "@python_plugin_module_src_sd@"
# Plugin Names = ""
- BackendDirectory = "@sd_backenddir@"
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/encrypt-signature-no-tls/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/encrypt-signature-no-tls/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/encrypt-signature-no-tls/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/encrypt-signature-no-tls/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/encrypt-signature-tls-cert/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/encrypt-signature-tls-cert/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c03e379d5..d4a918273 100644
--- a/systemtests/tests/encrypt-signature-tls-cert/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/encrypt-signature-tls-cert/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,6 +10,7 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
TLS Enable = yes
TLS Require = yes
diff --git a/systemtests/tests/fileset-multiple-blocks/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/fileset-multiple-blocks/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/fileset-multiple-blocks/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/fileset-multiple-blocks/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/filesets/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/filesets/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/filesets/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/filesets/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/gfapi-fd/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/gfapi-fd/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/gfapi-fd/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/gfapi-fd/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/glusterfs-backend/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/glusterfs-backend/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index ee35c51d6..14e2fd4eb 100644
--- a/systemtests/tests/glusterfs-backend/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/glusterfs-backend/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -9,6 +9,6 @@ Storage {
# Plugin Directory = "@python_plugin_module_src_sd@"
# Plugin Names = ""
Working Directory = "@working_dir@"
- Backend Directory = "@sd_backenddir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/list-backups/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/list-backups/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/list-backups/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/list-backups/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/multiplied-device/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/multiplied-device/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/multiplied-device/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/multiplied-device/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/ndmp/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/ndmp/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index 373a13239..ed3478721 100644
--- a/systemtests/tests/ndmp/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/ndmp/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -8,4 +8,5 @@ Storage {
Plugin Names = "autoxflate"
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/notls/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/notls/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/notls/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/notls/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/parallel-jobs/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/parallel-jobs/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index d555776e0..e8518885b 100644
--- a/systemtests/tests/parallel-jobs/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/parallel-jobs/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -8,4 +8,5 @@ Storage {
#
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/parallel-jobs/test-setup b/systemtests/tests/parallel-jobs/test-setup
index 9f7be3d9b..c48c83ec8 100755
--- a/systemtests/tests/parallel-jobs/test-setup
+++ b/systemtests/tests/parallel-jobs/test-setup
@@ -35,6 +35,7 @@ set -u
setup_data
bin/bareos start
+bin/bareos status
# make sure, director is up and running.
print_debug "$(bin/bconsole <<< "status dir")"
diff --git a/systemtests/tests/passive/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/passive/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/passive/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/passive/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/pruning/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/pruning/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/pruning/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/pruning/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-dir/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-dir/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index de00c2e35..763fcad3c 100644
--- a/systemtests/tests/py2plug-dir/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-dir/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-dir/lsan-suppressions.txt b/systemtests/tests/py2plug-dir/lsan-suppressions.txt
new file mode 100644
index 000000000..a58a0cab0
--- /dev/null
+++ b/systemtests/tests/py2plug-dir/lsan-suppressions.txt
@@ -0,0 +1 @@
+leak:libpython*
diff --git a/systemtests/tests/py2plug-dir/testrunner b/systemtests/tests/py2plug-dir/testrunner
index 323a5fe06..e0f985950 100755
--- a/systemtests/tests/py2plug-dir/testrunner
+++ b/systemtests/tests/py2plug-dir/testrunner
@@ -19,6 +19,9 @@ export TestName
#shellcheck source=../environment.in
. ./environment
+LSAN_OPTIONS=suppressions="$(pwd)/lsan-suppressions.txt"
+export LSAN_OPTIONS
+
#shellcheck source=../scripts/functions
. "${rscripts}"/functions
"${rscripts}"/cleanup
diff --git a/systemtests/tests/py2plug-fd-contrib-bareos_tasks_mysql/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-fd-contrib-bareos_tasks_mysql/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/py2plug-fd-contrib-bareos_tasks_mysql/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-fd-contrib-bareos_tasks_mysql/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-fd-ldap/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-fd-ldap/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/py2plug-fd-ldap/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-fd-ldap/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-fd-libcloud/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-fd-libcloud/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/py2plug-fd-libcloud/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-fd-libcloud/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-fd-local-fileset-basic/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-fd-local-fileset-basic/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/py2plug-fd-local-fileset-basic/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-fd-local-fileset-basic/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-fd-local-fileset-restoreobject/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-fd-local-fileset-restoreobject/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/py2plug-fd-local-fileset-restoreobject/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-fd-local-fileset-restoreobject/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-fd-mariabackup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-fd-mariabackup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index 3e1723fa6..3e8d20d14 100644
--- a/systemtests/tests/py2plug-fd-mariabackup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-fd-mariabackup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -11,4 +11,5 @@ Storage {
Working Directory = "@working_dir@"
Pid Directory = "@piddir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-fd-ovirt/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-fd-ovirt/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/py2plug-fd-ovirt/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-fd-ovirt/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-fd-percona-xtrabackup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-fd-percona-xtrabackup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/py2plug-fd-percona-xtrabackup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-fd-percona-xtrabackup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-fd-vmware/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-fd-vmware/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/py2plug-fd-vmware/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-fd-vmware/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py2plug-sd/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py2plug-sd/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index 66ee623e6..623634277 100644
--- a/systemtests/tests/py2plug-sd/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py2plug-sd/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
Plugin Names = "@python_module_name@"
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py3plug-fd-contrib-mysql_dump/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py3plug-fd-contrib-mysql_dump/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/py3plug-fd-contrib-mysql_dump/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py3plug-fd-contrib-mysql_dump/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/py3plug-fd-postgres/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/py3plug-fd-postgres/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/py3plug-fd-postgres/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/py3plug-fd-postgres/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/python-bareos/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/python-bareos/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/python-bareos/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/python-bareos/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/python-bareos/test-setup b/systemtests/tests/python-bareos/test-setup
index 5fa79d635..1c138dbbe 100755
--- a/systemtests/tests/python-bareos/test-setup
+++ b/systemtests/tests/python-bareos/test-setup
@@ -21,5 +21,6 @@ setup_data
echo "${BackupDirectory}/build" >"$tmp/file-list-simple"
bin/bareos start
+bin/bareos status
print_debug "$(bin/bconsole <<< "status dir")"
diff --git a/systemtests/tests/quota-softquota/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/quota-softquota/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/quota-softquota/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/quota-softquota/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/restapi/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/restapi/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/restapi/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/restapi/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/scheduler-backup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/scheduler-backup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/scheduler-backup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/scheduler-backup/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/scheduler-backup/test-setup b/systemtests/tests/scheduler-backup/test-setup
index 30231d4c2..85695c25e 100755
--- a/systemtests/tests/scheduler-backup/test-setup
+++ b/systemtests/tests/scheduler-backup/test-setup
@@ -53,6 +53,7 @@ echo "Schedule {
}" > "$conf"/bareos-dir.d/schedule/schedule.conf
bin/bareos start
+bin/bareos status
# make sure, director is up and running.
print_debug "$(bin/bconsole <<< "status dir")"
diff --git a/systemtests/tests/sparse-file/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/sparse-file/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/sparse-file/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/sparse-file/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/spool/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/spool/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/spool/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/spool/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/stresstest/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/stresstest/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index 8847967d8..99b0aa967 100644
--- a/systemtests/tests/stresstest/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/stresstest/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -8,5 +8,6 @@ Storage {
#
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
#Checkpoint Interval = 30
}
diff --git a/systemtests/tests/stresstest/test-setup b/systemtests/tests/stresstest/test-setup
index 1207a7dce..31c0e2b6f 100755
--- a/systemtests/tests/stresstest/test-setup
+++ b/systemtests/tests/stresstest/test-setup
@@ -38,6 +38,7 @@ fi
echo "$1" >$tmp/file-list
bin/bareos start
+bin/bareos status
# make sure, director is up and running.
print_debug "$(bin/bconsole <<< "status dir")"
diff --git a/systemtests/tests/truncate-command/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/truncate-command/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/truncate-command/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/truncate-command/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/virtualfull-bscan/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/virtualfull-bscan/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/virtualfull-bscan/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/virtualfull-bscan/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/virtualfull/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/virtualfull/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/virtualfull/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/virtualfull/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/webui-common/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/webui-common/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/webui-common/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/webui-common/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/systemtests/tests/xattr/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/xattr/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
index c10462de6..14e2fd4eb 100644
--- a/systemtests/tests/xattr/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
+++ b/systemtests/tests/xattr/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in
@@ -10,4 +10,5 @@ Storage {
# Plugin Names = ""
Working Directory = "@working_dir@"
SD Port = @sd_port@
+ @sd_backend_config@
}
diff --git a/webui/CMakeLists.txt b/webui/CMakeLists.txt
index 0c75fc989..288be678b 100644
--- a/webui/CMakeLists.txt
+++ b/webui/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOSĀ® - Backup Archiving REcovery Open Sourced
#
-# Copyright (C) 2018-2021 Bareos GmbH & Co. KG
+# Copyright (C) 2018-2022 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
@@ -17,7 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
-cmake_minimum_required(VERSION 3.0)
project(bareos-webui)
include(GNUInstallDirs)
diff --git a/webui/module/Job/view/job/job/details.phtml b/webui/module/Job/view/job/job/details.phtml
index 760feab51..c7698c09c 100644
--- a/webui/module/Job/view/job/job/details.phtml
+++ b/webui/module/Job/view/job/job/details.phtml
@@ -155,7 +155,7 @@ $this->headTitle($title);
html.push('</tr>');
html.push('<tr>');
html.push('<th><?php echo addslashes($this->translate("Pool")); ?></th>');
- html.push('<td><a href="<?php echo $this->basePath() . '/pool/details/'; ?>' + row.poolname + '">' + row.poolname + '</a></td>');
+ html.push('<td><a href="<?php echo $this->basePath() . '/pool/details/?pool='; ?>' + row.poolname + '">' + row.poolname + '</a></td>');
html.push('</tr>');
html.push('<tr>');
html.push('<th><?php echo addslashes($this->translate("Scheduled")); ?></th>');
diff --git a/webui/module/Job/view/job/job/index.phtml b/webui/module/Job/view/job/job/index.phtml
index 56a2e83e6..89b49f20c 100644
--- a/webui/module/Job/view/job/job/index.phtml
+++ b/webui/module/Job/view/job/job/index.phtml
@@ -310,7 +310,7 @@ $this->headTitle($title);
html.push('</tr>');
html.push('<tr>');
html.push('<th><?php echo addslashes($this->translate("Pool")); ?></th>');
- html.push('<td><a href="<?php echo $this->basePath() . '/pool/details/'; ?>' + row.poolname + '">' + row.poolname + '</a></td>');
+ html.push('<td><a href="<?php echo $this->basePath() . '/pool/details/?pool='; ?>' + row.poolname + '">' + row.poolname + '</a></td>');
html.push('</tr>');
html.push('<tr>');
html.push('<th><?php echo addslashes($this->translate("Scheduled")); ?></th>');
diff --git a/write_version_files.cmake b/write_version_files.cmake
index ecfa9613a..8d812c46b 100644
--- a/write_version_files.cmake
+++ b/write_version_files.cmake
@@ -1,6 +1,6 @@
# BAREOSĀ® - Backup Archiving REcovery Open Sourced
#
-# Copyright (C) 2019-2021 Bareos GmbH & Co. KG
+# Copyright (C) 2019-2022 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or modify it under
# the terms of version three of the GNU Affero General Public License as
@@ -15,7 +15,8 @@
# with this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.17)
+cmake_policy(VERSION 3.17...3.19)
set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake" "${CMAKE_CURRENT_LIST_DIR}/core/cmake"