1 /*
2    BAREOS® - Backup Archiving REcovery Open Sourced
3 
4    Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
5    Copyright (C) 2011-2012 Planets Communications B.V.
6    Copyright (C) 2013-2019 Bareos GmbH & Co. KG
7 
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12 
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    Affero General Public License for more details.
17 
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22 */
23 
24 #ifndef BAREOS_STORED_DEVICE_RESOURCE_H_
25 #define BAREOS_STORED_DEVICE_RESOURCE_H_
26 
27 #include "stored/dev.h"
28 #include "lib/bareos_resource.h"
29 
30 namespace storagedaemon {
31 
32 class Device;
33 class AutochangerResource;
34 
35 class DeviceResource : public BareosResource {
36  public:
37   char* media_type;             /**< User assigned media type */
38   char* device_name;            /**< Archive device name */
39   char* device_options;         /**< Device specific option string */
40   char* diag_device_name;       /**< Diagnostic device name */
41   char* changer_name;           /**< Changer device name */
42   char* changer_command;        /**< Changer command  -- external program */
43   char* alert_command;          /**< Alert command -- external program */
44   char* spool_directory;        /**< Spool file directory */
45   uint32_t dev_type;            /**< device type */
46   uint32_t label_type;          /**< label type */
47   bool autoselect;              /**< Automatically select from AutoChanger */
48   bool norewindonclose;         /**< Don't rewind tape drive on close */
49   bool drive_tapealert_enabled; /**< Enable Tape Alert monitoring */
50   bool drive_crypto_enabled;    /**< Enable hardware crypto */
51   bool query_crypto_status;     /**< Query device for crypto status */
52   bool collectstats;            /**< Set if statistics should be collected */
53   bool eof_on_error_is_eot;     /**< Interpret EOF during read error as EOT */
54   drive_number_t drive;         /**< Autochanger logical drive number */
55   drive_number_t drive_index;   /**< Autochanger physical drive index */
56   char cap_bits[CAP_BYTES];     /**< Capabilities of this device */
57   utime_t max_changer_wait;     /**< Changer timeout */
58   utime_t max_rewind_wait;      /**< Maximum secs to wait for rewind */
59   utime_t max_open_wait;        /**< Maximum secs to wait for open */
60   uint32_t max_open_vols;       /**< Maximum simultaneous open volumes */
61   uint32_t label_block_size;    /**< block size of the label block*/
62   uint32_t min_block_size;      /**< Current Minimum block size */
63   uint32_t max_block_size;      /**< Current Maximum block size */
64   uint32_t max_network_buffer_size; /**< Max network buf size */
65   uint32_t max_concurrent_jobs;     /**< Maximum concurrent jobs this drive */
66   uint32_t autodeflate_algorithm;   /**< Compression algorithm to use for
67                                        compression */
68   uint16_t autodeflate_level; /**< Compression level to use for compression
69                                  algorithm which uses levels */
70   uint16_t autodeflate; /**< Perform auto deflation in this IO direction */
71   uint16_t autoinflate; /**< Perform auto inflation in this IO direction */
72   utime_t
73       vol_poll_interval;   /**< Interval between polling volume during mount */
74   int64_t max_volume_size; /**< Max bytes to put on one volume */
75   int64_t max_file_size;   /**< Max file size in bytes */
76   int64_t volume_capacity; /**< Advisory capacity */
77   int64_t max_spool_size;  /**< Max spool size for all jobs */
78   int64_t max_job_spool_size; /**< Max spool size for any single job */
79 
80   int64_t max_part_size;    /**< Max part size */
81   char* mount_point;        /**< Mount point for require mount devices */
82   char* mount_command;      /**< Mount command */
83   char* unmount_command;    /**< Unmount command */
84   char* write_part_command; /**< Write part command */
85   char* free_space_command; /**< Free space command */
86   uint32_t count;           /**< Total number of multiplied devices */
87   DeviceResource* multiplied_device_resource; /**< Copied from this device */
88 
89   Device* dev; /* Pointer to physical dev -- set at runtime */
90   AutochangerResource* changer_res; /* Pointer to changer res if any */
91 
92   DeviceResource();
93   virtual ~DeviceResource() = default;
94   DeviceResource(const DeviceResource& other);
95   DeviceResource& operator=(const DeviceResource& rhs);
96   bool PrintConfig(PoolMem& buf,
97                    const ConfigurationParser& /* unused */,
98                    bool hide_sensitive_data = false,
99                    bool verbose = false) override;
100   void CreateAndAssignSerialNumber(uint16_t number);
101   void MultipliedDeviceRestoreBaseName();
102   void MultipliedDeviceRestoreNumberedName();
103 
104  private:
105   std::string multiplied_device_resource_base_name; /** < base name without
106                                                      appended numbers */
107   char* temporarily_swapped_numbered_name;
108 };
109 } /* namespace storagedaemon */
110 
111 #endif /* BAREOS_STORED_DEVICE_RESOURCE_H_ */
112