static void rrcmd();
static void eodcmd();
static void fillcmd();
+static void qfillcmd();
static void statcmd();
static void unfillcmd();
static int flush_block(DEV_BLOCK *block, int dump);
static void eomcmd()
{
if (!eod_dev(dev)) {
- Pmsg1(0, _("Bad status from eod. ERR=%s\n"), strerror_dev(dev));
+ Pmsg1(0, _("Bad status from MTEOD. ERR=%s\n"), strerror_dev(dev));
return;
} else {
- Pmsg0(0, _("Moved to end of media\n"));
+ Pmsg0(0, _("Moved to end of medium.\n"));
}
}
/*
- * Go to the end of the media (either hardware determined
+ * Go to the end of the medium (either hardware determined
* or defined by two eofs.
*/
static void eodcmd()
wrcmd();
weofcmd(); /* end file 2 */
rewindcmd();
- Pmsg0(0, _("Now moving to end of media.\n"));
+ Pmsg0(0, _("Now moving to end of medium.\n"));
eodcmd();
Pmsg2(-1, _("We should be in file 3. I am at file %d. This is %s\n"),
dev->file, dev->file == 3 ? "correct!" : "NOT correct!!!!");
int blocks, tot_blocks, tot_files;
int block_size;
uint64_t bytes;
+ char ec1[50];
blocks = block_size = tot_blocks = 0;
}
update_pos_dev(dev);
tot_files = dev->file - tot_files;
- printf("Total files=%d, blocks=%d, bytes = %" lld "\n", tot_files, tot_blocks, bytes);
+ printf("Total files=%d, blocks=%d, bytes = %s\n", tot_files, tot_blocks,
+ edit_uint64_with_commas(bytes, ec1));
}
uint32_t block_size;
uint64_t bytes;
DEV_BLOCK *block;
+ char ec1[50];
block = new_block(dev);
blocks = block_size = tot_blocks = 0;
bail_out:
free_block(block);
tot_files = dev->file - tot_files;
- printf("Total files=%d, blocks=%d, bytes = %" lld "\n", tot_files, tot_blocks, bytes);
+ printf("Total files=%d, blocks=%d, bytes = %s\n", tot_files, tot_blocks,
+ edit_uint64_with_commas(bytes, ec1));
}
end_of_tape = 0;
+ /* Close device so user can use autochanger if desired */
+ if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
+ offline_dev(dev);
+ }
+ force_close_dev(dev);
get_cmd(_("Mount first tape. Press enter when ready: "));
free_vol_list(jcr);
Pmsg0(000, _("Done with reread of fill data.\n"));
}
-
/*
* We are called here from "unfill" for each record on the tape.
*/
static void record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
{
-
SESSION_LABEL label;
- if (stop > 1) { /* on second tape */
+
+ if (stop > 1 && !dumped) { /* on second tape */
+ dumped = 1;
+ dump_block(block, "First block on second tape");
Pmsg4(-1, "Blk: FileIndex=%d: block=%u size=%d vol=%s\n",
rec->FileIndex, block->BlockNumber, block->block_len, dev->VolHdr.VolName);
Pmsg6(-1, " Rec: VId=%d VT=%d FI=%s Strm=%s len=%d state=%x\n",
rec->VolSessionId, rec->VolSessionTime,
FI_to_ascii(rec->FileIndex), stream_to_ascii(rec->Stream, rec->FileIndex),
rec->data_len, rec->state);
-
- if (!dumped) {
- dumped = 1;
- dump_block(block, "Block not written to previous tape");
- }
}
if (rec->FileIndex < 0) {
if (verbose > 1) {
}
+/*
+ * First we label the tape, then we fill
+ * it with data get a new tape and write a few blocks.
+ */
+static void qfillcmd()
+{
+ DEV_BLOCK *block;
+ DEV_RECORD *rec;
+ int i, count;
+
+ Pmsg0(0, "Test writing blocks of 64512 bytes to tape.\n");
+
+ get_cmd("How many blocks do you want to write? (1000): ");
+
+ count = atoi(cmd);
+ if (count <= 0) {
+ count = 1000;
+ }
+
+ sm_check(__FILE__, __LINE__, False);
+ block = new_block(dev);
+ rec = new_record();
+
+ i = block->buf_len - 100;
+ ASSERT (i > 0);
+ rec->data = check_pool_memory_size(rec->data, i);
+ memset(rec->data, i & 0xFF, i);
+ rec->data_len = i;
+ rewindcmd();
+ Pmsg1(0, "Begin writing %d blocks to tape ...\n", count);
+ for (i=0; i < count; i++) {
+ if (i % 100 == 0) {
+ printf("+");
+ }
+ if (!write_record_to_block(block, rec)) {
+ Pmsg0(0, _("Error writing record to block.\n"));
+ goto bail_out;
+ }
+ if (!write_block_to_dev(jcr, dev, block)) {
+ Pmsg0(0, _("Error writing block to device.\n"));
+ goto bail_out;
+ }
+ }
+ printf("\n");
+ weofcmd();
+ weofcmd();
+ rewindcmd();
+ scan_blocks();
+
+bail_out:
+ sm_check(__FILE__, __LINE__, False);
+ free_record(rec);
+ free_block(block);
+ sm_check(__FILE__, __LINE__, False);
+
+}
+
+
+
struct cmdstruct { char *key; void (*func)(); char *help; };
static struct cmdstruct commands[] = {
{"bsf", bsfcmd, "backspace file"},
{"weof", weofcmd, "write an EOF on the tape"},
{"wr", wrcmd, "write a single Bacula block"},
{"rr", rrcmd, "read a single record"},
+ {"qfill", qfillcmd, "quick fill command"},
};
#define comsize (sizeof(commands)/sizeof(struct cmdstruct))
int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev)
{
+ /* Close device so user can use autochanger if desired */
+ if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
+ offline_dev(dev);
+ }
+ force_close_dev(dev);
Pmsg1(-1, "%s", dev->errmsg); /* print reason */
fprintf(stderr, "Mount Volume \"%s\" on device %s and press return when ready: ",
jcr->VolumeName, dev_name(dev));
int dir_ask_sysop_to_mount_next_volume(JCR *jcr, DEVICE *dev)
{
+ /* Close device so user can use autochanger if desired */
+ if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
+ offline_dev(dev);
+ }
+ force_close_dev(dev);
fprintf(stderr, "Mount next Volume on device %s and press return when ready: ",
dev_name(dev));
getchar();