From 4ff2b2ba893d4035fa46a8e3d783f403f190610a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 17 Aug 2004 14:40:27 +0000 Subject: [PATCH] Fix conio.h problem on Solaris Add debug code to lock_jcr_chain Implement call by reference for Mmsg() and pm_strxxx() git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1541 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/config.h.in | 3 + bacula/autoconf/configure.in | 1 + bacula/configure | 2 + bacula/kernstodo | 22 +-- bacula/src/baconfig.h | 110 +++++------ bacula/src/cats/bdb.c | 2 +- bacula/src/cats/bdb_list.c | 14 +- bacula/src/cats/bdb_update.c | 8 +- bacula/src/cats/mysql.c | 2 +- bacula/src/cats/postgresql.c | 4 +- bacula/src/cats/sql.c | 2 +- bacula/src/cats/sql_create.c | 38 ++-- bacula/src/cats/sql_delete.c | 20 +- bacula/src/cats/sql_find.c | 18 +- bacula/src/cats/sql_get.c | 74 ++++---- bacula/src/cats/sql_list.c | 40 ++-- bacula/src/cats/sql_update.c | 28 +-- bacula/src/cats/sqlite.c | 12 +- bacula/src/console/conio.c | 7 + bacula/src/dird/bsr.c | 2 +- bacula/src/dird/catreq.c | 4 +- bacula/src/dird/fd_cmds.c | 24 +-- bacula/src/dird/job.c | 6 +- bacula/src/dird/jobq.c | 10 +- bacula/src/dird/msgchan.c | 10 +- bacula/src/dird/recycle.c | 6 +- bacula/src/dird/ua_cmds.c | 26 +-- bacula/src/dird/ua_dotcmds.c | 4 +- bacula/src/dird/ua_input.c | 2 +- bacula/src/dird/ua_label.c | 2 +- bacula/src/dird/ua_prune.c | 40 ++-- bacula/src/dird/ua_purge.c | 30 +-- bacula/src/dird/ua_query.c | 4 +- bacula/src/dird/ua_restore.c | 40 ++-- bacula/src/dird/ua_server.c | 2 +- bacula/src/dird/ua_status.c | 8 +- bacula/src/dird/verify.c | 4 +- bacula/src/filed/job.c | 4 +- bacula/src/filed/status.c | 32 ++-- bacula/src/jcr.h | 10 +- bacula/src/lib/jcr.c | 23 ++- bacula/src/lib/message.c | 63 ++++++- bacula/src/lib/protos.h | 248 +++++++++++++------------ bacula/src/lib/util.c | 23 +++ bacula/src/stored/acquire.c | 2 +- bacula/src/stored/askdir.c | 18 +- bacula/src/stored/block.c | 24 +-- bacula/src/stored/btape.c | 2 +- bacula/src/stored/dev.c | 4 +- bacula/src/stored/fd_cmds.c | 2 +- bacula/src/stored/label.c | 20 +- bacula/src/wx-console/wxbmainframe.cpp | 2 +- 52 files changed, 604 insertions(+), 504 deletions(-) diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index a6ae9dfc99..a0e5f68d5e 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -502,6 +502,9 @@ /* Define to 1 if you have the `tcgetattr' function. */ #undef HAVE_TCGETATTR +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMCAP_H + /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index d7eead010f..e72a34826b 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -988,6 +988,7 @@ AC_CHECK_HEADERS( \ stdint.h \ string.h \ termios.h \ + termcap.h \ unistd.h \ sys/bitypes.h \ sys/byteorder.h \ diff --git a/bacula/configure b/bacula/configure index 92a5040dbb..4f10810af4 100755 --- a/bacula/configure +++ b/bacula/configure @@ -9163,6 +9163,7 @@ fi + for ac_header in \ @@ -9177,6 +9178,7 @@ for ac_header in \ stdint.h \ string.h \ termios.h \ + termcap.h \ unistd.h \ sys/bitypes.h \ sys/byteorder.h \ diff --git a/bacula/kernstodo b/bacula/kernstodo index 05d28bce80..c80bec7902 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -11,22 +11,11 @@ Version 1.35 Kern (see below) ======================================================== 1.35 Items to do for release: -- Find memory leaks in address_conf.c -- Network order of port and ip addresses. -- SetIP in dird/fd_cmds.c is broken. -- don't use inet_addr() it is deprecated. -- Fix code in filed.c for init_bsock(); -- Fix code in console.c for init_bsock(); - - - Knoppix CDROM -- Make Verify jobs require exclusive use of Volume as Restore - jobs do. - Perhaps add read/write programs and/or plugins to FileSets. - Add new DCR calling sequences everywhere in SD. This will permit simultaneous use of multiple devices by a single job. - Fix restore ++++ that get intermingled with "Building directory tree" -- Solve the termcap.h problem on Solaris configure. - Test Win32 errno handling. @@ -80,6 +69,8 @@ For 1.37 Testing/Documentation: non-existent directories will not be restored properly. Wish list: +- Fix restore jobs so that multiple jobs can run if they + are not using the same tape(s). - Allow the user to select JobType for manual pruning/purging. - Look at adding Client run command that will use the port opened by the client. @@ -1177,3 +1168,12 @@ Block Position: 0 - When passwords do not match, print message that points the user to the doc. - Do tape alerts -- see tapealert.txt +- Find memory leaks in address_conf.c +- Network order of port and ip addresses. +- SetIP in dird/fd_cmds.c is broken. +- don't use inet_addr() it is deprecated. +- Fix code in filed.c for init_bsock(); +- Fix code in console.c for init_bsock(); +- Solve the termcap.h problem on Solaris configure. +- Make Verify jobs require exclusive use of Volume as Restore + jobs do. diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 455e498bbb..8802f16871 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -30,8 +30,8 @@ /* Bacula common configuration defines */ -#undef TRUE -#undef FALSE +#undef TRUE +#undef FALSE #define TRUE 1 #define FALSE 0 @@ -40,9 +40,9 @@ #endif #ifdef PROTOTYPES -# define __PROTO(p) p +# define __PROTO(p) p #else -# define __PROTO(p) () +# define __PROTO(p) () #endif #ifdef DEBUG @@ -100,7 +100,7 @@ #define DEFAULT_NETWORK_BUFFER_SIZE (32 * 1024) /* - * Stream definitions. Once defined these must NEVER + * Stream definitions. Once defined these must NEVER * change as they go on the storage media. * Note, the following streams are passed from the SD to the DIR * so that they may be put into the catalog (actually only the @@ -111,62 +111,62 @@ * STREAM_MD5_SIGNATURE * STREAM_SHA1_SIGNATURE */ -#define STREAM_UNIX_ATTRIBUTES 1 /* Generic Unix attributes */ -#define STREAM_FILE_DATA 2 /* Standard uncompressed data */ -#define STREAM_MD5_SIGNATURE 3 /* MD5 signature for the file */ -#define STREAM_GZIP_DATA 4 /* GZip compressed file data */ +#define STREAM_UNIX_ATTRIBUTES 1 /* Generic Unix attributes */ +#define STREAM_FILE_DATA 2 /* Standard uncompressed data */ +#define STREAM_MD5_SIGNATURE 3 /* MD5 signature for the file */ +#define STREAM_GZIP_DATA 4 /* GZip compressed file data */ /* Extended Unix attributes with Win32 Extended data. Deprecated. */ #define STREAM_UNIX_ATTRIBUTES_EX 5 /* Extended Unix attr for Win32 EX */ -#define STREAM_SPARSE_DATA 6 /* Sparse data stream */ +#define STREAM_SPARSE_DATA 6 /* Sparse data stream */ #define STREAM_SPARSE_GZIP_DATA 7 -#define STREAM_PROGRAM_NAMES 8 /* program names for program data */ -#define STREAM_PROGRAM_DATA 9 /* Data needing program */ -#define STREAM_SHA1_SIGNATURE 10 /* SHA1 signature for the file */ -#define STREAM_WIN32_DATA 11 /* Win32 BackupRead data */ -#define STREAM_WIN32_GZIP_DATA 12 /* Gzipped Win32 BackupRead data */ -#define STREAM_MACOS_FORK_DATA 13 /* Mac resource fork */ +#define STREAM_PROGRAM_NAMES 8 /* program names for program data */ +#define STREAM_PROGRAM_DATA 9 /* Data needing program */ +#define STREAM_SHA1_SIGNATURE 10 /* SHA1 signature for the file */ +#define STREAM_WIN32_DATA 11 /* Win32 BackupRead data */ +#define STREAM_WIN32_GZIP_DATA 12 /* Gzipped Win32 BackupRead data */ +#define STREAM_MACOS_FORK_DATA 13 /* Mac resource fork */ #define STREAM_HFSPLUS_ATTRIBUTES 14 /* Mac OS extra attributes */ #define STREAM_UNIX_ATTRIBUTES_ACL 15 /* ACL attributes on UNIX */ /* - * File type (Bacula defined). + * File type (Bacula defined). * NOTE!!! These are saved in the Attributes record on the tape, so - * do not change them. If need be, add to them. + * do not change them. If need be, add to them. * * This is stored as 32 bits on tape, but only FT_MASK bits are * used for the file type. The upper bits are used to indicate * additional optional fields in the attribute record. */ -#define FT_MASK 0xFFFF /* Bits used by FT (type) */ -#define FT_LNKSAVED 1 /* hard link to file already saved */ -#define FT_REGE 2 /* Regular file but empty */ -#define FT_REG 3 /* Regular file */ -#define FT_LNK 4 /* Soft Link */ -#define FT_DIREND 5 /* Directory at end (saved) */ -#define FT_SPEC 6 /* Special file -- chr, blk, fifo, sock */ -#define FT_NOACCESS 7 /* Not able to access */ -#define FT_NOFOLLOW 8 /* Could not follow link */ -#define FT_NOSTAT 9 /* Could not stat file */ -#define FT_NOCHG 10 /* Incremental option, file not changed */ -#define FT_DIRNOCHG 11 /* Incremental option, directory not changed */ -#define FT_ISARCH 12 /* Trying to save archive file */ -#define FT_NORECURSE 13 /* No recursion into directory */ -#define FT_NOFSCHG 14 /* Different file system, prohibited */ -#define FT_NOOPEN 15 /* Could not open directory */ -#define FT_RAW 16 /* Raw block device */ -#define FT_FIFO 17 /* Raw fifo device */ +#define FT_MASK 0xFFFF /* Bits used by FT (type) */ +#define FT_LNKSAVED 1 /* hard link to file already saved */ +#define FT_REGE 2 /* Regular file but empty */ +#define FT_REG 3 /* Regular file */ +#define FT_LNK 4 /* Soft Link */ +#define FT_DIREND 5 /* Directory at end (saved) */ +#define FT_SPEC 6 /* Special file -- chr, blk, fifo, sock */ +#define FT_NOACCESS 7 /* Not able to access */ +#define FT_NOFOLLOW 8 /* Could not follow link */ +#define FT_NOSTAT 9 /* Could not stat file */ +#define FT_NOCHG 10 /* Incremental option, file not changed */ +#define FT_DIRNOCHG 11 /* Incremental option, directory not changed */ +#define FT_ISARCH 12 /* Trying to save archive file */ +#define FT_NORECURSE 13 /* No recursion into directory */ +#define FT_NOFSCHG 14 /* Different file system, prohibited */ +#define FT_NOOPEN 15 /* Could not open directory */ +#define FT_RAW 16 /* Raw block device */ +#define FT_FIFO 17 /* Raw fifo device */ /* This directory packet is sent to the FD file processing routine so * that it can filter packets, but otherwise, it is not used * or saved */ -#define FT_DIRBEGIN 18 /* Directory at beginning (not saved) */ +#define FT_DIRBEGIN 18 /* Directory at beginning (not saved) */ /* Definitions for upper part of type word (see above). */ -#define AR_DATA_STREAM (1<<16) /* Data stream id present */ +#define AR_DATA_STREAM (1<<16) /* Data stream id present */ /* * Internal code for Signature types */ -#define NO_SIG 0 +#define NO_SIG 0 #define MD5_SIG 1 #define SHA1_SIG 2 @@ -286,8 +286,8 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num); */ /* Debug Messages that are printed */ #ifdef DEBUG -#define Dmsg0(lvl, msg) d_msg(__FILE__, __LINE__, lvl, msg) -#define Dmsg1(lvl, msg, a1) d_msg(__FILE__, __LINE__, lvl, msg, a1) +#define Dmsg0(lvl, msg) d_msg(__FILE__, __LINE__, lvl, msg) +#define Dmsg1(lvl, msg, a1) d_msg(__FILE__, __LINE__, lvl, msg, a1) #define Dmsg2(lvl, msg, a1, a2) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2) #define Dmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3) #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4) @@ -316,8 +316,8 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num); #endif /* DEBUG */ #ifdef TRACE_FILE -#define Tmsg0(lvl, msg) t_msg(__FILE__, __LINE__, lvl, msg) -#define Tmsg1(lvl, msg, a1) t_msg(__FILE__, __LINE__, lvl, msg, a1) +#define Tmsg0(lvl, msg) t_msg(__FILE__, __LINE__, lvl, msg) +#define Tmsg1(lvl, msg, a1) t_msg(__FILE__, __LINE__, lvl, msg, a1) #define Tmsg2(lvl, msg, a1, a2) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2) #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3) #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4) @@ -348,8 +348,8 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num); /* Messages that are printed (uses d_msg) */ -#define Pmsg0(lvl, msg) p_msg(__FILE__, __LINE__, lvl, msg) -#define Pmsg1(lvl, msg, a1) p_msg(__FILE__, __LINE__, lvl, msg, a1) +#define Pmsg0(lvl, msg) p_msg(__FILE__, __LINE__, lvl, msg) +#define Pmsg1(lvl, msg, a1) p_msg(__FILE__, __LINE__, lvl, msg, a1) #define Pmsg2(lvl, msg, a1, a2) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2) #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3) #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4) @@ -366,17 +366,17 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num); /* Daemon Error Messages that are delivered according to the message resource */ -#define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg) -#define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1) -#define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2) +#define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg) +#define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1) +#define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2) #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3) #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4) #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5) #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6) /* Job Error Messages that are delivered according to the message resource */ -#define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg) -#define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1) +#define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg) +#define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1) #define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2) #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3) #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4) @@ -384,8 +384,8 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num); #define Jmsg6(jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6) /* Queued Job Error Messages that are delivered according to the message resource */ -#define Qmsg0(jcr, typ, lvl, msg) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg) -#define Qmsg1(jcr, typ, lvl, msg, a1) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1) +#define Qmsg0(jcr, typ, lvl, msg) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg) +#define Qmsg1(jcr, typ, lvl, msg, a1) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1) #define Qmsg2(jcr, typ, lvl, msg, a1, a2) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2) #define Qmsg3(jcr, typ, lvl, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3) #define Qmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4) @@ -394,8 +394,8 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num); /* Memory Messages that are edited into a Pool Memory buffer */ -#define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg) -#define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1) +#define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg) +#define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1) #define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2) #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3) #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4) @@ -408,6 +408,7 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num); /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */ int Mmsg(POOLMEM **msgbuf, const char *fmt,...); +int Mmsg(POOLMEM *&msgbuf, const char *fmt,...); struct JCR; @@ -417,6 +418,7 @@ void e_msg(const char *file, int line, int type, int level, const char *fmt,...) void j_msg(const char *file, int line, JCR *jcr, int type, int level, const char *fmt,...); void q_msg(const char *file, int line, JCR *jcr, int type, int level, const char *fmt,...); int m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...); +int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...); /* Use our strdup with smartalloc */ diff --git a/bacula/src/cats/bdb.c b/bacula/src/cats/bdb.c index 7545e3d941..df980da160 100644 --- a/bacula/src/cats/bdb.c +++ b/bacula/src/cats/bdb.c @@ -81,7 +81,7 @@ static POOLMEM *make_filename(B_DB *mdb, char *name) } else { sep = '/'; } - Mmsg(&dbf, "%s%c%s-%s", working_directory, sep, mdb->db_name, name); + Mmsg(dbf, "%s%c%s-%s", working_directory, sep, mdb->db_name, name); return dbf; } diff --git a/bacula/src/cats/bdb_list.c b/bacula/src/cats/bdb_list.c index 837e1e1b85..49fa0f39b7 100644 --- a/bacula/src/cats/bdb_list.c +++ b/bacula/src/cats/bdb_list.c @@ -84,7 +84,7 @@ void db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ct fseek(mdb->poolfd, 0L, SEEK_SET); /* rewind file */ len = sizeof(pr); while (fread(&pr, len, 1, mdb->poolfd) > 0) { - Mmsg(&mdb->cmd, " %7d %6d %6d %-10s %s\n", + Mmsg(mdb->cmd, " %7d %6d %6d %-10s %s\n", pr.PoolId, pr.NumVols, pr.MaxVols, pr.PoolType, pr.Name); sendit(ctx, mdb->cmd); } @@ -115,7 +115,7 @@ void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, fseek(mdb->mediafd, 0L, SEEK_SET); /* rewind file */ len = sizeof(mr); while (fread(&mr, len, 1, mdb->mediafd) > 0) { - Mmsg(&mdb->cmd, " %-10s %17s %-15s %s\n", + Mmsg(mdb->cmd, " %-10s %17s %-15s %s\n", mr.VolStatus, edit_uint64_with_commas(mr.VolBytes, ewc), mr.MediaType, mr.VolumeName); sendit(ctx, mdb->cmd); @@ -154,7 +154,7 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, fseek(mdb->mediafd, 0L, SEEK_SET); while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) { if (mr.MediaId == jm.MediaId) { - Mmsg(&mdb->cmd, " %7d %-10s %10d %10d\n", + Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n", jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex); sendit(ctx, mdb->cmd); break; @@ -166,7 +166,7 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, fseek(mdb->mediafd, 0L, SEEK_SET); while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) { if (mr.MediaId == jm.MediaId) { - Mmsg(&mdb->cmd, " %7d %-10s %10d %10d\n", + Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n", jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex); sendit(ctx, mdb->cmd); break; @@ -216,8 +216,8 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, } localtime_r(&ojr.StartTime, &tm); strftime(dt, sizeof(dt), "%m-%d %H:%M", &tm); - Mmsg(&mdb->cmd, " %7d %-10s %c %c %14s %10s %c %s\n", - ojr.JobId, dt, (char)ojr.Type, (char)ojr.Level, + Mmsg(mdb->cmd, " %7d %-10s %c %c %14s %10s %c %s\n", + ojr.JobId, dt, (char)ojr.JobType, (char)ojr.JobLevel, edit_uint64_with_commas(ojr.JobBytes, ewc1), edit_uint64_with_commas(ojr.JobFiles, ewc2), (char)ojr.JobStatus, ojr.Name); @@ -259,7 +259,7 @@ void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, total_bytes += ojr.JobBytes; total_jobs++; } - Mmsg(&mdb->cmd, " %7s %10s %15s\n", + Mmsg(mdb->cmd, " %7s %10s %15s\n", edit_uint64_with_commas(total_jobs, ewc1), edit_uint64_with_commas(total_files, ewc2), edit_uint64_with_commas(total_bytes, ewc3)); diff --git a/bacula/src/cats/bdb_update.c b/bacula/src/cats/bdb_update.c index d3e594558d..f50a1c8e31 100755 --- a/bacula/src/cats/bdb_update.c +++ b/bacula/src/cats/bdb_update.c @@ -80,7 +80,7 @@ bool db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) fseek(mdb->jobfd, ojr.rec_addr, SEEK_SET); if (fwrite(jr, len, 1, mdb->jobfd) != 1) { - Mmsg1(&mdb->errmsg, _("Error updating DB Job file. ERR=%s\n"), strerror(errno)); + Mmsg1(mdb->errmsg, _("Error updating DB Job file. ERR=%s\n"), strerror(errno)); stat = 0; } fflush(mdb->jobfd); @@ -111,7 +111,7 @@ int db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) fseek(mdb->jobfd, ojr.rec_addr, SEEK_SET); if (fwrite(jr, len, 1, mdb->jobfd) != 1) { - Mmsg1(&mdb->errmsg, _("Error updating DB Job file. ERR=%s\n"), strerror(errno)); + Mmsg1(&db->errmsg, _("Error updating DB Job file. ERR=%s\n"), strerror(errno)); stat = 0; } fflush(mdb->jobfd); @@ -150,7 +150,7 @@ int db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) fseek(mdb->mediafd, omr.rec_addr, SEEK_SET); if (fwrite(mr, len, 1, mdb->mediafd) != 1) { - Mmsg1(&mdb->errmsg, _("Error updating DB Media file. ERR=%s\n"), strerror(errno)); + Mmsg1(mdb->errmsg, _("Error updating DB Media file. ERR=%s\n"), strerror(errno)); stat = 0; } fflush(mdb->mediafd); @@ -186,7 +186,7 @@ int db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) fseek(mdb->poolfd, opr.rec_addr, SEEK_SET); if (fwrite(&opr, len, 1, mdb->poolfd) != 1) { - Mmsg1(&mdb->errmsg, _("Error updating DB Media file. ERR=%s\n"), strerror(errno)); + Mmsg1(mdb->errmsg, _("Error updating DB Media file. ERR=%s\n"), strerror(errno)); stat = 0; } else { memcpy(pr, &opr, len); /* return record written */ diff --git a/bacula/src/cats/mysql.c b/bacula/src/cats/mysql.c index a0ba1b83d9..d327927c44 100644 --- a/bacula/src/cats/mysql.c +++ b/bacula/src/cats/mysql.c @@ -318,7 +318,7 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler db_lock(mdb); if (sql_query(mdb, query) != 0) { - Mmsg(&mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb)); + Mmsg(mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb)); db_unlock(mdb); return 0; } diff --git a/bacula/src/cats/postgresql.c b/bacula/src/cats/postgresql.c index 92b7f72b32..a8779e8b66 100644 --- a/bacula/src/cats/postgresql.c +++ b/bacula/src/cats/postgresql.c @@ -262,7 +262,7 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler db_lock(mdb); if (sql_query(mdb, query) != 0) { - Mmsg(&mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb)); + Mmsg(mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb)); db_unlock(mdb); Dmsg0(500, "db_sql_query failed\n"); return 0; @@ -493,7 +493,7 @@ int my_postgresql_currval(B_DB *mdb, char *table_name) bstrncat(sequence, "_seq", sizeof(sequence)); bsnprintf(query, sizeof(query), "SELECT currval('%s')", sequence); -// Mmsg(&query, "SELECT currval('%s')", sequence); +// Mmsg(query, "SELECT currval('%s')", sequence); Dmsg1(500, "my_postgresql_currval invoked with '%s'\n", query); result = PQexec(mdb->db, query); diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index ad7ce60caa..92d4a17254 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -79,7 +79,7 @@ int check_tables_version(JCR *jcr, B_DB *mdb) bacula_db_version = 0; db_sql_query(mdb, query, int_handler, (void *)&bacula_db_version); if (bacula_db_version != BDB_VERSION) { - Mmsg(&mdb->errmsg, "Version error for database \"%s\". Wanted %d, got %d\n", + Mmsg(mdb->errmsg, "Version error for database \"%s\". Wanted %d, got %d\n", mdb->db_name, BDB_VERSION, bacula_db_version); Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg); return 0; diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 2d0187fa76..feb650b573 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -82,7 +82,7 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) JobTDate = (utime_t)stime; /* Must create it */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "INSERT INTO Job (Job,Name,Type,Level,JobStatus,SchedTime,JobTDate) VALUES \ ('%s','%s','%c','%c','%c','%s',%s)", jr->Job, jr->Name, (char)(jr->JobType), (char)(jr->JobLevel), @@ -113,7 +113,7 @@ db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jm) db_lock(mdb); #ifdef not_used_in_new_code - Mmsg(&mdb->cmd, "SELECT JobId, MediaId FROM JobMedia WHERE \ + Mmsg(mdb->cmd, "SELECT JobId, MediaId FROM JobMedia WHERE \ JobId=%d AND MediaId=%d", jm->JobId, jm->MediaId); Dmsg0(300, mdb->cmd); @@ -131,7 +131,7 @@ JobId=%d AND MediaId=%d", jm->JobId, jm->MediaId); #endif /* Now get count for VolIndex */ - Mmsg(&mdb->cmd, "SELECT count(*) from JobMedia"); + Mmsg(mdb->cmd, "SELECT count(*) from JobMedia"); count = get_sql_record_max(jcr, mdb); if (count < 0) { count = 0; @@ -139,7 +139,7 @@ JobId=%d AND MediaId=%d", jm->JobId, jm->MediaId); count++; /* Must create it */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "INSERT INTO JobMedia (JobId,MediaId,FirstIndex,LastIndex,\ StartFile,EndFile,StartBlock,EndBlock,VolIndex) \ VALUES (%u,%u,%u,%u,%u,%u,%u,%u,%u)", @@ -173,7 +173,7 @@ db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) Dmsg0(200, "In create pool\n"); db_lock(mdb); - Mmsg(&mdb->cmd, "SELECT PoolId,Name FROM Pool WHERE Name='%s'", pr->Name); + Mmsg(mdb->cmd, "SELECT PoolId,Name FROM Pool WHERE Name='%s'", pr->Name); Dmsg1(200, "selectpool: %s\n", mdb->cmd); if (QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -188,7 +188,7 @@ db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) } /* Must create it */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "INSERT INTO Pool (Name,NumVols,MaxVols,UseOnce,UseCatalog,\ AcceptAnyVolume,AutoPrune,Recycle,VolRetention,VolUseDuration,\ MaxVolJobs,MaxVolFiles,MaxVolBytes,PoolType,LabelFormat) \ @@ -233,7 +233,7 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) struct tm tm; db_lock(mdb); - Mmsg(&mdb->cmd, "SELECT MediaId FROM Media WHERE VolumeName='%s'", + Mmsg(mdb->cmd, "SELECT MediaId FROM Media WHERE VolumeName='%s'", mr->VolumeName); Dmsg1(300, "selectpool: %s\n", mdb->cmd); @@ -249,7 +249,7 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) } /* Must create it */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "INSERT INTO Media (VolumeName,MediaType,PoolId,MaxVolBytes,VolCapacityBytes," "Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," "VolStatus,Slot,VolBytes,InChanger,VolReadTime,VolWriteTime) " @@ -283,7 +283,7 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) char dt[MAX_TIME_LENGTH]; localtime_r(&mr->LabelDate, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); - Mmsg(&mdb->cmd, "UPDATE Media SET LabelDate='%s' " + Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' " "WHERE MediaId=%d", dt, mr->MediaId); stat = UPDATE_DB(jcr, mdb, mdb->cmd); } @@ -313,7 +313,7 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) char ed1[30], ed2[30]; db_lock(mdb); - Mmsg(&mdb->cmd, "SELECT ClientId,Uname FROM Client WHERE Name='%s'", cr->Name); + Mmsg(mdb->cmd, "SELECT ClientId,Uname FROM Client WHERE Name='%s'", cr->Name); cr->ClientId = 0; if (QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -345,7 +345,7 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) } /* Must create it */ - Mmsg(&mdb->cmd, "INSERT INTO Client (Name, Uname, AutoPrune, \ + Mmsg(mdb->cmd, "INSERT INTO Client (Name, Uname, AutoPrune, \ FileRetention, JobRetention) VALUES \ ('%s', '%s', %d, %s, %s)", cr->Name, cr->Uname, cr->AutoPrune, edit_uint64(cr->FileRetention, ed1), @@ -386,7 +386,7 @@ int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) } /* Must create it */ - Mmsg(&mdb->cmd, "INSERT INTO Counters (Counter,MinValue,MaxValue,CurrentValue," + Mmsg(mdb->cmd, "INSERT INTO Counters (Counter,MinValue,MaxValue,CurrentValue," "WrapCounter) VALUES ('%s','%d','%d','%d','%s')", cr->Counter, cr->MinValue, cr->MaxValue, cr->CurrentValue, cr->WrapCounter); @@ -418,7 +418,7 @@ int db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) db_lock(mdb); fsr->created = false; - Mmsg(&mdb->cmd, "SELECT FileSetId,CreateTime FROM FileSet WHERE " + Mmsg(mdb->cmd, "SELECT FileSetId,CreateTime FROM FileSet WHERE " "FileSet='%s' AND MD5='%s'", fsr->FileSet, fsr->MD5); fsr->FileSetId = 0; @@ -456,7 +456,7 @@ int db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) strftime(fsr->cCreateTime, sizeof(fsr->cCreateTime), "%Y-%m-%d %T", &tm); /* Must create it */ - Mmsg(&mdb->cmd, "INSERT INTO FileSet (FileSet,MD5,CreateTime) " + Mmsg(mdb->cmd, "INSERT INTO FileSet (FileSet,MD5,CreateTime) " "VALUES ('%s','%s','%s')", fsr->FileSet, fsr->MD5, fsr->cCreateTime); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { @@ -564,7 +564,7 @@ static int db_create_file_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) ASSERT(ar->FilenameId); /* Must create it */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "INSERT INTO File (FileIndex,JobId,PathId,FilenameId," "LStat,MD5) VALUES (%u,%u,%u,%u,'%s','0')", ar->FileIndex, ar->JobId, ar->PathId, ar->FilenameId, @@ -598,7 +598,7 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) return 1; } - Mmsg(&mdb->cmd, "SELECT PathId FROM Path WHERE Path='%s'", mdb->esc_name); + Mmsg(mdb->cmd, "SELECT PathId FROM Path WHERE Path='%s'", mdb->esc_name); if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); @@ -632,7 +632,7 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) sql_free_result(mdb); } - Mmsg(&mdb->cmd, "INSERT INTO Path (Path) VALUES ('%s')", mdb->esc_name); + Mmsg(mdb->cmd, "INSERT INTO Path (Path) VALUES ('%s')", mdb->esc_name); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { Mmsg2(&mdb->errmsg, _("Create db Path record %s failed. ERR=%s\n"), @@ -662,7 +662,7 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2); db_escape_string(mdb->esc_name, mdb->fname, mdb->fnl); - Mmsg(&mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name); + Mmsg(mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name); if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); @@ -687,7 +687,7 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) sql_free_result(mdb); } - Mmsg(&mdb->cmd, "INSERT INTO Filename (Name) VALUES ('%s')", mdb->esc_name); + Mmsg(mdb->cmd, "INSERT INTO Filename (Name) VALUES ('%s')", mdb->esc_name); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { Mmsg2(&mdb->errmsg, _("Create db Filename record %s failed. ERR=%s\n"), diff --git a/bacula/src/cats/sql_delete.c b/bacula/src/cats/sql_delete.c index aece65b648..fd07956607 100644 --- a/bacula/src/cats/sql_delete.c +++ b/bacula/src/cats/sql_delete.c @@ -66,7 +66,7 @@ db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) SQL_ROW row; db_lock(mdb); - Mmsg(&mdb->cmd, "SELECT PoolId FROM Pool WHERE Name='%s'", pr->Name); + Mmsg(mdb->cmd, "SELECT PoolId FROM Pool WHERE Name='%s'", pr->Name); Dmsg1(10, "selectpool: %s\n", mdb->cmd); pr->PoolId = pr->NumVols = 0; @@ -76,12 +76,12 @@ db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows == 0) { - Mmsg(&mdb->errmsg, _("No pool record %s exists\n"), pr->Name); + Mmsg(mdb->errmsg, _("No pool record %s exists\n"), pr->Name); sql_free_result(mdb); db_unlock(mdb); return 0; } else if (mdb->num_rows != 1) { - Mmsg(&mdb->errmsg, _("Expecting one pool record, got %d\n"), mdb->num_rows); + Mmsg(mdb->errmsg, _("Expecting one pool record, got %d\n"), mdb->num_rows); sql_free_result(mdb); db_unlock(mdb); return 0; @@ -96,14 +96,14 @@ db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) } /* Delete Media owned by this pool */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "DELETE FROM Media WHERE Media.PoolId = %d", pr->PoolId); pr->NumVols = DELETE_DB(jcr, mdb, mdb->cmd); Dmsg1(200, "Deleted %d Media records\n", pr->NumVols); /* Delete Pool */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "DELETE FROM Pool WHERE Pool.PoolId = %d", pr->PoolId); pr->PoolId = DELETE_DB(jcr, mdb, mdb->cmd); Dmsg1(200, "Deleted %d Pool records\n", pr->PoolId); @@ -161,7 +161,7 @@ static int do_media_purge(B_DB *mdb, MEDIA_DBR *mr) del.tot_ids = 0; del.num_del = 0; del.max_ids = 0; - Mmsg(&mdb->cmd, "SELECT JobId from JobMedia WHERE MediaId=%d", mr->MediaId); + Mmsg(mdb->cmd, "SELECT JobId from JobMedia WHERE MediaId=%d", mr->MediaId); del.max_ids = mr->VolJobs; if (del.max_ids < 100) { del.max_ids = 100; @@ -173,11 +173,11 @@ static int do_media_purge(B_DB *mdb, MEDIA_DBR *mr) for (i=0; i < del.num_ids; i++) { Dmsg1(400, "Delete JobId=%d\n", del.JobId[i]); - Mmsg(&query, "DELETE FROM Job WHERE JobId=%u", del.JobId[i]); + Mmsg(query, "DELETE FROM Job WHERE JobId=%u", del.JobId[i]); db_sql_query(mdb, query, NULL, (void *)NULL); - Mmsg(&query, "DELETE FROM File WHERE JobId=%u", del.JobId[i]); + Mmsg(query, "DELETE FROM File WHERE JobId=%u", del.JobId[i]); db_sql_query(mdb, query, NULL, (void *)NULL); - Mmsg(&query, "DELETE FROM JobMedia WHERE JobId=%u", del.JobId[i]); + Mmsg(query, "DELETE FROM JobMedia WHERE JobId=%u", del.JobId[i]); db_sql_query(mdb, query, NULL, (void *)NULL); } free(del.JobId); @@ -201,7 +201,7 @@ int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) do_media_purge(mdb, mr); } - Mmsg(&mdb->cmd, "DELETE FROM Media WHERE MediaId=%d", mr->MediaId); + Mmsg(mdb->cmd, "DELETE FROM Media WHERE MediaId=%d", mr->MediaId); db_sql_query(mdb, mdb->cmd, NULL, (void *)NULL); db_unlock(mdb); return 1; diff --git a/bacula/src/cats/sql_find.c b/bacula/src/cats/sql_find.c index a74cfd2048..74a1e4039b 100644 --- a/bacula/src/cats/sql_find.c +++ b/bacula/src/cats/sql_find.c @@ -72,7 +72,7 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) /* If no Id given, we must find corresponding job */ if (jr->JobId == 0) { /* Differential is since last Full backup */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT StartTime FROM Job WHERE JobStatus='T' AND Type='%c' AND " "Level='%c' AND Name='%s' AND ClientId=%u AND FileSetId=%u " "ORDER BY StartTime DESC LIMIT 1", @@ -97,13 +97,13 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) } if ((row = sql_fetch_row(mdb)) == NULL) { sql_free_result(mdb); - Mmsg(&mdb->errmsg, _("No prior Full backup Job record found.\n")); + Mmsg(mdb->errmsg, _("No prior Full backup Job record found.\n")); db_unlock(mdb); return 0; } sql_free_result(mdb); /* Now edit SQL command for Incremental Job */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT StartTime FROM Job WHERE JobStatus='T' AND Type='%c' AND " "Level IN ('%c','%c','%c') AND Name='%s' AND ClientId=%u " "AND FileSetId=%u ORDER BY StartTime DESC LIMIT 1", @@ -116,7 +116,7 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) } } else { Dmsg1(100, "Submitting: %s\n", mdb->cmd); - Mmsg(&mdb->cmd, "SELECT StartTime FROM Job WHERE Job.JobId=%u", jr->JobId); + Mmsg(mdb->cmd, "SELECT StartTime FROM Job WHERE Job.JobId=%u", jr->JobId); } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -158,7 +158,7 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr) /* Find last full */ db_lock(mdb); if (jr->JobLevel == L_VERIFY_CATALOG) { - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT JobId FROM Job WHERE Type='V' AND Level='%c' AND " " JobStatus='T' AND Name='%s' AND " "ClientId=%u ORDER BY StartTime DESC LIMIT 1", @@ -166,11 +166,11 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr) } else if (jr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG || jr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { if (Name) { - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT JobId FROM Job WHERE Type='B' AND JobStatus='T' AND " "Name='%s' ORDER BY StartTime DESC LIMIT 1", Name); } else { - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT JobId FROM Job WHERE Type='B' AND JobStatus='T' AND " "ClientId=%u ORDER BY StartTime DESC LIMIT 1", jr->ClientId); } @@ -223,7 +223,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr db_lock(mdb); if (item == -1) { /* find oldest volume */ /* Find oldest volume */ - Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot," "FirstWritten,LastWritten,VolStatus,InChanger " @@ -244,7 +244,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr } else { order = "ORDER BY LastWritten IS NULL,LastWritten DESC,MediaId"; /* take most recently written */ } - Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot," "FirstWritten,LastWritten,VolStatus,InChanger " diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index 85689733d3..2c53a8f360 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -105,14 +105,14 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr) int stat = 0; if (jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT FileId, LStat, MD5 FROM File,Job WHERE " "File.JobId=Job.JobId AND File.PathId=%u AND " "File.FilenameId=%u AND Job.Type='B' AND Job.JobSTATUS='T' AND " "ClientId=%u ORDER BY StartTime DESC LIMIT 1", fdbr->PathId, fdbr->FilenameId, jr->ClientId); } else { - Mmsg(&mdb->cmd, + 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); } @@ -143,7 +143,7 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr) } sql_free_result(mdb); } else { - Mmsg(&mdb->errmsg, _("File record not found in Catalog.\n")); + Mmsg(mdb->errmsg, _("File record not found in Catalog.\n")); } return stat; @@ -163,7 +163,7 @@ static int db_get_filename_record(JCR *jcr, B_DB *mdb) mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2); db_escape_string(mdb->esc_name, mdb->fname, mdb->fnl); - Mmsg(&mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name); + Mmsg(mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name); if (QUERY_DB(jcr, mdb, mdb->cmd)) { char ed1[30]; mdb->num_rows = sql_num_rows(mdb); @@ -188,7 +188,7 @@ static int db_get_filename_record(JCR *jcr, B_DB *mdb) } sql_free_result(mdb); } else { - Mmsg(&mdb->errmsg, _("Filename record: %s not found in Catalog.\n"), mdb->fname); + Mmsg(mdb->errmsg, _("Filename record: %s not found in Catalog.\n"), mdb->fname); } return FilenameId; } @@ -212,7 +212,7 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb) return mdb->cached_path_id; } - Mmsg(&mdb->cmd, "SELECT PathId FROM Path WHERE Path='%s'", mdb->esc_name); + Mmsg(mdb->cmd, "SELECT PathId FROM Path WHERE Path='%s'", mdb->esc_name); if (QUERY_DB(jcr, mdb, mdb->cmd)) { char ed1[30]; @@ -246,7 +246,7 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb) } sql_free_result(mdb); } else { - Mmsg(&mdb->errmsg, _("Path record: %s not found in Catalog.\n"), mdb->path); + Mmsg(mdb->errmsg, _("Path record: %s not found in Catalog.\n"), mdb->path); } return PathId; } @@ -263,12 +263,12 @@ int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) db_lock(mdb); if (jr->JobId == 0) { - Mmsg(&mdb->cmd, "SELECT VolSessionId,VolSessionTime," + Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime," "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus," "Type,Level,ClientId " "FROM Job WHERE Job='%s'", jr->Job); } else { - Mmsg(&mdb->cmd, "SELECT VolSessionId,VolSessionTime," + Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime," "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus," "Type,Level,ClientId " "FROM Job WHERE JobId=%u", jr->JobId); @@ -322,7 +322,7 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum db_lock(mdb); /* Get one entry per VolumeName, but "sort" by VolIndex */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT VolumeName,MAX(VolIndex) FROM JobMedia,Media WHERE " "JobMedia.JobId=%u AND JobMedia.MediaId=Media.MediaId " "GROUP BY VolumeName " @@ -354,7 +354,7 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum } sql_free_result(mdb); } else { - Mmsg(&mdb->errmsg, _("No Volume for JobId %d found in Catalog.\n"), JobId); + Mmsg(mdb->errmsg, _("No Volume for JobId %d found in Catalog.\n"), JobId); } db_unlock(mdb); return stat; @@ -376,7 +376,7 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS VOL_PARAMS *Vols = NULL; db_lock(mdb); - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT VolumeName,FirstIndex,LastIndex,StartFile,EndFile,StartBlock,EndBlock" " FROM JobMedia,Media WHERE JobMedia.JobId=%u" " AND JobMedia.MediaId=Media.MediaId ORDER BY VolIndex,JobMediaId", JobId); @@ -429,7 +429,7 @@ int db_get_num_pool_records(JCR *jcr, B_DB *mdb) int stat = 0; db_lock(mdb); - Mmsg(&mdb->cmd, "SELECT count(*) from Pool"); + Mmsg(mdb->cmd, "SELECT count(*) from Pool"); stat = get_sql_record_max(jcr, mdb); db_unlock(mdb); return stat; @@ -451,7 +451,7 @@ int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[]) db_lock(mdb); *ids = NULL; - Mmsg(&mdb->cmd, "SELECT PoolId FROM Pool"); + Mmsg(mdb->cmd, "SELECT PoolId FROM Pool"); if (QUERY_DB(jcr, mdb, mdb->cmd)) { *num_ids = sql_num_rows(mdb); if (*num_ids > 0) { @@ -464,7 +464,7 @@ int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[]) sql_free_result(mdb); stat = 1; } else { - Mmsg(&mdb->errmsg, _("Pool id select failed: ERR=%s\n"), sql_strerror(mdb)); + Mmsg(mdb->errmsg, _("Pool id select failed: ERR=%s\n"), sql_strerror(mdb)); Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); stat = 0; } @@ -488,7 +488,7 @@ int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[]) db_lock(mdb); *ids = NULL; - Mmsg(&mdb->cmd, "SELECT ClientId FROM Client"); + Mmsg(mdb->cmd, "SELECT ClientId FROM Client"); if (QUERY_DB(jcr, mdb, mdb->cmd)) { *num_ids = sql_num_rows(mdb); if (*num_ids > 0) { @@ -501,7 +501,7 @@ int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[]) sql_free_result(mdb); stat = 1; } else { - Mmsg(&mdb->errmsg, _("Client id select failed: ERR=%s\n"), sql_strerror(mdb)); + Mmsg(mdb->errmsg, _("Client id select failed: ERR=%s\n"), sql_strerror(mdb)); Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); stat = 0; } @@ -525,12 +525,12 @@ int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pdbr) db_lock(mdb); if (pdbr->PoolId != 0) { /* find by id */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,\ AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,\ MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.PoolId=%u", pdbr->PoolId); } else { /* find by name */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,\ AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,\ MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name); @@ -567,11 +567,11 @@ MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name); stat = pdbr->PoolId; } } else { - Mmsg(&mdb->errmsg, _("Pool record not found in Catalog.\n")); + Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n")); } sql_free_result(mdb); } else { - Mmsg(&mdb->errmsg, _("Pool record not found in Catalog.\n")); + Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n")); } db_unlock(mdb); return stat; @@ -591,11 +591,11 @@ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr) db_lock(mdb); if (cdbr->ClientId != 0) { /* find by id */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT ClientId,Name,Uname,AutoPrune,FileRetention,JobRetention " "FROM Client WHERE Client.ClientId=%u", cdbr->ClientId); } else { /* find by name */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT ClientId,Name,Uname,AutoPrune,FileRetention,JobRetention " "FROM Client WHERE Client.Name='%s'", cdbr->Name); } @@ -621,11 +621,11 @@ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr) stat = 1; } } else { - Mmsg(&mdb->errmsg, _("Client record not found in Catalog.\n")); + Mmsg(mdb->errmsg, _("Client record not found in Catalog.\n")); } sql_free_result(mdb); } else { - Mmsg(&mdb->errmsg, _("Client record not found in Catalog.\n")); + Mmsg(mdb->errmsg, _("Client record not found in Catalog.\n")); } db_unlock(mdb); return stat; @@ -642,7 +642,7 @@ int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) SQL_ROW row; db_lock(mdb); - Mmsg(&mdb->cmd, "SELECT MinValue,MaxValue,CurrentValue,WrapCounter " + Mmsg(mdb->cmd, "SELECT MinValue,MaxValue,CurrentValue,WrapCounter " "FROM Counters WHERE Counter='%s'", cr->Counter); if (QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -675,7 +675,7 @@ int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) } sql_free_result(mdb); } else { - Mmsg(&mdb->errmsg, _("Counter record: %s not found in Catalog.\n"), cr->Counter); + Mmsg(mdb->errmsg, _("Counter record: %s not found in Catalog.\n"), cr->Counter); } db_unlock(mdb); return 0; @@ -696,11 +696,11 @@ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) db_lock(mdb); if (fsr->FileSetId != 0) { /* find by id */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT FileSetId,FileSet,MD5,CreateTime FROM FileSet " "WHERE FileSetId=%u", fsr->FileSetId); } else { /* find by name */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT FileSetId,FileSet,CreateTime,MD5 FROM FileSet " "WHERE FileSet='%s'", fsr->FileSet); } @@ -724,7 +724,7 @@ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) } sql_free_result(mdb); } else { - Mmsg(&mdb->errmsg, _("FileSet record not found in Catalog.\n")); + Mmsg(mdb->errmsg, _("FileSet record not found in Catalog.\n")); } db_unlock(mdb); return stat; @@ -742,7 +742,7 @@ int db_get_num_media_records(JCR *jcr, B_DB *mdb) int stat = 0; db_lock(mdb); - Mmsg(&mdb->cmd, "SELECT count(*) from Media"); + Mmsg(mdb->cmd, "SELECT count(*) from Media"); stat = get_sql_record_max(jcr, mdb); db_unlock(mdb); return stat; @@ -766,7 +766,7 @@ int db_get_media_ids(JCR *jcr, B_DB *mdb, uint32_t PoolId, int *num_ids, uint32_ db_lock(mdb); *ids = NULL; - Mmsg(&mdb->cmd, "SELECT MediaId FROM Media WHERE PoolId=%u", PoolId); + Mmsg(mdb->cmd, "SELECT MediaId FROM Media WHERE PoolId=%u", PoolId); if (QUERY_DB(jcr, mdb, mdb->cmd)) { *num_ids = sql_num_rows(mdb); if (*num_ids > 0) { @@ -779,7 +779,7 @@ int db_get_media_ids(JCR *jcr, B_DB *mdb, uint32_t PoolId, int *num_ids, uint32_ sql_free_result(mdb); stat = 1; } else { - Mmsg(&mdb->errmsg, _("Media id select failed: ERR=%s\n"), sql_strerror(mdb)); + Mmsg(mdb->errmsg, _("Media id select failed: ERR=%s\n"), sql_strerror(mdb)); Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); stat = 0; } @@ -800,19 +800,19 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) db_lock(mdb); if (mr->MediaId == 0 && mr->VolumeName[0] == 0) { - Mmsg(&mdb->cmd, "SELECT count(*) from Media"); + Mmsg(mdb->cmd, "SELECT count(*) from Media"); mr->MediaId = get_sql_record_max(jcr, mdb); db_unlock(mdb); return 1; } if (mr->MediaId != 0) { /* find by id */ - Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," "Recycle,Slot,FirstWritten,LastWritten,InChanger " "FROM Media WHERE MediaId=%d", mr->MediaId); } else { /* find by name */ - Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," "Recycle,Slot,FirstWritten,LastWritten,InChanger " @@ -869,7 +869,7 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) } sql_free_result(mdb); } else { - Mmsg(&mdb->errmsg, _("Media record not found in Catalog.\n")); + Mmsg(mdb->errmsg, _("Media record not found in Catalog.\n")); } db_unlock(mdb); return stat; diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index 91625f563a..15e49fb6e7 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -56,7 +56,7 @@ int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, { db_lock(mdb); if (sql_query(mdb, query) != 0) { - Mmsg(&mdb->errmsg, _("Query failed: %s\n"), sql_strerror(mdb)); + Mmsg(mdb->errmsg, _("Query failed: %s\n"), sql_strerror(mdb)); if (verbose) { sendit(ctx, mdb->errmsg); } @@ -79,13 +79,13 @@ db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_ { db_lock(mdb); if (type == VERT_LIST) { - Mmsg(&mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog," + Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog," "AcceptAnyVolume,VolRetention,VolUseDuration,MaxVolJobs,MaxVolBytes," "AutoPrune,Recycle,PoolType,LabelFormat,Enabled,ScratchPoolId," "RecyclePoolId " "FROM Pool ORDER BY PoolId"); } else { - Mmsg(&mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,PoolType,LabelFormat " + Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,PoolType,LabelFormat " "FROM Pool ORDER BY PoolId"); } @@ -105,11 +105,11 @@ db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, { db_lock(mdb); if (type == VERT_LIST) { - Mmsg(&mdb->cmd, "SELECT ClientId,Name,Uname,AutoPrune,FileRetention," + Mmsg(mdb->cmd, "SELECT ClientId,Name,Uname,AutoPrune,FileRetention," "FileRetention,JobRetention " "FROM Client ORDER BY ClientId"); } else { - Mmsg(&mdb->cmd, "SELECT ClientId,Name,FileRetention,JobRetention " + Mmsg(mdb->cmd, "SELECT ClientId,Name,FileRetention,JobRetention " "FROM Client ORDER BY ClientId"); } @@ -136,14 +136,14 @@ db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, db_lock(mdb); if (type == VERT_LIST) { if (mdbr->VolumeName[0] != 0) { - Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," "VolCapacityBytes,VolStatus,Recycle,VolRetention," "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger " "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); } else { - Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," "VolCapacityBytes,VolStatus,Recycle,VolRetention," @@ -152,11 +152,11 @@ db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, } } else { if (mdbr->VolumeName[0] != 0) { - Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); } else { - Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId); } @@ -179,23 +179,23 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, db_lock(mdb); if (type == VERT_LIST) { if (JobId > 0) { /* do by JobId */ - Mmsg(&mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," + Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," "FirstIndex,LastIndex,StartFile,EndFile,StartBlock,EndBlock " "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " "AND JobMedia.JobId=%u", JobId); } else { - Mmsg(&mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," + Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," "FirstIndex,LastIndex,StartFile,EndFile,StartBlock,EndBlock " "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); } } else { if (JobId > 0) { /* do by JobId */ - Mmsg(&mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " + Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " "AND JobMedia.JobId=%u", JobId); } else { - Mmsg(&mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " + Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); } } @@ -225,7 +225,7 @@ db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, db_lock(mdb); if (type == VERT_LIST) { if (jr->JobId == 0 && jr->Job[0] == 0) { - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level," "Job.ClientId,Client.Name,JobStatus,SchedTime," "StartTime,EndTime,JobTDate," @@ -235,7 +235,7 @@ db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId " "AND FileSet.FileSetId=Job.FileSetId ORDER BY StartTime"); } else { /* single record */ - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level," "Job.ClientId,Client.Name,JobStatus,SchedTime," "StartTime,EndTime,JobTDate," @@ -247,11 +247,11 @@ db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, } } else { if (jr->JobId == 0 && jr->Job[0] == 0) { - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus " "FROM Job ORDER BY StartTime"); } else { /* single record */ - Mmsg(&mdb->cmd, "SELECT JobId,Name,StartTime,Type,Level," + Mmsg(mdb->cmd, "SELECT JobId,Name,StartTime,Type,Level," "JobFiles,JobBytes,JobStatus FROM Job WHERE JobId=%u", jr->JobId); } } @@ -275,7 +275,7 @@ db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, vo db_lock(mdb); /* List by Job */ - Mmsg(&mdb->cmd, "SELECT count(*) AS Jobs,sum(JobFiles) " + Mmsg(mdb->cmd, "SELECT count(*) AS Jobs,sum(JobFiles) " "AS Files,sum(JobBytes) AS Bytes,Name AS Job FROM Job GROUP BY Name"); if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -288,7 +288,7 @@ db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, vo sql_free_result(mdb); /* Do Grand Total */ - Mmsg(&mdb->cmd, "SELECT count(*) AS Jobs,sum(JobFiles) \ + Mmsg(mdb->cmd, "SELECT count(*) AS Jobs,sum(JobFiles) \ AS Files,sum(JobBytes) As Bytes FROM Job"); if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -316,7 +316,7 @@ db_list_files_for_job(JCR *jcr, B_DB *mdb, uint32_t jobid, DB_LIST_HANDLER *send { db_lock(mdb); - Mmsg(&mdb->cmd, "SELECT " FN " AS Filename FROM File," + Mmsg(mdb->cmd, "SELECT " FN " AS Filename FROM File," "Filename,Path WHERE File.JobId=%u AND Filename.FilenameId=File.FilenameId " "AND Path.PathId=File.PathId", jobid); diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index fed8d82c20..f47bf6acbc 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -61,7 +61,7 @@ db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG, int stat; db_lock(mdb); - Mmsg(&mdb->cmd, "UPDATE File SET MD5='%s' WHERE FileId=%u", SIG, FileId); + Mmsg(mdb->cmd, "UPDATE File SET MD5='%s' WHERE FileId=%u", SIG, FileId); stat = UPDATE_DB(jcr, mdb, mdb->cmd); db_unlock(mdb); return stat; @@ -75,7 +75,7 @@ int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId) int stat; db_lock(mdb); - Mmsg(&mdb->cmd, "UPDATE File SET MarkId=%u WHERE FileId=%u", JobId, FileId); + Mmsg(mdb->cmd, "UPDATE File SET MarkId=%u WHERE FileId=%u", JobId, FileId); stat = UPDATE_DB(jcr, mdb, mdb->cmd); db_unlock(mdb); return stat; @@ -103,7 +103,7 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) JobTDate = (btime_t)stime; db_lock(mdb); - Mmsg(&mdb->cmd, "UPDATE Job SET JobStatus='%c',Level='%c',StartTime='%s'," + Mmsg(mdb->cmd, "UPDATE Job SET JobStatus='%c',Level='%c',StartTime='%s'," "ClientId=%u,JobTDate=%s WHERE JobId=%u", (char)(jcr->JobStatus), (char)(jr->JobLevel), dt, jr->ClientId, edit_uint64(JobTDate, ed1), jr->JobId); @@ -155,7 +155,7 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) JobTDate = ttime; db_lock(mdb); - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "UPDATE Job SET JobStatus='%c', EndTime='%s', \ ClientId=%s, JobBytes=%s, JobFiles=%u, JobErrors=%u, VolSessionId=%u, \ VolSessionTime=%u, PoolId=%s, FileSetId=%s, JobTDate=%s WHERE JobId=%u", @@ -188,7 +188,7 @@ db_update_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) return 0; } - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "UPDATE Client SET AutoPrune=%d,FileRetention=%s,JobRetention=%s," "Uname='%s' WHERE Name='%s'", cr->AutoPrune, @@ -211,7 +211,7 @@ int db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) { db_lock(mdb); - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "UPDATE Counters SET MinValue=%d,MaxValue=%d,CurrentValue=%d," "WrapCounter='%s' WHERE Counter='%s'", cr->MinValue, cr->MaxValue, cr->CurrentValue, @@ -230,7 +230,7 @@ db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) char ed1[50], ed2[50], ed3[50]; db_lock(mdb); - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "UPDATE Pool SET NumVols=%u,MaxVols=%u,UseOnce=%d,UseCatalog=%d," "AcceptAnyVolume=%d,VolRetention='%s',VolUseDuration='%s'," "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s,Recycle=%d," @@ -271,7 +271,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) ttime = mr->FirstWritten; localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); - Mmsg(&mdb->cmd, "UPDATE Media SET FirstWritten='%s'\ + Mmsg(mdb->cmd, "UPDATE Media SET FirstWritten='%s'\ WHERE VolumeName='%s'", dt, mr->VolumeName); stat = UPDATE_DB(jcr, mdb, mdb->cmd); Dmsg1(400, "Firstwritten stat=%d\n", stat); @@ -285,7 +285,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) } localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); - Mmsg(&mdb->cmd, "UPDATE Media SET LabelDate='%s' " + Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' " "WHERE VolumeName='%s'", dt, mr->VolumeName); stat = UPDATE_DB(jcr, mdb, mdb->cmd); } @@ -295,7 +295,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); - Mmsg(&mdb->cmd, "UPDATE Media SET VolJobs=%u," + 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'," "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s " @@ -308,7 +308,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) edit_uint64(mr->VolWriteTime, ed4), mr->VolumeName); } else { - Mmsg(&mdb->cmd, "UPDATE Media SET VolJobs=%u," + Mmsg(mdb->cmd, "UPDATE Media SET VolJobs=%u," "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u," "VolWrites=%u,MaxVolBytes=%s,VolStatus='%s'," "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s " @@ -348,7 +348,7 @@ db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) db_lock(mdb); if (mr->VolumeName[0]) { - Mmsg(&mdb->cmd, "UPDATE Media SET " + Mmsg(mdb->cmd, "UPDATE Media SET " "Recycle=%d,VolRetention=%s,VolUseDuration=%s," "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s" " WHERE VolumeName='%s'", @@ -358,7 +358,7 @@ db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) edit_uint64(mr->VolBytes, ed3), mr->VolumeName); } else { - Mmsg(&mdb->cmd, "UPDATE Media SET " + Mmsg(mdb->cmd, "UPDATE Media SET " "Recycle=%d,VolRetention=%s,VolUseDuration=%s," "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s" " WHERE PoolId=%u", @@ -388,7 +388,7 @@ void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { if (mr->InChanger != 0 && mr->Slot != 0) { - Mmsg(&mdb->cmd, "UPDATE Media SET InChanger=0 WHERE " + Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE " "Slot=%d AND MediaId!=%u", mr->Slot, mr->MediaId); Dmsg1(400, "%s\n", mdb->cmd); UPDATE_DB(jcr, mdb, mdb->cmd); diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index 7a3d46b421..c98b571242 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -198,25 +198,25 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index) db_lock(mdb); - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "SELECT id FROM NextId WHERE TableName=\"%s\"", table); if (!QUERY_DB(jcr, mdb, mdb->cmd)) { - Mmsg(&mdb->errmsg, _("next_index query error: ERR=%s\n"), sql_strerror(mdb)); + Mmsg(mdb->errmsg, _("next_index query error: ERR=%s\n"), sql_strerror(mdb)); db_unlock(mdb); return 0; } if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg(&mdb->errmsg, _("Error fetching index: ERR=%s\n"), sql_strerror(mdb)); + Mmsg(mdb->errmsg, _("Error fetching index: ERR=%s\n"), sql_strerror(mdb)); db_unlock(mdb); return 0; } bstrncpy(index, row[0], 28); sql_free_result(mdb); - Mmsg(&mdb->cmd, + Mmsg(mdb->cmd, "UPDATE NextId SET id=id+1 WHERE TableName=\"%s\"", table); if (!QUERY_DB(jcr, mdb, mdb->cmd)) { - Mmsg(&mdb->errmsg, _("next_index update error: ERR=%s\n"), sql_strerror(mdb)); + Mmsg(mdb->errmsg, _("next_index update error: ERR=%s\n"), sql_strerror(mdb)); db_unlock(mdb); return 0; } @@ -297,7 +297,7 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler rh_data.ctx = ctx; stat = sqlite_exec(mdb->db, query, sqlite_result, (void *)&rh_data, &mdb->sqlite_errmsg); if (stat != 0) { - Mmsg(&mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb)); + Mmsg(mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb)); db_unlock(mdb); return 0; } diff --git a/bacula/src/console/conio.c b/bacula/src/console/conio.c index ca8ca4a19b..372310b692 100755 --- a/bacula/src/console/conio.c +++ b/bacula/src/console/conio.c @@ -45,7 +45,14 @@ #endif #include +#ifdef HAVE_SUN_OS +extern "C" int tgetent(void *, const char *); +extern "C" int tgetnum(const char *); +extern "C" char *tgetstr (const char*, char**); +extern "C" char *tgoto (const char *, int, int); +#else #include +#endif #include "func.h" diff --git a/bacula/src/dird/bsr.c b/bacula/src/dird/bsr.c index 88f89d1627..664bf4fe8b 100644 --- a/bacula/src/dird/bsr.c +++ b/bacula/src/dird/bsr.c @@ -184,7 +184,7 @@ int write_bsr_file(UAContext *ua, RBSR *bsr) POOLMEM *fname = get_pool_memory(PM_MESSAGE); int stat; - Mmsg(&fname, "%s/restore.bsr", working_directory); + Mmsg(fname, "%s/restore.bsr", working_directory); fd = fopen(fname, "w+"); if (!fd) { bsendmsg(ua, _("Unable to create bootstrap file %s. ERR=%s\n"), diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index c3b4250536..1cc8369a99 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -70,7 +70,7 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50]; jcr->MediaId = mr->MediaId; - pm_strcpy(&jcr->VolumeName, mr->VolumeName); + pm_strcpy(jcr->VolumeName, mr->VolumeName); bash_spaces(mr->VolumeName); stat = bnet_fsend(sd, OK_media, mr->VolumeName, mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1), @@ -269,7 +269,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) } else { omsg = get_memory(bs->msglen+1); - pm_strcpy(&omsg, bs->msg); + pm_strcpy(omsg, bs->msg); bnet_fsend(bs, "1990 Invalid Catalog Request: %s", omsg); Jmsg1(jcr, M_ERROR, 0, _("Invalid Catalog request: %s"), omsg); free_memory(omsg); diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 5d05c051e2..075bc9eac2 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -269,7 +269,7 @@ static int send_list(JCR *jcr, int list) Dmsg1(500, "Opts=%s\n", buf); optlen = strlen(buf); while (fgets(buf+optlen, sizeof(buf)-optlen, bpipe->rfd)) { - fd->msglen = Mmsg(&fd->msg, "%s", buf); + fd->msglen = Mmsg(fd->msg, "%s", buf); Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg); if (!bnet_send(fd)) { Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); @@ -301,7 +301,7 @@ static int send_list(JCR *jcr, int list) Dmsg1(500, "Opts=%s\n", buf); optlen = strlen(buf); while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) { - fd->msglen = Mmsg(&fd->msg, "%s", buf); + fd->msglen = Mmsg(fd->msg, "%s", buf); if (!bnet_send(fd)) { Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); goto bail_out; @@ -315,12 +315,12 @@ static int send_list(JCR *jcr, int list) default: if (ie->num_opts) { Dmsg2(500, "numopts=%d opts=%s\n", ie->num_opts, NPRT(ie->opts_list[0]->opts)); - pm_strcpy(&fd->msg, ie->opts_list[0]->opts); - pm_strcat(&fd->msg, " "); + pm_strcpy(fd->msg, ie->opts_list[0]->opts); + pm_strcat(fd->msg, " "); } else { - pm_strcpy(&fd->msg, "0 "); + pm_strcpy(fd->msg, "0 "); } - fd->msglen = pm_strcat(&fd->msg, p); + fd->msglen = pm_strcat(fd->msg, p); Dmsg1(500, "Inc/Exc name=%s\n", fd->msg); if (!bnet_send(fd)) { Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); @@ -416,7 +416,7 @@ static int send_fileset(JCR *jcr) Dmsg1(500, "Opts=%s\n", buf); optlen = strlen(buf); while (fgets(buf+optlen, sizeof(buf)-optlen, bpipe->rfd)) { - fd->msglen = Mmsg(&fd->msg, "%s", buf); + fd->msglen = Mmsg(fd->msg, "%s", buf); Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg); if (!bnet_send(fd)) { Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); @@ -442,7 +442,7 @@ static int send_fileset(JCR *jcr) Dmsg1(500, "Opts=%s\n", buf); optlen = strlen(buf); while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) { - fd->msglen = Mmsg(&fd->msg, "%s", buf); + fd->msglen = Mmsg(fd->msg, "%s", buf); if (!bnet_send(fd)) { Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); goto bail_out; @@ -454,8 +454,8 @@ static int send_fileset(JCR *jcr) p++; /* skip over \ */ /* Note, fall through wanted */ default: - pm_strcpy(&fd->msg, "F "); - fd->msglen = pm_strcat(&fd->msg, p); + pm_strcpy(fd->msg, "F "); + fd->msglen = pm_strcat(fd->msg, p); Dmsg1(500, "Inc/Exc name=%s\n", fd->msg); if (!bnet_send(fd)) { Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); @@ -558,7 +558,7 @@ int send_run_before_and_after_commands(JCR *jcr) POOLMEM *msg = get_pool_memory(PM_FNAME); BSOCK *fd = jcr->file_bsock; if (jcr->job->ClientRunBeforeJob) { - pm_strcpy(&msg, jcr->job->ClientRunBeforeJob); + pm_strcpy(msg, jcr->job->ClientRunBeforeJob); bash_spaces(msg); bnet_fsend(fd, runbefore, msg); if (!response(jcr, fd, OKRunBefore, "ClientRunBeforeJob", DISPLAY_ERROR)) { @@ -568,7 +568,7 @@ int send_run_before_and_after_commands(JCR *jcr) } } if (jcr->job->ClientRunAfterJob) { - fd->msglen = pm_strcpy(&msg, jcr->job->ClientRunAfterJob); + fd->msglen = pm_strcpy(msg, jcr->job->ClientRunAfterJob); bash_spaces(msg); bnet_fsend(fd, runafter, msg); if (!response(jcr, fd, OKRunAfter, "ClientRunAfterJob", DISPLAY_ERROR)) { diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 659c3618b9..6c71c7096f 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -538,7 +538,7 @@ bool get_or_create_client_record(JCR *jcr) if (!jcr->client_name) { jcr->client_name = get_pool_memory(PM_NAME); } - pm_strcpy(&jcr->client_name, jcr->client->hdr.name); + pm_strcpy(jcr->client_name, jcr->client->hdr.name); if (!db_create_client_record(jcr, jcr->db, &cr)) { Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s\n"), db_strerror(jcr->db)); @@ -549,7 +549,7 @@ bool get_or_create_client_record(JCR *jcr) if (!jcr->client_uname) { jcr->client_uname = get_pool_memory(PM_NAME); } - pm_strcpy(&jcr->client_uname, cr.Uname); + pm_strcpy(jcr->client_uname, cr.Uname); } Dmsg2(100, "Created Client %s record %d\n", jcr->client->hdr.name, jcr->jr.ClientId); @@ -743,7 +743,7 @@ void set_jcr_defaults(JCR *jcr, JOB *job) if (!jcr->client_name) { jcr->client_name = get_pool_memory(PM_NAME); } - pm_strcpy(&jcr->client_name, jcr->client->hdr.name); + pm_strcpy(jcr->client_name, jcr->client->hdr.name); jcr->pool = job->pool; jcr->full_pool = job->full_pool; jcr->inc_pool = job->inc_pool; diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index f62d949907..338415e20d 100755 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -450,7 +450,7 @@ void *jobq_server(void *arg) */ if (jcr->acquired_resource_locks) { jcr->store->NumConcurrentJobs--; - if (jcr->JobType == JT_RESTORE) { + if (jcr->JobType == JT_RESTORE || jcr->JobType == JT_VERIFY) { jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; } jcr->client->NumConcurrentJobs--; @@ -551,8 +551,8 @@ void *jobq_server(void *arg) set_jcr_job_status(jcr, JS_WaitPriority); break; } - if (jcr->JobType == JT_RESTORE) { - /* Let only one Restore job run at a time regardless of MaxConcurrentJobs */ + if (jcr->JobType == JT_RESTORE || jcr->JobType == JT_VERIFY) { + /* Let only one Restore/verify job run at a time regardless of MaxConcurrentJobs */ if (jcr->store->NumConcurrentJobs == 0) { jcr->store->NumConcurrentJobs++; jcr->saveMaxConcurrentJobs = jcr->store->MaxConcurrentJobs; @@ -575,7 +575,7 @@ void *jobq_server(void *arg) } else { /* Back out previous locks */ jcr->store->NumConcurrentJobs--; - if (jcr->JobType == JT_RESTORE) { + if (jcr->JobType == JT_RESTORE || jcr->JobType == JT_VERIFY) { jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; } set_jcr_job_status(jcr, JS_WaitClientRes); @@ -587,7 +587,7 @@ void *jobq_server(void *arg) } else { /* Back out previous locks */ jcr->store->NumConcurrentJobs--; - if (jcr->JobType == JT_RESTORE) { + if (jcr->JobType == JT_RESTORE || jcr->JobType == JT_VERIFY) { jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; } jcr->client->NumConcurrentJobs--; diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 8b8ee68f29..c92f07fb00 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -139,10 +139,10 @@ int start_storage_daemon_job(JCR *jcr) pool_name = get_pool_memory(PM_NAME); pool_type = get_pool_memory(PM_NAME); media_type = get_pool_memory(PM_NAME); - pm_strcpy(&device_name, storage->dev_name); - pm_strcpy(&media_type, storage->media_type); - pm_strcpy(&pool_type, jcr->pool->pool_type); - pm_strcpy(&pool_name, jcr->pool->hdr.name); + pm_strcpy(device_name, storage->dev_name); + pm_strcpy(media_type, storage->media_type); + pm_strcpy(pool_type, jcr->pool->pool_type); + pm_strcpy(pool_name, jcr->pool->hdr.name); bash_spaces(device_name); bash_spaces(media_type); bash_spaces(pool_type); @@ -151,7 +151,7 @@ int start_storage_daemon_job(JCR *jcr) Dmsg1(110, ">stored: %s", sd->msg); status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY); if (!status) { - pm_strcpy(&pool_type, sd->msg); /* save message */ + pm_strcpy(pool_type, sd->msg); /* save message */ Jmsg(jcr, M_FATAL, 0, _("\n" " Storage daemon didn't accept Device \"%s\" because:\n %s"), device_name, pool_type/* sd->msg */); diff --git a/bacula/src/dird/recycle.c b/bacula/src/dird/recycle.c index 44e4945a0f..84a39a9dc4 100644 --- a/bacula/src/dird/recycle.c +++ b/bacula/src/dird/recycle.c @@ -57,7 +57,7 @@ int find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) if (db_find_next_volume(jcr, jcr->db, 1, InChanger, mr)) { jcr->MediaId = mr->MediaId; Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->MediaId); - pm_strcpy(&jcr->VolumeName, mr->VolumeName); + pm_strcpy(jcr->VolumeName, mr->VolumeName); return 1; } return 0; @@ -80,9 +80,9 @@ int recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) Dmsg0(100, "Enter recycle_oldest_purged_volume\n"); oldest.MediaId = 0; if (InChanger) { - Mmsg(&query, select, mr->PoolId, mr->MediaType, "AND InChanger=1 "); + Mmsg(query, select, mr->PoolId, mr->MediaType, "AND InChanger=1 "); } else { - Mmsg(&query, select, mr->PoolId, mr->MediaType, ""); + Mmsg(query, select, mr->PoolId, mr->MediaType, ""); } if (!db_sql_query(jcr->db, query, oldest_handler, (void *)&oldest)) { diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 6c46946015..e79094fb4d 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -675,7 +675,7 @@ static void update_volstatus(UAContext *ua, const char *val, MEDIA_DBR *mr) bsendmsg(ua, _("Invalid VolStatus specified: %s\n"), val); } else { bstrncpy(mr->VolStatus, kw[i], sizeof(mr->VolStatus)); - Mmsg(&query, "UPDATE Media SET VolStatus='%s' WHERE MediaId=%u", + Mmsg(query, "UPDATE Media SET VolStatus='%s' WHERE MediaId=%u", mr->VolStatus, mr->MediaId); if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -695,7 +695,7 @@ static void update_volretention(UAContext *ua, char *val, MEDIA_DBR *mr) return; } query = get_pool_memory(PM_MESSAGE); - Mmsg(&query, "UPDATE Media SET VolRetention=%s WHERE MediaId=%u", + Mmsg(query, "UPDATE Media SET VolRetention=%s WHERE MediaId=%u", edit_uint64(mr->VolRetention, ed1), mr->MediaId); if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -716,7 +716,7 @@ static void update_voluseduration(UAContext *ua, char *val, MEDIA_DBR *mr) return; } query = get_pool_memory(PM_MESSAGE); - Mmsg(&query, "UPDATE Media SET VolUseDuration=%s WHERE MediaId=%u", + Mmsg(query, "UPDATE Media SET VolUseDuration=%s WHERE MediaId=%u", edit_uint64(mr->VolUseDuration, ed1), mr->MediaId); if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -730,7 +730,7 @@ static void update_voluseduration(UAContext *ua, char *val, MEDIA_DBR *mr) static void update_volmaxjobs(UAContext *ua, char *val, MEDIA_DBR *mr) { POOLMEM *query = get_pool_memory(PM_MESSAGE); - Mmsg(&query, "UPDATE Media SET MaxVolJobs=%s WHERE MediaId=%u", + Mmsg(query, "UPDATE Media SET MaxVolJobs=%s WHERE MediaId=%u", val, mr->MediaId); if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -743,7 +743,7 @@ static void update_volmaxjobs(UAContext *ua, char *val, MEDIA_DBR *mr) static void update_volmaxfiles(UAContext *ua, char *val, MEDIA_DBR *mr) { POOLMEM *query = get_pool_memory(PM_MESSAGE); - Mmsg(&query, "UPDATE Media SET MaxVolFiles=%s WHERE MediaId=%u", + Mmsg(query, "UPDATE Media SET MaxVolFiles=%s WHERE MediaId=%u", val, mr->MediaId); if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -764,7 +764,7 @@ static void update_volmaxbytes(UAContext *ua, char *val, MEDIA_DBR *mr) return; } query = get_pool_memory(PM_MESSAGE); - Mmsg(&query, "UPDATE Media SET MaxVolBytes=%s WHERE MediaId=%u", + Mmsg(query, "UPDATE Media SET MaxVolBytes=%s WHERE MediaId=%u", edit_uint64(maxbytes, ed1), mr->MediaId); if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -787,7 +787,7 @@ static void update_volrecycle(UAContext *ua, char *val, MEDIA_DBR *mr) return; } query = get_pool_memory(PM_MESSAGE); - Mmsg(&query, "UPDATE Media SET Recycle=%d WHERE MediaId=%u", + Mmsg(query, "UPDATE Media SET Recycle=%d WHERE MediaId=%u", recycle, mr->MediaId); if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -814,7 +814,7 @@ static void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *o */ query = get_pool_memory(PM_MESSAGE); db_lock(ua->db); - Mmsg(&query, "UPDATE Media SET PoolId=%d WHERE MediaId=%u", + Mmsg(query, "UPDATE Media SET PoolId=%d WHERE MediaId=%u", mr->PoolId, mr->MediaId); if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -1109,7 +1109,7 @@ static int update_volume(UAContext *ua) } } query = get_pool_memory(PM_MESSAGE); - Mmsg(&query, "UPDATE Media SET VolFiles=%u WHERE MediaId=%u", + Mmsg(query, "UPDATE Media SET VolFiles=%u WHERE MediaId=%u", VolFiles, mr.MediaId); if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -1176,7 +1176,7 @@ static int update_pool(UAContext *ua) id, db_strerror(ua->db)); } query = get_pool_memory(PM_MESSAGE); - Mmsg(&query, list_pool, pr.PoolId); + Mmsg(query, list_pool, pr.PoolId); db_list_sql_query(ua->jcr, ua->db, query, prtit, ua, 1, HORZ_LIST); free_pool_memory(query); bsendmsg(ua, _("Pool DB record updated from resource.\n")); @@ -1688,11 +1688,11 @@ static int delete_job(UAContext *ua) } else { JobId = ua->pint32_val; } - Mmsg(&query, "DELETE FROM Job WHERE JobId=%u", JobId); + Mmsg(query, "DELETE FROM Job WHERE JobId=%u", JobId); db_sql_query(ua->db, query, NULL, (void *)NULL); - Mmsg(&query, "DELETE FROM File WHERE JobId=%u", JobId); + Mmsg(query, "DELETE FROM File WHERE JobId=%u", JobId); db_sql_query(ua->db, query, NULL, (void *)NULL); - Mmsg(&query, "DELETE FROM JobMedia WHERE JobId=%u", JobId); + Mmsg(query, "DELETE FROM JobMedia WHERE JobId=%u", JobId); db_sql_query(ua->db, query, NULL, (void *)NULL); free_pool_memory(query); bsendmsg(ua, _("Job %u and associated records deleted from the catalog.\n"), JobId); diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index 01296ef0eb..d22fe6af9a 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -107,7 +107,7 @@ int do_a_dot_command(UAContext *ua, const char *cmd) } } if (!found) { - pm_strcat(&ua->UA_sock->msg, _(": is an illegal command\n")); + pm_strcat(ua->UA_sock->msg, _(": is an illegal command\n")); ua->UA_sock->msglen = strlen(ua->UA_sock->msg); bnet_send(ua->UA_sock); } @@ -220,7 +220,7 @@ static int backupscmd(UAContext *ua, const char *cmd) if (ua->argc == 2 && strcmp(ua->argk[1], "client") != 0) { return 1; } - Mmsg(&ua->cmd, client_backups, ua->argv[1]); + Mmsg(ua->cmd, client_backups, ua->argv[1]); if (!db_sql_query(ua->db, ua->cmd, client_backups_handler, (void *)ua)) { bsendmsg(ua, _("Query failed: %s. ERR=%s\n"), ua->cmd, db_strerror(ua->db)); return 1; diff --git a/bacula/src/dird/ua_input.c b/bacula/src/dird/ua_input.c index dde38e8b40..3c3afeac99 100644 --- a/bacula/src/dird/ua_input.c +++ b/bacula/src/dird/ua_input.c @@ -55,7 +55,7 @@ int get_cmd(UAContext *ua, const char *prompt) if (is_bnet_stop(sock)) { return 0; /* error or terminate */ } - pm_strcpy(&ua->cmd, sock->msg); + pm_strcpy(ua->cmd, sock->msg); strip_trailing_junk(ua->cmd); if (strcmp(ua->cmd, ".messages") == 0) { qmessagescmd(ua, ua->cmd); diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index 16d2e28cbc..588ac1acbd 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -332,7 +332,7 @@ checkVol: /* Check for volume=NewVolume */ i = find_arg_with_value(ua, "volume"); if (i >= 0) { - pm_strcpy(&ua->cmd, ua->argv[i]); + pm_strcpy(ua->cmd, ua->argv[i]); goto checkName; } diff --git a/bacula/src/dird/ua_prune.c b/bacula/src/dird/ua_prune.c index 4fb5e4be10..d72fe1d370 100644 --- a/bacula/src/dird/ua_prune.c +++ b/bacula/src/dird/ua_prune.c @@ -245,7 +245,7 @@ int prune_files(UAContext *ua, CLIENT *client) now = (utime_t)time(NULL); /* Select Jobs -- for counting */ - Mmsg(&query, select_job, edit_uint64(now - period, ed1), cr.ClientId); + Mmsg(query, select_job, edit_uint64(now - period, ed1), cr.ClientId); Dmsg1(050, "select sql=%s\n", query); if (!db_sql_query(ua->db, query, file_count_handler, (void *)&del)) { if (ua->verbose) { @@ -277,11 +277,11 @@ int prune_files(UAContext *ua, CLIENT *client) for (i=0; i < del.num_ids; i++) { struct s_count_ctx cnt; Dmsg1(050, "Delete JobId=%d\n", del.JobId[i]); - Mmsg(&query, cnt_File, del.JobId[i]); + Mmsg(query, cnt_File, del.JobId[i]); cnt.count = 0; db_sql_query(ua->db, query, count_handler, (void *)&cnt); del.tot_ids += cnt.count; - Mmsg(&query, del_File, del.JobId[i]); + Mmsg(query, del_File, del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); /* * Now mark Job as having files purged. This is necessary to @@ -289,7 +289,7 @@ int prune_files(UAContext *ua, CLIENT *client) * we don't do this, the number of JobId's in our in memory list * could grow very large. */ - Mmsg(&query, upd_Purged, del.JobId[i]); + Mmsg(query, upd_Purged, del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); Dmsg1(050, "Del sql=%s\n", query); } @@ -348,7 +348,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) { struct s_job_del_ctx del; struct s_count_ctx cnt; - char *query = (char *)get_pool_memory(PM_MESSAGE); + POOLMEM *query = (char *)get_pool_memory(PM_MESSAGE); int i; utime_t now, period; CLIENT_DBR cr; @@ -379,7 +379,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) * and stuff them into the "DeletionCandidates" table. */ edit_uint64(now - period, ed1); - Mmsg(&query, insert_delcand, (char)JobType, ed1, cr.ClientId); + Mmsg(query, insert_delcand, (char)JobType, ed1, cr.ClientId); if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) { if (ua->verbose) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -389,7 +389,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) } /* Count Files to be deleted */ - pm_strcpy(&query, cnt_DelCand); + pm_strcpy(query, cnt_DelCand); Dmsg1(100, "select sql=%s\n", query); cnt.count = 0; if (!db_sql_query(ua->db, query, count_handler, (void *)&cnt)) { @@ -415,16 +415,16 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) switch (JobType) { case JT_BACKUP: - Mmsg(&query, select_backup_del, ed1, ed1, cr.ClientId); + Mmsg(query, select_backup_del, ed1, ed1, cr.ClientId); break; case JT_RESTORE: - Mmsg(&query, select_restore_del, ed1, ed1, cr.ClientId); + Mmsg(query, select_restore_del, ed1, ed1, cr.ClientId); break; case JT_VERIFY: - Mmsg(&query, select_verify_del, ed1, ed1, cr.ClientId); + Mmsg(query, select_verify_del, ed1, ed1, cr.ClientId); break; case JT_ADMIN: - Mmsg(&query, select_admin_del, ed1, ed1, cr.ClientId); + Mmsg(query, select_admin_del, ed1, ed1, cr.ClientId); break; } if (!db_sql_query(ua->db, query, job_delete_handler, (void *)&del)) { @@ -439,20 +439,20 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) for (i=0; i < del.num_ids; i++) { Dmsg1(050, "Delete JobId=%d\n", del.JobId[i]); if (!del.PurgedFiles[i]) { - Mmsg(&query, del_File, del.JobId[i]); + Mmsg(query, del_File, del.JobId[i]); if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } Dmsg1(050, "Del sql=%s\n", query); } - Mmsg(&query, del_Job, del.JobId[i]); + Mmsg(query, del_Job, del.JobId[i]); if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } Dmsg1(050, "Del sql=%s\n", query); - Mmsg(&query, del_JobMedia, del.JobId[i]); + Mmsg(query, del_JobMedia, del.JobId[i]); if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } @@ -479,7 +479,7 @@ bail_out: */ int prune_volume(UAContext *ua, MEDIA_DBR *mr) { - char *query = (char *)get_pool_memory(PM_MESSAGE); + POOLMEM *query = (char *)get_pool_memory(PM_MESSAGE); struct s_count_ctx cnt; struct s_file_del_ctx del; int i, stat = 0; @@ -495,7 +495,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) * counting the JobMedia records. */ cnt.count = 0; - Mmsg(&query, cnt_JobMedia, mr->MediaId); + Mmsg(query, cnt_JobMedia, mr->MediaId); if (!db_sql_query(ua->db, query, count_handler, (void *)&cnt)) { bsendmsg(ua, "%s", db_strerror(ua->db)); Dmsg0(050, "Count failed\n"); @@ -522,7 +522,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) * Could optimize here by adding JobTDate > (now - period). */ del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids); - Mmsg(&query, sel_JobMedia, mr->MediaId); + Mmsg(query, sel_JobMedia, mr->MediaId); if (!db_sql_query(ua->db, query, file_delete_handler, (void *)&del)) { if (ua->verbose) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -548,11 +548,11 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) continue; } Dmsg2(200, "Delete JobId=%d Job=%s\n", del.JobId[i], jr.Job); - Mmsg(&query, del_File, del.JobId[i]); + Mmsg(query, del_File, del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); - Mmsg(&query, del_Job, del.JobId[i]); + Mmsg(query, del_Job, del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); - Mmsg(&query, del_JobMedia, del.JobId[i]); + Mmsg(query, del_JobMedia, del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); Dmsg1(050, "Del sql=%s\n", query); del.num_del++; diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index 7ac5ac121f..87d43b3d76 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -291,7 +291,7 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client) return 0; } bsendmsg(ua, _("Begin purging files for Client \"%s\"\n"), cr.Name); - Mmsg(&query, select_jobsfiles_from_client, cr.ClientId); + Mmsg(query, select_jobsfiles_from_client, cr.ClientId); Dmsg1(050, "select sql=%s\n", query); @@ -320,7 +320,7 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client) for (i=0; i < del.num_ids; i++) { Dmsg1(050, "Delete JobId=%d\n", del.JobId[i]); - Mmsg(&query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]); + Mmsg(query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); /* * Now mark Job as having files purged. This is necessary to @@ -328,7 +328,7 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client) * we don't do this, the number of JobId's in our in memory list * will grow very large. */ - Mmsg(&query, "UPDATE Job Set PurgedFiles=1 WHERE JobId=%d", del.JobId[i]); + Mmsg(query, "UPDATE Job Set PurgedFiles=1 WHERE JobId=%d", del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); Dmsg1(050, "Del sql=%s\n", query); } @@ -369,7 +369,7 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client) } bsendmsg(ua, _("Begin purging jobs from Client \"%s\"\n"), cr.Name); - Mmsg(&query, select_jobs_from_client, cr.ClientId); + Mmsg(query, select_jobs_from_client, cr.ClientId); Dmsg1(050, "select sql=%s\n", query); @@ -405,16 +405,16 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client) for (i=0; i < del.num_ids; i++) { Dmsg1(050, "Delete JobId=%d\n", del.JobId[i]); if (!del.PurgedFiles[i]) { - Mmsg(&query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]); + Mmsg(query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); Dmsg1(050, "Del sql=%s\n", query); } - Mmsg(&query, "DELETE FROM Job WHERE JobId=%d", del.JobId[i]); + Mmsg(query, "DELETE FROM Job WHERE JobId=%d", del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); Dmsg1(050, "Del sql=%s\n", query); - Mmsg(&query, "DELETE FROM JobMedia WHERE JobId=%d", del.JobId[i]); + Mmsg(query, "DELETE FROM JobMedia WHERE JobId=%d", del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); Dmsg1(050, "Del sql=%s\n", query); } @@ -436,10 +436,10 @@ void purge_files_from_job(UAContext *ua, JOB_DBR *jr) { char *query = (char *)get_pool_memory(PM_MESSAGE); - Mmsg(&query, "DELETE FROM File WHERE JobId=%u", jr->JobId); + Mmsg(query, "DELETE FROM File WHERE JobId=%u", jr->JobId); db_sql_query(ua->db, query, NULL, (void *)NULL); - Mmsg(&query, "UPDATE Job Set PurgedFiles=1 WHERE JobId=%u", jr->JobId); + Mmsg(query, "UPDATE Job Set PurgedFiles=1 WHERE JobId=%u", jr->JobId); db_sql_query(ua->db, query, NULL, (void *)NULL); free_pool_memory(query); @@ -475,7 +475,7 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) memset(&jr, 0, sizeof(jr)); memset(&del, 0, sizeof(del)); cnt.count = 0; - Mmsg(&query, "SELECT count(*) FROM JobMedia WHERE MediaId=%d", mr->MediaId); + Mmsg(query, "SELECT count(*) FROM JobMedia WHERE MediaId=%d", mr->MediaId); if (!db_sql_query(ua->db, query, count_handler, (void *)&cnt)) { bsendmsg(ua, "%s", db_strerror(ua->db)); Dmsg0(050, "Count failed\n"); @@ -512,7 +512,7 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) */ del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids); - Mmsg(&query, "SELECT JobId FROM JobMedia WHERE MediaId=%d", mr->MediaId); + Mmsg(query, "SELECT JobId FROM JobMedia WHERE MediaId=%d", mr->MediaId); if (!db_sql_query(ua->db, query, file_delete_handler, (void *)&del)) { bsendmsg(ua, "%s", db_strerror(ua->db)); Dmsg0(050, "Count failed\n"); @@ -522,11 +522,11 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) for (i=0; i < del.num_ids; i++) { Dmsg1(050, "Delete JobId=%d\n", del.JobId[i]); - Mmsg(&query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]); + Mmsg(query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); - Mmsg(&query, "DELETE FROM Job WHERE JobId=%d", del.JobId[i]); + Mmsg(query, "DELETE FROM Job WHERE JobId=%d", del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); - Mmsg(&query, "DELETE FROM JobMedia WHERE JobId=%d", del.JobId[i]); + Mmsg(query, "DELETE FROM JobMedia WHERE JobId=%d", del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); Dmsg1(050, "Del sql=%s\n", query); del.num_del++; @@ -539,7 +539,7 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) /* If purged, mark it so */ cnt.count = 0; - Mmsg(&query, "SELECT count(*) FROM JobMedia WHERE MediaId=%d", mr->MediaId); + Mmsg(query, "SELECT count(*) FROM JobMedia WHERE MediaId=%d", mr->MediaId); if (!db_sql_query(ua->db, query, count_handler, (void *)&cnt)) { bsendmsg(ua, "%s", db_strerror(ua->db)); Dmsg0(050, "Count failed\n"); diff --git a/bacula/src/dird/ua_query.c b/bacula/src/dird/ua_query.c index faa8c0614b..5cf84260a3 100644 --- a/bacula/src/dird/ua_query.c +++ b/bacula/src/dird/ua_query.c @@ -115,9 +115,9 @@ int querycmd(UAContext *ua, const char *cmd) } } if (*query != 0) { - pm_strcat(&query, " "); + pm_strcat(query, " "); } - pm_strcat(&query, line); + pm_strcat(query, line); if (line[len-1] != ';') { continue; } diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 2b1cf9cd0a..956ab45a98 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -206,20 +206,20 @@ int restore_cmd(UAContext *ua, const char *cmd) /* Build run command */ if (rx.where) { - Mmsg(&ua->cmd, + Mmsg(ua->cmd, "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s/restore.bsr\"" " where=\"%s\" files=%d", job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"", working_directory, rx.where, rx.selected_files); } else { - Mmsg(&ua->cmd, + Mmsg(ua->cmd, "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s/restore.bsr\"" " files=%d", job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"", working_directory, rx.selected_files); } if (find_arg(ua, _("yes")) > 0) { - pm_strcat(&ua->cmd, " yes"); /* pass it on to the run command */ + pm_strcat(ua->cmd, " yes"); /* pass it on to the run command */ } Dmsg1(400, "Submitting: %s\n", ua->cmd); parse_ua_args(ua); @@ -337,9 +337,9 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) switch (j) { case 0: /* jobid */ if (*rx->JobIds != 0) { - pm_strcat(&rx->JobIds, ","); + pm_strcat(rx->JobIds, ","); } - pm_strcat(&rx->JobIds, ua->argv[i]); + pm_strcat(rx->JobIds, ua->argv[i]); done = true; break; case 1: /* current */ @@ -361,7 +361,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) if (!get_client_name(ua, rx)) { return 0; } - pm_strcpy(&ua->cmd, ua->argv[i]); + pm_strcpy(ua->cmd, ua->argv[i]); insert_one_file(ua, rx, date); if (rx->name_list.num_ids) { /* Check MediaType and select storage that corresponds */ @@ -439,7 +439,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) len = strlen(ua->cmd); fname = (char *)malloc(len * 2 + 1); db_escape_string(fname, ua->cmd, len); - Mmsg(&rx->query, uar_file, fname); + Mmsg(rx->query, uar_file, fname); free(fname); gui_save = ua->jcr->gui; ua->jcr->gui = true; @@ -451,7 +451,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) if (!get_cmd(ua, _("Enter JobId(s), comma separated, to restore: "))) { return 0; } - pm_strcpy(&rx->JobIds, ua->cmd); + pm_strcpy(rx->JobIds, ua->cmd); break; case 3: /* Enter an SQL list command */ if (!get_cmd(ua, _("Enter SQL list command: "))) { @@ -632,7 +632,7 @@ static int insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *fi { strip_trailing_junk(file); split_path_and_filename(rx, file); - Mmsg(&rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, rx->ClientName); + Mmsg(rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, rx->ClientName); rx->found = false; /* Find and insert jobid and File Index */ if (!db_sql_query(ua->db, rx->query, jobid_fileindex_handler, (void *)rx)) { @@ -647,7 +647,7 @@ static int insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *fi /* * Find the MediaTypes for this JobId and add to the name_list */ - Mmsg(&rx->query, uar_mediatype, rx->JobId); + Mmsg(rx->query, uar_mediatype, rx->JobId); if (!db_sql_query(ua->db, rx->query, unique_name_list_handler, (void *)&rx->name_list)) { bsendmsg(ua, "%s", db_strerror(ua->db)); return 0; @@ -730,7 +730,7 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx) tree.FileEstimate = 0; if (get_next_jobid_from_list(&p, &JobId) > 0) { /* Use first JobId as estimate of the number of files to restore */ - Mmsg(&rx->query, uar_count_files, JobId); + Mmsg(rx->query, uar_count_files, JobId); if (!db_sql_query(ua->db, rx->query, count_handler, (void *)rx)) { bsendmsg(ua, "%s\n", db_strerror(ua->db)); } @@ -746,19 +746,19 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx) continue; /* eliminate duplicate JobIds */ } last_JobId = JobId; - bsendmsg(ua, _("Building directory tree for JobId %u ...\n"), JobId); + bsendmsg(ua, _("\nBuilding directory tree for JobId %u ... "), JobId); items++; /* * Find files for this JobId and insert them in the tree */ - Mmsg(&rx->query, uar_sel_files, JobId); + Mmsg(rx->query, uar_sel_files, JobId); if (!db_sql_query(ua->db, rx->query, insert_tree_handler, (void *)&tree)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } /* * Find the MediaTypes for this JobId and add to the name_list */ - Mmsg(&rx->query, uar_mediatype, JobId); + Mmsg(rx->query, uar_mediatype, JobId); if (!db_sql_query(ua->db, rx->query, unique_name_list_handler, (void *)&rx->name_list)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } @@ -845,7 +845,7 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date } } if (i < 0) { /* fileset not found */ - Mmsg(&rx->query, uar_sel_fileset, cr.ClientId, cr.ClientId); + Mmsg(rx->query, uar_sel_fileset, cr.ClientId, cr.ClientId); start_prompt(ua, _("The defined FileSet resources are:\n")); if (!db_sql_query(ua->db, rx->query, fileset_handler, (void *)ua)) { bsendmsg(ua, "%s\n", db_strerror(ua->db)); @@ -877,7 +877,7 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date } /* Find JobId of last Full backup for this client, fileset */ - Mmsg(&rx->query, uar_last_full, cr.ClientId, cr.ClientId, date, fsr.FileSet, + Mmsg(rx->query, uar_last_full, cr.ClientId, cr.ClientId, date, fsr.FileSet, pool_select); if (!db_sql_query(ua->db, rx->query, NULL, NULL)) { bsendmsg(ua, "%s\n", db_strerror(ua->db)); @@ -902,7 +902,7 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date } /* Now find most recent Differental Job after Full save, if any */ - Mmsg(&rx->query, uar_dif, edit_uint64(rx->JobTDate, ed1), date, + Mmsg(rx->query, uar_dif, edit_uint64(rx->JobTDate, ed1), date, cr.ClientId, fsr.FileSet, pool_select); if (!db_sql_query(ua->db, rx->query, NULL, NULL)) { bsendmsg(ua, "%s\n", db_strerror(ua->db)); @@ -918,7 +918,7 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date } /* Now find all Incremental Jobs after Full/dif save */ - Mmsg(&rx->query, uar_inc, edit_uint64(rx->JobTDate, ed1), date, + Mmsg(rx->query, uar_inc, edit_uint64(rx->JobTDate, ed1), date, cr.ClientId, fsr.FileSet, pool_select); if (!db_sql_query(ua->db, rx->query, NULL, NULL)) { bsendmsg(ua, "%s\n", db_strerror(ua->db)); @@ -1002,9 +1002,9 @@ static int jobid_handler(void *ctx, int num_fields, char **row) } bstrncpy(rx->last_jobid, row[0], sizeof(rx->last_jobid)); if (rx->JobIds[0] != 0) { - pm_strcat(&rx->JobIds, ","); + pm_strcat(rx->JobIds, ","); } - pm_strcat(&rx->JobIds, row[0]); + pm_strcat(rx->JobIds, row[0]); return 0; } diff --git a/bacula/src/dird/ua_server.c b/bacula/src/dird/ua_server.c index bdfb98acdb..bfdc5ec885 100644 --- a/bacula/src/dird/ua_server.c +++ b/bacula/src/dird/ua_server.c @@ -149,7 +149,7 @@ static void *handle_UA_client_request(void *arg) while (!ua->quit) { stat = bnet_recv(ua->UA_sock); if (stat >= 0) { - pm_strcpy(&ua->cmd, ua->UA_sock->msg); + pm_strcpy(ua->cmd, ua->UA_sock->msg); parse_ua_args(ua); if (ua->argc > 0 && ua->argk[0][0] == '.') { do_a_dot_command(ua, ua->cmd); diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 29eb20f6c8..9acb7fd0e5 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -508,13 +508,13 @@ static void list_running_jobs(UAContext *ua) break; case JS_WaitFD: emsg = (char *) get_pool_memory(PM_FNAME); - Mmsg(&emsg, _("is waiting on Client %s"), jcr->client->hdr.name); + Mmsg(emsg, _("is waiting on Client %s"), jcr->client->hdr.name); pool_mem = true; msg = emsg; break; case JS_WaitSD: emsg = (char *) get_pool_memory(PM_FNAME); - Mmsg(&emsg, _("is waiting on Storage %s"), jcr->store->hdr.name); + Mmsg(emsg, _("is waiting on Storage %s"), jcr->store->hdr.name); pool_mem = true; msg = emsg; break; @@ -539,7 +539,7 @@ static void list_running_jobs(UAContext *ua) default: emsg = (char *) get_pool_memory(PM_FNAME); - Mmsg(&emsg, _("is in unknown state %c"), jcr->JobStatus); + Mmsg(emsg, _("is in unknown state %c"), jcr->JobStatus); pool_mem = true; msg = emsg; break; @@ -567,7 +567,7 @@ static void list_running_jobs(UAContext *ua) emsg = (char *) get_pool_memory(PM_FNAME); pool_mem = true; } - Mmsg(&emsg, _("is waiting for Client %s to connect to Storage %s"), + Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"), jcr->client->hdr.name, jcr->store->hdr.name); msg = emsg; break; diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index e6ec1ac986..94b0f57389 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -175,7 +175,7 @@ int do_verify(JCR *jcr) free(jcr->RestoreBootstrap); } POOLMEM *fname = get_pool_memory(PM_MESSAGE); - Mmsg(&fname, "%s/restore.bsr", working_directory); + Mmsg(fname, "%s/restore.bsr", working_directory); jcr->RestoreBootstrap = bstrdup(fname); free_pool_memory(fname); @@ -547,7 +547,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) decode_stat(attr, &statf, &LinkFIf); /* decode file stat packet */ do_SIG = NO_SIG; jcr->fn_printed = false; - pm_strcpy(&jcr->fname, fname); /* move filename into JCR */ + pm_strcpy(jcr->fname, fname); /* move filename into JCR */ Dmsg2(040, "dirdfname); Dmsg1(020, "dirdRestoreBootstrap); free_pool_memory(jcr->RestoreBootstrap); } - Mmsg(&fname, "%s/%s.%s.bootstrap", me->working_directory, me->hdr.name, + Mmsg(fname, "%s/%s.%s.bootstrap", me->working_directory, me->hdr.name, jcr->Job); Dmsg1(400, "bootstrap=%s\n", fname); jcr->RestoreBootstrap = fname; @@ -1583,7 +1583,7 @@ static int send_bootstrap_file(JCR *jcr) sd->msglen = strlen(sd->msg); bnet_send(sd); while (fgets(buf, sizeof(buf), bs)) { - sd->msglen = Mmsg(&sd->msg, "%s", buf); + sd->msglen = Mmsg(sd->msg, "%s", buf); bnet_send(sd); } bnet_sig(sd, BNET_EOD); diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index bcb896db6a..1ff65244cb 100755 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -56,11 +56,11 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a msg = (char *)get_pool_memory(PM_MESSAGE); found = 0; - len = Mmsg(&msg, "%s Version: " VERSION " (" BDATE ") %s %s %s\n", my_name, + len = Mmsg(msg, "%s Version: " VERSION " (" BDATE ") %s %s %s\n", my_name, HOST_OS, DISTNAME, DISTVER); sendit(msg, len, arg); bstrftime_nc(dt, sizeof(dt), daemon_start_time); - len = Mmsg(&msg, _("Daemon started %s, %d Job%s run since started.\n"), + len = Mmsg(msg, _("Daemon started %s, %d Job%s run since started.\n"), dt, num_jobs_run, num_jobs_run == 1 ? "" : "s"); sendit(msg, len, arg); #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) @@ -68,7 +68,7 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a if (!privs) { privs = enable_backup_privileges(NULL, 1); } - len = Mmsg(&msg, + len = Mmsg(msg, _(" Priv 0x%x APIs=%sOPT,%sATP,%sLPV,%sGFAE,%sBR,%sBW,%sSPSP\n"), privs, p_OpenProcessToken?"":"!", p_AdjustTokenPrivileges?"":"!", @@ -81,7 +81,7 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a } #endif if (debug_level > 0) { - len = Mmsg(&msg, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), + len = Mmsg(msg, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), edit_uint64_with_commas(sm_bytes, b1), edit_uint64_with_commas(sm_max_bytes, b2), edit_uint64_with_commas(sm_buffers, b3), @@ -89,7 +89,7 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a sendit(msg, len, arg); } if (debug_level > 0) { - len = Mmsg(&msg, _(" Sizeof: off_t=%d size_t=%d\n"), sizeof(off_t), + len = Mmsg(msg, _(" Sizeof: off_t=%d size_t=%d\n"), sizeof(off_t), sizeof(size_t)); sendit(msg, len, arg); } @@ -100,18 +100,18 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a * List running jobs */ Dmsg0(1000, "Begin status jcr loop.\n"); - len = Mmsg(&msg, _("Running Jobs:\n")); + len = Mmsg(msg, _("Running Jobs:\n")); sendit(msg, len, arg); lock_jcr_chain(); foreach_jcr(njcr) { bstrftime_nc(dt, sizeof(dt), njcr->start_time); if (njcr->JobId == 0) { - len = Mmsg(&msg, _("Director connected at: %s\n"), dt); + len = Mmsg(msg, _("Director connected at: %s\n"), dt); } else { - len = Mmsg(&msg, _("JobId %d Job %s is running.\n"), + len = Mmsg(msg, _("JobId %d Job %s is running.\n"), njcr->JobId, njcr->Job); sendit(msg, len, arg); - len = Mmsg(&msg, _(" %s Job started: %s\n"), + len = Mmsg(msg, _(" %s Job started: %s\n"), job_type_to_str(njcr->JobType), dt); } sendit(msg, len, arg); @@ -124,28 +124,28 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a sec = 1; } bps = (int)(njcr->JobBytes / sec); - len = Mmsg(&msg, _(" Files=%s Bytes=%s Bytes/sec=%s\n"), + len = Mmsg(msg, _(" Files=%s Bytes=%s Bytes/sec=%s\n"), edit_uint64_with_commas(njcr->JobFiles, b1), edit_uint64_with_commas(njcr->JobBytes, b2), edit_uint64_with_commas(bps, b3)); sendit(msg, len, arg); - len = Mmsg(&msg, _(" Files Examined=%s\n"), + len = Mmsg(msg, _(" Files Examined=%s\n"), edit_uint64_with_commas(njcr->num_files_examined, b1)); sendit(msg, len, arg); if (njcr->JobFiles > 0) { P(njcr->mutex); - len = Mmsg(&msg, _(" Processing file: %s\n"), njcr->last_fname); + len = Mmsg(msg, _(" Processing file: %s\n"), njcr->last_fname); V(njcr->mutex); sendit(msg, len, arg); } found = 1; if (njcr->store_bsock) { - len = Mmsg(&msg, " SDReadSeqNo=%" lld " fd=%d\n", + len = Mmsg(msg, " SDReadSeqNo=%" lld " fd=%d\n", njcr->store_bsock->read_seqno, njcr->store_bsock->fd); sendit(msg, len, arg); } else { - len = Mmsg(&msg, _(" SDSocket closed.\n")); + len = Mmsg(msg, _(" SDSocket closed.\n")); sendit(msg, len, arg); } free_locked_jcr(njcr); @@ -153,10 +153,10 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a unlock_jcr_chain(); Dmsg0(1000, "Begin status jcr loop.\n"); if (!found) { - len = Mmsg(&msg, _("No Jobs running.\n")); + len = Mmsg(msg, _("No Jobs running.\n")); sendit(msg, len, arg); } - len = Mmsg(&msg, _("====\n")); + len = Mmsg(msg, _("====\n")); sendit(msg, len, arg); free_pool_memory(msg); } diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index dbb707663d..9b267a4235 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -288,9 +288,17 @@ extern JCR *get_jcr_by_session(uint32_t SessionId, uint32_t SessionTime); extern JCR *get_jcr_by_partial_name(char *Job); extern JCR *get_jcr_by_full_name(char *Job); extern JCR *get_next_jcr(JCR *jcr); +extern void set_jcr_job_status(JCR *jcr, int JobStatus); + +#ifdef TRACE_JCR_CHAIN +extern void b_lock_jcr_chain(const char *filen, int line); +extern void b_unlock_jcr_chain(const char *filen, int line); +#define lock_jcr_chain() b_lock_jcr_chain(__FILE__, __LINE__); +#define unlock_jcr_chain() b_unlock_jcr_chain(__FILE__, __LINE__); +#else extern void lock_jcr_chain(); extern void unlock_jcr_chain(); -extern void set_jcr_job_status(JCR *jcr, int JobStatus); +#endif #ifdef DEBUG extern void b_free_jcr(const char *file, int line, JCR *jcr); diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index d7fdc9d494..afa0555c8e 100755 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -352,6 +352,7 @@ void free_jcr(JCR *jcr) #endif + dequeue_messages(jcr); lock_jcr_chain(); jcr->use_count--; /* decrement use count */ if (jcr->use_count < 0) { @@ -364,19 +365,17 @@ void free_jcr(JCR *jcr) Dmsg2(400, "free_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); return; } - dequeue_messages(jcr); - remove_jcr(jcr); + remove_jcr(jcr); /* remove Jcr from chain */ + unlock_jcr_chain(); + job_end_pop(jcr); /* pop and call hooked routines */ Dmsg1(400, "End job=%d\n", jcr->JobId); if (jcr->daemon_free_jcr) { jcr->daemon_free_jcr(jcr); /* call daemon free routine */ } - free_common_jcr(jcr); - close_msg(NULL); /* flush any daemon messages */ - unlock_jcr_chain(); Dmsg0(400, "Exit free_jcr\n"); } @@ -530,11 +529,16 @@ static int lock_count = 0; /* * Lock the chain */ +#ifdef TRACE_JCR_CHAIN +void b_lock_jcr_chain(const char *fname, int line) +#else void lock_jcr_chain() +#endif { int errstat; #ifdef TRACE_JCR_CHAIN - Dmsg1(000, "Lock jcr chain %d.\n", ++lock_count); + Dmsg3(000, "Lock jcr chain %d from %s:%d\n", ++lock_count, + fname, line); #endif if ((errstat=rwl_writelock(&lock)) != 0) { Emsg1(M_ABORT, 0, "rwl_writelock failure. ERR=%s\n", @@ -545,11 +549,16 @@ void lock_jcr_chain() /* * Unlock the chain */ +#ifdef TRACE_JCR_CHAIN +void b_unlock_jcr_chain(const char *fname, int line) +#else void unlock_jcr_chain() +#endif { int errstat; #ifdef TRACE_JCR_CHAIN - Dmsg1(000, "Unlock jcr chain %d\n", lock_count--); + Dmsg3(000, "Unlock jcr chain %d from %s:%d\n", lock_count--, + fname, line); #endif if ((errstat=rwl_writeunlock(&lock)) != 0) { Emsg1(M_ABORT, 0, "rwl_writeunlock failure. ERR=%s\n", diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index f33380aa67..8519389e9f 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -354,7 +354,7 @@ void rem_msg_dest(MSGS *msg, int dest_code, int msg_type, char *where) /* * Create a unique filename for the mail command */ -static void make_unique_mail_filename(JCR *jcr, POOLMEM **name, DEST *d) +static void make_unique_mail_filename(JCR *jcr, POOLMEM *&name, DEST *d) { if (jcr) { Mmsg(name, "%s/%s.mail.%s.%d", working_directory, my_name, @@ -369,13 +369,13 @@ static void make_unique_mail_filename(JCR *jcr, POOLMEM **name, DEST *d) /* * Open a mail pipe */ -static BPIPE *open_mail_pipe(JCR *jcr, POOLMEM **cmd, DEST *d) +static BPIPE *open_mail_pipe(JCR *jcr, POOLMEM *&cmd, DEST *d) { BPIPE *bpipe; int use_bsmtp = (d->mail_cmd && jcr); if (use_bsmtp) { - *cmd = edit_job_codes(jcr, *cmd, d->mail_cmd, d->where); + cmd = edit_job_codes(jcr, cmd, d->mail_cmd, d->where); } else { #if 1 Mmsg(cmd, "/usr/lib/sendmail -F Bacula %s", d->where); @@ -385,9 +385,10 @@ static BPIPE *open_mail_pipe(JCR *jcr, POOLMEM **cmd, DEST *d) } fflush(stdout); - if (!(bpipe = open_bpipe(*cmd, 120, "rw"))) { + if (!(bpipe = open_bpipe(cmd, 120, "rw"))) { + berrno be; Jmsg(jcr, M_ERROR, 0, "open mail pipe %s failed: ERR=%s\n", - *cmd, strerror(errno)); + cmd, be.strerror()); } #if 1 @@ -444,7 +445,7 @@ void close_msg(JCR *jcr) goto rem_temp_file; } - if (!(bpipe=open_mail_pipe(jcr, &cmd, d))) { + if (!(bpipe=open_mail_pipe(jcr, cmd, d))) { Pmsg0(000, "open mail pipe failed.\n"); goto rem_temp_file; } @@ -641,7 +642,7 @@ void dispatch_message(JCR *jcr, int type, int level, char *msg) case MD_OPERATOR: Dmsg1(800, "OPERATOR for collowing msg: %s\n", msg); mcmd = get_pool_memory(PM_MESSAGE); - if ((bpipe=open_mail_pipe(jcr, &mcmd, d))) { + if ((bpipe=open_mail_pipe(jcr, mcmd, d))) { int stat; fputs(msg, bpipe->wfd); /* Messages to the operator go one at a time */ @@ -661,7 +662,7 @@ void dispatch_message(JCR *jcr, int type, int level, char *msg) Dmsg1(800, "MAIL for following msg: %s", msg); if (!d->fd) { POOLMEM *name = get_pool_memory(PM_MESSAGE); - make_unique_mail_filename(jcr, &mp_chr(name), d); + make_unique_mail_filename(jcr, name, d); d->fd = fopen(mp_chr(name), "w+"); if (!d->fd) { d->fd = stdout; @@ -1065,7 +1066,7 @@ void j_msg(const char *file, int line, JCR *jcr, int type, int level, const char POOLMEM *pool_buf; pool_buf = get_pool_memory(PM_EMSG); - i = Mmsg(&pool_buf, "%s:%d ", file, line); + i = Mmsg(pool_buf, "%s:%d ", file, line); for (;;) { maxlen = sizeof_pool_memory(pool_buf) - i - 1; @@ -1108,6 +1109,28 @@ int m_msg(const char *file, int line, POOLMEM **pool_buf, const char *fmt, ...) return len; } +int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...) +{ + va_list arg_ptr; + int i, len, maxlen; + + i = sprintf(pool_buf, "%s:%d ", file, line); + + for (;;) { + maxlen = sizeof_pool_memory(pool_buf) - i - 1; + va_start(arg_ptr, fmt); + len = bvsnprintf(pool_buf+i, maxlen, fmt, arg_ptr); + va_end(arg_ptr); + if (len < 0 || len >= (maxlen-5)) { + pool_buf = realloc_pool_memory(pool_buf, maxlen + i + maxlen/2); + continue; + } + break; + } + return len; +} + + /* * Edit a message into a Pool Memory buffer NO file:lineno * Returns: string length of what was edited. @@ -1131,6 +1154,26 @@ int Mmsg(POOLMEM **pool_buf, const char *fmt, ...) return len; } +int Mmsg(POOLMEM *&pool_buf, const char *fmt, ...) +{ + va_list arg_ptr; + int len, maxlen; + + for (;;) { + maxlen = sizeof_pool_memory(pool_buf) - 1; + va_start(arg_ptr, fmt); + len = bvsnprintf(pool_buf, maxlen, fmt, arg_ptr); + va_end(arg_ptr); + if (len < 0 || len >= (maxlen-5)) { + pool_buf = realloc_pool_memory(pool_buf, maxlen + maxlen/2); + continue; + } + break; + } + return len; +} + + static pthread_mutex_t msg_queue_mutex = PTHREAD_MUTEX_INITIALIZER; /* @@ -1208,7 +1251,7 @@ void q_msg(const char *file, int line, JCR *jcr, int type, int level, const char POOLMEM *pool_buf; pool_buf = get_pool_memory(PM_EMSG); - i = Mmsg(&pool_buf, "%s:%d ", file, line); + i = Mmsg(pool_buf, "%s:%d ", file, line); for (;;) { maxlen = sizeof_pool_memory(pool_buf) - i - 1; diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index dbf6828e49..4d054e1ae8 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -26,101 +26,101 @@ struct JCR; /* attr.c */ -ATTR *new_attr(); -void free_attr(ATTR *attr); -int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr); -void build_attr_output_fnames(JCR *jcr, ATTR *attr); -void print_ls_output(JCR *jcr, ATTR *attr); +ATTR *new_attr(); +void free_attr(ATTR *attr); +int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr); +void build_attr_output_fnames(JCR *jcr, ATTR *attr); +void print_ls_output(JCR *jcr, ATTR *attr); /* base64.c */ -void base64_init (void); -int to_base64 (intmax_t value, char *where); -int from_base64 (intmax_t *value, char *where); -int bin_to_base64 (char *buf, char *bin, int len); +void base64_init (void); +int to_base64 (intmax_t value, char *where); +int from_base64 (intmax_t *value, char *where); +int bin_to_base64 (char *buf, char *bin, int len); /* bsys.c */ -char *bstrncpy (char *dest, const char *src, int maxlen); -char *bstrncat (char *dest, const char *src, int maxlen); -void *b_malloc (const char *file, int line, size_t size); +char *bstrncpy (char *dest, const char *src, int maxlen); +char *bstrncat (char *dest, const char *src, int maxlen); +void *b_malloc (const char *file, int line, size_t size); #ifndef DEBUG -void *bmalloc (size_t size); +void *bmalloc (size_t size); #endif -void *brealloc (void *buf, size_t size); -void *bcalloc (size_t size1, size_t size2); -int bsnprintf (char *str, int32_t size, const char *format, ...); -int bvsnprintf (char *str, int32_t size, const char *format, va_list ap); -int pool_sprintf (char *pool_buf, const char *fmt, ...); -void create_pid_file (char *dir, const char *progname, int port); -int delete_pid_file (char *dir, const char *progname, int port); -void drop (char *uid, char *gid); -int bmicrosleep (time_t sec, long usec); -char *bfgets (char *s, int size, FILE *fd); -void make_unique_filename (POOLMEM **name, int Id, char *what); +void *brealloc (void *buf, size_t size); +void *bcalloc (size_t size1, size_t size2); +int bsnprintf (char *str, int32_t size, const char *format, ...); +int bvsnprintf (char *str, int32_t size, const char *format, va_list ap); +int pool_sprintf (char *pool_buf, const char *fmt, ...); +void create_pid_file (char *dir, const char *progname, int port); +int delete_pid_file (char *dir, const char *progname, int port); +void drop (char *uid, char *gid); +int bmicrosleep (time_t sec, long usec); +char *bfgets (char *s, int size, FILE *fd); +void make_unique_filename (POOLMEM **name, int Id, char *what); #ifndef HAVE_STRTOLL -long long int strtoll (const char *ptr, char **endptr, int base); +long long int strtoll (const char *ptr, char **endptr, int base); #endif -void read_state_file(char *dir, const char *progname, int port); -int bstrerror(int errnum, char *buf, size_t bufsiz); +void read_state_file(char *dir, const char *progname, int port); +int bstrerror(int errnum, char *buf, size_t bufsiz); /* bnet.c */ -int32_t bnet_recv (BSOCK *bsock); -bool bnet_send (BSOCK *bsock); -bool bnet_fsend (BSOCK *bs, const char *fmt, ...); -bool bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw); -bool bnet_sig (BSOCK *bs, int sig); -int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has); -int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need); -BSOCK * bnet_connect (JCR *jcr, int retry_interval, - int max_retry_time, const char *name, char *host, char *service, - int port, int verbose); -void bnet_close (BSOCK *bsock); -BSOCK * init_bsock (JCR *jcr, int sockfd, const char *who, const char *ip, - int port, struct sockaddr *client_addr); -BSOCK * dup_bsock (BSOCK *bsock); -void term_bsock (BSOCK *bsock); -char * bnet_strerror (BSOCK *bsock); -const char *bnet_sig_to_ascii (BSOCK *bsock); -int bnet_wait_data (BSOCK *bsock, int sec); -int bnet_wait_data_intr (BSOCK *bsock, int sec); -int bnet_despool_to_bsock (BSOCK *bsock, void update(ssize_t size), ssize_t size); -bool is_bnet_stop (BSOCK *bsock); -int is_bnet_error (BSOCK *bsock); -void bnet_suppress_error_messages(BSOCK *bsock, bool flag); +int32_t bnet_recv (BSOCK *bsock); +bool bnet_send (BSOCK *bsock); +bool bnet_fsend (BSOCK *bs, const char *fmt, ...); +bool bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw); +bool bnet_sig (BSOCK *bs, int sig); +int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has); +int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need); +BSOCK * bnet_connect (JCR *jcr, int retry_interval, + int max_retry_time, const char *name, char *host, char *service, + int port, int verbose); +void bnet_close (BSOCK *bsock); +BSOCK * init_bsock (JCR *jcr, int sockfd, const char *who, const char *ip, + int port, struct sockaddr *client_addr); +BSOCK * dup_bsock (BSOCK *bsock); +void term_bsock (BSOCK *bsock); +char * bnet_strerror (BSOCK *bsock); +const char *bnet_sig_to_ascii (BSOCK *bsock); +int bnet_wait_data (BSOCK *bsock, int sec); +int bnet_wait_data_intr (BSOCK *bsock, int sec); +int bnet_despool_to_bsock (BSOCK *bsock, void update(ssize_t size), ssize_t size); +bool is_bnet_stop (BSOCK *bsock); +int is_bnet_error (BSOCK *bsock); +void bnet_suppress_error_messages(BSOCK *bsock, bool flag); dlist *bnet_host2ipaddrs(const char *host, int family, const char **errstr); /* bget_msg.c */ -int bget_msg(BSOCK *sock); +int bget_msg(BSOCK *sock); /* bpipe.c */ -BPIPE * open_bpipe(char *prog, int wait, const char *mode); -int close_wpipe(BPIPE *bpipe); -int close_bpipe(BPIPE *bpipe); +BPIPE * open_bpipe(char *prog, int wait, const char *mode); +int close_wpipe(BPIPE *bpipe); +int close_bpipe(BPIPE *bpipe); /* cram-md5.c */ int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need); int cram_md5_auth(BSOCK *bs, char *password, int ssl_need); void hmac_md5(uint8_t* text, int text_len, uint8_t* key, - int key_len, uint8_t *hmac); + int key_len, uint8_t *hmac); /* crc32.c */ uint32_t bcrc32(uint8_t *buf, int len); /* daemon.c */ -void daemon_start (); +void daemon_start (); /* edit.c */ -uint64_t str_to_uint64(char *str); -int64_t str_to_int64(char *str); -char * edit_uint64_with_commas (uint64_t val, char *buf); -char * add_commas (char *val, char *buf); -char * edit_uint64 (uint64_t val, char *buf); -int duration_to_utime (char *str, utime_t *value); -int size_to_uint64(char *str, int str_len, uint64_t *rtn_value); -char *edit_utime (utime_t val, char *buf, int buf_len); -bool is_a_number (const char *num); -bool is_an_integer (const char *n); -bool is_name_valid (char *name, POOLMEM **msg); +uint64_t str_to_uint64(char *str); +int64_t str_to_int64(char *str); +char * edit_uint64_with_commas (uint64_t val, char *buf); +char * add_commas (char *val, char *buf); +char * edit_uint64 (uint64_t val, char *buf); +int duration_to_utime (char *str, utime_t *value); +int size_to_uint64(char *str, int str_len, uint64_t *rtn_value); +char *edit_utime (utime_t val, char *buf, int buf_len); +bool is_a_number (const char *num); +bool is_an_integer (const char *n); +bool is_name_valid (char *name, POOLMEM **msg); /* jcr.c (most definitions are in src/jcr.h) */ void init_last_jobs_list(); @@ -134,36 +134,36 @@ void job_end_push(JCR *jcr, void job_end_cb(JCR *jcr,void *), void *ctx); /* lex.c */ -LEX * lex_close_file (LEX *lf); -LEX * lex_open_file (LEX *lf, const char *fname, LEX_ERROR_HANDLER *scan_error); -int lex_get_char (LEX *lf); -void lex_unget_char (LEX *lf); -const char * lex_tok_to_str (int token); -int lex_get_token (LEX *lf, int expect); +LEX * lex_close_file (LEX *lf); +LEX * lex_open_file (LEX *lf, const char *fname, LEX_ERROR_HANDLER *scan_error); +int lex_get_char (LEX *lf); +void lex_unget_char (LEX *lf); +const char * lex_tok_to_str (int token); +int lex_get_token (LEX *lf, int expect); /* message.c */ -void my_name_is (int argc, char *argv[], const char *name); -void init_msg (JCR *jcr, MSGS *msg); -void term_msg (void); -void close_msg (JCR *jcr); -void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code); -void rem_msg_dest (MSGS *msg, int dest, int type, char *where); -void Jmsg (JCR *jcr, int type, int level, const char *fmt, ...); -void dispatch_message (JCR *jcr, int type, int level, char *buf); -void init_console_msg (const char *wd); -void free_msgs_res (MSGS *msgs); -void dequeue_messages (JCR *jcr); -void set_trace (int trace_flag); -void set_exit_on_error (int value); +void my_name_is (int argc, char *argv[], const char *name); +void init_msg (JCR *jcr, MSGS *msg); +void term_msg (void); +void close_msg (JCR *jcr); +void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code); +void rem_msg_dest (MSGS *msg, int dest, int type, char *where); +void Jmsg (JCR *jcr, int type, int level, const char *fmt, ...); +void dispatch_message (JCR *jcr, int type, int level, char *buf); +void init_console_msg (const char *wd); +void free_msgs_res (MSGS *msgs); +void dequeue_messages (JCR *jcr); +void set_trace (int trace_flag); +void set_exit_on_error (int value); /* bnet_server.c */ -void bnet_thread_server(dlist *addr, int max_clients, workq_t *client_wq, - void *handle_client_request(void *bsock)); -void bnet_stop_thread_server(pthread_t tid); -void bnet_server (int port, void handle_client_request(BSOCK *bsock)); -int net_connect (int port); -BSOCK * bnet_bind (int port); -BSOCK * bnet_accept (BSOCK *bsock, char *who); +void bnet_thread_server(dlist *addr, int max_clients, workq_t *client_wq, + void *handle_client_request(void *bsock)); +void bnet_stop_thread_server(pthread_t tid); +void bnet_server (int port, void handle_client_request(BSOCK *bsock)); +int net_connect (int port); +BSOCK * bnet_bind (int port); +BSOCK * bnet_accept (BSOCK *bsock, char *who); /* idcache.c */ char *getuser(uid_t uid); @@ -173,41 +173,43 @@ void free_getgroup_cache(); /* signal.c */ -void init_signals (void terminate(int sig)); -void init_stack_dump (void); +void init_signals (void terminate(int sig)); +void init_stack_dump (void); /* scan.c */ -void strip_trailing_junk (char *str); -void strip_trailing_slashes (char *dir); -bool skip_spaces (char **msg); -bool skip_nonspaces (char **msg); -int fstrsch (const char *a, const char *b); -char *next_arg(char **s); -int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, - char **argk, char **argv, int max_args); -void split_path_and_filename(const char *fname, POOLMEM **path, - int *pnl, POOLMEM **file, int *fnl); -int bsscanf(const char *buf, const char *fmt, ...); +void strip_trailing_junk (char *str); +void strip_trailing_slashes (char *dir); +bool skip_spaces (char **msg); +bool skip_nonspaces (char **msg); +int fstrsch (const char *a, const char *b); +char *next_arg(char **s); +int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, + char **argk, char **argv, int max_args); +void split_path_and_filename(const char *fname, POOLMEM **path, + int *pnl, POOLMEM **file, int *fnl); +int bsscanf(const char *buf, const char *fmt, ...); /* util.c */ -int is_buf_zero (char *buf, int len); -void lcase (char *str); -void bash_spaces (char *str); -void unbash_spaces (char *str); -char * encode_time (time_t time, char *buf); -char * encode_mode (mode_t mode, char *buf); -int do_shell_expansion (char *name, int name_len); -void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen); -int pm_strcat (POOLMEM **pm, const char *str); -int pm_strcpy (POOLMEM **pm, const char *str); -int run_program (char *prog, int wait, POOLMEM *results); -const char * job_type_to_str (int type); -const char * job_status_to_str (int stat); -const char * job_level_to_str (int level); -void make_session_key (char *key, char *seed, int mode); -POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to); -void set_working_directory(char *wd); +int is_buf_zero (char *buf, int len); +void lcase (char *str); +void bash_spaces (char *str); +void unbash_spaces (char *str); +char * encode_time (time_t time, char *buf); +char * encode_mode (mode_t mode, char *buf); +int do_shell_expansion (char *name, int name_len); +void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen); +int pm_strcat (POOLMEM **pm, const char *str); +int pm_strcat (POOLMEM *&pm, const char *str); +int pm_strcpy (POOLMEM **pm, const char *str); +int pm_strcpy (POOLMEM *&pm, const char *str); +int run_program (char *prog, int wait, POOLMEM *results); +const char * job_type_to_str (int type); +const char * job_status_to_str (int stat); +const char * job_level_to_str (int level); +void make_session_key (char *key, char *seed, int mode); +POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to); +void set_working_directory(char *wd); /* watchdog.c */ diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 3086e5c527..b1eec70438 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -127,6 +127,17 @@ int pm_strcat(POOLMEM **pm, const char *str) return pmlen + len - 1; } +int pm_strcat(POOLMEM *&pm, const char *str) +{ + int pmlen = strlen(pm); + int len = strlen(str) + 1; + + pm = check_pool_memory_size(pm, pmlen + len); + memcpy(pm+pmlen, str, len); + return pmlen + len - 1; +} + + /* * Copy a string (str) into a pool memory buffer pm @@ -141,6 +152,18 @@ int pm_strcpy(POOLMEM **pm, const char *str) return len - 1; } +int pm_strcpy(POOLMEM *&pm, const char *str) +{ + int len = strlen(str) + 1; + + pm = check_pool_memory_size(pm, len); + memcpy(pm, str, len); + return len - 1; +} + + + + /* * Convert a JobStatus code into a human readable form diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index b99fb56d57..bf739ac7ce 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -134,7 +134,7 @@ DCR *acquire_device_for_read(JCR *jcr) for (i=0; i<5; i++) { if (job_canceled(jcr)) { - Mmsg1(&dev->errmsg, _("Job %d canceled.\n"), jcr->JobId); + Mmsg1(dev->errmsg, _("Job %d canceled.\n"), jcr->JobId); goto get_out; /* error return */ } /* diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 9677fe50cf..418342faad 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -85,7 +85,7 @@ static bool do_get_volume_info(DCR *dcr) dcr->VolumeName[0] = 0; /* No volume */ if (bnet_recv(dir) <= 0) { Dmsg0(200, "getvolname error bnet_recv\n"); - Mmsg(&jcr->errmsg, _("Network error on bnet_recv in req_vol_info.\n")); + Mmsg(jcr->errmsg, _("Network error on bnet_recv in req_vol_info.\n")); return false; } memset(&vol, 0, sizeof(vol)); @@ -100,7 +100,7 @@ static bool do_get_volume_info(DCR *dcr) &InChanger, &vol.VolReadTime, &vol.VolWriteTime); if (n != 17) { Dmsg2(100, "Bad response from Dir fields=%d: %s\n", n, dir->msg); - Mmsg(&jcr->errmsg, _("Error getting Volume info: %s\n"), dir->msg); + Mmsg(jcr->errmsg, _("Error getting Volume info: %s\n"), dir->msg); return false; } vol.InChanger = InChanger; /* bool in structure */ @@ -340,7 +340,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) ASSERT(dev->dev_blocked); for ( ;; ) { if (job_canceled(jcr)) { - Mmsg(&dev->errmsg, + Mmsg(dev->errmsg, _("Job %s canceled while waiting for mount on Storage Device \"%s\".\n"), jcr->Job, jcr->dev_name); Jmsg(jcr, M_INFO, 0, "%s", dev->errmsg); @@ -399,7 +399,7 @@ Please use the \"label\" command to create a new Volume for:\n\ if (stat == ETIMEDOUT) { if (!double_dev_wait_time(dev)) { - Mmsg(&dev->errmsg, _("Gave up waiting to mount Storage Device \"%s\" for Job %s\n"), + Mmsg(dev->errmsg, _("Gave up waiting to mount Storage Device \"%s\" for Job %s\n"), dev_name(dev), jcr->Job); Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg); Dmsg1(190, "Gave up waiting on device %s\n", dev_name(dev)); @@ -408,7 +408,7 @@ Please use the \"label\" command to create a new Volume for:\n\ continue; } if (stat == EINVAL) { - Mmsg2(&dev->errmsg, _("pthread error in mount_next_volume stat=%d ERR=%s\n"), + Mmsg2(dev->errmsg, _("pthread error in mount_next_volume stat=%d ERR=%s\n"), stat, strerror(stat)); Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg); return false; @@ -467,13 +467,13 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr) Dmsg0(130, "enter dir_ask_sysop_to_mount_volume\n"); if (!jcr->VolumeName[0]) { - Mmsg0(&dev->errmsg, _("Cannot request another volume: no volume name given.\n")); + Mmsg0(dev->errmsg, _("Cannot request another volume: no volume name given.\n")); return 0; } ASSERT(dev->dev_blocked); for ( ;; ) { if (job_canceled(jcr)) { - Mmsg(&dev->errmsg, _("Job %s canceled while waiting for mount on Storage Device \"%s\".\n"), + Mmsg(dev->errmsg, _("Job %s canceled while waiting for mount on Storage Device \"%s\".\n"), jcr->Job, jcr->dev_name); return false; } @@ -498,7 +498,7 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr) if (stat == ETIMEDOUT) { if (!double_dev_wait_time(dev)) { - Mmsg(&dev->errmsg, _("Gave up waiting to mount Storage Device \"%s\" for Job %s\n"), + Mmsg(dev->errmsg, _("Gave up waiting to mount Storage Device \"%s\" for Job %s\n"), dev_name(dev), jcr->Job); Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg); Dmsg1(190, "Gave up waiting on device %s\n", dev_name(dev)); @@ -507,7 +507,7 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr) continue; } if (stat == EINVAL) { - Mmsg2(&dev->errmsg, _("pthread error in mount_volume stat=%d ERR=%s\n"), + Mmsg2(dev->errmsg, _("pthread error in mount_volume stat=%d ERR=%s\n"), stat, strerror(stat)); Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg); return false; diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index e4d1429191..a06460d161 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -233,7 +233,7 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) block->bufp = block->buf + bhl; if (strncmp(Id, BLKHDR1_ID, BLKHDR_ID_LENGTH) != 0) { dev->dev_errno = EIO; - Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"), + Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"), dev->file, dev->block_num, BLKHDR1_ID, Id); if (block->read_errors == 0 || verbose >= 2) { Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); @@ -249,7 +249,7 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) block->bufp = block->buf + bhl; if (strncmp(Id, BLKHDR2_ID, BLKHDR_ID_LENGTH) != 0) { dev->dev_errno = EIO; - Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"), + Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"), dev->file, dev->block_num, BLKHDR2_ID, Id); if (block->read_errors == 0 || verbose >= 2) { Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); @@ -259,7 +259,7 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) } } else { dev->dev_errno = EIO; - Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"), + Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"), dev->file, dev->block_num, BLKHDR2_ID, Id); if (block->read_errors == 0 || verbose >= 2) { Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); @@ -273,7 +273,7 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) /* Sanity check */ if (block_len > MAX_BLOCK_LENGTH) { dev->dev_errno = EIO; - Mmsg3(&dev->errmsg, _("Volume data error at %u:%u! Block length %u is insane (too large), probably due to a bad archive.\n"), + Mmsg3(dev->errmsg, _("Volume data error at %u:%u! Block length %u is insane (too large), probably due to a bad archive.\n"), dev->file, dev->block_num, block_len); if (block->read_errors == 0 || verbose >= 2) { Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); @@ -299,7 +299,7 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) block_len-BLKHDR_CS_LENGTH); if (BlockCheckSum != CheckSum) { dev->dev_errno = EIO; - Mmsg5(&dev->errmsg, _("Volume data error at %u:%u! Block checksum mismatch in block %u: calc=%x blk=%x\n"), + Mmsg5(dev->errmsg, _("Volume data error at %u:%u! Block checksum mismatch in block %u: calc=%x blk=%x\n"), dev->file, dev->block_num, (unsigned)BlockNumber, BlockCheckSum, CheckSum); if (block->read_errors == 0 || verbose >= 2) { Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); @@ -717,7 +717,7 @@ bool read_block_from_dev(DCR *dcr, DEV_BLOCK *block, bool check_block_numbers) reread: if (looping > 1) { dev->dev_errno = EIO; - Mmsg1(&dev->errmsg, _("Block buffer size looping problem on device %s\n"), + Mmsg1(dev->errmsg, _("Block buffer size looping problem on device %s\n"), dev->dev_name); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); block->read_len = 0; @@ -741,7 +741,7 @@ reread: clrerror_dev(dev, -1); Dmsg1(90, "Read device got: ERR=%s\n", strerror(errno)); block->read_len = 0; - Mmsg4(&dev->errmsg, _("Read error at file:blk %u:%u on device %s. ERR=%s.\n"), + Mmsg4(dev->errmsg, _("Read error at file:blk %u:%u on device %s. ERR=%s.\n"), dev->file, dev->block_num, dev->dev_name, strerror(dev->dev_errno)); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); if (dev->state & ST_EOF) { /* EOF just seen? */ @@ -752,7 +752,7 @@ reread: Dmsg1(90, "Read device got %d bytes\n", stat); if (stat == 0) { /* Got EOF ! */ dev->block_num = block->read_len = 0; - Mmsg3(&dev->errmsg, _("Read zero bytes at %u:%u on device %s.\n"), + Mmsg3(dev->errmsg, _("Read zero bytes at %u:%u on device %s.\n"), dev->file, dev->block_num, dev->dev_name); if (dev->state & ST_EOF) { /* EOF already read? */ dev->state |= ST_EOT; /* yes, 2 EOFs => EOT */ @@ -768,7 +768,7 @@ reread: block->read_len = stat; /* save length read */ if (block->read_len < BLKHDR2_LENGTH) { dev->dev_errno = EIO; - Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Very short block of %d bytes on device %s discarded.\n"), + Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Very short block of %d bytes on device %s discarded.\n"), dev->file, dev->block_num, block->read_len, dev->dev_name); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); dev->state |= ST_SHORT; /* set short block */ @@ -793,7 +793,7 @@ reread: */ if (block->block_len > block->buf_len) { dev->dev_errno = EIO; - Mmsg2(&dev->errmsg, _("Block length %u is greater than buffer %u. Attempting recovery.\n"), + Mmsg2(dev->errmsg, _("Block length %u is greater than buffer %u. Attempting recovery.\n"), block->block_len, block->buf_len); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); Pmsg1(000, "%s", dev->errmsg); @@ -812,7 +812,7 @@ reread: lseek(dev->fd, pos, SEEK_SET); dev->file_addr = pos; } - Mmsg1(&dev->errmsg, _("Setting block buffer size to %u bytes.\n"), block->block_len); + Mmsg1(dev->errmsg, _("Setting block buffer size to %u bytes.\n"), block->block_len); Jmsg(jcr, M_INFO, 0, "%s", dev->errmsg); Pmsg1(000, "%s", dev->errmsg); /* Set new block length */ @@ -827,7 +827,7 @@ reread: if (block->block_len > block->read_len) { dev->dev_errno = EIO; - Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Short block of %d bytes on device %s discarded.\n"), + Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Short block of %d bytes on device %s discarded.\n"), dev->file, dev->block_num, block->read_len, dev->dev_name); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); dev->state |= ST_SHORT; /* set short block */ diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index d588a400af..65c6303e27 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -1544,7 +1544,7 @@ static void scancmd() for (;;) { if ((stat = read(dev->fd, buf, sizeof(buf))) < 0) { clrerror_dev(dev, -1); - Mmsg2(&dev->errmsg, "read error on %s. ERR=%s.\n", + Mmsg2(dev->errmsg, "read error on %s. ERR=%s.\n", dev->dev_name, strerror(dev->dev_errno)); Pmsg2(0, "Bad status from read %d. ERR=%s\n", stat, strerror_dev(dev)); if (blocks > 0) diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 3bb3d0c71e..52320bd725 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -303,7 +303,7 @@ open_dev(DEVICE *dev, char *VolName, int mode) * Handle opening of File Archive (not a tape) */ if (VolName == NULL || *VolName == 0) { - Mmsg(&dev->errmsg, _("Could not open file device %s. No Volume name given.\n"), + Mmsg(dev->errmsg, _("Could not open file device %s. No Volume name given.\n"), dev->dev_name); return -1; } @@ -1158,7 +1158,7 @@ weof_dev(DEVICE *dev, int num) /* * Return string message with last error in English * Be careful not to call this routine from within dev.c - * while editing an Mmsg(&) or you will end up in a recursive + * while editing an Mmsg() or you will end up in a recursive * loop creating a Segmentation Violation. */ char * diff --git a/bacula/src/stored/fd_cmds.c b/bacula/src/stored/fd_cmds.c index 99ab03a030..3dd28588e9 100644 --- a/bacula/src/stored/fd_cmds.c +++ b/bacula/src/stored/fd_cmds.c @@ -323,7 +323,7 @@ static int bootstrap_cmd(JCR *jcr) unlink(jcr->RestoreBootstrap); free_pool_memory(jcr->RestoreBootstrap); } - Mmsg(&fname, "%s/%s.%s.bootstrap", me->working_directory, me->hdr.name, + Mmsg(fname, "%s/%s.%s.bootstrap", me->working_directory, me->hdr.name, jcr->Job); Dmsg1(400, "bootstrap=%s\n", fname); jcr->RestoreBootstrap = fname; diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index fc816bee1c..a7d1b768aa 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -70,7 +70,7 @@ int read_dev_volume_label(DCR *dcr, DEV_BLOCK *block) if (dev_state(dev, ST_LABEL)) { /* did we already read label? */ /* Compare Volume Names allow special wild card */ if (VolName && *VolName && *VolName != '*' && strcmp(dev->VolHdr.VolName, VolName) != 0) { - Mmsg(&jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"), + Mmsg(jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"), dev_name(dev), VolName, dev->VolHdr.VolName); /* * Cancel Job if too many label errors @@ -88,7 +88,7 @@ int read_dev_volume_label(DCR *dcr, DEV_BLOCK *block) dev->state &= ~(ST_LABEL|ST_APPEND|ST_READ); /* set no label, no append */ if (!rewind_dev(dev)) { - Mmsg(&jcr->errmsg, _("Couldn't rewind device %s ERR=%s\n"), dev_name(dev), + Mmsg(jcr->errmsg, _("Couldn't rewind device %s ERR=%s\n"), dev_name(dev), strerror_dev(dev)); return jcr->label_status = VOL_NO_MEDIA; } @@ -98,17 +98,17 @@ int read_dev_volume_label(DCR *dcr, DEV_BLOCK *block) record = new_record(); Dmsg0(90, "Big if statement in read_volume_label\n"); if (!read_block_from_dev(dcr, block, NO_BLOCK_NUMBER_CHECK)) { - Mmsg(&jcr->errmsg, _("Requested Volume \"%s\" on %s is not a Bacula " + Mmsg(jcr->errmsg, _("Requested Volume \"%s\" on %s is not a Bacula " "labeled Volume, because: ERR=%s"), NPRT(VolName), dev_name(dev), strerror_dev(dev)); } else if (!read_record_from_block(block, record)) { - Mmsg(&jcr->errmsg, _("Could not read Volume label from block.\n")); + Mmsg(jcr->errmsg, _("Could not read Volume label from block.\n")); } else if (!unser_volume_label(dev, record)) { - Mmsg(&jcr->errmsg, _("Could not unserialize Volume label: ERR=%s\n"), + Mmsg(jcr->errmsg, _("Could not unserialize Volume label: ERR=%s\n"), strerror_dev(dev)); } else if (strcmp(dev->VolHdr.Id, BaculaId) != 0 && strcmp(dev->VolHdr.Id, OldBaculaId) != 0) { - Mmsg(&jcr->errmsg, _("Volume Header Id bad: %s\n"), dev->VolHdr.Id); + Mmsg(jcr->errmsg, _("Volume Header Id bad: %s\n"), dev->VolHdr.Id); } else { ok = true; } @@ -134,7 +134,7 @@ int read_dev_volume_label(DCR *dcr, DEV_BLOCK *block) if (dev->VolHdr.VerNum != BaculaTapeVersion && dev->VolHdr.VerNum != OldCompatibleBaculaTapeVersion1 && dev->VolHdr.VerNum != OldCompatibleBaculaTapeVersion2) { - Mmsg(&jcr->errmsg, _("Volume on %s has wrong Bacula version. Wanted %d got %d\n"), + Mmsg(jcr->errmsg, _("Volume on %s has wrong Bacula version. Wanted %d got %d\n"), dev_name(dev), BaculaTapeVersion, dev->VolHdr.VerNum); return jcr->label_status = VOL_VERSION_ERROR; } @@ -143,7 +143,7 @@ int read_dev_volume_label(DCR *dcr, DEV_BLOCK *block) * a Bacula volume label (VOL_LABEL) */ if (dev->VolHdr.LabelType != PRE_LABEL && dev->VolHdr.LabelType != VOL_LABEL) { - Mmsg(&jcr->errmsg, _("Volume on %s has bad Bacula label type: %x\n"), + Mmsg(jcr->errmsg, _("Volume on %s has bad Bacula label type: %x\n"), dev_name(dev), dev->VolHdr.LabelType); return jcr->label_status = VOL_LABEL_ERROR; } @@ -153,7 +153,7 @@ int read_dev_volume_label(DCR *dcr, DEV_BLOCK *block) /* Compare Volume Names */ Dmsg2(30, "Compare Vol names: VolName=%s hdr=%s\n", VolName?VolName:"*", dev->VolHdr.VolName); if (VolName && *VolName && *VolName != '*' && strcmp(dev->VolHdr.VolName, VolName) != 0) { - Mmsg(&jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"), + Mmsg(jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"), dev_name(dev), VolName, dev->VolHdr.VolName); /* * Cancel Job if too many label errors @@ -189,7 +189,7 @@ bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec) ser_declare; if (rec->FileIndex != VOL_LABEL && rec->FileIndex != PRE_LABEL) { - Mmsg3(&dev->errmsg, _("Expecting Volume Label, got FI=%s Stream=%s len=%d\n"), + Mmsg3(dev->errmsg, _("Expecting Volume Label, got FI=%s Stream=%s len=%d\n"), FI_to_ascii(rec->FileIndex), stream_to_ascii(rec->Stream, rec->FileIndex), rec->data_len); diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index f9633378b5..bd95f2c305 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -569,7 +569,7 @@ void wxbMainFrame::Print(wxString str, int status) wxbDataTokenizer* dt = wxbUtils::WaitForEnd(".help", true); int i, j; wxString str; - for (i = 0; i < dt->GetCount(); i++) { + for (i = 0; i < (int)dt->GetCount(); i++) { str = (*dt)[i]; str.RemoveLast(); if ((j = str.Find(' ')) > -1) { -- 2.39.5