]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/getmsg.c
23Aug07
[bacula/bacula] / bacula / src / dird / getmsg.c
index bd5dea6157d35ab0fe3597d0c1c26c8a56d4a2d5..ae4a190bf6dc30f94bc35896a7f479eba16c4666 100644 (file)
@@ -1,3 +1,30 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2000-2007 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.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 /*
  *
  *   Bacula Director -- routines to receive network data and
  *
  *   Version $Id$
  */
-/*
-   Copyright (C) 2000-2006 Kern Sibbald
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as amended with additional clauses defined in the
-   file LICENSE in the main source directory.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
-   the file LICENSE for additional details.
-
- */
 
 #include "bacula.h"
 #include "dird.h"
@@ -49,7 +62,9 @@ static char Device_update[]   = "DevUpd Job=%127s "
    "open=%d labeled=%d offline=%d "
    "reserved=%d max_writers=%d "
    "autoselect=%d autochanger=%d "
-   "changer_name=%127s media_type=%127s volume_name=%127s\n";
+   "changer_name=%127s media_type=%127s volume_name=%127s "
+   "DevReadTime=%d DevWriteTime=%d DevReadBytes=%d "
+   "DevWriteBytes=%d\n";
 #endif
 
 
@@ -91,8 +106,8 @@ int bget_dirmsg(BSOCK *bs)
    char *msg;
 
    for (;;) {
-      n = bnet_recv(bs);
-      Dmsg2(900, "bget_dirmsg %d: %s", n, bs->msg);
+      n = bs->recv();
+      Dmsg2(100, "bget_dirmsg %d: %s", n, bs->msg);
 
       if (is_bnet_stop(bs)) {
          return n;                    /* error or terminate */
@@ -103,13 +118,13 @@ int bget_dirmsg(BSOCK *bs)
          case BNET_EOD:            /* end of data */
             return n;
          case BNET_EOD_POLL:
-            bnet_fsend(bs, OK_msg);/* send response */
+            bs->fsend(OK_msg);/* send response */
             return n;              /* end of data */
          case BNET_TERMINATE:
-            bs->terminated = 1;
+            bs->set_terminated();
             return n;
          case BNET_POLL:
-            bnet_fsend(bs, OK_msg); /* send response */
+            bs->fsend(OK_msg); /* send response */
             break;
          case BNET_HEARTBEAT:
 //          encode_time(time(NULL), Job);
@@ -119,12 +134,12 @@ int bget_dirmsg(BSOCK *bs)
             break;
          case BNET_STATUS:
             /* *****FIXME***** Implement more completely */
-            bnet_fsend(bs, "Status OK\n");
-            bnet_sig(bs, BNET_EOD);
+            bs->fsend("Status OK\n");
+            bs->signal(BNET_EOD);
             break;
          case BNET_BTIME:             /* send Bacula time */
             char ed1[50];
-            bnet_fsend(bs, "btime %s\n", edit_uint64(get_current_btime(),ed1));
+            bs->fsend("btime %s\n", edit_uint64(get_current_btime(),ed1));
             break;
          default:
             Emsg1(M_WARNING, 0, _("bget_dirmsg: unknown bnet signal %d\n"), bs->msglen);
@@ -230,6 +245,7 @@ int bget_dirmsg(BSOCK *bs)
          int dev_open, dev_append, dev_read, dev_labeled;
          int dev_offline, dev_autochanger, dev_autoselect;
          int dev_num_writers, dev_max_writers, dev_reserved;
+         uint64_t dev_read_time, dev_write_time, dev_write_bytes, dev_read_bytes;
          uint64_t dev_PoolId;
          Dmsg1(100, "<stored: %s", bs->msg);
          if (sscanf(bs->msg, Device_update,
@@ -240,7 +256,9 @@ int bget_dirmsg(BSOCK *bs)
              &dev_max_writers, &dev_autoselect, 
              &dev_autochanger, 
              changer_name.c_str(), media_type.c_str(),
-             volume_name.c_str()) != 15) {
+             volume_name.c_str(),
+             &dev_read_time, &dev_write_time, &dev_read_bytes,
+             &dev_write_bytes) != 19) {
             Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
          } else {
             unbash_spaces(dev_name);
@@ -270,6 +288,10 @@ int bget_dirmsg(BSOCK *bs)
             dev->max_writers = dev_max_writers;
             dev->reserved = dev_reserved;
             dev->found = true;
+            dev->DevReadTime = dev_read_time; /* TODO : have to update database */
+            dev->DevWriteTime = dev_write_time;
+            dev->DevReadBytes = dev_read_bytes;
+            dev->DevWriteBytes = dev_write_bytes;
          }
          continue;
       }