]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Introduce 'SetVolumeAppendOnly' and 'SetVolumeImmutable' SD directives
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Fri, 17 Dec 2021 16:24:06 +0000 (17:24 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:57 +0000 (13:56 +0200)
Those two are instead of previously existing ProtectVolumes.

bacula/src/stored/block_util.c
bacula/src/stored/file_dev.c
bacula/src/stored/mount.c
bacula/src/stored/stored_conf.c
bacula/src/stored/stored_conf.h

index b770b193d4e53d10078572e43a1b25363025e06c..508b38e5f2500232ca499ff8592262a373fb5cd6 100644 (file)
@@ -620,7 +620,7 @@ bool is_user_volume_size_reached(DCR *dcr, bool quiet)
             dev->getVolCatName());
       }
 
-      if (dev->device->protect_vols) {
+      if (dev->device->set_vol_immutable) {
          /* Set volume as immutable */
          if (!dev->set_immutable(dev->getVolCatName())) {
             /* We may proceed with that but warn the user */
index c003a3360dec6c74daeeeecc5e27f32e10c20299..c4b7314ecbed09efdeccfe2b250be86d904267c0 100644 (file)
@@ -246,10 +246,12 @@ bool DEVICE::truncate(DCR *dcr)
    Dmsg2(100, "Truncate adata=%d fd=%d\n", dev->adata, dev->m_fd);
 
    /* Need to clear the APPEND flag before truncating */
-   if (!clear_append_only(dcr->VolumeName)) {
-      Mmsg2(errmsg, _("Unable to clear append_only flag for volume %s on device %s.\n"),
-            dcr->VolumeName, print_name());
-      return false;
+   if (dev->device->set_vol_append_only) {
+      if (!clear_append_only(dcr->VolumeName)) {
+         Mmsg2(errmsg, _("Unable to clear append_only flag for volume %s on device %s.\n"),
+               dcr->VolumeName, print_name());
+         return false;
+      }
    }
 
    if (ftruncate(dev->m_fd, 0) != 0) {
@@ -556,7 +558,7 @@ void file_dev::get_volume_fpath(const char *vol_name, POOLMEM **fname)
  */
 bool file_dev::check_volume_protection_time(const char *vol_name)
 {
-   if (!device->protect_vols) {
+   if (!device->set_vol_immutable) {
       Dmsg1(DT_VOLUME|50, "ProtectVolumes turned off for volume: %s\n", vol_name);
       return true;
    }
index 479f1eff5d34e95988594c6e4dcc26f7408b7906..9e0bc62a3d2ef82ee65e820cb0165d3b6c3e2056 100644 (file)
@@ -296,10 +296,12 @@ read_volume:
       }
 
       /* Set the append flag on the volume */
-      if (!dev->set_append_only(getVolCatName())) {
-         Jmsg(jcr, M_WARNING, 0, _("Unable to set the APPEND flag on the volume: %s, err: %s\n"),
-              getVolCatName(), dev->bstrerror());
-         goto mount_next_vol;
+      if (dev->device->set_vol_append_only) {
+         if (!dev->set_append_only(getVolCatName())) {
+            Jmsg(jcr, M_WARNING, 0, _("Unable to set the APPEND flag on the volume: %s, err: %s\n"),
+                  getVolCatName(), dev->bstrerror());
+            goto mount_next_vol;
+         }
       }
    } else {
       /*
index 82ea02d9002591cfbf42ba91439791c2a67eb800..011218d0e372f0a4b40390a833e91c730dd0d1d6 100644 (file)
@@ -159,7 +159,8 @@ static RES_ITEM dev_items[] = {
    {"Enabled",               store_bool, ITEM(res_dev.enabled), 0, ITEM_DEFAULT, 1},
    {"AutoSelect",            store_bool, ITEM(res_dev.autoselect), 0, ITEM_DEFAULT, 1},
    {"ReadOnly",              store_bool, ITEM(res_dev.read_only), 0, ITEM_DEFAULT, 0},
-   {"ProtectVolumes",        store_bool, ITEM(res_dev.protect_vols), 0, ITEM_DEFAULT, 0},
+   {"SetVolumeAppendOnly",   store_bool, ITEM(res_dev.set_vol_append_only), 0, ITEM_DEFAULT, 0},
+   {"SetVolumeImmutable",    store_bool, ITEM(res_dev.set_vol_immutable), 0, ITEM_DEFAULT, 0},
    {"MinimumVolumeProtectionTime",    store_time,   ITEM(res_dev.min_volume_protection_time), 0, ITEM_DEFAULT, 30*24*60*60},
    {"ChangerDevice",         store_strname,ITEM(res_dev.changer_name), 0, 0, 0},
    {"ControlDevice",         store_strname,ITEM(res_dev.control_name), 0, 0, 0},
index fff1e285a73d8ca99dd40a1ba640592d42ba6183..c8ce15b1d928cce77a8afda0bb8dfc497bec1f0b 100644 (file)
@@ -223,7 +223,8 @@ public:
    bool enabled;                      /* Set when enabled (default) */
    bool autoselect;                   /* Automatically select from AutoChanger */
    bool read_only;                    /* Drive is read only */
-   bool protect_vols;                 /* Protect Volumes */
+   bool set_vol_append_only;          /* Set 'Append Only' filesystem flag for volumes */
+   bool set_vol_immutable;            /* Set 'Immutable' filesystem flag for volumes */
    utime_t min_volume_protection_time;         /* Minimum Volume Protection Time */
    uint32_t drive_index;              /* Autochanger drive index */
    uint32_t cap_bits;                 /* Capabilities of this device */