Kern's ToDo List
- 01 July 2004
+ 04 July 2004
1.35 Items to do:
- Make btape release the drive during the "test" append.
- Document a get out of jail procedure if everything breaks if
you lost/broke the Catalog -- do the same for "I know my
file is there how do I get it back?".
-- When restore started from console, report jobid.
- Look at Win32 inc problem when new directory added files not saved???
- Make FD run on Win95 if possible:
The error I when I installed 1.34.2 clients:
- Test if rewind at end of tape waits for tape to rewind.
- Test cancel at EOM.
-For 1.33 Testing/Documentation:
-- Figure out how to use ssh or stunnel to protect Bacula communications.
- Add Dan's work to manual See ssl.txt
+For 1.37 Testing/Documentation:
- Add db check test to regression. Test each function like delete,
purge, ...
- If you use restore replace=never, the directory attributes for
non-existent directories will not be restored properly.
Wish list:
-- Sort Scheduled jobs status listing by start time.
-- Add priority to Scheduled jobs status listing.
+- Compaction of Disk space by "migrating" Volumes that have pruned
+ Jobs (what criteria? size, #jobs, time).
+- Add prune all command
+- Document fact that purge can destroy a part of a restore by purging
+ one volume while others remain valid -- perhaps mark Jobs.
- Add multiple-media-types.txt
- look at mxt-changer.html
- Make ? do a help command (no return needed).
mount it.
- Implement Fixed storage LabelFormat test.
- Add reporting in attr despooling.
+- Figure out how to use ssh or stunnel to protect Bacula communications.
+ Add Dan's work to manual See ssl.txt
==== Done in 1.35.0
- Implement fast tree insert (doubly linked list?)
(Implement resources on a single pointer)
- Add regular expressions to FileSets.
- Test new I/O error despooling code.
+- Sort Scheduled jobs status listing by start time.
+- Add priority to Scheduled jobs status listing.
mysql_init(&(mdb->mysql));
Dmsg0(50, "mysql_init done\n");
/* If connection fails, try at 5 sec intervals for 30 seconds. */
- for (int return=0; retry < 6; retry++) {
+ for (int retry=0; retry < 6; retry++) {
mdb->db = mysql_real_connect(
&(mdb->mysql), /* db */
mdb->db_address, /* default = localhost */
FROM JobMedia,Job
WHERE JobMedia.JobId=Job.JobId
AND JobMedia.MediaId=%1
- GROUP BY Job.JobId;
+ GROUP BY Job.JobId ORDER by Job.StartTime;
# 15
:List Jobs stored for a given Volume name:
*Enter Volume name:
-SELECT Job.JobId,Job.Name,Job.StartTime,Job.Type,
- Job.Level,Job.JobFiles,Job.JobBytes,Job.JobStatus
+SELECT Job.JobId as JobId,Job.Name as Name,Job.StartTime as StartTime,
+ Job.Type as Type,Job.Level as Level,Job.JobFiles as Files,
+ Job.JobBytes as Bytes,Job.JobStatus as Status
FROM Media,JobMedia,Job
WHERE Media.VolumeName='%1'
AND Media.MediaId=JobMedia.MediaId
AND JobMedia.JobId=Job.JobId
- GROUP BY Job.JobId;
+ GROUP BY Job.JobId ORDER by Job.StartTime;
* Version $Id$
*/
/*
- Copyright (C) 2002-2003 Kern Sibbald and John Walker
+ Copyright (C) 2002-2004 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
*/
DCR *acquire_device_for_append(JCR *jcr)
{
- int release = 0;
+ bool release = false;
bool recycle = false;
bool do_mount = false;
DCR *dcr;
P(dev->mutex);
unblock_device(dev);
V(dev->mutex);
+ free_dcr(dcr); /* release dcr pointing to old dev */
/* Make new device current device and lock it */
dev = d;
+ dcr = new_dcr(jcr, dev); /* get new dcr for new device */
lock_device(dev);
block_device(dev, BST_DOING_ACQUIRE);
unlock_device(dev);
}
}
/* Wrong tape mounted, release it, then fall through to get correct one */
- release = 1;
+ release = true;
do_mount = true;
} else {
/*
#include "stored.h"
/* Forward referenced functions */
-static int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
+static bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
/* Global variables */
/*
* read_records() calls back here for each record it gets
*/
-static int record_cb(JCR *in_jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
+static bool record_cb(JCR *in_jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
{
if (list_records) {
Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
switch (rec->FileIndex) {
case PRE_LABEL:
Pmsg0(000, "Volume is prelabeled. This volume cannot be copied.\n");
- return 1;
+ return false;
case VOL_LABEL:
Pmsg0(000, "Volume label not copied.\n");
- return 1;
+ return true;
case SOS_LABEL:
jobs++;
break;
break;
case EOM_LABEL:
Pmsg0(000, "EOM label not copied.\n");
- return 1;
+ return true;
case EOT_LABEL: /* end of all tapes */
Pmsg0(000, "EOT label not copied.\n");
- return 1;
+ return true;
default:
break;
}
break;
}
}
- return 1;
+ return true;
}
#endif
static void do_extract(char *fname);
-static int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
+static bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
static DEVICE *dev = NULL;
static BFILE bfd;
static FF_PKT my_ff;
static FF_PKT *ff = &my_ff;
static BSR *bsr = NULL;
-static int extract = FALSE;
+static bool extract = false;
static int non_support_data = 0;
static long total = 0;
static ATTR *attr;
/*
* Called here for each record from read_records()
*/
-static int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
+static bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
{
int stat;
if (rec->FileIndex < 0) {
- return 1; /* we don't want labels */
+ return true; /* we don't want labels */
}
/* File Attributes stream */
Emsg0(M_ERROR, 0, _("Logic error output file should be open but is not.\n"));
}
set_attributes(jcr, attr, &bfd);
- extract = FALSE;
+ extract = false;
}
if (!unpack_attributes_record(jcr, rec->Stream, rec->data, attr)) {
Jmsg(jcr, M_ERROR, 0, _("%s stream not supported on this Client.\n"),
stream_to_ascii(attr->data_stream));
}
- extract = FALSE;
- return 1;
+ extract = false;
+ return true;
}
build_attr_output_fnames(jcr, attr);
- extract = FALSE;
+ extract = false;
stat = create_file(jcr, attr, &bfd, REPLACE_ALWAYS);
switch (stat) {
case CF_ERROR:
case CF_SKIP:
break;
case CF_EXTRACT:
- extract = TRUE;
+ extract = true;
print_ls_output(jcr, attr);
num_files++;
fileAddr = 0;
if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) {
Emsg3(M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
edit_uint64(fileAddr, ec1), attr->ofname, berror(&bfd));
- extract = FALSE;
- return 1;
+ extract = false;
+ return true;
}
}
} else {
if ((stat=uncompress((Bytef *)compress_buf, &compress_len,
(const Bytef *)wbuf, (uLong)wsize) != Z_OK)) {
Emsg1(M_ERROR, 0, _("Uncompression error. ERR=%d\n"), stat);
- extract = FALSE;
- return 1;
+ extract = false;
+ return true;
}
Dmsg2(100, "Write uncompressed %d bytes, total before write=%d\n", compress_len, total);
Pmsg0(0, "===Write error===\n");
Emsg2(M_ERROR, 0, _("Write error on %s: %s\n"),
attr->ofname, strerror(errno));
- extract = FALSE;
- return 1;
+ extract = false;
+ return true;
}
total += compress_len;
fileAddr += compress_len;
#else
if (extract) {
Emsg0(M_ERROR, 0, "GZIP data stream found, but GZIP not configured!\n");
- extract = FALSE;
- return 1;
+ extract = false;
+ return true;
}
#endif
break;
Emsg0(M_ERROR, 0, "Logic error output file should be open but is not.\n");
}
set_attributes(jcr, attr, &bfd);
- extract = FALSE;
+ extract = false;
}
Jmsg(jcr, M_ERROR, 0, _("Unknown stream=%d ignored. This shouldn't happen!\n"),
rec->Stream);
break;
} /* end switch */
- return 1;
+ return true;
}
static void do_ls(char *fname);
static void do_close(JCR *jcr);
static void get_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *sessrec);
-static int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
+static bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
static DEVICE *dev;
static int dump_label = FALSE;
/*
* We are only looking for labels or in particular Job Session records
*/
-static int jobs_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
+static bool jobs_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
{
if (rec->FileIndex < 0) {
dump_label_record(dev, rec, verbose);
}
rec->remainder = 0;
- return 1;
+ return true;
}
/* Do list job records */
/*
* Called here for each record from read_records()
*/
-static int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
+static bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
{
if (rec->FileIndex < 0) {
get_session_record(dev, rec, &sessrec);
- return 1;
+ return true;
}
/* File Attributes stream */
if (rec->Stream == STREAM_UNIX_ATTRIBUTES ||
num_files++;
}
}
- return 1;
+ return true;
}
/* Forward referenced functions */
static void do_scan(void);
-static int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
+static bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
static int create_file_attributes_record(B_DB *db, JCR *mjcr,
char *fname, char *lname, int type,
char *ap, DEV_RECORD *rec);
* the end of writing a tape by wiffling through the attached
* jcrs creating jobmedia records.
*/
-static int bscan_mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
+static bool bscan_mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
{
Dmsg1(100, "Walk attached jcrs. Volume=%s\n", dev->VolCatInfo.VolCatName);
for (JCR *mjcr=NULL; (mjcr=next_attached_jcr(dev, mjcr)); ) {
* we call mount_next... with bscan's jcr because that is where we
* have the Volume list, but we get attached.
*/
- int stat = mount_next_read_volume(jcr, dev, block);
+ bool stat = mount_next_read_volume(jcr, dev, block);
/* we must once more detach ourselves (attached by mount_next ...) */
detach_jcr_from_device(dev, jcr); /* detach bscan jcr */
return stat;
term_dev(dev);
}
-static int record_cb(JCR *bjcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
+/*
+ * Returns: true if OK
+ * false if error
+ */
+static bool record_cb(JCR *bjcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
{
JCR *mjcr;
DCR *dcr;
switch (rec->FileIndex) {
case PRE_LABEL:
Pmsg0(000, _("Volume is prelabeled. This tape cannot be scanned.\n"));
- return 1;
+ return false;
break;
case VOL_LABEL:
if (strcmp(pr.PoolType, dev->VolHdr.PoolType) != 0) {
Pmsg2(000, _("VOL_LABEL: PoolType mismatch. DB=%s Vol=%s\n"),
pr.PoolType, dev->VolHdr.PoolType);
- return 1;
+ return true;
} else if (verbose) {
Pmsg1(000, _("Pool type \"%s\" is OK.\n"), pr.PoolType);
}
if (strcmp(mr.MediaType, dev->VolHdr.MediaType) != 0) {
Pmsg2(000, _("VOL_LABEL: MediaType mismatch. DB=%s Vol=%s\n"),
mr.MediaType, dev->VolHdr.MediaType);
- return 1;
+ return true; /* ignore error */
} else if (verbose) {
Pmsg1(000, _("Media type \"%s\" is OK.\n"), mr.MediaType);
}
Pmsg3(000, _("SOS_LABEL: VolSessId mismatch for JobId=%u. DB=%d Vol=%d\n"),
jr.JobId,
jr.VolSessionId, rec->VolSessionId);
- return 1;
+ return true; /* ignore error */
}
if (rec->VolSessionTime != jr.VolSessionTime) {
Pmsg3(000, _("SOS_LABEL: VolSessTime mismatch for JobId=%u. DB=%d Vol=%d\n"),
jr.JobId,
jr.VolSessionTime, rec->VolSessionTime);
- return 1;
+ return true; /* ignore error */
}
if (jr.PoolId != pr.PoolId) {
Pmsg3(000, _("SOS_LABEL: PoolId mismatch for JobId=%u. DB=%d Vol=%d\n"),
jr.JobId,
jr.PoolId, pr.PoolId);
- return 1;
+ return true; /* ignore error */
}
break;
default:
break;
} /* end switch */
- return 1;
+ return true;
}
mjcr = get_jcr_by_session(rec->VolSessionId, rec->VolSessionTime);
} else {
ignored_msgs++;
}
- return 1;
+ return true;
}
dcr = mjcr->dcr;
if (dcr->VolFirstIndex == 0) {
Pmsg2(0, _("Unknown stream type!!! stream=%d data=%s\n"), rec->Stream, rec->data);
break;
}
- return 1;
+ return true;
}
/*
static void statcmd();
static void unfillcmd();
static int flush_block(DEV_BLOCK *block, int dump);
-static int quickie_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
+static bool quickie_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
static bool compare_blocks(DEV_BLOCK *last_block, DEV_BLOCK *block);
-static int my_mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+static bool my_mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
static void scan_blocks();
static void set_volume_name(const char *VolName, int volnum);
static void rawfill_cmd();
}
}
rewind_dev(dev);
- write_new_volume_label_to_dev(jcr, jcr->device, cmd, "Default");
+ write_new_volume_label_to_dev(jcr, jcr->device->dev, cmd, "Default");
Pmsg1(-1, "Wrote Volume label for volume \"%s\".\n", cmd);
}
}
/* Read 1000 records then stop */
-static int quickie_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
+static bool quickie_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
{
quickie_count++;
return quickie_count <= 1000;
return 1;
}
-static int my_mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
+static bool my_mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
{
char ec1[50];
if (strcmp(jcr->VolumeName, "TestVolume2") == 0) {
end_of_tape = 1;
- return 0;
+ return false;
}
free_vol_list(jcr);
dev->state &= ~ST_READ;
if (!acquire_device_for_read(jcr)) {
Pmsg2(0, "Cannot open Dev=%s, Vol=%s\n", dev_name(dev), jcr->VolumeName);
- return 0;
+ return false;
}
- return 1; /* next volume mounted */
+ return true; /* next volume mounted */
}
static void set_volume_name(const char *VolName, int volnum)
init_dev(DEVICE *dev, DEVRES *device)
{
struct stat statp;
- int tape, fifo;
+ bool tape, fifo;
int errstat;
DCR *dcr = NULL;
strerror(errno));
return NULL;
}
- tape = FALSE;
- fifo = FALSE;
+ tape = false;
+ fifo = false;
if (S_ISDIR(statp.st_mode)) {
- tape = FALSE;
+ tape = false;
} else if (S_ISCHR(statp.st_mode)) {
- tape = TRUE;
+ tape = true;
} else if (S_ISFIFO(statp.st_mode)) {
- fifo = TRUE;
+ fifo = true;
} else {
if (dev) {
dev->dev_errno = ENODEV;
/* Fall through wanted! */
case VOL_IO_ERROR:
case VOL_NO_LABEL:
- if (!write_new_volume_label_to_dev(jcr, jcr->device, newname, poolname)) {
+ if (!write_new_volume_label_to_dev(jcr, jcr->device->dev, newname, poolname)) {
bnet_fsend(dir, _("3912 Failed to label Volume: ERR=%s\n"), strerror_dev(dev));
break;
}
*
* This routine should be used only when labeling a blank tape.
*/
-bool write_new_volume_label_to_dev(JCR *jcr, DEVRES *device, const char *VolName, const char *PoolName)
+bool write_new_volume_label_to_dev(JCR *jcr, DEVICE *dev, const char *VolName, const char *PoolName)
{
- DEVICE *dev = device->dev;
DEV_RECORD rec;
DEV_BLOCK *block;
bool stat = true;
* impossible to get the requested Volume.
*
*/
-int mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool release)
+bool mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool release)
{
int retry = 0;
bool ask = false, recycle, autochanger;
if (!dir_ask_sysop_to_mount_volume(jcr, dev)) {
Jmsg(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"),
dev_name(dev));
- return 0;
+ return false;
}
}
if (job_canceled(jcr)) {
Jmsg(jcr, M_FATAL, 0, _("Job %d canceled.\n"), jcr->JobId);
- return 0;
+ return false;
}
recycle = false;
if (release) {
while (!dir_find_next_appendable_volume(jcr)) {
Dmsg0(200, "not dir_find_next\n");
if (!dir_ask_sysop_to_create_appendable_volume(jcr, dev)) {
- return 0;
+ return false;
}
Dmsg0(200, "Again dir_find_next_append...\n");
}
if (job_canceled(jcr)) {
- return 0;
+ return false;
}
Dmsg2(100, "After find_next_append. Vol=%s Slot=%d\n",
jcr->VolCatInfo.VolCatName, jcr->VolCatInfo.Slot);
if (ask && !dir_ask_sysop_to_mount_volume(jcr, dev)) {
Dmsg0(100, "Error return ask_sysop ...\n");
- return 0; /* error return */
+ return false; /* error return */
}
if (job_canceled(jcr)) {
- return 0;
+ return false;
}
Dmsg1(100, "want vol=%s\n", jcr->VolumeName);
/* Ensure the device is open */
if (!open_device(jcr, dev)) {
- return 0;
+ return false;
}
/*
"Recycle") == 0))) {
Dmsg0(100, "Create volume label\n");
/* Create a new Volume label and write it to the device */
- if (!write_new_volume_label_to_dev(jcr, (DEVRES *)dev->device, jcr->VolumeName,
+ if (!write_new_volume_label_to_dev(jcr, dev, jcr->VolumeName,
jcr->pool_name)) {
Dmsg0(100, "!write_vol_label\n");
goto mount_next_vol;
}
dev->state |= ST_APPEND;
Dmsg0(100, "Normal return from read_dev_for_append\n");
- return 1;
+ return true;
}
/*
* If we are reading, we come here at the end of the tape
* and see if there are more volumes to be mounted.
*/
-int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
+bool mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
{
Dmsg2(90, "NumVolumes=%d CurVolume=%d\n", jcr->NumVolumes, jcr->CurVolume);
/*
if (!acquire_device_for_read(jcr)) {
Jmsg2(jcr, M_FATAL, 0, "Cannot open Dev=%s, Vol=%s\n", dev_name(dev),
jcr->VolumeName);
- return 0;
+ return false;
}
- return 1; /* next volume mounted */
+ return true; /* next volume mounted */
}
Dmsg0(90, "End of Device reached.\n");
- return 0;
+ return false;
}
/*
uint32_t new_VolSessionId();
/* From acquire.c */
-DCR *acquire_device_for_append(JCR *jcr);
-DCR *acquire_device_for_read(JCR *jcr);
-int release_device(JCR *jcr);
-DCR *new_dcr(JCR *jcr, DEVICE *dev);
-void free_dcr(DCR *dcr);
+DCR *acquire_device_for_append(JCR *jcr);
+DCR *acquire_device_for_read(JCR *jcr);
+int release_device(JCR *jcr);
+DCR *new_dcr(JCR *jcr, DEVICE *dev);
+void free_dcr(DCR *dcr);
/* From askdir.c */
enum get_vol_info_rw {
GET_VOL_INFO_FOR_WRITE,
GET_VOL_INFO_FOR_READ
};
-int dir_get_volume_info(JCR *jcr, enum get_vol_info_rw);
-int dir_find_next_appendable_volume(JCR *jcr);
-int dir_update_volume_info(JCR *jcr, DEVICE *dev, int label);
-int dir_ask_sysop_to_create_appendable_volume(JCR *jcr, DEVICE *dev);
-int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev);
-int dir_update_file_attributes(JCR *jcr, DEV_RECORD *rec);
-int dir_send_job_status(JCR *jcr);
-int dir_create_jobmedia_record(JCR *jcr);
+int dir_get_volume_info(JCR *jcr, enum get_vol_info_rw);
+int dir_find_next_appendable_volume(JCR *jcr);
+int dir_update_volume_info(JCR *jcr, DEVICE *dev, int label);
+int dir_ask_sysop_to_create_appendable_volume(JCR *jcr, DEVICE *dev);
+int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev);
+int dir_update_file_attributes(JCR *jcr, DEV_RECORD *rec);
+int dir_send_job_status(JCR *jcr);
+int dir_create_jobmedia_record(JCR *jcr);
/* authenticate.c */
-int authenticate_director(JCR *jcr);
-int authenticate_filed(JCR *jcr);
+int authenticate_director(JCR *jcr);
+int authenticate_filed(JCR *jcr);
/* From block.c */
-void dump_block(DEV_BLOCK *b, const char *msg);
+void dump_block(DEV_BLOCK *b, const char *msg);
DEV_BLOCK *new_block(DEVICE *dev);
DEV_BLOCK *dup_block(DEV_BLOCK *eblock);
-void init_block_write(DEV_BLOCK *block);
-void empty_block(DEV_BLOCK *block);
-void free_block(DEV_BLOCK *block);
-int write_block_to_device(DCR *dcr, DEV_BLOCK *block);
-int write_block_to_dev(DCR *dcr, DEV_BLOCK *block);
-void print_block_read_errors(JCR *jcr, DEV_BLOCK *block);
-void ser_block_header(DEV_BLOCK *block);
+void init_block_write(DEV_BLOCK *block);
+void empty_block(DEV_BLOCK *block);
+void free_block(DEV_BLOCK *block);
+int write_block_to_device(DCR *dcr, DEV_BLOCK *block);
+int write_block_to_dev(DCR *dcr, DEV_BLOCK *block);
+void print_block_read_errors(JCR *jcr, DEV_BLOCK *block);
+void ser_block_header(DEV_BLOCK *block);
#define CHECK_BLOCK_NUMBERS true
#define NO_BLOCK_NUMBER_CHECK false
-int read_block_from_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_block_numbers);
-int read_block_from_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_block_numbers);
+int read_block_from_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_block_numbers);
+int read_block_from_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_block_numbers);
/* From butil.c -- utilities for SD tool programs */
-void print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
+void print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
JCR *setup_jcr(const char *name, const char * device, BSR *bsr, const char *VolumeName);
DEVICE *setup_to_access_device(JCR *jcr, int read_access);
-void display_tape_error_status(JCR *jcr, DEVICE *dev);
+void display_tape_error_status(JCR *jcr, DEVICE *dev);
DEVRES *find_device_res(char *device_name, int read_access);
/* From dev.c */
-DEVICE *init_dev(DEVICE *dev, DEVRES *device);
-int open_dev(DEVICE *dev, char *VolName, int mode);
-void close_dev(DEVICE *dev);
-void force_close_dev(DEVICE *dev);
-int truncate_dev(DEVICE *dev);
-void term_dev(DEVICE *dev);
-char * strerror_dev(DEVICE *dev);
-void clrerror_dev(DEVICE *dev, int func);
-int update_pos_dev(DEVICE *dev);
-int rewind_dev(DEVICE *dev);
-int load_dev(DEVICE *dev);
-int offline_dev(DEVICE *dev);
-int flush_dev(DEVICE *dev);
-int weof_dev(DEVICE *dev, int num);
-int write_block(DEVICE *dev);
-int write_dev(DEVICE *dev, char *buf, size_t len);
-int read_dev(DEVICE *dev, char *buf, size_t len);
+DEVICE *init_dev(DEVICE *dev, DEVRES *device);
+int open_dev(DEVICE *dev, char *VolName, int mode);
+void close_dev(DEVICE *dev);
+void force_close_dev(DEVICE *dev);
+int truncate_dev(DEVICE *dev);
+void term_dev(DEVICE *dev);
+char * strerror_dev(DEVICE *dev);
+void clrerror_dev(DEVICE *dev, int func);
+int update_pos_dev(DEVICE *dev);
+int rewind_dev(DEVICE *dev);
+int load_dev(DEVICE *dev);
+int offline_dev(DEVICE *dev);
+int flush_dev(DEVICE *dev);
+int weof_dev(DEVICE *dev, int num);
+int write_block(DEVICE *dev);
+int write_dev(DEVICE *dev, char *buf, size_t len);
+int read_dev(DEVICE *dev, char *buf, size_t len);
uint32_t status_dev(DEVICE *dev);
-int eod_dev(DEVICE *dev);
-int fsf_dev(DEVICE *dev, int num);
-int fsr_dev(DEVICE *dev, int num);
-int bsf_dev(DEVICE *dev, int num);
-int bsr_dev(DEVICE *dev, int num);
-void attach_jcr_to_device(DEVICE *dev, JCR *jcr);
-void detach_jcr_from_device(DEVICE *dev, JCR *jcr);
-JCR *next_attached_jcr(DEVICE *dev, JCR *jcr);
-int dev_can_write(DEVICE *dev);
-int offline_or_rewind_dev(DEVICE *dev);
-int reposition_dev(DEVICE *dev, uint32_t file, uint32_t block);
-void init_dev_wait_timers(DEVICE *dev);
-bool double_dev_wait_time(DEVICE *dev);
+int eod_dev(DEVICE *dev);
+int fsf_dev(DEVICE *dev, int num);
+int fsr_dev(DEVICE *dev, int num);
+int bsf_dev(DEVICE *dev, int num);
+int bsr_dev(DEVICE *dev, int num);
+void attach_jcr_to_device(DEVICE *dev, JCR *jcr);
+void detach_jcr_from_device(DEVICE *dev, JCR *jcr);
+JCR *next_attached_jcr(DEVICE *dev, JCR *jcr);
+int dev_can_write(DEVICE *dev);
+int offline_or_rewind_dev(DEVICE *dev);
+int reposition_dev(DEVICE *dev, uint32_t file, uint32_t block);
+void init_dev_wait_timers(DEVICE *dev);
+bool double_dev_wait_time(DEVICE *dev);
/* Get info about device */
-char * dev_name(DEVICE *dev);
-char * dev_vol_name(DEVICE *dev);
+char * dev_name(DEVICE *dev);
+char * dev_vol_name(DEVICE *dev);
uint32_t dev_block(DEVICE *dev);
uint32_t dev_file(DEVICE *dev);
-int dev_is_tape(DEVICE *dev);
+int dev_is_tape(DEVICE *dev);
/* From device.c */
-int open_device(JCR *jcr, DEVICE *dev);
-int first_open_device(DEVICE *dev);
-int fixup_device_block_write_error(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
-void _lock_device(const char *file, int line, DEVICE *dev);
-void _unlock_device(const char *file, int line, DEVICE *dev);
-void _block_device(const char *file, int line, DEVICE *dev, int state);
-void _unblock_device(const char *file, int line, DEVICE *dev);
-void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
-void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
-void set_new_volume_parameters(JCR *jcr, DEVICE *dev);
-void set_new_file_parameters(JCR *jcr, DEVICE *dev);
-int device_is_unmounted(DEVICE *dev);
+int open_device(JCR *jcr, DEVICE *dev);
+int first_open_device(DEVICE *dev);
+int fixup_device_block_write_error(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+void _lock_device(const char *file, int line, DEVICE *dev);
+void _unlock_device(const char *file, int line, DEVICE *dev);
+void _block_device(const char *file, int line, DEVICE *dev, int state);
+void _unblock_device(const char *file, int line, DEVICE *dev);
+void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
+void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
+void set_new_volume_parameters(JCR *jcr, DEVICE *dev);
+void set_new_file_parameters(JCR *jcr, DEVICE *dev);
+int device_is_unmounted(DEVICE *dev);
/* From dircmd.c */
-void *handle_connection_request(void *arg);
+void *handle_connection_request(void *arg);
/* From fd_cmds.c */
-void run_job(JCR *jcr);
+void run_job(JCR *jcr);
/* From job.c */
-void stored_free_jcr(JCR *jcr);
-void connection_from_filed(void *arg);
-void handle_filed_connection(BSOCK *fd, char *job_name);
+void stored_free_jcr(JCR *jcr);
+void connection_from_filed(void *arg);
+void handle_filed_connection(BSOCK *fd, char *job_name);
/* From label.c */
-int read_dev_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
-void create_session_label(JCR *jcr, DEV_RECORD *rec, int label);
-void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName);
-bool write_new_volume_label_to_dev(JCR *jcr, DEVRES *device, const char *VolName, const char *PoolName);
-int write_session_label(JCR *jcr, DEV_BLOCK *block, int label);
-bool write_volume_label_to_block(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
-void dump_volume_label(DEVICE *dev);
-void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose);
-int unser_volume_label(DEVICE *dev, DEV_RECORD *rec);
-int unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec);
+int read_dev_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+void create_session_label(JCR *jcr, DEV_RECORD *rec, int label);
+void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName);
+bool write_new_volume_label_to_dev(JCR *jcr, DEVICE *dev, const char *VolName, const char *PoolName);
+int write_session_label(JCR *jcr, DEV_BLOCK *block, int label);
+bool write_volume_label_to_block(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+void dump_volume_label(DEVICE *dev);
+void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose);
+int unser_volume_label(DEVICE *dev, DEV_RECORD *rec);
+int unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec);
/* From match_bsr.c */
-int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
- SESSION_LABEL *sesrec);
-int match_bsr_block(BSR *bsr, DEV_BLOCK *block);
-void position_bsr_block(BSR *bsr, DEV_BLOCK *block);
-BSR *find_next_bsr(BSR *root_bsr, DEVICE *dev);
-bool match_set_eof(BSR *bsr, DEV_RECORD *rec);
+int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
+ SESSION_LABEL *sesrec);
+int match_bsr_block(BSR *bsr, DEV_BLOCK *block);
+void position_bsr_block(BSR *bsr, DEV_BLOCK *block);
+BSR *find_next_bsr(BSR *root_bsr, DEVICE *dev);
+bool match_set_eof(BSR *bsr, DEV_RECORD *rec);
/* From mount.c */
-int mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool release);
-int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
-void release_volume(JCR *jcr, DEVICE *dev);
-void mark_volume_in_error(JCR *jcr, DEVICE *dev);
+bool mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool release);
+bool mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+void release_volume(JCR *jcr, DEVICE *dev);
+void mark_volume_in_error(JCR *jcr, DEVICE *dev);
/* From autochanger.c */
-int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir);
-int autochanger_list(JCR *jcr, DEVICE *dev, BSOCK *dir);
-void invalidate_slot_in_catalog(JCR *jcr, DEVICE *dev);
+int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir);
+int autochanger_list(JCR *jcr, DEVICE *dev, BSOCK *dir);
+void invalidate_slot_in_catalog(JCR *jcr, DEVICE *dev);
/* From parse_bsr.c */
-BSR *parse_bsr(JCR *jcr, char *lf);
-void dump_bsr(BSR *bsr, bool recurse);
-void free_bsr(BSR *bsr);
+BSR *parse_bsr(JCR *jcr, char *lf);
+void dump_bsr(BSR *bsr, bool recurse);
+void free_bsr(BSR *bsr);
VOL_LIST *new_vol();
-int add_vol(JCR *jcr, VOL_LIST *vol);
-void free_vol_list(JCR *jcr);
-void create_vol_list(JCR *jcr);
+int add_vol(JCR *jcr, VOL_LIST *vol);
+void free_vol_list(JCR *jcr);
+void create_vol_list(JCR *jcr);
/* From record.c */
const char *FI_to_ascii(int fi);
const char *stream_to_ascii(int stream, int fi);
-int write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
-int can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
-int read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec);
+int write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
+int can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
+int read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec);
DEV_RECORD *new_record();
-void free_record(DEV_RECORD *rec);
+void free_record(DEV_RECORD *rec);
/* From read_record.c */
-int read_records(JCR *jcr, DEVICE *dev,
- int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec),
- int mount_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block));
+bool read_records(JCR *jcr, DEVICE *dev,
+ bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec),
+ bool mount_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block));
/* From spool.c */
-bool begin_data_spool (JCR *jcr);
-bool discard_data_spool (JCR *jcr);
-bool commit_data_spool (JCR *jcr);
-bool are_attributes_spooled (JCR *jcr);
-bool begin_attribute_spool (JCR *jcr);
-bool discard_attribute_spool (JCR *jcr);
-bool commit_attribute_spool (JCR *jcr);
-bool write_block_to_spool_file (DCR *dcr, DEV_BLOCK *block);
-void list_spool_stats (BSOCK *bs);
+bool begin_data_spool (JCR *jcr);
+bool discard_data_spool (JCR *jcr);
+bool commit_data_spool (JCR *jcr);
+bool are_attributes_spooled (JCR *jcr);
+bool begin_attribute_spool (JCR *jcr);
+bool discard_attribute_spool (JCR *jcr);
+bool commit_attribute_spool (JCR *jcr);
+bool write_block_to_spool_file (DCR *dcr, DEV_BLOCK *block);
+void list_spool_stats (BSOCK *bs);
#include "stored.h"
/* Forward referenced subroutines */
-static int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
+static bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
/* Responses sent to the File daemon */
* Returns: 0 on failure
* 1 on success
*/
-int do_read_data(JCR *jcr)
+bool do_read_data(JCR *jcr)
{
BSOCK *fd = jcr->file_bsock;
- int ok = TRUE;
+ bool ok = true;
DEVICE *dev;
Dmsg0(20, "Start read data.\n");
Dmsg1(10, "bstored>filed: %s\n", fd->msg);
if (!bnet_set_buffer_size(fd, jcr->device->max_network_buffer_size, BNET_SETBUF_WRITE)) {
- return 0;
+ return false;
}
Jmsg(jcr, M_FATAL, 0, _("No Volume names found for restore.\n"));
free_vol_list(jcr);
bnet_fsend(fd, FD_error);
- return 0;
+ return false;
}
Dmsg2(200, "Found %d volumes names to restore. First=%s\n", jcr->NumVolumes,
*/
if (!acquire_device_for_read(jcr)) {
free_vol_list(jcr);
- return 0;
+ return false;
}
/* Tell File daemon we will send data */
bnet_sig(fd, BNET_EOD);
if (!release_device(jcr)) {
- ok = FALSE;
+ ok = false;
}
free_vol_list(jcr);
Dmsg0(30, "Done reading.\n");
- return ok ? 1 : 0;
+ return ok;
}
/*
* Called here for each record from read_records()
+ * Returns: true if OK
+ * false if error
*/
-static int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
+static bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
{
BSOCK *fd = jcr->file_bsock;
- int ok = TRUE;
+ bool ok = true;
POOLMEM *save_msg;
if (rec->FileIndex < 0) {
- return 1;
+ return true;
}
Dmsg5(100, "Send to FD: SessId=%u SessTim=%u FI=%d Strm=%d, len=%d\n",
rec->VolSessionId, rec->VolSessionTime, rec->FileIndex, rec->Stream,
Dmsg1(30, ">filed: Error Hdr=%s\n", fd->msg);
Jmsg1(jcr, M_FATAL, 0, _("Error sending to File daemon. ERR=%s\n"),
bnet_strerror(fd));
- return FALSE;
+ return false;
} else {
Dmsg1(30, ">filed: Hdr=%s\n", fd->msg);
}
Jmsg1(jcr, M_FATAL, 0, _("Error sending to File daemon. ERR=%s\n"),
bnet_strerror(fd));
- ok = FALSE;
+ ok = false;
}
fd->msg = save_msg; /* restore fd message pointer */
return ok;
static char *rec_state_to_str(DEV_RECORD *rec);
#endif
-int read_records(JCR *jcr, DEVICE *dev,
- int record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec),
- int mount_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block))
+bool read_records(JCR *jcr, DEVICE *dev,
+ bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec),
+ bool mount_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block))
{
DEV_BLOCK *block;
DEV_RECORD *rec = NULL;
uint32_t record;
- int ok = TRUE;
+ bool ok = true;
bool done = false;
SESSION_LABEL sessrec;
dlist *recs; /* linked list of rec packets open */
for ( ; ok && !done; ) {
if (job_canceled(jcr)) {
- ok = FALSE;
+ ok = false;
break;
}
if (!read_block_from_device(jcr, dev, block, CHECK_BLOCK_NUMBERS)) {
dev->file, dev_name(dev), jcr->VolumeName);
if (!mount_cb(jcr, dev, block)) {
Jmsg(jcr, M_INFO, 0, "End of all volumes.\n");
- ok = FALSE;
+ ok = false;
/*
* Create EOT Label so that Media record may
* be properly updated because this is the last
Dmsg0(000, "Did fsr\n");
continue; /* try to continue */
}
- ok = FALSE;
+ ok = false;
break;
}
}
#undef VERSION
#define VERSION "1.35.0"
#define VSTRING "1"
-#define BDATE "01 July 2004"
-#define LSMDATE "01Jul04"
+#define BDATE "04 July 2004"
+#define LSMDATE "04Jul04"
/* Debug flags */
#undef DEBUG