]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/dircmd.c
Fix ActionOnPurge with a relabel command
[bacula/bacula] / bacula / src / stored / dircmd.c
index 400647da13eeffa314b86e41f46edccdad314a0c..61e51fae2a43536f35de9e7d95e410b173eb951d 100644 (file)
@@ -880,44 +880,39 @@ static bool unmount_cmd(JCR *jcr)
  * after purging a volume so that disk space will not be wasted. Only useful
  * for File Storage, of course.
  *
+ *
+ * It is currently disabled
  */
 static bool action_on_purge_cmd(JCR *jcr)
 {
-   POOL_MEM devname;
-   POOL_MEM volumename;
    BSOCK *dir = jcr->dir_bsock;
-   DEVICE *dev;
-   DCR *dcr;
+
+   /* Currently disabled */
+   dir->fsend(_("3916 Feature action_on_purge currently disabled\n"));
+   goto done;
+
+#if 0
+   char devname[MAX_NAME_LENGTH];
+   char volumename[MAX_NAME_LENGTH];
    int action;
 
-   if (sscanf(dir->msg, "action_on_purge %127s vol=%s action=%d",
-              devname.c_str(), volumename.c_str(), &action) != 3) {
+   /* TODO: Need to find a free device and ask for slot to the director */
+   if (sscanf(dir->msg, 
+              "action_on_purge %127s vol=%127s action=%d",
+              devname, volumename, &action)!= 5) 
+   {
       dir->fsend(_("3916 Error scanning action_on_purge command\n"));
       goto done;
    }
-   unbash_spaces(volumename.c_str());
-   unbash_spaces(devname.c_str());
-
-   /* FIXME: autochanger, drive = 0? how can we avoid that? we only work on
-    * files 
-    */
-   if ((dcr = find_device(jcr, devname, 0)) == NULL) {
-      dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
-      goto done;
-   }
-
-   dev = dcr->dev;
+   unbash_spaces(volumename);
+   unbash_spaces(devname);
 
-   /* Store the VolumeName for opening and re-labeling the volume */
-   bstrncpy(dcr->VolumeName, volumename.c_str(), sizeof(dcr->VolumeName));
-   bstrncpy(dev->VolHdr.VolumeName, volumename.c_str(), sizeof(dev->VolHdr.VolumeName));
+   /* Check if action is correct */
+   if (action & AOP_TRUNCTATE) {
 
-   /* Re-write the label with the recycle flag */
-   if (rewrite_volume_label(dcr, true)) {
-      dir->fsend(_("3917 Volume recycled\n"));
-   } else {
-      dir->fsend(_("3918 Recycle failed\n"));
-   }
+   } 
+   /* ... */
+#endif
 
 done:
    dir->signal(BNET_EOD);