]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/btape.c
- Simplify code in askdir.c that waits for creating an appendable
[bacula/bacula] / bacula / src / stored / btape.c
index c957de79a4acd2c1fc00acfea96d699e9e11d791..c4e7d50da22abcedf23fbd1a2a86280501c14096 100644 (file)
@@ -366,7 +366,7 @@ static void labelcmd()
          Pmsg1(0, _("Device open failed. ERR=%s\n"), strerror_dev(dev));
       }
    }
-   rewind_dev(dev);
+   dev->rewind(dcr);
    write_new_volume_label_to_dev(dcr, cmd, "Default");
    Pmsg1(-1, _("Wrote Volume label for volume \"%s\".\n"), cmd);
 }
@@ -431,7 +431,7 @@ static void loadcmd()
  */
 static void rewindcmd()
 {
-   if (!rewind_dev(dev)) {
+   if (!dev->rewind(dcr)) {
       Pmsg1(0, _("Bad status from rewind. ERR=%s\n"), strerror_dev(dev));
       clrerror_dev(dev, -1);
    } else {
@@ -771,7 +771,7 @@ static int write_read_test()
       "This is an *essential* feature ...\n\n"));
    block = dcr->block;
    rec = new_record();
-   if (!rewind_dev(dev)) {
+   if (!dev->rewind(dcr)) {
       Pmsg1(0, _("Bad status from rewind. ERR=%s\n"), strerror_dev(dev));
       goto bail_out;
    }
@@ -813,7 +813,7 @@ static int write_read_test()
    if (dev_cap(dev, CAP_TWOEOF)) {
       weofcmd();
    }
-   if (!rewind_dev(dev)) {
+   if (!dev->rewind(dcr)) {
       Pmsg1(0, _("Bad status from rewind. ERR=%s\n"), strerror_dev(dev));
       goto bail_out;
    } else {
@@ -883,7 +883,7 @@ static int position_test()
       "This is an *essential* feature ...\n\n"));
    empty_block(block);
    rec = new_record();
-   if (!rewind_dev(dev)) {
+   if (!dev->rewind(dcr)) {
       Pmsg1(0, _("Bad status from rewind. ERR=%s\n"), strerror_dev(dev));
       goto bail_out;
    }
@@ -925,7 +925,7 @@ static int position_test()
    if (dev_cap(dev, CAP_TWOEOF)) {
       weofcmd();
    }
-   if (!rewind_dev(dev)) {
+   if (!dev->rewind(dcr)) {
       Pmsg1(0, _("Bad status from rewind. ERR=%s\n"), strerror_dev(dev));
       goto bail_out;
    } else {
@@ -1194,7 +1194,7 @@ try_again:
     * a failure.
     */
    bmicrosleep(sleep_time, 0);
-   if (!rewind_dev(dev) || weof_dev(dev,1) < 0) {
+   if (!dev->rewind(dcr) || weof_dev(dev,1) < 0) {
       Pmsg1(0, _("Bad status from rewind. ERR=%s\n"), strerror_dev(dev));
       clrerror_dev(dev, -1);
       Pmsg0(-1, _("\nThe test failed, probably because you need to put\n"
@@ -1661,6 +1661,7 @@ static void scan_blocks()
    uint64_t bytes;
    DEV_BLOCK *block = dcr->block;
    char ec1[50];
+   char buf1[100], buf2[100];
 
    blocks = block_size = tot_blocks = 0;
    bytes = 0;
@@ -1735,8 +1736,8 @@ static void scan_blocks()
          read_record_from_block(block, rec);
          Pmsg8(-1, _("Blk_block: %u dev_blk=%u blen=%u First rec FI=%s SessId=%u SessTim=%u Strm=%s rlen=%d\n"),
               block->BlockNumber, dev->block_num, block->block_len,
-              FI_to_ascii(rec->FileIndex), rec->VolSessionId, rec->VolSessionTime,
-              stream_to_ascii(rec->Stream, rec->FileIndex), rec->data_len);
+              FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId, rec->VolSessionTime,
+              stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);
          rec->remainder = 0;
          free_record(rec);
       } else if (verbose > 1) {
@@ -1772,6 +1773,7 @@ static void fillcmd()
    DEV_RECORD rec;
    DEV_BLOCK  *block = dcr->block;
    char ec1[50];
+   char buf1[100], buf2[100];
    int fd;
    uint32_t i;
    uint32_t min_block_size;
@@ -1821,7 +1823,7 @@ static void fillcmd()
    dev->min_block_size = dev->max_block_size;
    set_volume_name("TestVolume1", 1);
 
-   if (!dev->rewind()) {
+   if (!dev->rewind(dcr)) {
       Pmsg0(000, _("Rewind failed.\n"));
    }
    if (!dev->weof()) {
@@ -1899,7 +1901,8 @@ static void fillcmd()
       }
 
       Dmsg4(250, "before write_rec FI=%d SessId=%d Strm=%s len=%d\n",
-         rec.FileIndex, rec.VolSessionId, stream_to_ascii(rec.Stream, rec.FileIndex),
+         rec.FileIndex, rec.VolSessionId, 
+         stream_to_ascii(buf1, rec.Stream, rec.FileIndex),
          rec.data_len);
 
       while (!write_record_to_block(block, &rec)) {
@@ -1946,8 +1949,8 @@ static void fillcmd()
       }
       jcr->JobBytes += rec.data_len;   /* increment bytes this job */
       Dmsg4(190, "write_record FI=%s SessId=%d Strm=%s len=%d\n",
-         FI_to_ascii(rec.FileIndex), rec.VolSessionId,
-         stream_to_ascii(rec.Stream, rec.FileIndex), rec.data_len);
+         FI_to_ascii(buf1, rec.FileIndex), rec.VolSessionId,
+         stream_to_ascii(buf2, rec.Stream, rec.FileIndex), rec.data_len);
 
       /* Get out after writing 10 blocks to the second tape */
       if (BlockNumber > 10 && stop != 0) {      /* get out */
@@ -2116,11 +2119,13 @@ static void do_unfill()
     * Note, re-reading last block may have caused us to
     *   loose track of where we are (block number unknown).
     */
-   if (!rewind_dev(dev)) {                /* get to a known place on tape */
+   Pmsg0(-1, _("Rewinding.\n"));
+   if (!dev->rewind(dcr)) {                /* get to a known place on tape */
       goto bail_out;
    }
    /* Read the first 10000 records */
-   Pmsg0(-1, _("Reading the first 10000 records.\n"));
+   Pmsg2(-1, _("Reading the first 10000 records from %u:%u.\n"),
+      dev->file, dev->block_num);
    quickie_count = 0;
    read_records(dcr, quickie_cb, my_mount_next_read_volume);
    Pmsg4(-1, _("Reposition from %u:%u to %u:%u\n"), dev->file, dev->block_num,
@@ -2215,14 +2220,9 @@ bail_out:
 static bool quickie_cb(DCR *dcr, DEV_RECORD *rec)
 {
    DEVICE *dev = dcr->dev;
-   if (dev->file != 0) {
-      Pmsg3(-1, _("ERROR! device at %d:%d count=%d\n"), dev->file, dev->block_num,
-         quickie_count);
-      return false;
-   }
    quickie_count++;
    if (quickie_count == 10000) {
-      Pmsg2(-1, _("1000 records read now at %d:%d\n"), dev->file, dev->block_num);
+      Pmsg2(-1, _("10000 records read now at %d:%d\n"), dev->file, dev->block_num);
    }
    return quickie_count < 10000;
 }