]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/dircmd.c
Rework Mac OS 10.6 mtio.h fix
[bacula/bacula] / bacula / src / stored / dircmd.c
index ff2aa951e7a07670d7140e9e777edfa8b027ac82..e34f9466e93bd9646ed38db3be73b60b86728b62 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2001-2009 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -83,7 +83,7 @@ static bool setdebug_cmd(JCR *jcr);
 static bool cancel_cmd(JCR *cjcr);
 static bool mount_cmd(JCR *jcr);
 static bool unmount_cmd(JCR *jcr);
-static bool truncate_on_purge_cmd(JCR *jcr);
+static bool action_on_purge_cmd(JCR *jcr);
 static bool bootstrap_cmd(JCR *jcr);
 static bool changer_cmd(JCR *sjcr);
 static bool do_label(JCR *jcr, int relabel);
@@ -119,7 +119,7 @@ static struct s_cmds cmds[] = {
    {"status",      status_cmd,      1},
    {".status",     qstatus_cmd,     1},
    {"unmount",     unmount_cmd,     0},
-   {"truncate_on_purge",       truncate_on_purge_cmd,  0},
+   {"action_on_purge",  action_on_purge_cmd,    0},
    {"use storage=", use_cmd,        0},
    {"run",         run_cmd,         0},
 // {"query",       query_cmd,       0},
@@ -250,6 +250,8 @@ 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;
 }
 
@@ -327,7 +329,8 @@ static bool cancel_cmd(JCR *cjcr)
             Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId);
             pthread_cond_broadcast(&wait_device_release);
          }
-         Jmsg(jcr, M_INFO, 0, _("Job %s marked to be canceled.\n"), jcr->Job);
+         Jmsg(jcr, M_INFO, 0, _("JobId=%d Job=\"%s\" marked to be canceled.\n"), 
+            (int)jcr->JobId, jcr->Job);
          dir->fsend(_("3000 Job %s marked to be canceled.\n"), jcr->Job);
          free_jcr(jcr);
       }
@@ -758,6 +761,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;
 
@@ -877,21 +883,25 @@ static bool unmount_cmd(JCR *jcr)
  * for File Storage, of course.
  *
  */
-static bool truncate_on_purge_cmd(JCR *jcr)
+static bool action_on_purge_cmd(JCR *jcr)
 {
    POOL_MEM devname;
    POOL_MEM volumename;
    BSOCK *dir = jcr->dir_bsock;
    DEVICE *dev;
    DCR *dcr;
-   int drive;
+   int action;
 
-   if (sscanf(dir->msg, "truncate_on_purge %127s vol=%s", devname.c_str(), volumename.c_str()) != 2) {
-      dir->fsend(_("3916 Error scanning truncate_on_purge command\n"));
+   if (sscanf(dir->msg, "action_on_purge %127s vol=%s action=%d",
+              devname.c_str(), volumename.c_str(), &action) != 3) {
+      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 */
+   /* 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;
@@ -899,19 +909,16 @@ static bool truncate_on_purge_cmd(JCR *jcr)
 
    dev = dcr->dev;
 
-   if (!dev->truncate_on_purge) {
-      dir->fsend(_("3919 Truncate on purge not enabled, skipping\n"));
-      goto done;
-   }
-
    /* 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));
 
    /* Re-write the label with the recycle flag */
-   if (rewrite_volume_label(dcr, true))
+   if (rewrite_volume_label(dcr, true)) {
       dir->fsend(_("3917 Volume recycled\n"));
-   else dir->fsend(_("3918 Recycle failed\n"));
+   } else {
+      dir->fsend(_("3918 Recycle failed\n"));
+   }
 
 done:
    dir->signal(BNET_EOD);
@@ -1068,7 +1075,10 @@ static bool changer_cmd(JCR *jcr)
     */
    bool safe_cmd = false;
 
-   if (sscanf(dir->msg, "autochanger list %127s", devname.c_str()) == 1) {
+   if (sscanf(dir->msg, "autochanger listall %127s", devname.c_str()) == 1) {
+      cmd = "listall";
+      safe_cmd = ok = true;
+   } else if (sscanf(dir->msg, "autochanger list %127s", devname.c_str()) == 1) {
       cmd = "list";
       safe_cmd = ok = true;
    } else if (sscanf(dir->msg, "autochanger slots %127s", devname.c_str()) == 1) {