3 * Bacula Tape manipulation program
5 * Has various tape manipulation commands -- mostly for
6 * use in determining how tapes really work.
8 * Kern Sibbald, April MM
10 * Note, this program reads stored.conf, and will only
11 * talk to devices that are configured.
17 Copyright (C) 2000-2003 Kern Sibbald and John Walker
19 This program is free software; you can redistribute it and/or
20 modify it under the terms of the GNU General Public License as
21 published by the Free Software Foundation; either version 2 of
22 the License, or (at your option) any later version.
24 This program is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 General Public License for more details.
29 You should have received a copy of the GNU General Public
30 License along with this program; if not, write to the Free
31 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
40 /* External subroutines */
41 extern void free_config_resources();
43 /* Exported variables */
46 int bsize = TAPE_BSIZE;
47 char VolName[MAX_NAME_LENGTH];
50 DEVRES *device = NULL;
53 /* Forward referenced subroutines */
54 static void do_tape_cmds();
55 static void helpcmd();
56 static void scancmd();
57 static void rewindcmd();
58 static void clearcmd();
62 static void fillcmd();
63 static void qfillcmd();
64 static void statcmd();
65 static void unfillcmd();
66 static int flush_block(DEV_BLOCK *block, int dump);
67 static int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
68 static int my_mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
69 static void scan_blocks();
70 static void set_volume_name(char *VolName, int volnum);
71 static void rawfill_cmd();
72 static void bfill_cmd();
75 /* Static variables */
76 #define CONFIG_FILE "bacula-sd.conf"
79 static BSR *bsr = NULL;
80 static char cmd[1000];
81 static int signals = TRUE;
84 static uint64_t vol_size;
85 static uint64_t VolBytes;
88 static int32_t file_index;
89 static int end_of_tape = 0;
90 static uint32_t LastBlock = 0;
91 static uint32_t eot_block;
92 static uint32_t eot_block_len;
93 static uint32_t eot_FileIndex;
94 static int dumped = 0;
95 static DEV_BLOCK *last_block = NULL;
96 static DEV_BLOCK *this_block = NULL;
97 static uint32_t last_file = 0;
98 static uint32_t last_block_num = 0;
99 static uint32_t BlockNumber = 0;
100 static int simple = FALSE;
102 static char *VolumeName = NULL;
105 static JCR *jcr = NULL;
109 static void terminate_btape(int sig);
110 int get_cmd(char *prompt);
113 /*********************************************************************
115 * Main Bacula Pool Creation Program
118 int main(int argc, char *argv[])
124 if (TAPE_BSIZE % DEV_BSIZE != 0 || TAPE_BSIZE / DEV_BSIZE == 0) {
125 Emsg2(M_ABORT, 0, "Tape block size (%d) not multiple of system size (%d)\n",
126 TAPE_BSIZE, DEV_BSIZE);
128 if (TAPE_BSIZE != (1 << (ffs(TAPE_BSIZE)-1))) {
129 Emsg1(M_ABORT, 0, "Tape block size (%d) is not a power of 2\n", TAPE_BSIZE);
132 printf("Tape block granularity is %d bytes.\n", TAPE_BSIZE);
134 working_directory = "/tmp";
135 my_name_is(argc, argv, "btape");
136 init_msg(NULL, NULL);
138 while ((ch = getopt(argc, argv, "b:c:d:sv?")) != -1) {
140 case 'b': /* bootstrap file */
141 bsr = parse_bsr(NULL, optarg);
142 // dump_bsr(bsr, true);
145 case 'c': /* specify config file */
146 if (configfile != NULL) {
149 configfile = bstrdup(optarg);
152 case 'd': /* set debug level */
153 debug_level = atoi(optarg);
154 if (debug_level <= 0) {
180 init_signals(terminate_btape);
183 if (configfile == NULL) {
184 configfile = bstrdup(CONFIG_FILE);
187 daemon_start_time = time(NULL);
189 parse_config(configfile);
192 /* See if we can open a device */
194 Pmsg0(000, "No archive name specified.\n");
197 } else if (argc != 1) {
198 Pmsg0(000, "Improper number of arguments specified.\n");
203 jcr = setup_jcr("btape", argv[0], bsr, NULL);
204 dev = setup_to_access_device(jcr, 0); /* acquire for write */
208 block = new_block(dev);
210 if (!(dev->state & ST_OPENED)) {
211 Dmsg0(129, "Opening device.\n");
212 if (open_dev(dev, jcr->VolumeName, READ_WRITE) < 0) {
213 Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
219 Dmsg1(129, "open_dev %s OK\n", dev_name(dev));
223 Dmsg0(200, "Do tape commands\n");
231 static void terminate_btape(int stat)
234 sm_check(__FILE__, __LINE__, False);
238 free_config_resources();
244 if (debug_level > 10)
245 print_memory_pool_stats();
255 free_block(last_block);
258 free_block(this_block);
262 close_memory_pool(); /* free memory in pool */
274 * Write a label to the tape
276 static void labelcmd()
282 for (device=NULL; (device=(DEVRES *)GetNextRes(R_DEVICE, (RES *)device)); ) {
283 if (strcmp(device->device_name, dev->dev_name) == 0) {
284 jcr->device = device; /* Arggg a bit of duplication here */
286 dev->device = device;
293 Pmsg2(0, "Could not find device %s in %s\n", dev->dev_name, configfile);
298 strcpy(cmd, VolumeName);
300 if (!get_cmd("Enter Volume Name: ")) {
305 if (!(dev->state & ST_OPENED)) {
306 if (!open_device(dev)) {
307 Pmsg1(0, "Device open failed. ERR=%s\n", strerror_dev(dev));
310 write_volume_label_to_dev(jcr, device, cmd, "Default");
314 * Read the tape label
316 static void readlabelcmd()
318 int save_debug_level = debug_level;
322 block = new_block(dev);
323 stat = read_dev_volume_label(jcr, dev, block);
326 Pmsg0(0, "Volume has no label.\n");
329 Pmsg0(0, "Volume label read correctly.\n");
332 Pmsg1(0, "I/O error on device: ERR=%s", strerror_dev(dev));
335 Pmsg0(0, "Volume name error\n");
337 case VOL_CREATE_ERROR:
338 Pmsg1(0, "Error creating label. ERR=%s", strerror_dev(dev));
340 case VOL_VERSION_ERROR:
341 Pmsg0(0, "Volume version error.\n");
343 case VOL_LABEL_ERROR:
344 Pmsg0(0, "Bad Volume label type.\n");
347 Pmsg0(0, "Unknown error.\n");
352 dump_volume_label(dev);
353 debug_level = save_debug_level;
359 * Load the tape should have prevously been taken
360 * off line, otherwise this command is not necessary.
362 static void loadcmd()
365 if (!load_dev(dev)) {
366 Pmsg1(0, "Bad status from load. ERR=%s\n", strerror_dev(dev));
368 Pmsg1(0, "Loaded %s\n", dev_name(dev));
374 static void rewindcmd()
376 if (!rewind_dev(dev)) {
377 Pmsg1(0, "Bad status from rewind. ERR=%s\n", strerror_dev(dev));
378 clrerror_dev(dev, -1);
380 Pmsg1(0, "Rewound %s\n", dev_name(dev));
385 * Clear any tape error
387 static void clearcmd()
389 clrerror_dev(dev, -1);
393 * Write and end of file on the tape
395 static void weofcmd()
399 if ((stat = weof_dev(dev, 1)) < 0) {
400 Pmsg2(0, "Bad status from weof %d. ERR=%s\n", stat, strerror_dev(dev));
403 Pmsg1(0, "Wrote EOF to %s\n", dev_name(dev));
408 /* Go to the end of the medium -- raw command
409 * The idea was orginally that the end of the Bacula
410 * medium would be flagged differently. This is not
411 * currently the case. So, this is identical to the
417 Pmsg1(0, "%s", strerror_dev(dev));
420 Pmsg0(0, _("Moved to end of medium.\n"));
425 * Go to the end of the medium (either hardware determined
426 * or defined by two eofs.
439 if (!bsf_dev(dev, 1)) {
440 Pmsg1(0, _("Bad status from bsf. ERR=%s\n"), strerror_dev(dev));
442 Pmsg0(0, _("Backspaced one file.\n"));
451 if (!bsr_dev(dev, 1)) {
452 Pmsg1(0, _("Bad status from bsr. ERR=%s\n"), strerror_dev(dev));
454 Pmsg0(0, _("Backspaced one record.\n"));
459 * List device capabilities as defined in the
464 printf(_("Configured device capabilities:\n"));
465 printf("%sEOF ", dev->capabilities & CAP_EOF ? "" : "!");
466 printf("%sBSR ", dev->capabilities & CAP_BSR ? "" : "!");
467 printf("%sBSF ", dev->capabilities & CAP_BSF ? "" : "!");
468 printf("%sFSR ", dev->capabilities & CAP_FSR ? "" : "!");
469 printf("%sFSF ", dev->capabilities & CAP_FSF ? "" : "!");
470 printf("%sEOM ", dev->capabilities & CAP_EOM ? "" : "!");
471 printf("%sREM ", dev->capabilities & CAP_REM ? "" : "!");
472 printf("%sRACCESS ", dev->capabilities & CAP_RACCESS ? "" : "!");
473 printf("%sAUTOMOUNT ", dev->capabilities & CAP_AUTOMOUNT ? "" : "!");
474 printf("%sLABEL ", dev->capabilities & CAP_LABEL ? "" : "!");
475 printf("%sANONVOLS ", dev->capabilities & CAP_ANONVOLS ? "" : "!");
476 printf("%sALWAYSOPEN ", dev->capabilities & CAP_ALWAYSOPEN ? "" : "!");
479 printf(_("Device status:\n"));
480 printf("%sOPENED ", dev->state & ST_OPENED ? "" : "!");
481 printf("%sTAPE ", dev->state & ST_TAPE ? "" : "!");
482 printf("%sLABEL ", dev->state & ST_LABEL ? "" : "!");
483 printf("%sMALLOC ", dev->state & ST_MALLOC ? "" : "!");
484 printf("%sAPPEND ", dev->state & ST_APPEND ? "" : "!");
485 printf("%sREAD ", dev->state & ST_READ ? "" : "!");
486 printf("%sEOT ", dev->state & ST_EOT ? "" : "!");
487 printf("%sWEOT ", dev->state & ST_WEOT ? "" : "!");
488 printf("%sEOF ", dev->state & ST_EOF ? "" : "!");
489 printf("%sNEXTVOL ", dev->state & ST_NEXTVOL ? "" : "!");
490 printf("%sSHORT ", dev->state & ST_SHORT ? "" : "!");
493 printf(_("Device parameters:\n"));
494 printf("Device name: %s\n", dev->dev_name);
495 printf("File=%u block=%u\n", dev->file, dev->block_num);
496 printf("Min block=%u Max block=%u\n", dev->min_block_size, dev->max_block_size);
504 * Test writting larger and larger records.
505 * This is a torture test for records.
507 static void rectestcmd()
513 Pmsg0(0, "Test writting larger and larger records.\n"
514 "This is a torture test for records.\nI am going to write\n"
515 "larger and larger records. It will stop when the record size\n"
516 "plus the header exceeds the block size (by default about 64K)\n");
519 get_cmd("Do you want to continue? (y/n): ");
521 Pmsg0(000, "Command aborted.\n");
525 sm_check(__FILE__, __LINE__, False);
526 block = new_block(dev);
529 for (i=1; i<500000; i++) {
530 rec->data = check_pool_memory_size(rec->data, i);
531 memset(rec->data, i & 0xFF, i);
533 sm_check(__FILE__, __LINE__, False);
534 if (write_record_to_block(block, rec)) {
537 Pmsg2(0, "Block %d i=%d\n", blkno, i);
541 sm_check(__FILE__, __LINE__, False);
545 sm_check(__FILE__, __LINE__, False);
549 * This test attempts to re-read a block written by Bacula
550 * normally at the end of the tape. Bacula will then back up
551 * over the two eof marks, backup over the record and reread
552 * it to make sure it is valid. Bacula can skip this validation
553 * if you set "Backward space record = no"
555 static int re_read_block_test()
562 if (!(dev->capabilities & CAP_BSR)) {
563 Pmsg0(-1, _("Skipping read backwards test because BSR turned off.\n"));
567 Pmsg0(-1, _("\n=== Write, backup, and re-read test ===\n\n"
568 "I'm going to write three records and two eof's\n"
569 "then backup over the eof's and re-read the last record.\n"
570 "Bacula does this after writing the last block on the\n"
571 "tape to verify that the block was written correctly.\n"
572 "It is not an *essential* feature ...\n\n"));
574 block = new_block(dev);
576 rec->data = check_pool_memory_size(rec->data, block->buf_len);
577 len = rec->data_len = block->buf_len-100;
578 memset(rec->data, 1, rec->data_len);
579 if (!write_record_to_block(block, rec)) {
580 Pmsg0(0, _("Error writing record to block.\n"));
583 if (!write_block_to_dev(jcr, dev, block)) {
584 Pmsg0(0, _("Error writing block to device.\n"));
587 Pmsg1(0, _("Wrote first record of %d bytes.\n"), rec->data_len);
589 memset(rec->data, 2, rec->data_len);
590 if (!write_record_to_block(block, rec)) {
591 Pmsg0(0, _("Error writing record to block.\n"));
594 if (!write_block_to_dev(jcr, dev, block)) {
595 Pmsg0(0, _("Error writing block to device.\n"));
598 Pmsg1(0, _("Wrote second record of %d bytes.\n"), rec->data_len);
600 memset(rec->data, 3, rec->data_len);
601 if (!write_record_to_block(block, rec)) {
602 Pmsg0(0, _("Error writing record to block.\n"));
605 if (!write_block_to_dev(jcr, dev, block)) {
606 Pmsg0(0, _("Error writing block to device.\n"));
609 Pmsg1(0, _("Wrote third record of %d bytes.\n"), rec->data_len);
613 if (!bsf_dev(dev, 1)) {
614 Pmsg1(0, _("Backspace file failed! ERR=%s\n"), strerror_dev(dev));
617 if (!bsf_dev(dev, 1)) {
618 Pmsg1(0, _("Backspace file failed! ERR=%s\n"), strerror_dev(dev));
621 Pmsg0(0, "Backspaced over two EOFs OK.\n");
622 if (!bsr_dev(dev, 1)) {
623 Pmsg1(0, _("Backspace record failed! ERR=%s\n"), strerror_dev(dev));
626 Pmsg0(0, "Backspace record OK.\n");
627 if (!read_block_from_dev(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
628 Pmsg1(0, _("Read block failed! ERR=%s\n"), strerror(dev->dev_errno));
631 memset(rec->data, 0, rec->data_len);
632 if (!read_record_from_block(block, rec)) {
633 Pmsg1(0, _("Read block failed! ERR=%s\n"), strerror(dev->dev_errno));
636 for (int i=0; i<len; i++) {
637 if (rec->data[i] != 3) {
638 Pmsg0(0, _("Bad data in record. Test failed!\n"));
642 Pmsg0(0, _("\nBlock re-read correct. Test succeeded!\n"));
643 Pmsg0(-1, _("=== End Write, backup, and re-read test ===\n\n"));
651 Pmsg0(0, _("This is not terribly serious since Bacula only uses\n"
652 "this function to verify the last block written to the\n"
653 "tape. Bacula will skip the last block verification\n"
655 "Backward Space Record = No\n\n"
656 "to your Storage daemon's Device resource definition.\n"));
662 * This test writes some records, then writes an end of file,
663 * rewinds the tape, moves to the end of the data and attepts
664 * to append to the tape. This function is essential for
665 * Bacula to be able to write multiple jobs to the tape.
667 static int append_test()
669 Pmsg0(-1, _("\n\n=== Append files test ===\n\n"
670 "This test is essential to Bacula.\n\n"
671 "I'm going to write one record in file 0,\n"
672 " two records in file 1,\n"
673 " and three records in file 2\n\n"));
676 weofcmd(); /* end file 0 */
679 weofcmd(); /* end file 1 */
683 weofcmd(); /* end file 2 */
685 Pmsg0(0, _("Now moving to end of medium.\n"));
687 Pmsg2(-1, _("We should be in file 3. I am at file %d. This is %s\n"),
688 dev->file, dev->file == 3 ? "correct!" : "NOT correct!!!!");
690 if (dev->file != 3) {
694 Pmsg0(-1, _("\nNow the important part, I am going to attempt to append to the tape.\n\n"));
698 Pmsg0(-1, _("Done appending, there should be no I/O errors\n\n"));
699 Pmsg0(-1, "Doing Bacula scan of blocks:\n");
701 Pmsg0(-1, _("End scanning the tape.\n"));
702 Pmsg2(-1, _("We should be in file 4. I am at file %d. This is %s\n"),
703 dev->file, dev->file == 4 ? "correct!" : "NOT correct!!!!");
705 if (dev->file != 4) {
713 * This is a general test of Bacula's functions
714 * needed to read and write the tape.
716 static void testcmd()
720 stat = append_test();
721 if (stat == 1) { /* OK get out */
724 if (stat == -1) { /* first test failed */
725 if (dev_cap(dev, CAP_EOM)) {
726 Pmsg0(-1, "\nAppend test failed. Attempting again.\n"
727 "Setting \"Hardware End of Medium = no\" and retrying append test.\n\n");
728 dev->capabilities &= ~CAP_EOM; /* turn off eom */
729 stat = append_test();
731 Pmsg0(-1, "\n\nIt looks like the test worked this time, please add:\n\n"
732 " Hardware End of Medium = No\n\n"
733 "to your Device resource in the Storage conf file.\n");
737 Pmsg0(-1, "\n\nThat appears not to have corrected the problem.\n");
740 /* Wrong count after append */
742 Pmsg0(-1, "\n\nIt looks like the append failed. Attempting again.\n"
743 "Setting \"BSF at EOM = yes\" and retrying append test.\n");
744 dev->capabilities |= CAP_BSFATEOM; /* backspace on eom */
745 stat = append_test();
747 Pmsg0(-1, "\n\nIt looks like the test worked this time, please add:\n\n"
748 " Hardware End of Medium = No\n"
749 " BSF at EOM = yes\n\n"
750 "to your Device resource in the Storage conf file.\n");
755 Pmsg0(-1, "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
756 "Unable to correct the problem. You MUST fix this\n"
757 "problem before Bacula can use your tape drive correctly\n");
758 Pmsg0(-1, "\nPerhaps running Bacula in fixed block mode will work.\n"
759 "Do so by setting:\n\n"
760 "Minimum Block Size = nnn\n"
761 "Maximum Block Size = nnn\n\n"
762 "in your Storage daemon's Device definition.\n"
763 "nnn must match your tape driver's block size.\n"
764 "This, however, is not really an ideal solution.\n");
769 Pmsg0(-1, _("\nThe above Bacula scan should have output identical to what follows.\n"
770 "Please double check it ...\n"
771 "=== Sample correct output ===\n"
772 "1 block of 64448 bytes in file 1\n"
773 "End of File mark.\n"
774 "2 blocks of 64448 bytes in file 2\n"
775 "End of File mark.\n"
776 "3 blocks of 64448 bytes in file 3\n"
777 "End of File mark.\n"
778 "1 block of 64448 bytes in file 4\n"
779 "End of File mark.\n"
780 "Total files=4, blocks=7, bytes = 451,136\n"
781 "=== End sample correct output ===\n\n"));
783 Pmsg0(-1, _("If the above scan output is not identical to the\n"
784 "sample output, you MUST correct the problem\n"
785 "or Bacula will not be able to write multiple Jobs to \n"
789 re_read_block_test();
792 Pmsg0(-1, _("\n=== End Append files test ===\n"));
796 /* Forward space a file */
799 if (!fsf_dev(dev, 1)) {
800 Pmsg1(0, "Bad status from fsf. ERR=%s\n", strerror_dev(dev));
803 Pmsg0(0, "Forward spaced one file.\n");
806 /* Forward space a record */
809 if (!fsr_dev(dev, 1)) {
810 Pmsg1(0, "Bad status from fsr. ERR=%s\n", strerror_dev(dev));
813 Pmsg0(0, "Forward spaced one record.\n");
818 * Write a Bacula block to the tape
826 sm_check(__FILE__, __LINE__, False);
827 block = new_block(dev);
829 dump_block(block, "test");
831 i = block->buf_len - 100;
833 rec->data = check_pool_memory_size(rec->data, i);
834 memset(rec->data, i & 0xFF, i);
836 sm_check(__FILE__, __LINE__, False);
837 if (!write_record_to_block(block, rec)) {
838 Pmsg0(0, _("Error writing record to block.\n"));
841 if (!write_block_to_dev(jcr, dev, block)) {
842 Pmsg0(0, _("Error writing block to device.\n"));
845 Pmsg1(0, _("Wrote one record of %d bytes.\n"), i);
847 Pmsg0(0, _("Wrote block to device.\n"));
850 sm_check(__FILE__, __LINE__, False);
853 sm_check(__FILE__, __LINE__, False);
857 * Read a record from the tape
864 if (!get_cmd("Enter length to read: ")) {
868 if (len < 0 || len > 1000000) {
869 Pmsg0(0, _("Bad length entered, using default of 1024 bytes.\n"));
872 buf = (char *)malloc(len);
873 stat = read(dev->fd, buf, len);
874 if (stat > 0 && stat <= len) {
877 Pmsg3(0, _("Read of %d bytes gives stat=%d. ERR=%s\n"),
878 len, stat, strerror(errno));
884 * Scan tape by reading block by block. Report what is
885 * on the tape. Note, this command does raw reads, and as such
886 * will not work with fixed block size devices.
888 static void scancmd()
891 int blocks, tot_blocks, tot_files;
897 blocks = block_size = tot_blocks = 0;
899 if (dev->state & ST_EOT) {
900 Pmsg0(0, "End of tape\n");
904 tot_files = dev->file;
905 Pmsg1(0, _("Starting scan at file %u\n"), dev->file);
907 if ((stat = read(dev->fd, buf, sizeof(buf))) < 0) {
908 clrerror_dev(dev, -1);
909 Mmsg2(&dev->errmsg, "read error on %s. ERR=%s.\n",
910 dev->dev_name, strerror(dev->dev_errno));
911 Pmsg2(0, "Bad status from read %d. ERR=%s\n", stat, strerror_dev(dev));
913 printf("%d block%s of %d bytes in file %d\n",
914 blocks, blocks>1?"s":"", block_size, dev->file);
917 Dmsg1(200, "read status = %d\n", stat);
919 if (stat != block_size) {
922 printf("%d block%s of %d bytes in file %d\n",
923 blocks, blocks>1?"s":"", block_size, dev->file);
928 if (stat == 0) { /* EOF */
930 printf("End of File mark.\n");
931 /* Two reads of zero means end of tape */
932 if (dev->state & ST_EOF)
933 dev->state |= ST_EOT;
935 dev->state |= ST_EOF;
938 if (dev->state & ST_EOT) {
939 printf("End of tape\n");
942 } else { /* Got data */
943 dev->state &= ~ST_EOF;
950 tot_files = dev->file - tot_files;
951 printf("Total files=%d, blocks=%d, bytes = %s\n", tot_files, tot_blocks,
952 edit_uint64_with_commas(bytes, ec1));
957 * Scan tape by reading Bacula block by block. Report what is
958 * on the tape. This function reads Bacula blocks, so if your
959 * Device resource is correctly defined, it should work with
960 * either variable or fixed block sizes.
962 static void scan_blocks()
964 int blocks, tot_blocks, tot_files;
970 block = new_block(dev);
971 blocks = block_size = tot_blocks = 0;
975 tot_files = dev->file;
977 if (!read_block_from_device(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
978 Dmsg1(100, "!read_block(): ERR=%s\n", strerror_dev(dev));
979 if (dev->state & ST_EOT) {
981 printf("%d block%s of %d bytes in file %d\n",
982 blocks, blocks>1?"s":"", block_size, dev->file);
987 if (dev->state & ST_EOF) {
989 printf("%d block%s of %d bytes in file %d\n",
990 blocks, blocks>1?"s":"", block_size, dev->file);
993 printf(_("End of File mark.\n"));
996 if (dev->state & ST_SHORT) {
998 printf("%d block%s of %d bytes in file %d\n",
999 blocks, blocks>1?"s":"", block_size, dev->file);
1002 printf(_("Short block read.\n"));
1005 printf(_("Error reading block. ERR=%s\n"), strerror_dev(dev));
1008 if (block->block_len != block_size) {
1010 printf("%d block%s of %d bytes in file %d\n",
1011 blocks, blocks>1?"s":"", block_size, dev->file);
1014 block_size = block->block_len;
1018 bytes += block->block_len;
1019 Dmsg6(100, "Blk_blk=%u dev_blk=%u blen=%u bVer=%d SessId=%u SessTim=%u\n",
1020 block->BlockNumber, dev->block_num, block->block_len, block->BlockVer,
1021 block->VolSessionId, block->VolSessionTime);
1023 DEV_RECORD *rec = new_record();
1024 read_record_from_block(block, rec);
1025 Pmsg8(-1, "Blk_block: %u dev_blk=%u blen=%u First rec FI=%s SessId=%u SessTim=%u Strm=%s rlen=%d\n",
1026 block->BlockNumber, dev->block_num, block->block_len,
1027 FI_to_ascii(rec->FileIndex), rec->VolSessionId, rec->VolSessionTime,
1028 stream_to_ascii(rec->Stream, rec->FileIndex), rec->data_len);
1031 } else if (verbose > 1) {
1032 dump_block(block, "");
1038 tot_files = dev->file - tot_files;
1039 printf("Total files=%d, blocks=%d, bytes = %s\n", tot_files, tot_blocks,
1040 edit_uint64_with_commas(bytes, ec1));
1044 static void statcmd()
1050 debug = debug_level;
1052 if (!status_dev(dev, &status)) {
1053 Pmsg2(0, "Bad status from status %d. ERR=%s\n", stat, strerror_dev(dev));
1056 dump_volume_label(dev);
1058 debug_level = debug;
1063 * First we label the tape, then we fill
1064 * it with data get a new tape and write a few blocks.
1066 static void fillcmd()
1077 This command simulates Bacula writing to a tape.\n\
1078 It requires either one or two blank tapes, which it\n\
1079 will label and write. It will print a status approximately\n\
1080 every 322 MB, and write an EOF every 3.2 GB. If you have\n\
1081 selected the simple test option, after writing the first tape\n\
1082 it will rewind it and re-read the last block written.\n\
1083 If you have selected the multiple tape test, when the first tape\n\
1084 fills, it will ask for a second, and after writing a few more \n\
1085 blocks, it will stop. Then it will begin re-reading the\n\
1087 This may take a long time -- hours! ...\n\n");
1089 get_cmd("Insert a blank tape then indicate if you want\n"
1090 "to run the simplified test (s) with one tape or\n"
1091 "the complete multiple tape (m) test: (s/m) ");
1092 if (cmd[0] == 's') {
1093 Pmsg0(-1, "Simple test (single tape) selected.\n");
1095 } else if (cmd[0] == 'm') {
1096 Pmsg0(-1, "Complete multiple tape test selected.\n");
1099 Pmsg0(000, "Command aborted.\n");
1103 set_volume_name("TestVolume1", 1);
1108 Dmsg1(20, "Begin append device=%s\n", dev_name(dev));
1110 block = new_block(dev);
1113 * Acquire output device for writing. Note, after acquiring a
1114 * device, we MUST release it, which is done at the end of this
1117 Dmsg0(100, "just before acquire_device\n");
1118 if (!(dev=acquire_device_for_append(jcr, dev, block))) {
1119 set_jcr_job_status(jcr, JS_ErrorTerminated);
1124 Dmsg0(100, "Just after acquire_device_for_append\n");
1126 * Write Begin Session Record
1128 if (!write_session_label(jcr, block, SOS_LABEL)) {
1129 set_jcr_job_status(jcr, JS_ErrorTerminated);
1130 Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"),
1134 Pmsg0(-1, "Wrote Start Of Session label.\n");
1136 memset(&rec, 0, sizeof(rec));
1137 rec.data = get_memory(100000); /* max record size */
1139 #define REC_SIZE 32768
1140 rec.data_len = REC_SIZE;
1143 * Generate data as if from File daemon, write to device
1145 jcr->VolFirstIndex = 0;
1146 time(&jcr->run_time); /* start counting time for rates */
1147 Pmsg0(-1, "Begin writing Bacula records to first tape ...\n");
1148 Pmsg1(-1, "Block num = %d\n", dev->block_num);
1149 for (file_index = 0; ok && !job_canceled(jcr); ) {
1150 rec.VolSessionId = jcr->VolSessionId;
1151 rec.VolSessionTime = jcr->VolSessionTime;
1152 rec.FileIndex = ++file_index;
1153 rec.Stream = STREAM_FILE_DATA;
1156 * Fill the buffer with the file_index negated. Negation ensures that
1157 * more bits are turned on.
1159 uint64_t *lp = (uint64_t *)rec.data;
1160 for (uint32_t i=0; i < (rec.data_len-sizeof(uint64_t))/sizeof(uint64_t); i++) {
1161 *lp++ = ~file_index;
1164 Dmsg4(250, "before writ_rec FI=%d SessId=%d Strm=%s len=%d\n",
1165 rec.FileIndex, rec.VolSessionId, stream_to_ascii(rec.Stream, rec.FileIndex),
1168 while (!write_record_to_block(block, &rec)) {
1170 * When we get here we have just filled a block
1172 Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec.data_len,
1175 /* Write block to tape */
1176 if (!flush_block(block, 1)) {
1180 /* Every 5000 blocks (approx 322MB) report where we are.
1182 if ((block->BlockNumber % 5000) == 0) {
1184 now -= jcr->run_time;
1188 kbs = (double)dev->VolCatInfo.VolCatBytes / (1000.0 * (double)now);
1189 Pmsg4(-1, "Wrote block=%u, blk_num=%d VolBytes=%s rate=%.1f KB/s\n", block->BlockNumber,
1191 edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, ec1), (float)kbs);
1193 /* Every 15000 blocks (approx 1GB) write an EOF.
1195 if ((block->BlockNumber % 15000) == 0) {
1196 Pmsg0(-1, "Flush block, write EOF\n");
1197 flush_block(block, 0);
1201 /* Get out after writing 10 blocks to the second tape */
1202 if (++BlockNumber > 10 && stop != 0) { /* get out */
1207 Pmsg0(000, _("Not OK\n"));
1210 jcr->JobBytes += rec.data_len; /* increment bytes this job */
1211 Dmsg4(190, "write_record FI=%s SessId=%d Strm=%s len=%d\n",
1212 FI_to_ascii(rec.FileIndex), rec.VolSessionId,
1213 stream_to_ascii(rec.Stream, rec.FileIndex), rec.data_len);
1215 /* Get out after writing 10 blocks to the second tape */
1216 if (BlockNumber > 10 && stop != 0) { /* get out */
1217 Pmsg0(-1, "Done writing ...\n");
1222 Dmsg0(100, "Write_end_session_label()\n");
1223 /* Create Job status for end of session label */
1224 if (!job_canceled(jcr) && ok) {
1225 set_jcr_job_status(jcr, JS_Terminated);
1227 set_jcr_job_status(jcr, JS_ErrorTerminated);
1229 if (!write_session_label(jcr, block, EOS_LABEL)) {
1230 Pmsg1(000, _("Error writting end session label. ERR=%s\n"), strerror_dev(dev));
1233 /* Write out final block of this session */
1234 if (!write_block_to_device(jcr, dev, block)) {
1235 Pmsg0(-1, _("Set ok=FALSE after write_block_to_device.\n"));
1238 Pmsg0(-1, "Wrote End Of Session label.\n");
1241 /* Release the device */
1242 if (!release_device(jcr, dev)) {
1243 Pmsg0(-1, _("Error in release_device\n"));
1248 free_memory(rec.data);
1250 dump_block(last_block, _("Last block written to tape.\n"));
1252 Pmsg0(-1, _("\n\nDone filling tape. Now beginning re-read of tape ...\n"));
1258 * Read two tapes written by the "fill" command and ensure
1259 * that the data is valid. If stop==1 we simulate full read back
1260 * of two tapes. If stop==-1 we simply read the last block and
1261 * verify that it is correct.
1263 static void unfillcmd()
1270 block = new_block(dev);
1272 dev->capabilities |= CAP_ANONVOLS; /* allow reading any volume */
1273 dev->capabilities &= ~CAP_LABEL; /* don't label anything here */
1278 /* Close device so user can use autochanger if desired */
1279 if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
1282 force_close_dev(dev);
1283 get_cmd(_("Mount first tape. Press enter when ready: "));
1286 set_volume_name("TestVolume1", 1);
1288 create_vol_list(jcr);
1290 dev->state &= ~ST_READ;
1291 if (!acquire_device_for_read(jcr, dev, block)) {
1292 Pmsg1(-1, "%s", dev->errmsg);
1297 time(&jcr->run_time); /* start counting time for rates */
1301 /* Read all records and then second tape */
1302 read_records(jcr, dev, record_cb, my_mount_next_read_volume);
1305 * Simplified test, we simply fsf to file, then read the
1306 * last block and make sure it is the same as the saved block.
1308 Pmsg0(000, "Rewinding tape ...\n");
1309 if (!rewind_dev(dev)) {
1310 Pmsg1(-1, _("Error rewinding: ERR=%s\n"), strerror_dev(dev));
1313 if (last_file > 0) {
1314 Pmsg1(000, "Forward spacing to last file=%u\n", last_file);
1315 if (!fsf_dev(dev, last_file)) {
1316 Pmsg1(-1, _("Error in FSF: ERR=%s\n"), strerror_dev(dev));
1320 Pmsg1(-1, _("Forward space to file %u complete. Reading blocks ...\n"),
1322 Pmsg1(-1, _("Now reading to block %u.\n"), last_block_num);
1323 for (uint32_t i=0; i <= last_block_num; i++) {
1324 if (!read_block_from_device(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
1325 Pmsg1(-1, _("Error reading blocks: ERR=%s\n"), strerror_dev(dev));
1326 Pmsg2(-1, _("Wanted block %u error at block %u\n"), last_block_num, i);
1329 if (i > 0 && i % 1000 == 0) {
1330 Pmsg1(-1, _("At block %u\n"), i);
1334 dump_block(last_block, _("Last block written"));
1335 dump_block(block, _("Block read back"));
1336 Pmsg0(-1, _("Except for the buffer address, the contents of\n"
1337 "the above two block dumps should be the same.\n"
1338 "If not you have a problem ...\n"));
1345 Pmsg0(000, _("Done with reread of fill data.\n"));
1349 * We are called here from "unfill" for each record on the tape.
1351 static int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
1353 SESSION_LABEL label;
1355 if (stop > 1 && !dumped) { /* on second tape */
1357 dump_block(block, "First block on second tape");
1358 Pmsg4(-1, "Blk: FileIndex=%d: block=%u size=%d vol=%s\n",
1359 rec->FileIndex, block->BlockNumber, block->block_len, dev->VolHdr.VolName);
1360 Pmsg6(-1, " Rec: VId=%d VT=%d FI=%s Strm=%s len=%d state=%x\n",
1361 rec->VolSessionId, rec->VolSessionTime,
1362 FI_to_ascii(rec->FileIndex), stream_to_ascii(rec->Stream, rec->FileIndex),
1363 rec->data_len, rec->state);
1365 if (rec->FileIndex < 0) {
1367 dump_label_record(dev, rec, 1);
1369 switch (rec->FileIndex) {
1371 Pmsg0(-1, "Volume is prelabeled. This tape cannot be scanned.\n");
1374 unser_volume_label(dev, rec);
1375 Pmsg3(-1, "VOL_LABEL: block=%u size=%d vol=%s\n", block->BlockNumber,
1376 block->block_len, dev->VolHdr.VolName);
1380 unser_session_label(&label, rec);
1381 Pmsg1(-1, "SOS_LABEL: JobId=%u\n", label.JobId);
1384 unser_session_label(&label, rec);
1385 Pmsg2(-1, "EOS_LABEL: block=%u JobId=%u\n", block->BlockNumber,
1389 Pmsg0(-1, "EOM_LABEL:\n");
1391 case EOT_LABEL: /* end of all tapes */
1394 if (LastBlock != block->BlockNumber) {
1395 VolBytes += block->block_len;
1397 LastBlock = block->BlockNumber;
1399 now -= jcr->run_time;
1403 kbs = (double)VolBytes / (1000 * now);
1404 Pmsg3(000, "Read block=%u, VolBytes=%s rate=%.1f KB/s\n", block->BlockNumber,
1405 edit_uint64_with_commas(VolBytes, ec1), (float)kbs);
1407 Pmsg0(000, "End of all tapes.\n");
1415 if (++file_index != rec->FileIndex) {
1416 Pmsg3(000, "Incorrect FileIndex in Block %u. Got %d, expected %d.\n",
1417 block->BlockNumber, rec->FileIndex, file_index);
1420 * Now check that the right data is in the record.
1422 uint64_t *lp = (uint64_t *)rec->data;
1423 uint64_t val = ~file_index;
1424 for (uint32_t i=0; i < (REC_SIZE-sizeof(uint64_t))/sizeof(uint64_t); i++) {
1426 Pmsg2(000, "Record %d contains bad data in Block %u.\n",
1427 file_index, block->BlockNumber);
1432 if (LastBlock != block->BlockNumber) {
1433 VolBytes += block->block_len;
1435 if ((block->BlockNumber != LastBlock) && (block->BlockNumber % 50000) == 0) {
1438 now -= jcr->run_time;
1442 kbs = (double)VolBytes / (1000 * now);
1443 Pmsg3(000, "Read block=%u, VolBytes=%s rate=%.1f KB/s\n", block->BlockNumber,
1444 edit_uint64_with_commas(VolBytes, ec1), (float)kbs);
1446 LastBlock = block->BlockNumber;
1448 Pmsg1(000, "End of all blocks. Block=%u\n", block->BlockNumber);
1456 * Write current block to tape regardless of whether or
1457 * not it is full. If the tape fills, attempt to
1458 * acquire another tape.
1460 static int flush_block(DEV_BLOCK *block, int dump)
1465 uint32_t this_file, this_block_num;
1468 this_block = new_block(dev);
1471 free_memory(this_block->buf);
1472 memcpy(this_block, block, sizeof(DEV_BLOCK));
1473 this_block->buf = get_memory(block->buf_len);
1474 memcpy(this_block->buf, block->buf, this_block->buf_len);
1475 this_file = dev->file;
1476 this_block_num = dev->block_num;
1477 if (!write_block_to_dev(jcr, dev, block)) {
1478 Pmsg3(000, "Block not written: FileIndex=%u Block=%u Size=%u\n",
1479 (unsigned)file_index, block->BlockNumber, block->block_len);
1480 Pmsg2(000, "last_block_num=%u this_block_num=%d\n", last_block_num,
1483 dump_block(block, "Block not written");
1486 eot_block = block->BlockNumber;
1487 eot_block_len = block->block_len;
1488 eot_FileIndex = file_index;
1491 now -= jcr->run_time;
1495 kbs = (double)dev->VolCatInfo.VolCatBytes / (1000 * now);
1496 vol_size = dev->VolCatInfo.VolCatBytes;
1497 Pmsg2(000, "End of tape. VolumeCapacity=%s. Write rate = %.1f KB/s\n",
1498 edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, ec1), kbs);
1501 stop = -1; /* stop, but do simplified test */
1503 /* Full test in progress */
1504 if (!fixup_device_block_write_error(jcr, dev, block)) {
1505 Pmsg1(000, _("Cannot fixup device error. %s\n"), strerror_dev(dev));
1511 BlockNumber = 0; /* start counting for second tape */
1514 return 1; /* end of tape reached */
1518 * Toggle between two allocated blocks for efficiency.
1519 * Switch blocks so that the block just successfully written is
1520 * always in last_block.
1522 tblock = last_block;
1523 last_block = this_block;
1524 this_block = tblock;
1525 last_file = this_file;
1526 last_block_num = this_block_num;
1534 * First we label the tape, then we fill
1535 * it with data get a new tape and write a few blocks.
1537 static void qfillcmd()
1543 Pmsg0(0, "Test writing blocks of 64512 bytes to tape.\n");
1545 get_cmd("How many blocks do you want to write? (1000): ");
1552 sm_check(__FILE__, __LINE__, False);
1553 block = new_block(dev);
1556 i = block->buf_len - 100;
1558 rec->data = check_pool_memory_size(rec->data, i);
1559 memset(rec->data, i & 0xFF, i);
1562 Pmsg1(0, "Begin writing %d Bacula blocks to tape ...\n", count);
1563 for (i=0; i < count; i++) {
1568 if (!write_record_to_block(block, rec)) {
1569 Pmsg0(0, _("Error writing record to block.\n"));
1572 if (!write_block_to_dev(jcr, dev, block)) {
1573 Pmsg0(0, _("Error writing block to device.\n"));
1584 sm_check(__FILE__, __LINE__, False);
1587 sm_check(__FILE__, __LINE__, False);
1592 * Fill a tape using raw write() command
1594 static void rawfill_cmd()
1599 uint32_t block_num = 0;
1603 block = new_block(dev);
1604 fd = open("/dev/urandom", O_RDONLY);
1606 read(fd, block->buf, block->buf_len);
1608 Pmsg0(0, "Cannot open /dev/urandom.\n");
1612 p = (uint32_t *)block->buf;
1613 Pmsg1(0, "Begin writing raw blocks of %u bytes.\n", block->buf_len);
1616 stat = write(dev->fd, block->buf, block->buf_len);
1617 if (stat == (int)block->buf_len) {
1618 if ((block_num++ % 100) == 0) {
1628 printf("Write failed at block %u. stat=%d ERR=%s\n", block_num, stat,
1629 strerror(my_errno));
1636 * Fill a tape using raw write() command
1638 static void bfill_cmd()
1641 uint32_t block_num = 0;
1646 block = new_block(dev);
1647 fd = open("/dev/urandom", O_RDONLY);
1649 read(fd, block->buf, block->buf_len);
1651 Pmsg0(0, "Cannot open /dev/urandom.\n");
1655 p = (uint32_t *)block->buf;
1656 Pmsg1(0, "Begin writing Bacula blocks of %u bytes.\n", block->buf_len);
1659 block->binbuf = block->buf_len;
1660 block->bufp = block->buf + block->binbuf;
1661 if (!write_block_to_dev(jcr, dev, block)) {
1664 if ((block_num++ % 100) == 0) {
1671 printf("Write failed at block %u.\n", block_num);
1677 struct cmdstruct { char *key; void (*func)(); char *help; };
1678 static struct cmdstruct commands[] = {
1679 {"bsf", bsfcmd, "backspace file"},
1680 {"bsr", bsrcmd, "backspace record"},
1681 {"bfill", bfill_cmd, "fill tape using Bacula writes"},
1682 {"cap", capcmd, "list device capabilities"},
1683 {"clear", clearcmd, "clear tape errors"},
1684 {"eod", eodcmd, "go to end of Bacula data for append"},
1685 {"eom", eomcmd, "go to the physical end of medium"},
1686 {"fill", fillcmd, "fill tape, write onto second volume"},
1687 {"unfill", unfillcmd, "read filled tape"},
1688 {"fsf", fsfcmd, "forward space a file"},
1689 {"fsr", fsrcmd, "forward space a record"},
1690 {"help", helpcmd, "print this command"},
1691 {"label", labelcmd, "write a Bacula label to the tape"},
1692 {"load", loadcmd, "load a tape"},
1693 {"quit", quitcmd, "quit btape"},
1694 {"rawfill", rawfill_cmd, "use write() to fill tape"},
1695 {"readlabel", readlabelcmd, "read and print the Bacula tape label"},
1696 {"rectest", rectestcmd, "test record handling functions"},
1697 {"rewind", rewindcmd, "rewind the tape"},
1698 {"scan", scancmd, "read() tape block by block to EOT and report"},
1699 {"scanblocks", scan_blocks, "Bacula read block by block to EOT and report"},
1700 {"status", statcmd, "print tape status"},
1701 {"test", testcmd, "General test Bacula tape functions"},
1702 {"weof", weofcmd, "write an EOF on the tape"},
1703 {"wr", wrcmd, "write a single Bacula block"},
1704 {"rr", rrcmd, "read a single record"},
1705 {"qfill", qfillcmd, "quick fill command"},
1707 #define comsize (sizeof(commands)/sizeof(struct cmdstruct))
1715 while (get_cmd("*")) {
1716 sm_check(__FILE__, __LINE__, False);
1718 for (i=0; i<comsize; i++) /* search for command */
1719 if (fstrsch(cmd, commands[i].key)) {
1720 (*commands[i].func)(); /* go execute command */
1725 Pmsg1(0, _("%s is an illegal command\n"), cmd);
1731 static void helpcmd()
1735 printf(_("Interactive commands:\n"));
1736 printf(_(" Command Description\n ======= ===========\n"));
1737 for (i=0; i<comsize; i++)
1738 printf(" %-10s %s\n", commands[i].key, commands[i].help);
1745 "\nVersion: " VERSION " (" BDATE ")\n\n"
1746 "Usage: btape <options> <device_name>\n"
1747 " -c <file> set configuration file to file\n"
1748 " -d <nn> set debug level to nn\n"
1749 " -s turn off signals\n"
1750 " -t open the default tape device\n"
1751 " -? print this message.\n"
1757 * Get next input command from terminal. This
1758 * routine is REALLY primitive, and should be enhanced
1759 * to have correct backspacing, etc.
1762 get_cmd(char *prompt)
1766 fprintf(stdout, prompt);
1768 /* We really should turn off echoing and pretty this
1772 while ((ch = fgetc(stdin)) != EOF) {
1774 strip_trailing_junk(cmd);
1776 } else if (ch == 4 || ch == 0xd3 || ch == 0x8) {
1789 /* Dummies to replace askdir.c */
1790 int dir_get_volume_info(JCR *jcr, enum get_vol_info_rw writing) { return 1;}
1791 int dir_update_volume_info(JCR *jcr, VOLUME_CAT_INFO *vol, int relabel) { return 1; }
1792 int dir_create_jobmedia_record(JCR *jcr) { return 1; }
1793 int dir_update_file_attributes(JCR *jcr, DEV_RECORD *rec) { return 1;}
1794 int dir_send_job_status(JCR *jcr) {return 1;}
1798 int dir_find_next_appendable_volume(JCR *jcr)
1803 int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev)
1805 /* Close device so user can use autochanger if desired */
1806 if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
1809 force_close_dev(dev);
1810 Pmsg1(-1, "%s", dev->errmsg); /* print reason */
1811 fprintf(stderr, "Mount Volume \"%s\" on device %s and press return when ready: ",
1812 jcr->VolumeName, dev_name(dev));
1817 int dir_ask_sysop_to_mount_next_volume(JCR *jcr, DEVICE *dev)
1819 /* Close device so user can use autochanger if desired */
1820 if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
1823 force_close_dev(dev);
1824 fprintf(stderr, "Mount next Volume on device %s and press return when ready: ",
1827 set_volume_name("TestVolume2", 2);
1835 static int my_mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
1839 Pmsg1(000, "End of Volume \"%s\"\n", jcr->VolumeName);
1841 if (LastBlock != block->BlockNumber) {
1842 VolBytes += block->block_len;
1844 LastBlock = block->BlockNumber;
1846 now -= jcr->run_time;
1850 kbs = (double)VolBytes / (1000.0 * (double)now);
1851 Pmsg3(-1, "Read block=%u, VolBytes=%s rate=%.1f KB/s\n", block->BlockNumber,
1852 edit_uint64_with_commas(VolBytes, ec1), (float)kbs);
1854 if (strcmp(jcr->VolumeName, "TestVolume2") == 0) {
1860 set_volume_name("TestVolume2", 2);
1862 create_vol_list(jcr);
1864 dev->state &= ~ST_READ;
1865 if (!acquire_device_for_read(jcr, dev, block)) {
1866 Pmsg2(0, "Cannot open Dev=%s, Vol=%s\n", dev_name(dev), jcr->VolumeName);
1869 return 1; /* next volume mounted */
1872 static void set_volume_name(char *VolName, int volnum)
1874 VolumeName = VolName;
1876 pm_strcpy(&jcr->VolumeName, VolName);
1877 bstrncpy(dev->VolCatInfo.VolCatName, VolName, sizeof(dev->VolCatInfo.VolCatName));