]> 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 7626fbb4be59035b4947cc82dd545b257fc02422..61e51fae2a43536f35de9e7d95e410b173eb951d 100644 (file)
@@ -250,8 +250,6 @@ bail_out:
    dequeue_messages(jcr);             /* send any queued messages */
    bs->signal(BNET_TERMINATE);
    free_jcr(jcr);
-   /* ***FIXME*** remove for production */
-   sm_check(__FILE__, __LINE__, true);
    return NULL;
 }
 
@@ -761,6 +759,9 @@ static bool mount_cmd(JCR *jcr)
             } else { /* must be file */
                dir->fsend(_("3906 File device %s is always mounted.\n"),
                   dev->print_name());
+               pthread_cond_broadcast(&dev->wait_next_vol);
+               Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)dcr->jcr->JobId);
+               pthread_cond_broadcast(&wait_device_release);
             }
             break;
 
@@ -879,43 +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());
-
-   /* 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);