]> git.sur5r.net Git - bacula/bacula/commitdiff
Misc see kes-1.34
authorKern Sibbald <kern@sibbald.com>
Sat, 12 Jun 2004 07:51:27 +0000 (07:51 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 12 Jun 2004 07:51:27 +0000 (07:51 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1409 91ce42f0-d328-0410-95d8-f526ca767f89

21 files changed:
bacula/kernstodo
bacula/src/baconfig.h
bacula/src/console/conio.c
bacula/src/dird/bsr.c
bacula/src/dird/dird.c
bacula/src/dird/inc_conf.c
bacula/src/filed/job.c
bacula/src/findlib/create_file.c
bacula/src/lib/cram-md5.c
bacula/src/lib/daemon.c
bacula/src/lib/protos.h
bacula/src/lib/scan.c
bacula/src/stored/acquire.c
bacula/src/stored/askdir.c
bacula/src/stored/dev.h
bacula/src/stored/dircmd.c
bacula/src/stored/job.c
bacula/src/stored/label.c
bacula/src/stored/mount.c
bacula/src/stored/spool.c
bacula/src/version.h

index b67fe879263d3393c9854c2ff66c4057827ed03b..9cc129afae8e7d2183ad65cdaf84f6dc6f9b8211 100644 (file)
@@ -13,6 +13,9 @@
    The error I when I installed 1.34.2 clients:
    The BACULA-FD file is  
    linked to missing export KERNEL32.DLL:GetFileAttributesExA.
+- Mark a non-removable disk Volume in error rather than asking sys op to
+  mount it.
+- Implement Fixed storage LabelFormat test.
 
 Documentation from Christopher Hull on new client job requests:
 ===
@@ -1091,4 +1094,3 @@ Block Position: 0
 - Add regression of btape "fill" 
 ==== Done in 1.34.4
 - Implement "label slots=1,2... pool=yyy barcodes"
-
index 38fea5666fffa11fa368f072dee5f4c24b716a25..0d0c80d11c6d3ff3936a20a85d6ff5032b93bcd5 100644 (file)
 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
 
+/* For multiplying by 10 with shift and addition */
+#define B_TIMES10(d) ((d<<3)+(d<<1))
+
 
 typedef void (HANDLER)();
 typedef int (INTHANDLER)();
@@ -415,6 +418,9 @@ int  m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
 #undef fgets
 #define fgets(x,y,z) bfgets((x), (y), (z))
 
+/* Use our sscanf, which is safer and works with known sizes */
+// #define sscanf bsscanf
+
 #ifdef DEBUG
 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
 #else
index 41127d2705c42fd63c98229e8683761f98ed8ce2..ca8ca4a19b6e5e146c352bb69b9cec0e2b939599 100755 (executable)
@@ -723,9 +723,9 @@ putline(char *newl, int newlen)
        nptr = (struct lstr *)((char *)lptr + newlen + PHDRL);
        /* Appropriate byte alignment - normally 2 byte, but on
          sparc we need 4 byte alignment, so we always do 4 */
-       if (((unsigned)nptr & 3) != 0) { /* test four byte alignment */
+       if (((long unsigned)nptr & 3) != 0) { /* test four byte alignment */
           p = (char *)nptr;
-          nptr = (struct lstr *)((((unsigned) p) & ~3) + 4);
+          nptr = (struct lstr *)((((long unsigned) p) & ~3) + 4);
        }
        nptr->len = lptr->len - ((char *)nptr - (char *)lptr);
        lptr->len -= nptr->len;
index c616b5873653d6f67c125ce6db7fd3da27c81cc5..88f89d162728e96ed2ccddab79b92e6000c4622d 100644 (file)
@@ -112,7 +112,7 @@ static bool is_volume_selected(RBSR_FINDEX *fi,
 
 static void print_findex(UAContext *ua, RBSR_FINDEX *fi)
 {
-   bsendmsg(ua, "fi=0x%x\n", (unsigned)fi);
+   bsendmsg(ua, "fi=0x%lx\n", fi);
    for ( ; fi; fi=fi->next) {
       if (fi->findex == fi->findex2) {
          bsendmsg(ua, "FileIndex=%d\n", fi->findex);
index 2e3843a2b37d040cfc0ce37be3e4aa1b423eba24..326999d84dd3835180c3bad72da3e237f59595ee 100644 (file)
@@ -494,7 +494,7 @@ Without that I don't know who I am :-(\n"), configfile);
                       job->hdr.name, job_items[i].name, *def_svalue, i, offset);
                  svalue = (char **)((char *)job + offset);
                  if (*svalue) {
-                     Dmsg1(000, "Hey something is wrong. p=0x%u\n", (unsigned)*svalue);
+                     Dmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue);
                  }
                  *svalue = bstrdup(*def_svalue);
                  set_bit(i, job->hdr.item_present);
@@ -504,7 +504,7 @@ Without that I don't know who I am :-(\n"), configfile);
                       job->hdr.name, job_items[i].name, i, offset);
                  svalue = (char **)((char *)job + offset);
                  if (*svalue) {
-                     Dmsg1(000, "Hey something is wrong. p=0x%u\n", (unsigned)*svalue);
+                     Dmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue);
                  }
                  *svalue = *def_svalue;
                  set_bit(i, job->hdr.item_present);
index ff76230b9c67792dbf925331eb8d8bcccf32ea8a..1dd970381e1a80c283fd59e9060a01b90a6aecdf 100644 (file)
@@ -77,6 +77,8 @@ static RES_ITEM options_items[] = {
    {"readfifo",        store_opts,    NULL,     0, 0, 0},
    {"replace",         store_opts,    NULL,     0, 0, 0},
    {"portable",        store_opts,    NULL,     0, 0, 0},
+   {"mtimeonly",       store_opts,    NULL,     0, 0, 0},
+   {"keepatime",       store_opts,    NULL,     0, 0, 0},
    {"regex",           store_regex,   NULL,     0, 0, 0},
    {"base",            store_base,    NULL,     0, 0, 0},
    {"wild",            store_wild,    NULL,     0, 0, 0},
index f29491699f901bc4a7c7075c6f094b5e54a3aa55..e095f2b5e772c4f521e8c8a945ee72d2dc855f64 100644 (file)
@@ -612,6 +612,61 @@ static findFOPTS *start_options(FF_PKT *ff)
 
 }
 
+/*
+ * Add fname to include/exclude fileset list. First check for
+ * | and < and if necessary perform command.
+ */
+static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *fileset)
+{
+   char *p;
+   BPIPE *bpipe;
+   POOLMEM *fn;
+   FILE *ffd;
+   char buf[1000];
+   int stat;
+
+   p = (char *)fname;
+   switch (*p) {
+   case '|':
+      p++;                           /* skip over | */
+      fn = get_pool_memory(PM_FNAME);
+      fn = edit_job_codes(jcr, fn, p, "");
+      bpipe = open_bpipe(fn, 0, "r");
+      free_pool_memory(fn);
+      if (!bpipe) {
+         Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
+           p, strerror(errno));
+        return;
+      }
+      while (fgets(buf, sizeof(buf), bpipe->rfd)) {
+        strip_trailing_junk(buf);
+        fileset->incexe->name_list.append(bstrdup(buf));
+      }
+      if ((stat=close_bpipe(bpipe)) != 0) {
+         Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
+           p, stat, strerror(errno));
+        return;
+      }
+      break;
+   case '<':
+      p++;                     /* skip over < */
+      if ((ffd = fopen(p, "r")) == NULL) {
+         Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"),
+           p, strerror(errno));
+        return;
+      }
+      while (fgets(buf, sizeof(buf), ffd)) {
+        strip_trailing_junk(buf);
+        fileset->incexe->name_list.append(bstrdup(buf));
+      }
+      fclose(ffd);
+      break;
+   default:
+      fileset->incexe->name_list.append(bstrdup(fname));
+      break;
+   }
+}
+
    
 static void add_fileset(JCR *jcr, const char *item)
 {
@@ -620,6 +675,7 @@ static void add_fileset(JCR *jcr, const char *item)
    int state = fileset->state;
    findFOPTS *current_opts;
 
+   Dmsg1(100, "%s\n", item);
    int code = item[0];
    if (item[1] == ' ') {              /* If string follows */
       item += 2;                     /* point to string */
@@ -649,9 +705,9 @@ static void add_fileset(JCR *jcr, const char *item)
       state = state_none;
       break;
    case 'F':
-      /* File item */
+      /* File item to either include/include list */
       state = state_include;
-      fileset->incexe->name_list.append(bstrdup(item));
+      add_file_to_fileset(jcr, item, fileset);
       break;
    case 'R':
       current_opts = start_options(ff);
@@ -1043,6 +1099,8 @@ static int storage_cmd(JCR *jcr)
    if (sd == NULL) {
       Jmsg(jcr, M_FATAL, 0, _("Failed to connect to Storage daemon: %s:%d\n"),
          jcr->stored_addr, stored_port);
+      Dmsg2(100, "Failed to connect to Storage daemon: %s:%d\n",
+         jcr->stored_addr, stored_port);
       return 0;
    }
 
index 1455ce11bd5c9ff83377abb3b91d96b4c81884ad..7f06d8bdcdf93b555bb3403c45e7a639494f57d3 100644 (file)
@@ -172,6 +172,7 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
          Dmsg1(50, "Create file: %s\n", attr->ofname);
         if (is_bopen(bfd)) {
             Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
+           bclose(bfd);
         }
         if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) {
             Jmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"), 
index c567e8621b64b1e16a1478e49730225c5db815b1..1be399bba09c2598cd54e0a6b32c5db60e9595a8 100644 (file)
@@ -49,15 +49,15 @@ int cram_md5_auth(BSOCK *bs, char *password, int ssl_need)
       bstrncpy(host, my_name, sizeof(host));
    }
    bsnprintf(chal, sizeof(chal), "<%u.%u@%s>", (uint32_t)random(), (uint32_t)time(NULL), host);
+   Dmsg2(100, "send: auth cram-md5 %s ssl=%d\n", chal, ssl_need);
    if (!bnet_fsend(bs, "auth cram-md5 %s ssl=%d\n", chal, ssl_need)) {
+      Dmsg0(100, "Send challenge error.\n");
       return 0;
    }
 
    if (!bnet_ssl_client(bs, password, ssl_need)) {
       return 0;
    }
-
-   Dmsg1(99, "sent challenge: %s", bs->msg);
    if (bnet_wait_data(bs, 180) <= 0 || bnet_recv(bs) <= 0) {
       bmicrosleep(5, 0);
       return 0;
@@ -65,8 +65,11 @@ int cram_md5_auth(BSOCK *bs, char *password, int ssl_need)
    hmac_md5((uint8_t *)chal, strlen(chal), (uint8_t *)password, strlen(password), hmac);
    bin_to_base64(host, (char *)hmac, 16);
    ok = strcmp(mp_chr(bs->msg), host) == 0;
-   Dmsg3(99, "Authenticate %s: wanted %s, got %s\n", 
-              ok ? "OK" : "NOT OK", host, bs->msg);
+   if (ok) {
+      Dmsg0(99, "Authenticate OK\n");
+   } else {
+      Dmsg2(99, "Authenticate NOT OK: wanted %s, got %s\n", host, bs->msg);
+   }
    if (ok) {
       bnet_fsend(bs, "1000 OK auth\n");
    } else {
@@ -93,11 +96,12 @@ int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need)
       bmicrosleep(5, 0);
       return 0;
    }
-   if (sscanf(mp_chr(bs->msg), "auth cram-md5 %s ssl=%d\n", chal, &ssl_has) != 2) {
+   Dmsg1(100, "cram-get: %s", bs->msg);
+   if (sscanf(bs->msg, "auth cram-md5 %s ssl=%d\n", chal, &ssl_has) != 2) {
       ssl_has = BNET_SSL_NONE;
-      if (sscanf(mp_chr(bs->msg), "auth cram-md5 %s\n", chal) != 1) {
+      if (sscanf(bs->msg, "auth cram-md5 %s\n", chal) != 1) {
+         Dmsg1(100, "Cannot scan challenge: %s", bs->msg);
          bnet_fsend(bs, "1999 Authorization failed.\n");
-         Dmsg1(100, "Cannot scan challenge: %s\n", bs->msg);
         bmicrosleep(5, 0);
         return 0;
       }
index 38b029987c6acfdbed8014cfd5edb2b9bda670da..678a5e07f311aeb84582dea2a8625cd88c06ee8b 100644 (file)
@@ -79,5 +79,23 @@ daemon_start()
    umask(oldmask);
 
    Dmsg0(200, "Exit daemon_start\n");
+
+   /*
+    * Make sure we have fd's 0, 1, 2 open
+    *  If we don't do this one of our sockets may open
+    *  there and if we then use stdout, it could
+    *  send total garbage to our socket.
+    *
+    */
+   int fd;
+   fd = open("/dev/null", O_RDONLY, 0644);
+   if (fd > 2) {
+      close(fd);
+   } else {
+      for(i=1; fd + i <= 2; i++) {
+        dup2(fd, fd+i);
+      }
+   }
+
 #endif /* HAVE_CYGWIN */
 }
index 3fa47ecede307f99c70bdde85957ec1354868305..931659b865cdbd45d87f8f716ea0bbb9c7305341 100644 (file)
@@ -185,6 +185,8 @@ int              parse_args(POOLMEM *cmd, POOLMEM **args, int *argc,
                         char **argk, char **argv, int max_args);
 void            split_path_and_filename(const char *fname, POOLMEM **path, 
                         int *pnl, POOLMEM **file, int *fnl);
+int             bsscanf(const char *buf, const char *fmt, ...);
+
 
 /* util.c */
 int              is_buf_zero             (char *buf, int len);
index c77917b586e2a76a992255211fa01b7882ee1d56..3c42135e2cd0759dcab20bdd24e5162159d41575 100644 (file)
@@ -291,3 +291,196 @@ void split_path_and_filename(const char *fname, POOLMEM **path, int *pnl,
    Dmsg2(200, "pnl=%d fnl=%d\n", *pnl, *fnl);
    Dmsg3(200, "split fname=%s path=%s file=%s\n", fname, *path, *file);
 }
+
+/*
+ * Extremely simple sscanf. Handles only %(u,d,ld,lu,lld,llu,c,nns) 
+ */
+const int BIG = 1000;
+int bsscanf(const char *buf, const char *fmt, ...)
+{
+   va_list ap;
+   int count = 0;
+   void *vp;
+   char *cp;
+   int l = 0;
+   int max_len = BIG;
+   uint64_t value;
+   bool error = false;
+
+   va_start(ap, fmt);
+   while (*fmt && !error) {
+//    Dmsg1(000, "fmt=%c\n", *fmt);
+      if (*fmt == '%') {
+        fmt++;
+//       Dmsg1(000, "Got %% nxt=%c\n", *fmt);
+switch_top:
+        switch (*fmt++) {
+         case 'u':
+         case 'd':
+           value = 0;
+           while (B_ISDIGIT(*buf)) {
+               value = B_TIMES10(value) + *buf++ - '0';
+           }
+           vp = (void *)va_arg(ap, void *);
+//          Dmsg2(000, "val=%lld at 0x%lx\n", value, (long unsigned)vp);
+           if (l < 2) {
+              *((uint32_t *)vp) = (uint32_t)value;
+//             Dmsg0(000, "Store 32 bit int\n");
+           } else {
+              *((uint64_t *)vp) = (uint64_t)value;
+//             Dmsg0(000, "Store 64 bit int\n");
+           }
+           count++;
+           l = 0;
+           break;
+         case 'l':
+//          Dmsg0(000, "got l\n");
+           l = 1;
+            if (*fmt == 'l') {
+              l++;
+              fmt++;
+           }
+            if (*fmt == 'd' || *fmt == 'u') {
+              goto switch_top;
+           }
+//          Dmsg1(000, "fmt=%c !=d,u\n", *fmt);
+           error = true;
+           break;
+         case 'q':
+           l = 2;
+            if (*fmt == 'd' || *fmt == 'u') {
+              goto switch_top;
+           }
+//          Dmsg1(000, "fmt=%c !=d,u\n", *fmt);
+           error = true;
+           break;
+         case 's':
+//          Dmsg1(000, "Store string max_len=%d\n", max_len);
+           cp = (char *)va_arg(ap, char *);
+           while (*buf && !B_ISSPACE(*buf) && max_len-- > 0) {
+              *cp++ = *buf++;
+           }
+           *cp = 0;
+           count++;
+           max_len = BIG;
+           break;
+         case 'c':
+           cp = (char *)va_arg(ap, char *);
+           *cp = *buf++;
+           count++;
+           break;
+         case '%':
+            if (*buf++ != '%') {
+              error = true;
+           }
+           break;
+        default:
+           fmt--;
+           max_len = 0;
+           while (B_ISDIGIT(*fmt)) {
+               max_len = B_TIMES10(max_len) + *fmt++ - '0';
+           }
+//          Dmsg1(000, "Default max_len=%d\n", max_len);
+            if (*fmt == 's') {
+              goto switch_top;
+           }
+//          Dmsg1(000, "Default c=%c\n", *fmt);
+           error = true;
+           break;                    /* error: unknown format */
+        }
+        continue;
+
+      /* White space eats zero or more whitespace */
+      } else if (B_ISSPACE(*fmt)) {
+        fmt++;
+        while (B_ISSPACE(*buf)) {
+           buf++;
+        }
+      /* Plain text must match */
+      } else if (*buf++ != *fmt++) {
+//       Dmsg2(000, "Mismatch buf=%c fmt=%c\n", *--buf, *--fmt);
+        error = true;
+      }
+   }
+   va_end(ap);
+// Dmsg2(000, "Error=%d count=%d\n", error, count);
+   if (error) {
+      count = -1;
+   }
+   return count;
+}
+
+#ifdef TEST_PROGRAM
+int main(int argc, char *argv[])
+{
+   char buf[100];
+   uint32_t val32;
+   uint64_t val64;
+   uint32_t FirstIndex, LastIndex, StartFile, EndFile, StartBlock, EndBlock;
+   char Job[200];
+   int cnt;
+   char *helloreq= "Hello *UserAgent* calling\n";
+   char *hello = "Hello %127s calling\n";
+   char *catreq = 
+"CatReq Job=NightlySave.2004-06-11_19.11.32 CreateJobMedia FirstIndex=1 LastIndex=114 StartFile=0 EndFile=0 StartBlock=208 EndBlock=2903248";
+static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia "
+  "FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u "
+  "StartBlock=%u EndBlock=%u\n";
+static char OK_media[] = "1000 OK VolName=%127s VolJobs=%u VolFiles=%u"
+   " VolBlocks=%u VolBytes=%" lld " VolMounts=%u VolErrors=%u VolWrites=%u"
+   " MaxVolBytes=%" lld " VolCapacityBytes=%" lld " VolStatus=%20s"
+   " Slot=%d MaxVolJobs=%u MaxVolFiles=%u InChanger=%d"
+   " VolReadTime=%" lld " VolWriteTime=%" lld;
+   char *media =
+"1000 OK VolName=TestVolume001 VolJobs=0 VolFiles=0 VolBlocks=0 VolBytes=1 VolMounts=0 VolErrors=0 VolWrites=0 MaxVolBytes=0 VolCapacityBytes=0 VolStatus=Append Slot=0 MaxVolJobs=0 MaxVolFiles=0 InChanger=1 VolReadTime=0 VolWriteTime=0";
+struct VOLUME_CAT_INFO {
+   /* Media info for the current Volume */
+   uint32_t VolCatJobs;              /* number of jobs on this Volume */
+   uint32_t VolCatFiles;             /* Number of files */
+   uint32_t VolCatBlocks;            /* Number of blocks */
+   uint64_t VolCatBytes;             /* Number of bytes written */
+   uint32_t VolCatMounts;            /* Number of mounts this volume */
+   uint32_t VolCatErrors;            /* Number of errors this volume */
+   uint32_t VolCatWrites;            /* Number of writes this volume */
+   uint32_t VolCatReads;             /* Number of reads this volume */
+   uint64_t VolCatRBytes;            /* Number of bytes read */
+   uint32_t VolCatRecycles;          /* Number of recycles this volume */
+   int32_t  Slot;                    /* Slot in changer */
+   bool     InChanger;               /* Set if vol in current magazine */
+   uint32_t VolCatMaxJobs;           /* Maximum Jobs to write to volume */
+   uint32_t VolCatMaxFiles;          /* Maximum files to write to volume */
+   uint64_t VolCatMaxBytes;          /* Max bytes to write to volume */
+   uint64_t VolCatCapacityBytes;      /* capacity estimate */
+   uint64_t VolReadTime;             /* time spent reading */
+   uint64_t VolWriteTime;            /* time spent writing this Volume */
+   char VolCatStatus[20];            /* Volume status */
+   char VolCatName[MAX_NAME_LENGTH];  /* Desired volume to mount */
+};               
+   struct VOLUME_CAT_INFO vol;
+
+#ifdef xxx
+   bsscanf("Hello_world 123 1234", "%120s %ld %lld", buf, &val32, &val64);
+   printf("%s %d %lld\n", buf, val32, val64);
+
+   *Job=0;
+   cnt = bsscanf(catreq, Create_job_media, &Job,
+      &FirstIndex, &LastIndex, &StartFile, &EndFile,
+      &StartBlock, &EndBlock);
+   printf("cnt=%d Job=%s\n", cnt, Job);
+   cnt = bsscanf(helloreq, hello, &Job);
+   printf("cnt=%d Agent=%s\n", cnt, Job);
+#endif
+   cnt = bsscanf(media, OK_media,
+              vol.VolCatName,
+              &vol.VolCatJobs, &vol.VolCatFiles,
+              &vol.VolCatBlocks, &vol.VolCatBytes,
+              &vol.VolCatMounts, &vol.VolCatErrors,
+              &vol.VolCatWrites, &vol.VolCatMaxBytes,
+              &vol.VolCatCapacityBytes, vol.VolCatStatus,
+              &vol.Slot, &vol.VolCatMaxJobs, &vol.VolCatMaxFiles,
+              &vol.InChanger, &vol.VolReadTime, &vol.VolWriteTime);
+   printf("cnt=%d Vol=%s\n", cnt, vol.VolCatName);
+
+}
+
+#endif
index 80e6ce3af8392d0b784ee25f0dc152c0eb4a079d..843490575a387d08ab57dec08ac80948558b6495 100644 (file)
@@ -78,7 +78,7 @@ DCR *acquire_device_for_read(JCR *jcr)
    bool tape_previously_mounted;
    bool tape_initially_mounted;
    VOL_LIST *vol;
-   int autochanger = 0;
+   bool try_autochanger = true;
    int i;
    DCR *dcr = jcr->dcr;
    DEVICE *dev;
@@ -175,13 +175,13 @@ default_path:
             Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg);
         }
         /* Call autochanger only once unless ask_sysop called */
-        if (!autochanger) {
+        if (try_autochanger) {
            int stat;
             Dmsg2(200, "calling autoload Vol=%s Slot=%d\n",
               jcr->VolumeName, jcr->VolCatInfo.Slot);                         
            stat = autoload_device(jcr, dev, 0, NULL);
            if (stat > 0) {
-              autochanger = 1;
+              try_autochanger = false;
               continue;
            }
         }
@@ -190,7 +190,7 @@ default_path:
         if (!dir_ask_sysop_to_mount_volume(jcr, dev)) {
            goto get_out;             /* error return */
         }
-        autochanger = 0;             /* permit using autochanger again */
+        try_autochanger = true;      /* permit using autochanger again */
         continue;                    /* try reading again */
       } /* end switch */
       break;
index 469d605510ce136196cbf9266cd1b51de77d5d4b..926e0db90c03d6f89ed8eae54cc1f730c0cc58a3 100644 (file)
@@ -79,6 +79,7 @@ static int do_get_volume_info(JCR *jcr)
     DCR *dcr = jcr->dcr;
     VOLUME_CAT_INFO vol;
     int n;
+    int InChanger;
 
     jcr->VolumeName[0] = 0;          /* No volume */
     dcr->VolumeName[0] = 0;          /* No volume */
@@ -96,12 +97,13 @@ static int do_get_volume_info(JCR *jcr)
               &vol.VolCatWrites, &vol.VolCatMaxBytes,
               &vol.VolCatCapacityBytes, vol.VolCatStatus,
               &vol.Slot, &vol.VolCatMaxJobs, &vol.VolCatMaxFiles,
-              &vol.InChanger, &vol.VolReadTime, &vol.VolWriteTime);
+              &InChanger, &vol.VolReadTime, &vol.VolWriteTime);
     if (n != 17) {
        Dmsg2(100, "Bad response from Dir fields=%d: %s\n", n, dir->msg);
        Mmsg(&jcr->errmsg, _("Error getting Volume info: %s\n"), dir->msg);
        return 0;
     }
+    vol.InChanger = InChanger;       /* bool in structure */
     unbash_spaces(vol.VolCatName);
     pm_strcpy(&jcr->VolumeName, vol.VolCatName); /* set desired VolumeName */
     bstrncpy(dcr->VolumeName, vol.VolCatName, sizeof(dcr->VolumeName));
@@ -195,7 +197,8 @@ int dir_find_next_appendable_volume(JCR *jcr)
     
 /*
  * After writing a Volume, send the updated statistics
- * back to the director.
+ * back to the director. The information comes from the
+ * dev record.    
  */
 int dir_update_volume_info(JCR *jcr, DEVICE *dev, int label)
 {
@@ -203,6 +206,7 @@ int dir_update_volume_info(JCR *jcr, DEVICE *dev, int label)
    time_t LastWritten = time(NULL);
    char ed1[50], ed2[50], ed3[50], ed4[50];
    VOLUME_CAT_INFO *vol = &dev->VolCatInfo;
+   int InChanger;
 
    if (vol->VolCatName[0] == 0) {
       Jmsg0(jcr, M_ERROR, 0, _("NULL Volume name. This shouldn't happen!!!\n"));
@@ -224,13 +228,14 @@ int dir_update_volume_info(JCR *jcr, DEVICE *dev, int label)
       vol->VolCatBytes = 1;          /* indicates tape labeled */
    }
    bash_spaces(vol->VolCatName);
+   InChanger = vol->InChanger;
    bnet_fsend(dir, Update_media, jcr->Job, 
       vol->VolCatName, vol->VolCatJobs, vol->VolCatFiles,
       vol->VolCatBlocks, edit_uint64(vol->VolCatBytes, ed1),
       vol->VolCatMounts, vol->VolCatErrors,
       vol->VolCatWrites, edit_uint64(vol->VolCatMaxBytes, ed2), 
       LastWritten, vol->VolCatStatus, vol->Slot, label,
-      vol->InChanger,
+      InChanger,                     /* bool in structure */
       edit_uint64(vol->VolReadTime, ed3), 
       edit_uint64(vol->VolWriteTime, ed4) );
 
@@ -468,6 +473,7 @@ int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev)
         return 0;
       }
 
+#ifdef needed
       /*
        * If we have a valid volume name and we are not
        *   removable media, return now, or if we have a
@@ -478,6 +484,7 @@ int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev)
          Dmsg0(100, "Return 1 from mount without wait.\n");
         return 1;
       }
+#endif
 
       if (!dev->poll) {
          msg = _("Please mount");
index e7dbf04a26aa9937969a4edd51117c2665fe6dde..0d318bc1b3f5ab89eb54ab7c23f36d265072ae8d 100644 (file)
@@ -241,8 +241,8 @@ struct DCR {
    uint32_t StartFile;                /* Start write file */
    uint32_t StartBlock;               /* Start write block */
    uint32_t EndBlock;                 /* Ending block written */
-   uint64_t spool_size;               /* Current spool size */
-   uint64_t max_spool_size;           /* Max job spool size */
+   int64_t spool_size;                /* Current spool size */
+   int64_t max_spool_size;            /* Max job spool size */
    char VolumeName[MAX_NAME_LENGTH];  /* Volume name */
    VOLUME_CAT_INFO VolCatInfo;        /* Catalog info for desired volume */
 };
index 574e9d89ec4688ee7d04e0844f5901a90b36c365..241855ef554c44b788f1ec0914805128aa9c5ad2 100644 (file)
@@ -142,11 +142,13 @@ void *connection_request(void *arg)
     * See if this is a File daemon connection. If so
     *  call FD handler.
     */
-   if (sscanf(bs->msg, "Hello Start Job %127s calling\n", name) == 1) {
+   Dmsg1(110, "Conn: %s", bs->msg);
+   if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) {
       handle_filed_connection(bs, name);
       return NULL;
    }
    
+   Dmsg0(110, "Start Dir Job\n");
    jcr = new_jcr(sizeof(JCR), stored_free_jcr);     /* create Job Control Record */
    jcr->dir_bsock = bs;              /* save Director bsock */
    jcr->dir_bsock->jcr = jcr;
index c04c3d3b13870afb0a5aead7612d2fcbd33f0fa3..9451ea3735579ba65e900f336b17b324cc7fed95 100644 (file)
@@ -139,7 +139,7 @@ int job_cmd(JCR *jcr)
       set_jcr_job_status(jcr, JS_ErrorTerminated);
       return 0;
    }
-   jcr->authenticated = FALSE;
+   jcr->authenticated = false;
 
    /*
     * Pass back an authorization key for the File daemon
@@ -202,6 +202,7 @@ void handle_filed_connection(BSOCK *fd, char *job_name)
    bmicrosleep(0, 50000);            /* wait 50 millisecs */
    if (!(jcr=get_jcr_by_full_name(job_name))) {
       Jmsg1(NULL, M_FATAL, 0, _("Job name not found: %s\n"), job_name);
+      Dmsg1(100, "Job name not found: %s\n", job_name);
       return;
    }
 
index db0ce2351854def1695e320f204689eaa4d329a5..5e0a9b9109132917a1062f15b5af65b249c497ae 100644 (file)
@@ -96,12 +96,13 @@ int read_dev_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
    record = new_record();
    Dmsg0(90, "Big if statement in read_volume_label\n");
    if (!read_block_from_dev(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) { 
-      Mmsg(&jcr->errmsg, _("Volume on %s is not a Bacula labeled Volume, \
-because:\n   %s"), dev_name(dev), strerror_dev(dev));
+      Mmsg(&jcr->errmsg, _("Requested Volume \"%s\" on %s is not a Bacula "
+           "labeled Volume, because: ERR=%s"), NPRT(VolName), dev_name(dev), 
+          strerror_dev(dev));
    } else if (!read_record_from_block(block, record)) {
       Mmsg(&jcr->errmsg, _("Could not read Volume label from block.\n"));
    } else if (!unser_volume_label(dev, record)) {
-      Mmsg(&jcr->errmsg, _("Could not unserialize Volume label: %s\n"),
+      Mmsg(&jcr->errmsg, _("Could not unserialize Volume label: ERR=%s\n"),
         strerror_dev(dev));
    } else if (strcmp(dev->VolHdr.Id, BaculaId) != 0 && 
              strcmp(dev->VolHdr.Id, OldBaculaId) != 0) {
index 5d411b743e5468061f6e0568bf67269192046adf..de9d151826356fc0f0dbb2f8cb7899a9c5740b86 100644 (file)
@@ -129,6 +129,10 @@ mount_next_vol:
    if (!release && dev_is_tape(dev) && dev_cap(dev, CAP_AUTOMOUNT)) {
       ask = false;                 /* don't ask SYSOP this time */
    }
+   /* Don't ask if not removable */
+   if (!dev_cap(dev, CAP_REM)) {
+      ask = false;
+   }
    Dmsg2(100, "Ask=%d autochanger=%d\n", ask, autochanger);
    release = true;                /* release next time if we "recurse" */
 
@@ -181,6 +185,17 @@ read_volume:
    case VOL_NAME_ERROR:
       VOLUME_CAT_INFO VolCatInfo;
 
+      /* If not removable, Volume is broken */
+      if (!dev_cap(dev, CAP_REM)) {
+         bstrncpy(jcr->VolCatInfo.VolCatStatus, "Error",
+           sizeof(jcr->VolCatInfo.VolCatStatus));
+        memcpy(&dev->VolCatInfo, &jcr->VolCatInfo, sizeof(dev->VolCatInfo));
+        dir_update_volume_info(jcr, dev, 1);  /* indicate tape labeled */
+         Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s. Volume marked in error.\n"),
+           jcr->VolumeName, dev_name(dev));
+        goto mount_next_vol;
+      }
+        
       Dmsg1(100, "Vol NAME Error Name=%s\n", jcr->VolumeName);
       /* If polling and got a previous bad name, ignore it */
       if (dev->poll && strcmp(dev->BadVolName, dev->VolHdr.VolName) == 0) {
@@ -247,6 +262,16 @@ read_volume:
            jcr->VolumeName, dev_name(dev));
         goto read_volume;      /* read label we just wrote */
       } 
+      /* If not removable, Volume is broken */
+      if (!dev_cap(dev, CAP_REM)) {
+         bstrncpy(jcr->VolCatInfo.VolCatStatus, "Error",
+           sizeof(jcr->VolCatInfo.VolCatStatus));
+        memcpy(&dev->VolCatInfo, &jcr->VolCatInfo, sizeof(dev->VolCatInfo));
+        dir_update_volume_info(jcr, dev, 1);  /* indicate tape labeled */
+         Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s. Volume marked in error.\n"),
+           jcr->VolumeName, dev_name(dev));
+        goto mount_next_vol;
+      }
       /* NOTE! Fall-through wanted. */
    case VOL_NO_MEDIA:
    default:
index 80f16f808d3cba6b6f031ed9bb068355b01b1785..ddc449acdebad3b13878e924a2c1994ace717bed 100644 (file)
@@ -42,9 +42,9 @@ struct spool_stats_t {
    uint32_t attr_jobs;               
    uint32_t total_data_jobs;         /* total jobs to have spooled data */
    uint32_t total_attr_jobs;
-   uint64_t max_data_size;           /* max data size */
-   uint64_t max_attr_size;
-   uint64_t data_size;               /* current data size (all jobs running) */
+   int64_t max_data_size;            /* max data size */
+   int64_t max_attr_size;
+   int64_t data_size;                /* current data size (all jobs running) */
    int64_t attr_size;
 };
 
index a27bd1a7f92f3fcc473be9a4a8f615b2fbb54413..43844756f3032d442727e951078c911324aa86a8 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.34.4"
 #define VSTRING "1"
-#define BDATE   "09 June 2004"
-#define LSMDATE "09Jun04"
+#define BDATE   "12 June 2004"
+#define LSMDATE "12Jun04"
 
 /* Debug flags */
 #undef  DEBUG