]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/dircmd.c
Add address and socket for MySQL
[bacula/bacula] / bacula / src / stored / dircmd.c
index 8e9e01cb64c0fc2cd10467efb77c0932f7af582a..6d8dbf71b92535da6e62b64c08c5a49de92236db 100644 (file)
@@ -19,7 +19,7 @@
  *  
  */
 /*
-   Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+   Copyright (C) 2000-2003 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -69,6 +69,7 @@ static int unmount_cmd(JCR *jcr);
 static int status_cmd(JCR *sjcr);
 static void label_volume_if_ok(JCR *jcr, DEVICE *dev, char *vname, char *poolname, 
                               int Slot);
+static void send_blocked_status(JCR *jcr, DEVICE *dev);
 
 struct s_cmds {
    char *cmd;
@@ -207,16 +208,15 @@ static int cancel_cmd(JCR *cjcr)
       } else {
         P(jcr->mutex);
         oldStatus = jcr->JobStatus;
-        jcr->JobStatus = JS_Cancelled;
-        if (!jcr->authenticated && jcr->JobStatus == JS_WaitFD) {
+        set_jcr_job_status(jcr, JS_Cancelled);
+        if (!jcr->authenticated && oldStatus == JS_WaitFD) {
            pthread_cond_signal(&jcr->job_start_wait); /* wake waiting thread */
         }
         V(jcr->mutex);
         if (jcr->file_bsock) {
            bnet_sig(jcr->file_bsock, BNET_TERMINATE);
         }
-         bnet_fsend(dir, _("3000 Job %s Status=%c marked to be cancelled.\n"), 
-           jcr->Job, oldStatus);
+         bnet_fsend(dir, _("3000 Job %s marked to be cancelled.\n"), jcr->Job);
         free_jcr(jcr);
       }
    } else {
@@ -468,7 +468,8 @@ static int mount_cmd(JCR *jcr)
                   bnet_fsend(dir, _("3001 Device %s is mounted with Volume %s\n"), 
                     dev->dev_name, dev->VolHdr.VolName);
               } else {
-                  bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"), 
+                  bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+                                    "Try unmounting and remounting the Volume.\n"),
                             dev->dev_name);
               }
               break;
@@ -488,7 +489,8 @@ static int mount_cmd(JCR *jcr)
                      bnet_fsend(dir, _("3001 Device %s is mounted with Volume %s\n"),
                        dev->dev_name, dev->VolHdr.VolName);
                  } else {
-                     bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"), 
+                     bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"   
+                                    "Try unmounting and remounting the Volume.\n"),
                                dev->dev_name);
                  }
               } else {
@@ -506,7 +508,8 @@ static int mount_cmd(JCR *jcr)
                      bnet_fsend(dir, _("3001 Device %s is mounted with Volume %s\n"), 
                        dev->dev_name, dev->VolHdr.VolName);
                  } else {
-                     bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"), 
+                     bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+                                       "Try unmounting and remounting the Volume.\n"),
                                dev->dev_name);
                  }
               }
@@ -565,7 +568,7 @@ static int unmount_cmd(JCR *jcr)
         } else if (dev->dev_blocked == BST_WAITING_FOR_SYSOP) {
             Dmsg2(90, "%d waiter dev_block=%d. doing unmount\n", dev->num_waiting,
               dev->dev_blocked);
-           if (dev->capabilities & CAP_OFFLINEUNMOUNT) {
+           if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
               offline_dev(dev);
            }
            force_close_dev(dev);
@@ -594,7 +597,7 @@ static int unmount_cmd(JCR *jcr)
         } else {                     /* device not being used */
             Dmsg0(90, "Device not in use, unmounting\n");
            block_device(dev, BST_UNMOUNTED);
-           if (dev->capabilities & CAP_OFFLINEUNMOUNT) {
+           if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
               offline_dev(dev);
            }
            force_close_dev(dev);
@@ -626,7 +629,7 @@ static int status_cmd(JCR *jcr)
    char dt[MAX_TIME_LENGTH];
    char b1[30], b2[30], b3[30];
 
-   bnet_fsend(user, "\n%s Version: " VERSION " (" DATE ")\n", my_name);
+   bnet_fsend(user, "\n%s Version: " VERSION " (" BDATE ")\n", my_name);
    bstrftime(dt, sizeof(dt), daemon_start_time);
    bnet_fsend(user, _("Daemon started %s, %d Job%s run.\n"), dt, last_job.NumJobs,
         last_job.NumJobs == 1 ? "" : "s");
@@ -645,8 +648,7 @@ static int status_cmd(JCR *jcr)
 
    LockRes();
    for (device=NULL;  (device=(DEVRES *)GetNextRes(R_DEVICE, (RES *)device)); ) {
-      dev = device->dev;
-      if (dev) {
+      for (dev=device->dev; dev; dev=dev->next) {
         if (dev->state & ST_OPENED) {
            if (dev->state & ST_LABEL) {
                bnet_fsend(user, _("Device %s is mounted with Volume %s\n"), 
@@ -654,29 +656,7 @@ static int status_cmd(JCR *jcr)
            } else {
                bnet_fsend(user, _("Device %s open but no Bacula volume is mounted.\n"), dev_name(dev));
            }
-           switch (dev->dev_blocked) {
-              case BST_UNMOUNTED:
-                  bnet_fsend(user, _("    Deviced is blocked. User unmounted.\n"));
-                 break;
-              case BST_UNMOUNTED_WAITING_FOR_SYSOP:
-                  bnet_fsend(user, _("    Deviced is blocked. User unmounted during wait for media/mount.\n"));
-                 break;
-              case BST_WAITING_FOR_SYSOP:
-                 if (jcr->JobStatus == JS_WaitMount) {
-                     bnet_fsend(user, _("    Device is blocked waiting for mount.\n"));
-                 } else {
-                     bnet_fsend(user, _("    Device is blocked waiting for appendable media.\n"));
-                 }
-                 break;
-              case BST_DOING_ACQUIRE:
-                  bnet_fsend(user, _("    Device is being initialized.\n"));
-                 break;
-              case BST_WRITING_LABEL:
-                  bnet_fsend(user, _("    Device is blocked labeling a Volume.\n"));
-                 break;
-              default:
-                 break;
-           }
+           send_blocked_status(jcr, dev);
            bpb = dev->VolCatInfo.VolCatBlocks;
            if (bpb <= 0) {
               bpb = 1;
@@ -692,6 +672,7 @@ static int status_cmd(JCR *jcr)
 
         } else {
             bnet_fsend(user, _("Device %s is not open.\n"), dev_name(dev));
+           send_blocked_status(jcr, dev);
         }
       }
    }
@@ -706,10 +687,11 @@ static int status_cmd(JCR *jcr)
            job_type_to_str(jcr->JobType), jcr->Job);
       }
       if (jcr->device) {
-         bnet_fsend(user, _("%s %s job %s is using device %s\n"), 
+         bnet_fsend(user, _("%s %s job %s is using device %s volume %s\n"), 
                   job_level_to_str(jcr->JobLevel),
                   job_type_to_str(jcr->JobType),
-                  jcr->Job, jcr->device->device_name);
+                  jcr->Job, jcr->device->device_name,
+                  jcr->VolumeName);
         sec = time(NULL) - jcr->run_time;
         if (sec <= 0) {
            sec = 1;
@@ -745,3 +727,32 @@ static int status_cmd(JCR *jcr)
    bnet_sig(user, BNET_EOD);
    return 1;
 }
+
+static void send_blocked_status(JCR *jcr, DEVICE *dev) 
+{
+   BSOCK *user = jcr->dir_bsock;
+
+   switch (dev->dev_blocked) {
+      case BST_UNMOUNTED:
+         bnet_fsend(user, _("    Device is BLOCKED. User unmounted.\n"));
+        break;
+      case BST_UNMOUNTED_WAITING_FOR_SYSOP:
+         bnet_fsend(user, _("    Device is BLOCKED. User unmounted during wait for media/mount.\n"));
+        break;
+      case BST_WAITING_FOR_SYSOP:
+        if (jcr->JobStatus == JS_WaitMount) {
+            bnet_fsend(user, _("    Device is BLOCKED waiting for mount.\n"));
+        } else {
+            bnet_fsend(user, _("    Device is BLOCKED waiting for appendable media.\n"));
+        }
+        break;
+      case BST_DOING_ACQUIRE:
+         bnet_fsend(user, _("    Device is being initialized.\n"));
+        break;
+      case BST_WRITING_LABEL:
+         bnet_fsend(user, _("    Device is blocked labeling a Volume.\n"));
+        break;
+      default:
+        break;
+   }
+}