]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/dircmd.c
kes Fix mtx-changer to detect both versions of Ubuntu (Debian)
[bacula/bacula] / bacula / src / stored / dircmd.c
index cd0153e8f57f8b839841ced014c4f4714d99cfae..ad294bb0627c2d6ba4ed45e8eedb78eaf83a767f 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2001-2008 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.
@@ -54,8 +54,6 @@
 
 /* Imported variables */
 extern BSOCK *filed_chan;
-extern int r_first, r_last;
-extern struct s_res resources[];
 extern struct s_last_job last_job;
 extern bool init_done;
 
@@ -97,7 +95,7 @@ static void send_dir_busy_message(BSOCK *dir, DEVICE *dev);
 struct s_cmds {
    const char *cmd;
    bool (*func)(JCR *jcr);
-   int monitoraccess; /* specify if monitors have access to this function */
+   bool monitoraccess;                      /* set if monitors can access this cmd */
 };
 
 /*
@@ -149,6 +147,7 @@ void *handle_connection_request(void *arg)
    bool found, quit;
    int bnet_stat = 0;
    char name[500];
+   char tbuf[100];
 
    if (bs->recv() <= 0) {
       Emsg0(M_ERROR, 0, _("Connection request failed.\n"));
@@ -174,7 +173,8 @@ void *handle_connection_request(void *arg)
       Dmsg1(000, "<filed: %s", bs->msg);
    }
    if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) {
-      Dmsg0(110, "Got a FD connection\n");
+      Dmsg1(110, "Got a FD connection at %s\n", bstrftimes(tbuf, sizeof(tbuf), 
+            (utime_t)time(NULL)));
       handle_filed_connection(bs, name);
       return NULL;
    }
@@ -182,7 +182,8 @@ void *handle_connection_request(void *arg)
    /* 
     * This is a connection from the Director, so setup a JCR 
     */
-   Dmsg0(110, "Got a DIR connection\n");
+   Dmsg1(110, "Got a DIR connection at %s\n", bstrftimes(tbuf, sizeof(tbuf), 
+         (utime_t)time(NULL)));
    jcr = new_jcr(sizeof(JCR), stored_free_jcr); /* create Job Control Record */
    jcr->dir_bsock = bs;               /* save Director bsock */
    jcr->dir_bsock->set_jcr(jcr);
@@ -190,7 +191,8 @@ void *handle_connection_request(void *arg)
    /* Initialize FD start condition variable */
    int errstat = pthread_cond_init(&jcr->job_start_wait, NULL);
    if (errstat != 0) {
-      Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), strerror(errstat));
+      berrno be;
+      Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(errstat));
       goto bail_out;
    }
 
@@ -275,12 +277,12 @@ static bool setdebug_cmd(JCR *jcr)
 
    Dmsg1(10, "setdebug_cmd: %s", dir->msg);
    if (sscanf(dir->msg, "setdebug=%d trace=%d", &level, &trace_flag) != 2 || level < 0) {
-      bnet_fsend(dir, _("3991 Bad setdebug command: %s\n"), dir->msg);
+      dir->fsend(_("3991 Bad setdebug command: %s\n"), dir->msg);
       return 0;
    }
    debug_level = level;
    set_trace(trace_flag);
-   return bnet_fsend(dir, OKsetdebug, level);
+   return dir->fsend(OKsetdebug, level);
 }
 
 
@@ -296,7 +298,7 @@ static bool cancel_cmd(JCR *cjcr)
 
    if (sscanf(dir->msg, "cancel Job=%127s", Job) == 1) {
       if (!(jcr=get_jcr_by_full_name(Job))) {
-         bnet_fsend(dir, _("3904 Job %s not found.\n"), Job);
+         dir->fsend(_("3904 Job %s not found.\n"), Job);
       } else {
          oldStatus = jcr->JobStatus;
          set_jcr_job_status(jcr, JS_Canceled);
@@ -321,13 +323,13 @@ static bool cancel_cmd(JCR *cjcr)
             pthread_cond_broadcast(&wait_device_release);
          }
          Jmsg(jcr, M_INFO, 0, _("Job %s marked to be canceled.\n"), jcr->Job);
-         bnet_fsend(dir, _("3000 Job %s marked to be canceled.\n"), jcr->Job);
+         dir->fsend(_("3000 Job %s marked to be canceled.\n"), jcr->Job);
          free_jcr(jcr);
       }
    } else {
-      bnet_fsend(dir, _("3903 Error scanning cancel command.\n"));
+      dir->fsend(_("3903 Error scanning cancel command.\n"));
    }
-   bnet_sig(dir, BNET_EOD);
+   dir->signal(BNET_EOD);
    return 1;
 }
 
@@ -384,7 +386,7 @@ static bool do_label(JCR *jcr, int relabel)
       if (dcr) {
          dev = dcr->dev;
          dev->dlock();                 /* Use P to avoid indefinite block */
-         if (!dev->is_open()) {
+         if (!dev->is_open() && !dev->is_busy()) {
             Dmsg1(400, "Can %slabel. Device is not open\n", relabel?"re":"");
             label_volume_if_ok(dcr, oldname, newname, poolname, slot, relabel);
             dev->close();
@@ -401,18 +403,18 @@ static bool do_label(JCR *jcr, int relabel)
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), dev_name.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), dev_name.c_str());
       }
    } else {
       /* NB dir->msg gets clobbered in bnet_fsend, so save command */
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3903 Error scanning label command: %s\n"), jcr->errmsg);
+      dir->fsend(_("3903 Error scanning label command: %s\n"), jcr->errmsg);
    }
    free_memory(oldname);
    free_memory(newname);
    free_memory(poolname);
    free_memory(mtype);
-   bnet_sig(dir, BNET_EOD);
+   dir->signal(BNET_EOD);
    return true;
 }
 
@@ -456,8 +458,8 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
    /* Set old volume name for open if relabeling */
    bstrncpy(dcr->VolCatInfo.VolCatName, volname, sizeof(dcr->VolCatInfo.VolCatName));
    if (dev->open(dcr, mode) < 0) {
-      bnet_fsend(dir, _("3910 Unable to open device %s: ERR=%s\n"),
-         dev->print_name(), dev->strerror());
+      dir->fsend(_("3910 Unable to open device %s: ERR=%s\n"),
+         dev->print_name(), dev->bstrerror());
       goto bail_out;      
    }
 
@@ -472,7 +474,7 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
    case VOL_LABEL_ERROR:
    case VOL_OK:
       if (!relabel) {
-         bnet_fsend(dir, _(
+         dir->fsend(_(
             "3920 Cannot label Volume because it is already labeled: \"%s\"\n"),
              dev->VolHdr.VolumeName);
          break;
@@ -480,11 +482,11 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
 
       /* Relabel request. If oldname matches, continue */
       if (strcmp(oldname, dev->VolHdr.VolumeName) != 0) {
-         bnet_fsend(dir, _("3921 Wrong volume mounted.\n"));
+         dir->fsend(_("3921 Wrong volume mounted.\n"));
          break;
       }
       if (dev->label_type != B_BACULA_LABEL) {
-         bnet_fsend(dir, _("3922 Cannot relabel an ANSI/IBM labeled Volume.\n"));
+         dir->fsend(_("3922 Cannot relabel an ANSI/IBM labeled Volume.\n"));
          break;
       }
       /* Fall through wanted! */
@@ -492,20 +494,20 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
    case VOL_NO_LABEL:
       if (!write_new_volume_label_to_dev(dcr, newname, poolname, 
            relabel, true /* write dvd now */)) {
-         bnet_fsend(dir, _("3912 Failed to label Volume: ERR=%s\n"), dev->bstrerror());
+         dir->fsend(_("3912 Failed to label Volume: ERR=%s\n"), dev->bstrerror());
          break;
       }
       bstrncpy(dcr->VolumeName, newname, sizeof(dcr->VolumeName));
       /* The following 3000 OK label. string is scanned in ua_label.c */
-      bnet_fsend(dir, "3000 OK label. VolBytes=%s DVD=%d Volume=\"%s\" Device=%s\n",
+      dir->fsend("3000 OK label. VolBytes=%s DVD=%d Volume=\"%s\" Device=%s\n",
                  edit_uint64(dev->VolCatInfo.VolCatBytes, ed1),
                  dev->is_dvd()?1:0, newname, dev->print_name());
       break;
    case VOL_NO_MEDIA:
-      bnet_fsend(dir, _("3914 Failed to label Volume (no media): ERR=%s\n"), dev->bstrerror());
+      dir->fsend(_("3914 Failed to label Volume (no media): ERR=%s\n"), dev->bstrerror());
       break;
    default:
-      bnet_fsend(dir, _("3913 Cannot label Volume. "
+      dir->fsend(_("3913 Cannot label Volume. "
 "Unknown status %d from read_volume_label()\n"), label_status);
       break;
    }
@@ -514,6 +516,7 @@ bail_out:
    if (!dev->is_open()) {
       dev->clear_volhdr();
    }
+   volume_unused(dcr);                   /* no longer using volume */
    give_back_device_lock(dev, &hold);
    return;
 }
@@ -538,15 +541,16 @@ static bool read_label(DCR *dcr)
    dev->clear_labeled();              /* force read of label */
    switch (read_dev_volume_label(dcr)) {
    case VOL_OK:
-      bnet_fsend(dir, _("3001 Mounted Volume: %s\n"), dev->VolHdr.VolumeName);
+      dir->fsend(_("3001 Mounted Volume: %s\n"), dev->VolHdr.VolumeName);
       ok = true;
       break;
    default:
-      bnet_fsend(dir, _("3902 Cannot mount Volume on Storage Device %s because:\n%s"),
+      dir->fsend(_("3902 Cannot mount Volume on Storage Device %s because:\n%s"),
          dev->print_name(), jcr->errmsg);
       ok = false;
       break;
    }
+   volume_unused(dcr);
    give_back_device_lock(dev, &hold);
    return ok;
 }
@@ -646,13 +650,14 @@ static bool mount_cmd(JCR *jcr)
       if (dcr) {
          dev = dcr->dev;
          dev->dlock();                 /* Use P to avoid indefinite block */
-         Dmsg1(100, "mount cmd blocked=%d\n", dev->blocked());
+         Dmsg2(100, "mount cmd blocked=%d must_unload=%d\n", dev->blocked(), 
+            dev->must_unload());
          switch (dev->blocked()) {         /* device blocked? */
          case BST_WAITING_FOR_SYSOP:
             /* Someone is waiting, wake him */
             Dmsg0(100, "Waiting for mount. Attempting to wake thread\n");
             dev->set_blocked(BST_MOUNT);
-            bnet_fsend(dir, "3001 OK mount. Device=%s\n", 
+            dir->fsend("3001 OK mount. Device=%s\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);
@@ -667,8 +672,8 @@ static bool mount_cmd(JCR *jcr)
             }
             /* We freed the device, so reopen it and wake any waiting threads */
             if (dev->open(dcr, OPEN_READ_ONLY) < 0) {
-               bnet_fsend(dir, _("3901 open device failed: ERR=%s\n"),
-                  dev->bstrerror());
+               dir->fsend(_("3901 Unable to open device %s: ERR=%s\n"),
+                  dev->print_name(), dev->bstrerror());
                if (dev->blocked() == BST_UNMOUNTED) {
                   /* We blocked the device, so unblock it */
                   Dmsg0(100, "Unmounted. Unblocking device\n");
@@ -687,10 +692,10 @@ static bool mount_cmd(JCR *jcr)
                dev->set_blocked(BST_MOUNT);
             }
             if (dev->is_labeled()) {
-               bnet_fsend(dir, _("3001 Device %s is mounted with Volume \"%s\"\n"),
+               dir->fsend(_("3001 Device %s is mounted with Volume \"%s\"\n"),
                   dev->print_name(), dev->VolHdr.VolumeName);
             } else {
-               bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+               dir->fsend(_("3905 Device %s open but no Bacula volume is mounted.\n"
                                  "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
                           dev->print_name());
             }
@@ -700,12 +705,12 @@ static bool mount_cmd(JCR *jcr)
             break;
 
          case BST_DOING_ACQUIRE:
-            bnet_fsend(dir, _("3001 Device %s is doing acquire.\n"),
+            dir->fsend(_("3001 Device %s is doing acquire.\n"),
                        dev->print_name());
             break;
 
          case BST_WRITING_LABEL:
-            bnet_fsend(dir, _("3903 Device %s is being labeled.\n"), 
+            dir->fsend(_("3903 Device %s is being labeled.\n"), 
                dev->print_name());
             break;
 
@@ -715,55 +720,55 @@ static bool mount_cmd(JCR *jcr)
             }
             if (dev->is_open()) {
                if (dev->is_labeled()) {
-                  bnet_fsend(dir, _("3001 Device %s is mounted with Volume \"%s\"\n"),
+                  dir->fsend(_("3001 Device %s is mounted with Volume \"%s\"\n"),
                      dev->print_name(), dev->VolHdr.VolumeName);
                } else {
-                  bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+                  dir->fsend(_("3905 Device %s open but no Bacula volume is mounted.\n"
                                  "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
                              dev->print_name());
                }
             } else if (dev->is_tape()) {
                if (dev->open(dcr, OPEN_READ_ONLY) < 0) {
-                  bnet_fsend(dir, _("3901 open device failed: ERR=%s\n"),
-                     dev->bstrerror());
+                  dir->fsend(_("3901 Unable to open device %s: ERR=%s\n"),
+                     dev->print_name(), dev->bstrerror());
                   break;
                }
                read_label(dcr);
                if (dev->is_labeled()) {
-                  bnet_fsend(dir, _("3001 Device %s is already mounted with Volume \"%s\"\n"),
+                  dir->fsend(_("3001 Device %s is already mounted with Volume \"%s\"\n"),
                      dev->print_name(), dev->VolHdr.VolumeName);
                } else {
-                  bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+                  dir->fsend(_("3905 Device %s open but no Bacula volume is mounted.\n"
                                     "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
                              dev->print_name());
                }
             } else if (dev->is_unmountable()) {
                if (dev->mount(1)) {
-                  bnet_fsend(dir, _("3002 Device %s is mounted.\n"), 
+                  dir->fsend(_("3002 Device %s is mounted.\n"), 
                      dev->print_name());
                } else {
-                  bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
+                  dir->fsend(_("3907 %s"), dev->bstrerror());
                } 
             } else { /* must be file */
-               bnet_fsend(dir, _("3906 File device %s is always mounted.\n"),
+               dir->fsend(_("3906 File device %s is always mounted.\n"),
                   dev->print_name());
             }
             break;
 
          default:
-            bnet_fsend(dir, _("3905 Bizarre wait state %d\n"), dev->blocked());
+            dir->fsend(_("3905 Bizarre wait state %d\n"), dev->blocked());
             break;
          }
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
       }
    } else {
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3909 Error scanning mount command: %s\n"), jcr->errmsg);
+      dir->fsend(_("3909 Error scanning mount command: %s\n"), jcr->errmsg);
    }
-   bnet_sig(dir, BNET_EOD);
+   dir->signal(BNET_EOD);
    return true;
 }
 
@@ -789,14 +794,14 @@ static bool unmount_cmd(JCR *jcr)
             }
             if (dev->is_unmountable()) {
                if (dev->unmount(0)) {
-                  bnet_fsend(dir, _("3002 Device %s unmounted.\n"), 
+                  dir->fsend(_("3002 Device %s unmounted.\n"), 
                      dev->print_name());
                } else {
-                  bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
+                  dir->fsend(_("3907 %s"), dev->bstrerror());
                } 
             } else {
                Dmsg0(90, "Device already unmounted\n");
-               bnet_fsend(dir, _("3901 Device %s is already unmounted.\n"), 
+               dir->fsend(_("3901 Device %s is already unmounted.\n"), 
                   dev->print_name());
             }
          } else if (dev->blocked() == BST_WAITING_FOR_SYSOP) {
@@ -807,19 +812,19 @@ static bool unmount_cmd(JCR *jcr)
                dev->close();
             }
             if (dev->is_unmountable() && !dev->unmount(0)) {
-               bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
+               dir->fsend(_("3907 %s"), dev->bstrerror());
             } else {
                dev->set_blocked(BST_UNMOUNTED_WAITING_FOR_SYSOP);
-               bnet_fsend(dir, _("3001 Device %s unmounted.\n"), 
+               dir->fsend(_("3001 Device %s unmounted.\n"), 
                   dev->print_name());
             }
 
          } else if (dev->blocked() == BST_DOING_ACQUIRE) {
-            bnet_fsend(dir, _("3902 Device %s is busy in acquire.\n"), 
+            dir->fsend(_("3902 Device %s is busy in acquire.\n"), 
                dev->print_name());
 
          } else if (dev->blocked() == BST_WRITING_LABEL) {
-            bnet_fsend(dir, _("3903 Device %s is being labeled.\n"), 
+            dir->fsend(_("3903 Device %s is being labeled.\n"), 
                dev->print_name());
 
          } else if (dev->is_busy()) {
@@ -838,23 +843,23 @@ static bool unmount_cmd(JCR *jcr)
                dev->close();
             }
             if (dev->is_unmountable() && !dev->unmount(0)) {
-               bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
+               dir->fsend(_("3907 %s"), dev->bstrerror());
             } else {
-               bnet_fsend(dir, _("3002 Device %s unmounted.\n"), 
+               dir->fsend(_("3002 Device %s unmounted.\n"), 
                   dev->print_name());
             }
          }
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
       }
    } else {
       /* NB dir->msg gets clobbered in bnet_fsend, so save command */
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3907 Error scanning unmount command: %s\n"), jcr->errmsg);
+      dir->fsend(_("3907 Error scanning unmount command: %s\n"), jcr->errmsg);
    }
-   bnet_sig(dir, BNET_EOD);
+   dir->signal(BNET_EOD);
    return true;
 }
 
@@ -883,50 +888,49 @@ static bool release_cmd(JCR *jcr)
                unload_autochanger(dcr, -1);
             }
             Dmsg0(90, "Device already released\n");
-            bnet_fsend(dir, _("3921 Device %s already released.\n"), 
+            dir->fsend(_("3921 Device %s already released.\n"), 
                dev->print_name());
 
          } else if (dev->blocked() == BST_WAITING_FOR_SYSOP) {
             Dmsg2(90, "%d waiter dev_block=%d.\n", dev->num_waiting,
                dev->blocked());
             unload_autochanger(dcr, -1);
-            bnet_fsend(dir, _("3922 Device %s waiting for sysop.\n"), 
+            dir->fsend(_("3922 Device %s waiting for sysop.\n"), 
                dev->print_name());
 
          } else if (dev->blocked() == BST_UNMOUNTED_WAITING_FOR_SYSOP) {
             Dmsg2(90, "%d waiter dev_block=%d. doing unmount\n", dev->num_waiting,
                dev->blocked());
-            bnet_fsend(dir, _("3922 Device %s waiting for mount.\n"), 
+            dir->fsend(_("3922 Device %s waiting for mount.\n"), 
                dev->print_name());
 
          } else if (dev->blocked() == BST_DOING_ACQUIRE) {
-            bnet_fsend(dir, _("3923 Device %s is busy in acquire.\n"), 
+            dir->fsend(_("3923 Device %s is busy in acquire.\n"), 
                dev->print_name());
 
          } else if (dev->blocked() == BST_WRITING_LABEL) {
-            bnet_fsend(dir, _("3914 Device %s is being labeled.\n"), 
+            dir->fsend(_("3914 Device %s is being labeled.\n"), 
                dev->print_name());
 
          } else if (dev->is_busy()) {
             send_dir_busy_message(dir, dev);
          } else {                     /* device not being used */
-            Dmsg0(90, "Device not in use, releaseing\n");
-            unload_autochanger(dcr, -1);
-            release_volume(dcr);
-            bnet_fsend(dir, _("3022 Device %s released.\n"), 
+            Dmsg0(90, "Device not in use, releasing\n");
+            dcr->release_volume();
+            dir->fsend(_("3022 Device %s released.\n"), 
                dev->print_name());
          }
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
       }
    } else {
       /* NB dir->msg gets clobbered in bnet_fsend, so save command */
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3927 Error scanning release command: %s\n"), jcr->errmsg);
+      dir->fsend(_("3927 Error scanning release command: %s\n"), jcr->errmsg);
    }
-   bnet_sig(dir, BNET_EOD);
+   dir->signal(BNET_EOD);
    return true;
 }
 
@@ -969,7 +973,7 @@ static bool changer_cmd(JCR *jcr)
          dev = dcr->dev;
          dev->dlock();                 /* Use P to avoid indefinite block */
          if (!dev->device->changer_res) {
-            bnet_fsend(dir, _("3995 Device %s is not an autochanger.\n"), 
+            dir->fsend(_("3995 Device %s is not an autochanger.\n"), 
                dev->print_name());
          /* Under certain "safe" conditions, we can steal the lock */
          } else if (safe_cmd || !dev->is_open() || dev->can_steal_lock()) {
@@ -982,11 +986,11 @@ static bool changer_cmd(JCR *jcr)
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
       }
    } else {  /* error on scanf */
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3908 Error scanning autocharger drives/list/slots command: %s\n"),
+      dir->fsend(_("3908 Error scanning autocharger drives/list/slots command: %s\n"),
          jcr->errmsg);
    }
    dir->signal(BNET_EOD);
@@ -1025,11 +1029,11 @@ static bool readlabel_cmd(JCR *jcr)
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
       }
    } else {
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3909 Error scanning readlabel command: %s\n"), jcr->errmsg);
+      dir->fsend(_("3909 Error scanning readlabel command: %s\n"), jcr->errmsg);
    }
    dir->signal(BNET_EOD);
    return true;
@@ -1057,11 +1061,11 @@ static void read_volume_label(JCR *jcr, DCR *dcr, DEVICE *dev, int Slot)
    switch (read_dev_volume_label(dcr)) {
    case VOL_OK:
       /* DO NOT add quotes around the Volume name. It is scanned in the DIR */
-      bnet_fsend(dir, _("3001 Volume=%s Slot=%d\n"), dev->VolHdr.VolumeName, Slot);
+      dir->fsend(_("3001 Volume=%s Slot=%d\n"), dev->VolHdr.VolumeName, Slot);
       Dmsg1(100, "Volume: %s\n", dev->VolHdr.VolumeName);
       break;
    default:
-      bnet_fsend(dir, _("3902 Cannot mount Volume on Storage Device %s because:\n%s"),
+      dir->fsend(_("3902 Cannot mount Volume on Storage Device %s because:\n%s"),
                  dev->print_name(), jcr->errmsg);
       break;
    }
@@ -1089,35 +1093,35 @@ static void send_dir_busy_message(BSOCK *dir, DEVICE *dev)
    if (dev->is_blocked()) {
       switch (dev->blocked()) {
       case BST_UNMOUNTED:
-         bnet_fsend(dir, _("3931 Device %s is BLOCKED. user unmounted.\n"),
+         dir->fsend(_("3931 Device %s is BLOCKED. user unmounted.\n"),
             dev->print_name());
          break;
       case BST_UNMOUNTED_WAITING_FOR_SYSOP:
-         bnet_fsend(dir, _("3932 Device %s is BLOCKED. user unmounted during wait for media/mount.\n"),
+         dir->fsend(_("3932 Device %s is BLOCKED. user unmounted during wait for media/mount.\n"),
              dev->print_name());
          break;
       case BST_WAITING_FOR_SYSOP:
-         bnet_fsend(dir, _("3933 Device %s is BLOCKED waiting for media.\n"),
+         dir->fsend(_("3933 Device %s is BLOCKED waiting for media.\n"),
             dev->print_name());
          break;
       case BST_DOING_ACQUIRE:
-         bnet_fsend(dir, _("3934 Device %s is being initialized.\n"),
+         dir->fsend(_("3934 Device %s is being initialized.\n"),
             dev->print_name());
          break;
       case BST_WRITING_LABEL:
-         bnet_fsend(dir, _("3935 Device %s is blocked labeling a Volume.\n"),
+         dir->fsend(_("3935 Device %s is blocked labeling a Volume.\n"),
             dev->print_name());
          break;
       default:
-         bnet_fsend(dir, _("3935 Device %s is blocked for unknown reason.\n"),
+         dir->fsend(_("3935 Device %s is blocked for unknown reason.\n"),
             dev->print_name());
          break;
       }
    } else if (dev->can_read()) {
-       bnet_fsend(dir, _("3936 Device %s is busy reading.\n"),
+       dir->fsend(_("3936 Device %s is busy reading.\n"),
                    dev->print_name());;
    } else {
-       bnet_fsend(dir, _("3937 Device %s is busy with %d writer(s).\n"),
+       dir->fsend(_("3937 Device %s is busy with %d writer(s).\n"),
           dev->print_name(), dev->num_writers);
    }
 }