}
-
+/*
+ * Escape strings so that MySQL is happy
+ *
+ * NOTE! len is the length of the old string. Your new
+ * string must be long enough (max 2*old) to hold
+ * the escaped output.
+ */
void
db_escape_string(char *snew, char *old, int len)
{
- mysql_escape_string(snew, old, len);
+ char *n, *o;
+
+ n = snew;
+ o = old;
+ while (len--) {
+ switch (*o) {
+ case 0:
+ *n++= '\\';
+ *n++= '0';
+ o++;
+ break;
+ case '\n':
+ *n++= '\\';
+ *n++= 'n';
+ o++;
+ break;
+ case '\r':
+ *n++= '\\';
+ *n++= 'r';
+ o++;
+ break;
+ case '\\':
+ *n++= '\\';
+ *n++= '\\';
+ o++;
+ break;
+ case '\'':
+ *n++= '\\';
+ *n++= '\'';
+ o++;
+ break;
+ case '"':
+ *n++= '\\';
+ *n++= '"';
+ o++;
+ break;
+ case '\032':
+ *n++= '\\';
+ *n++= 'Z';
+ o++;
+ break;
+ default:
+ *n++= *o++;
+ }
+ }
+ *n = 0;
}
/*
SQL_ROW row;
int stat;
- mdb->esc_name = check_pool_memory_size(mdb->esc_name, mdb->pnl+101);
- db_escape_string(mdb->esc_name, mdb->path, mdb->pnl+100);
+ mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->pnl+2);
+ db_escape_string(mdb->esc_name, mdb->path, mdb->pnl);
+ sm_check(__FILE__, __LINE__, True);
if (mdb->cached_path_id != 0 && mdb->cached_path_len == mdb->pnl &&
strcmp(mdb->cached_path, mdb->path) == 0) {
{
SQL_ROW row;
-
- mdb->esc_name = check_pool_memory_size(mdb->esc_name, mdb->fnl+101);
- db_escape_string(mdb->esc_name, mdb->fname, mdb->fnl+100);
+ mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2);
+ db_escape_string(mdb->esc_name, mdb->fname, mdb->fnl);
+ sm_check(__FILE__, __LINE__, True);
Mmsg(&mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name);
/* Forward referenced functions */
static int db_get_file_record(B_DB *mdb, FILE_DBR *fdbr);
-static int db_get_filename_record(B_DB *mdb, char *fname);
-static int db_get_path_record(B_DB *mdb, char *path);
+static int db_get_filename_record(B_DB *mdb);
+static int db_get_path_record(B_DB *mdb);
/* Imported subroutines */
extern void print_result(B_DB *mdb);
extern int QueryDB(char *file, int line, B_DB *db, char *select_cmd);
+extern void split_path_and_filename(B_DB *mdb, char *fname);
+
/*
*/
int db_get_file_attributes_record(B_DB *mdb, char *fname, FILE_DBR *fdbr)
{
- int fnl, pnl;
- char *l, *p;
int stat;
- char file[MAXSTRING];
- char spath[MAXSTRING];
- char buf[MAXSTRING];
Dmsg1(20, "Enter get_file_from_catalog fname=%s \n", fname);
- /* Find path without the filename.
- * I.e. everything after the last / is a "filename".
- * OK, maybe it is a directory name, but we treat it like
- * a filename. If we don't find a / then the whole name
- * must be a path name (e.g. c:).
- */
- for (p=l=fname; *p; p++) {
- if (*p == '/') {
- l = p;
- }
- }
- if (*l == '/') { /* did we find a slash? */
- l++; /* yes, point to filename */
- } else { /* no, whole thing must be path name */
- l = p;
- }
-
- /* If filename doesn't exist (i.e. root directory), we
- * simply create a blank name consisting of a single
- * space. This makes handling zero length filenames
- * easier.
- */
- fnl = p - l;
- if (fnl > 255) {
- Jmsg1(mdb->jcr, M_WARNING, 0, _("Filename truncated to 255 chars: %s\n"), l);
- fnl = 255;
- }
- if (fnl > 0) {
- strncpy(file, l, fnl); /* copy filename */
- file[fnl] = 0;
- } else {
- file[0] = ' '; /* blank filename */
- file[1] = 0;
- fnl = 1;
- }
-
- pnl = l - fname;
- if (pnl > 255) {
- Jmsg1(mdb->jcr, M_WARNING, 0, _("Path name truncated to 255 chars: %s\n"), fname);
- pnl = 255;
- }
- strncpy(spath, fname, pnl);
- spath[pnl] = 0;
-
- if (pnl == 0) {
- Mmsg1(&mdb->errmsg, _("Path length is zero. File=%s\n"), fname);
- Jmsg(mdb->jcr, M_ERROR, 0, "%s", mdb->errmsg);
- spath[0] = ' ';
- spath[1] = 0;
- pnl = 1;
- }
-
- Dmsg1(400, "spath=%s\n", spath);
- Dmsg1(400, "file=%s\n", file);
+ db_lock(mdb);
+ split_path_and_filename(mdb, fname);
- db_escape_string(buf, file, fnl);
- fdbr->FilenameId = db_get_filename_record(mdb, buf);
- Dmsg2(400, "db_get_filename_record FilenameId=%u file=%s\n", fdbr->FilenameId, buf);
+ fdbr->FilenameId = db_get_filename_record(mdb);
- db_escape_string(buf, spath, pnl);
- fdbr->PathId = db_get_path_record(mdb, buf);
- Dmsg2(400, "db_get_path_record PathId=%u path=%s\n", fdbr->PathId, buf);
+ fdbr->PathId = db_get_path_record(mdb);
stat = db_get_file_record(mdb, fdbr);
+ db_unlock(mdb);
+
return stat;
}
SQL_ROW row;
int stat = 0;
- db_lock(mdb);
Mmsg(&mdb->cmd,
"SELECT FileId, LStat, MD5 from File where File.JobId=%u and File.PathId=%u and \
File.FilenameId=%u", fdbr->JobId, fdbr->PathId, fdbr->FilenameId);
}
sql_free_result(mdb);
}
- db_unlock(mdb);
return stat;
}
*
* DO NOT use Jmsg in this routine (see notes for get_file_record)
*/
-static int db_get_filename_record(B_DB *mdb, char *fname)
+static int db_get_filename_record(B_DB *mdb)
{
SQL_ROW row;
int FilenameId = 0;
- if (*fname == 0) {
- Mmsg0(&mdb->errmsg, _("Null name given to db_get_filename_record\n"));
- Emsg0(M_ABORT, 0, mdb->errmsg);
- }
-
- db_lock(mdb);
- Mmsg(&mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", fname);
+ mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2);
+ db_escape_string(mdb->esc_name, mdb->fname, mdb->fnl);
+ sm_check(__FILE__, __LINE__, True);
+
+ Mmsg(&mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name);
if (QUERY_DB(mdb, mdb->cmd)) {
mdb->num_rows = sql_num_rows(mdb);
}
}
} else {
- Mmsg1(&mdb->errmsg, _("Filename record: %s not found.\n"), fname);
+ Mmsg1(&mdb->errmsg, _("Filename record: %s not found.\n"), mdb->fname);
}
sql_free_result(mdb);
}
- db_unlock(mdb);
return FilenameId;
}
*
* DO NOT use Jmsg in this routine (see notes for get_file_record)
*/
-static int db_get_path_record(B_DB *mdb, char *path)
+static int db_get_path_record(B_DB *mdb)
{
SQL_ROW row;
uint32_t PathId = 0;
- if (*path == 0) {
- Emsg0(M_ABORT, 0, _("Null path given to db_get_path_record\n"));
- }
+ mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->pnl+2);
+ db_escape_string(mdb->esc_name, mdb->path, mdb->pnl);
+ sm_check(__FILE__, __LINE__, True);
- db_lock(mdb);
-
- if (mdb->cached_path_id != 0 && strcmp(mdb->cached_path, path) == 0) {
- db_unlock(mdb);
+ if (mdb->cached_path_id != 0 && mdb->cached_path_len == mdb->pnl &&
+ strcmp(mdb->cached_path, mdb->path) == 0) {
return mdb->cached_path_id;
}
- Mmsg(&mdb->cmd, "SELECT PathId FROM Path WHERE Path='%s'", path);
+ Mmsg(&mdb->cmd, "SELECT PathId FROM Path WHERE Path='%s'", mdb->esc_name);
if (QUERY_DB(mdb, mdb->cmd)) {
char ed1[30];
/* Cache path */
if (PathId != mdb->cached_path_id) {
mdb->cached_path_id = PathId;
- mdb->cached_path = check_pool_memory_size(mdb->cached_path,
- strlen(path)+1);
- strcpy(mdb->cached_path, path);
+ mdb->cached_path_len = mdb->pnl;
+ pm_strcpy(&mdb->cached_path, mdb->path);
}
}
}
} else {
- Mmsg1(&mdb->errmsg, _("Path record: %s not found.\n"), path);
+ Mmsg1(&mdb->errmsg, _("Path record: %s not found.\n"), mdb->path);
}
sql_free_result(mdb);
}
- db_unlock(mdb);
return PathId;
}
int
db_update_media_record(B_DB *mdb, MEDIA_DBR *mr)
{
- char dt[MAX_TIME_LENGTH], dtF[MAX_TIME_LENGTH];
+ char dt[MAX_TIME_LENGTH];
time_t ttime;
struct tm tm;
int stat;
char ed1[30], ed2[30];
- ttime = mr->LastWritten;
- localtime_r(&ttime, &tm);
- strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
Dmsg1(100, "update_media: FirstWritten=%d\n", mr->FirstWritten);
db_lock(mdb);
Dmsg1(400, "Set FirstWritten Vol=%s\n", mr->VolumeName);
ttime = mr->FirstWritten;
localtime_r(&ttime, &tm);
- strftime(dtF, sizeof(dtF), "%Y-%m-%d %T", &tm);
+ strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
Mmsg(&mdb->cmd, "UPDATE Media SET FirstWritten='%s'\
- WHERE VolumeName='%s'", dtF, mr->VolumeName);
+ WHERE VolumeName='%s'", dt, mr->VolumeName);
stat = UPDATE_DB(mdb, mdb->cmd);
Dmsg1(400, "Firstwritten stat=%d\n", stat);
}
+ ttime = mr->LastWritten;
+ localtime_r(&ttime, &tm);
+ strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
+
Mmsg(&mdb->cmd, "UPDATE Media SET VolJobs=%u,\
- VolFiles=%u, VolBlocks=%u, VolBytes=%s, VolMounts=%u, VolErrors=%u,\
- VolWrites=%u, MaxVolBytes=%s, LastWritten='%s', VolStatus='%s',\
+ VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u,\
+ VolWrites=%u,MaxVolBytes=%s,LastWritten='%s',VolStatus='%s',\
Slot=%d WHERE VolumeName='%s'",
mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
mr->VolMounts, mr->VolErrors, mr->VolWrites,
edit_uint64(mr->MaxVolBytes, ed2), dt,
mr->VolStatus, mr->Slot, mr->VolumeName);
+ sm_check(__FILE__, __LINE__, True);
+
Dmsg1(400, "%s\n", mdb->cmd);
stat = UPDATE_DB(mdb, mdb->cmd);
}
-
+/*
+ * Escape strings so that SQLite is happy
+ *
+ * NOTE! len is the length of the old string. Your new
+ * string must be long enough (max 2*old) to hold
+ * the escaped output.
+ */
void
db_escape_string(char *snew, char *old, int len)
{
mr->LabelDate = 0;
strcpy(mr->MediaType, jcr->store->media_type);
strcpy(name, pr.LabelFormat);
+ if (strchr(name, (int)'%') != NULL) {
+ Jmsg(jcr, M_ERROR, 0, _("Illegal character in Label Format\n"));
+ return 0;
+ }
strcat(name, "%04d");
sprintf(mr->VolumeName, name, ++pr.NumVols);
if (db_create_media_record(jcr->db, mr) &&
bs->msglen = len;
bnet_send(bs);
} else { /* No UA, send to Job */
- Jmsg(ua->jcr, M_INFO, 0, msg);
+ Jmsg(ua->jcr, M_INFO, 0, "%s", msg);
free_pool_memory(msg);
}
*p++ = '\n';
*p = 0;
Dmsg0(20, buf);
- Jmsg(jcr, M_INFO, 0, buf);
+ Jmsg(jcr, M_INFO, 0, "%s", buf);
}
*p++ = '\n';
*p = 0;
Dmsg0(20, buf);
- Jmsg(jcr, M_INFO, 0, buf);
+ Jmsg(jcr, M_INFO, 0, "%s", buf);
}
#endif
*/
/*
- Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+ Copyright (C) 2000-2003 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
struct abufhead *free_buf; /* pointer to free buffers */
};
+#ifndef STRESS_TEST_POOL
+/*
+ * Define default Pool buffer sizes
+ */
static struct s_pool_ctl pool_ctl[] = {
{ 256, 256, 0, 0, NULL }, /* PM_NOPOOL no pooling */
{ 256, 256, 0, 0, NULL }, /* PM_FNAME filename buffers */
{ 512, 512, 0, 0, NULL }, /* PM_MESSAGE message buffer */
{ 1024, 1024, 0, 0, NULL } /* PM_EMSG error message buffer */
};
+#else
+
+/* This is used ONLY when stress testing the code */
+static struct s_pool_ctl pool_ctl[] = {
+ { 10, 10, 0, 0, NULL }, /* PM_NOPOOL no pooling */
+ { 10, 10, 0, 0, NULL }, /* PM_FNAME filename buffers */
+ { 10, 10, 0, 0, NULL }, /* PM_MESSAGE message buffer */
+ { 10, 10, 0, 0, NULL } /* PM_EMSG error message buffer */
+};
+#endif
+
/* Memory allocation control structures and storage. */
struct abufhead {
ASSERT(obuf);
P(mutex);
cp -= HEAD_SIZE;
- buf = realloc(cp, size+HEAD_SIZE);
+ buf = sm_realloc(fname, lineno, cp, size+HEAD_SIZE);
+ sm_check(fname, lineno, True);
if (buf == NULL) {
V(mutex);
Emsg1(M_ABORT, 0, "Out of memory requesting %d bytes\n", size);
return realloc_pool_memory(obuf, size);
}
+/* Free a memory buffer */
+void sm_free_pool_memory(char *fname, int lineno, POOLMEM *obuf)
+{
+ struct abufhead *buf;
+ int pool;
+
+ sm_check(fname, lineno, True);
+ ASSERT(obuf);
+ P(mutex);
+ buf = (struct abufhead *)((char *)obuf - HEAD_SIZE);
+ pool = buf->pool;
+ pool_ctl[pool].in_use--;
+ if (pool == 0) {
+ free((char *)buf); /* free nonpooled memory */
+ } else { /* otherwise link it to the free pool chain */
+#ifdef DEBUG
+ struct abufhead *next;
+ /* Don't let him free the same buffer twice */
+ for (next=pool_ctl[pool].free_buf; next; next=next->next) {
+ ASSERT(next != buf); /* attempt to free twice */
+ }
+#endif
+ buf->next = pool_ctl[pool].free_buf;
+ pool_ctl[pool].free_buf = buf;
+ }
+ Dmsg2(150, "free_pool_memory %x pool=%d\n", buf, pool);
+ V(mutex);
+}
+
+
#else
+/* =================================================================== */
+
POOLMEM *get_pool_memory(int pool)
{
struct abufhead *buf;
return realloc_pool_memory(obuf, size);
}
-#endif /* SMARTALLOC */
-
-
-
/* Free a memory buffer */
void free_pool_memory(POOLMEM *obuf)
{
V(mutex);
}
+#endif /* SMARTALLOC */
+
+
+
+
/* Release all pooled memory */
#define check_pool_memory_size(buf,size) sm_check_pool_memory_size(__FILE__, __LINE__, buf, size)
extern POOLMEM *sm_check_pool_memory_size(char *fname, int line, POOLMEM *buf, size_t size);
+#define free_pool_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x)
+#define free_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x)
+extern void sm_free_pool_memory(char *fname, int line, POOLMEM *buf);
+
+
#else
extern POOLMEM *get_pool_memory(int pool);
extern size_t sizeof_pool_memory(POOLMEM *buf);
extern POOLMEM *realloc_pool_memory(POOLMEM *buf, size_t size);
extern POOLMEM *check_pool_memory_size(POOLMEM *buf, size_t size);
+#define free_memory(x) free_pool_memory(x)
+extern void free_pool_memory(POOLMEM *buf);
#endif
-#define free_memory(x) free_pool_memory(x)
-extern void free_pool_memory(POOLMEM *buf);
extern void close_memory_pool();
extern void print_memory_pool_stats();
Dmsg2(200, "Enter dispatch_msg type=%d msg=%s\n", type, msg);
if (type == M_ABORT || type == M_ERROR_TERM) {
- fprintf(stdout, msg); /* print this here to INSURE that it is printed */
+ fprintf(stdout, "%s", msg); /* print this here to INSURE that it is printed */
}
/* Now figure out where to send the message */
case MD_STDOUT:
Dmsg1(400, "STDOUT for following msg: %s", msg);
if (type != M_ABORT && type != M_ERROR_TERM) /* already printed */
- fprintf(stdout, msg);
+ fprintf(stdout, "%s", msg);
break;
case MD_STDERR:
Dmsg1(400, "STDERR for following msg: %s", msg);
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
break;
default:
break;
bvsnprintf(buf+i, sizeof(buf)-i, (char *)fmt, arg_ptr);
va_end(arg_ptr);
- fprintf(stdout, buf);
+ fprintf(stdout, "%s", buf);
}
}
if (bad) {
Emsg2(M_FATAL, 0,
"\nDamaged buffers found at %s:%d\n", fname, lineno);
+
if (bad & 0x1) {
Emsg0(M_FATAL, 0, " discovery of bad prev link.\n");
}
}
/* Write out final block of this session */
if (!write_block_to_device(jcr, dev, block)) {
- Pmsg0(000, "Set ok=FALSE after write_block_to_device.\n");
+ Pmsg0(000, _("Set ok=FALSE after write_block_to_device.\n"));
ok = FALSE;
}
/* Release the device */
if (!release_device(jcr, dev)) {
- Pmsg0(000, "Error in release_device\n");
+ Pmsg0(000, _("Error in release_device\n"));
ok = FALSE;
}
case 'e': /* exclude list */
if ((fd = fopen(optarg, "r")) == NULL) {
- Pmsg2(0, "Could not open exclude file: %s, ERR=%s\n",
+ Pmsg2(0, _("Could not open exclude file: %s, ERR=%s\n"),
optarg, strerror(errno));
exit(1);
}
}
switch (rec->FileIndex) {
case PRE_LABEL:
- Pmsg0(000, "Volume is prelabeled. This tape cannot be scanned.\n");
+ Pmsg0(000, _("Volume is prelabeled. This tape cannot be scanned.\n"));
return;
break;
case VOL_LABEL:
strcpy(pr.PoolType, dev->VolHdr.PoolType);
if (db_get_pool_record(db, &pr)) {
if (verbose) {
- Pmsg1(000, "Pool record for %s found in DB.\n", pr.Name);
+ Pmsg1(000, _("Pool record for %s found in DB.\n"), pr.Name);
}
} else {
if (!update_db) {
- Pmsg1(000, "VOL_LABEL: Pool record not found for Pool: %s\n",
+ Pmsg1(000, _("VOL_LABEL: Pool record not found for Pool: %s\n"),
pr.Name);
}
create_pool_record(db, &pr);
}
if (strcmp(pr.PoolType, dev->VolHdr.PoolType) != 0) {
- Pmsg2(000, "VOL_LABEL: PoolType mismatch. DB=%s Vol=%s\n",
+ Pmsg2(000, _("VOL_LABEL: PoolType mismatch. DB=%s Vol=%s\n"),
pr.PoolType, dev->VolHdr.PoolType);
return;
} else if (verbose) {
- Pmsg1(000, "Pool type \"%s\" is OK.\n", pr.PoolType);
+ Pmsg1(000, _("Pool type \"%s\" is OK.\n"), pr.PoolType);
}
/* Check Media Info */
mr.PoolId = pr.PoolId;
if (db_get_media_record(db, &mr)) {
if (verbose) {
- Pmsg1(000, "Media record for %s found in DB.\n", mr.VolumeName);
+ Pmsg1(000, _("Media record for %s found in DB.\n"), mr.VolumeName);
}
/* Clear out some volume statistics that will be updated */
mr.VolJobs = mr.VolFiles = mr.VolBlocks = 0;
mr.VolBytes = rec->data_len + 20;
} else {
if (!update_db) {
- Pmsg1(000, "VOL_LABEL: Media record not found for Volume: %s\n",
+ Pmsg1(000, _("VOL_LABEL: Media record not found for Volume: %s\n"),
mr.VolumeName);
}
strcpy(mr.MediaType, dev->VolHdr.MediaType);
create_media_record(db, &mr, &dev->VolHdr);
}
if (strcmp(mr.MediaType, dev->VolHdr.MediaType) != 0) {
- Pmsg2(000, "VOL_LABEL: MediaType mismatch. DB=%s Vol=%s\n",
+ Pmsg2(000, _("VOL_LABEL: MediaType mismatch. DB=%s Vol=%s\n"),
mr.MediaType, dev->VolHdr.MediaType);
return;
} else if (verbose) {
- Pmsg1(000, "Media type \"%s\" is OK.\n", mr.MediaType);
+ Pmsg1(000, _("Media type \"%s\" is OK.\n"), mr.MediaType);
}
/* Reset some JCR variables */
for (mjcr=NULL; (mjcr=next_attached_jcr(dev, mjcr)); ) {
mjcr->StartFile = mjcr->EndFile = 0;
}
- Pmsg1(000, "VOL_LABEL: OK for Volume: %s\n", mr.VolumeName);
+ Pmsg1(000, _("VOL_LABEL: OK for Volume: %s\n"), mr.VolumeName);
break;
case SOS_LABEL:
mr.VolJobs++;
} else {
/* Must create a Job record in DB */
if (!update_db) {
- Pmsg1(000, "SOS_LABEL: Job record not found for JobId: %d\n",
+ Pmsg1(000, _("SOS_LABEL: Job record not found for JobId: %d\n"),
jr.JobId);
}
}
pm_strcpy(&mjcr->pool_name, label.PoolName);
if (rec->VolSessionId != jr.VolSessionId) {
- Pmsg3(000, "SOS_LABEL: VolSessId mismatch for JobId=%u. DB=%d Vol=%d\n",
+ Pmsg3(000, _("SOS_LABEL: VolSessId mismatch for JobId=%u. DB=%d Vol=%d\n"),
jr.JobId,
jr.VolSessionId, rec->VolSessionId);
return;
}
if (rec->VolSessionTime != jr.VolSessionTime) {
- Pmsg3(000, "SOS_LABEL: VolSessTime mismatch for JobId=%u. DB=%d Vol=%d\n",
+ Pmsg3(000, _("SOS_LABEL: VolSessTime mismatch for JobId=%u. DB=%d Vol=%d\n"),
jr.JobId,
jr.VolSessionTime, rec->VolSessionTime);
return;
}
if (jr.PoolId != pr.PoolId) {
- Pmsg3(000, "SOS_LABEL: PoolId mismatch for JobId=%u. DB=%d Vol=%d\n",
+ Pmsg3(000, _("SOS_LABEL: PoolId mismatch for JobId=%u. DB=%d Vol=%d\n"),
jr.JobId,
jr.PoolId, pr.PoolId);
return;
Dmsg1(100, "Walk attached jcrs. Volume=%s\n", dev->VolCatInfo.VolCatName);
for (JCR *mjcr=NULL; (mjcr=next_attached_jcr(dev, mjcr)); ) {
if (verbose) {
- Pmsg1(000, "create JobMedia for Job %s\n", mjcr->Job);
+ Pmsg1(000, _("Create JobMedia for Job %s\n"), mjcr->Job);
}
if (dev->state & ST_TAPE) {
mjcr->EndBlock = dev->EndBlock;
}
}
- fprintf(stderr, "Mount Volume %s on device %s and press return when ready: ",
+ fprintf(stderr, _("Mount Volume %s on device %s and press return when ready: "),
jcr->VolumeName, dev_name(dev));
getchar();
return 1;
* Handle opening of file
*/
archive_name = get_pool_memory(PM_FNAME);
- strcpy(archive_name, dev->dev_name);
+ pm_strcpy(&archive_name, dev->dev_name);
if (archive_name[strlen(archive_name)] != '/') {
- strcat(archive_name, "/");
+ pm_strcat(&archive_name, "/");
}
- strcat(archive_name, VolName);
+ pm_strcat(&archive_name, VolName);
Dmsg1(29, "open_dev: device is disk %s\n", archive_name);
if (mode == READ_WRITE) {
dev->mode = O_CREAT | O_RDWR | O_BINARY;
dev->VolHdr.LabelSize = rec->data_len;
- /* Unserialize the record into the Volume Header */
- ser_begin(rec->data, SER_LENGTH_Volume_Label);
+ /* Unserialize the record into the Volume Header */
+ rec->data = check_pool_memory_size(rec->data, SER_LENGTH_Volume_Label);
+ ser_begin(rec->data, SER_LENGTH_Volume_Label);
#define Fld(x) (dev->VolHdr.x)
unser_string(Fld(Id));
/* Serialize the label into the device record. */
+ rec->data = check_pool_memory_size(rec->data, SER_LENGTH_Volume_Label);
ser_begin(rec->data, SER_LENGTH_Volume_Label);
#define Fld(x) (dev->VolHdr.x)
ser_string(Fld(Id));
rec->VolSessionTime = jcr->VolSessionTime;
rec->Stream = jcr->JobId;
+ rec->data = check_pool_memory_size(rec->data, SER_LENGTH_Session_Label);
ser_begin(rec->data, SER_LENGTH_Session_Label);
ser_string(BaculaId);
ser_uint32(BaculaTapeVersion);
{
ser_declare;
+ rec->data = check_pool_memory_size(rec->data, SER_LENGTH_Session_Label);
unser_begin(rec->data, SER_LENGTH_Session_Label);
unser_string(label->Id);
unser_uint32(label->VerNum);