From: Kern Sibbald Date: Wed, 22 Sep 2004 19:51:07 +0000 (+0000) Subject: - Incremented the release number because this version requires X-Git-Tag: Release-1.35.6~24 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ea40e01f28ccef06e405a7ebc7295392b5745532;p=bacula%2Fbacula - Incremented the release number because this version requires an update to the database. Use: cd src/cats ./update_bacula_tables to update an existing database. - Implemented EndFile and EndBlock in the Media record. This will allow Bacula to know exactly when to stop reading a tape if the stupid tape driver does not give a logical end of tape indication and Bacula writes to the end of the tape getting an I/O error. - Added new routines to update the database, and there are new database creation routines to add the two new Media columns. - The Media record is updated each time a JobMedia record is created. This keeps the Media record up to date. - Undid the code to use automatic type converions to char * in POOL_MEM. This is due to the ugly consequences of essentially destroying the class type nature of the class. - Removed all the old mp_char() #define code. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1606 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/ChangeLog b/bacula/ChangeLog index 967eaeb087..d142365931 100644 --- a/bacula/ChangeLog +++ b/bacula/ChangeLog @@ -1,3 +1,78 @@ +Changes to 1.35.5: +22Sep04 +- Incremented the release number because this version requires + an update to the database. + Use: + cd src/cats + ./update_bacula_tables + to update an existing database. +- Implemented EndFile and EndBlock in the Media record. This will + allow Bacula to know exactly when to stop reading a tape if the + stupid tape driver does not give a logical end of tape indication + and Bacula writes to the end of the tape getting an I/O error. +- Added new routines to update the database, and there are + new database creation routines to add the two new Media columns. +- The Media record is updated each time a JobMedia record is created. + This keeps the Media record up to date. +- Undid the code to use automatic type converions to char * in + POOL_MEM. This is due to the ugly consequences of essentially + destroying the class type nature of the class. +- Removed all the old mp_char() #define code. + +Changes to 1.35.4: +22Sep04 +- Add additional doc. +- Implement automatic POOL_MEM type conversion to char *. Thanks + to Martin Simmons for the suggestion. +- Remove some unneeded function overloading -- need removed by + automatic type conversion. +21Sep04 +- Correct segfault in message.c with debug=200 (new code). +- Fix bug 109 verify with no options prints garbage. +- Add ioctl(MTIOCGET) call to clrerror_dev() in dev.c. As reported + by Frank Kardel, this should clear error conditions on NetBSD. +20Sep04 +- Modify the rescue script to create mount_drives with + the order specified by Philip Nash (mkdir, mount). +- Tweak install chapter of French manual to add new paragraph + from English. +- Tweak restore tree message to be a bit clearer. +- Modify watchdog to wakeup after 60 seconds, or wakeup if + there is work to do. +- Modify watchdog stop routine to "ping" watchdog so that it + stops immediately rather than after sleep time. +- Fix btape to use new dcr blocks rather than its own. +- Fix butil.c to correctly handle Volume names for the + utility routines (broke when updating to dcrs). +11-19Sep04 (vacation) +- Implement multiple Storage specifications in the Job resource + (AND) each containing multiple specifications (OR). Not yet functional. + Note, this needs more work as most things now use + job->storage[0]->first() rather than looping through devices. +- Implement "Multiple connections = yes/no" in Catalog record for + allowing multiple simultaneous connections to the database. +- Add new mac.c (Migrate, Archive, Copy) to dird -- not yet implemented. +- Implement a new POOL_MEM class that automatically allocates + and deallocates a pool buffer. +- Overload a number of utility routines to permit using both + POOLMEM and POOL_MEM. +- Start converting to using POOL_MEM. +- There were a number of Bacula console ACL checks missing in + ua_run.c. It allowed users to run jobs they really should not. +- Correct a number of dates on the Copyright. +- Overload pm_strcpy() and pm_strcat() to handle new POOL_MEM + class. +- Overload bash/unbash_spaces to handle new POOL_MEM class. +- Make a *MASSIVE* pass through the Storage daemon eliminating + all use of jcr->VolumeName and jcr->VolCatInfo in favor of + dcr->... +- Eliminate all all redundant arguments from calling sequences + in SD. This poses a number of problems due to the old way blocks + and records were allocated and released all the time. They are + now contained in the dcr. The problem is that old habits die hard + and there are still places where everything is not right. +- Implement "Block positioning = yes/no" in Device resource in SD. + Changes to 1.35.3: 09Sep04 - Add "Multiple Connections = yes/no" in catalog record. Only diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index d2c531623e..8490f444d3 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -1,20 +1,32 @@ - Release Notes for Bacula 1.35.3 + Release Notes for Bacula 1.35.5 Bacula code: Total files = 395 Total lines = 115,062 (*.h *.c *.in) -Changes for 1.35.3 + +Changes for 1.35.5 Major Changes: - Tray monitor program - Bacula Rescue CDROM +- Lots of improvements in the Rescue scripts -- better + network detection, better mounting code, ... - General bug fixes/stabilization - French translation of manual by Ludovic Strappazon well underway. +- UTF-8 is supported in conio (some minor cleanup is needed). +- Improved conf scanning code allowing FileSet components to + be put on a single line (previously everything had to be on + a different line). New Directives: -- Added Ignore FileSet Changes = yes +- Added "Ignore FileSet Changes = yes" +- Added "Block positioning = yes/no" in Device resource in SD. +- Added "Multiple connections = yes/no" in Catalog record for + allowing multiple simultaneous connections to the database. + This is a major performance improvement for PostgreSQL. Items to note!!! +- As of 1.35.5 you MUST do a database update. - All daemons should be compatible with 1.34 with the exception of the new FileSet features such as regular expressions. - Regular expressions are not implemented in the Win32 FD. @@ -22,6 +34,81 @@ Items to note!!! Other Items: - See below +Changes to 1.35.5: +22Sep04 +- Incremented the release number because this version requires + an update to the database. + Use: + cd src/cats + ./update_bacula_tables + to update an existing database. +- Implemented EndFile and EndBlock in the Media record. This will + allow Bacula to know exactly when to stop reading a tape if the + stupid tape driver does not give a logical end of tape indication + and Bacula writes to the end of the tape getting an I/O error. +- Added new routines to update the database, and there are + new database creation routines to add the two new Media columns. +- The Media record is updated each time a JobMedia record is created. + This keeps the Media record up to date. +- Undid the code to use automatic type converions to char * in + POOL_MEM. This is due to the ugly consequences of essentially + destroying the class type nature of the class. +- Removed all the old mp_char() #define code. + +Changes to 1.35.4: +22Sep04 +- Add additional doc. +- Implement automatic POOL_MEM type conversion to char *. Thanks + to Martin Simmons for the suggestion. +- Remove some unneeded function overloading -- need removed by + automatic type conversion. +21Sep04 +- Correct segfault in message.c with debug=200 (new code). +- Fix bug 109 verify with no options prints garbage. +- Add ioctl(MTIOCGET) call to clrerror_dev() in dev.c. As reported + by Frank Kardel, this should clear error conditions on NetBSD. +20Sep04 +- Modify the rescue script to create mount_drives with + the order specified by Philip Nash (mkdir, mount). +- Tweak install chapter of French manual to add new paragraph + from English. +- Tweak restore tree message to be a bit clearer. +- Modify watchdog to wakeup after 60 seconds, or wakeup if + there is work to do. +- Modify watchdog stop routine to "ping" watchdog so that it + stops immediately rather than after sleep time. +- Fix btape to use new dcr blocks rather than its own. +- Fix butil.c to correctly handle Volume names for the + utility routines (broke when updating to dcrs). +11-19Sep04 (vacation) +- Implement multiple Storage specifications in the Job resource + (AND) each containing multiple specifications (OR). Not yet functional. + Note, this needs more work as most things now use + job->storage[0]->first() rather than looping through devices. +- Implement "Multiple connections = yes/no" in Catalog record for + allowing multiple simultaneous connections to the database. +- Add new mac.c (Migrate, Archive, Copy) to dird -- not yet implemented. +- Implement a new POOL_MEM class that automatically allocates + and deallocates a pool buffer. +- Overload a number of utility routines to permit using both + POOLMEM and POOL_MEM. +- Start converting to using POOL_MEM. +- There were a number of Bacula console ACL checks missing in + ua_run.c. It allowed users to run jobs they really should not. +- Correct a number of dates on the Copyright. +- Overload pm_strcpy() and pm_strcat() to handle new POOL_MEM + class. +- Overload bash/unbash_spaces to handle new POOL_MEM class. +- Make a *MASSIVE* pass through the Storage daemon eliminating + all use of jcr->VolumeName and jcr->VolCatInfo in favor of + dcr->... +- Eliminate all all redundant arguments from calling sequences + in SD. This poses a number of problems due to the old way blocks + and records were allocated and released all the time. They are + now contained in the dcr. The problem is that old habits die hard + and there are still places where everything is not right. +- Implement "Block positioning = yes/no" in Device resource in SD. + Changes to 1.35.3: 09Sep04 - Add "Multiple Connections = yes/no" in catalog record. Only diff --git a/bacula/kernstodo b/bacula/kernstodo index 963aadbf6c..66f8605c7f 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -12,6 +12,9 @@ Version 1.35 Kern (see below) 1.35 Items to do for release: - Backspace to beginning of line (conio) does not erase first char. +- List verify options for DiskToCatalog in doc. +- Do unmount before removing magazine. +- Turn on transactions if multiple connections are on in DB. - Document a get out of jail procedure if everything breaks if you lost/broke the Catalog -- do the same for "I know my @@ -62,6 +65,9 @@ Testing to do: (painful) For 1.37 Testing/Documentation: +- If opening a tape in read/write mode fails attempt to open + it in read-only mode, and mark the tape for read only. +- Add a read-only mode to the mount option. - Add "Allow multiple connections" in Catalog resource to open a new database connection for each job. - Allow Simultaneous Priorities = yes => run up to Max concurrent jobs even @@ -1351,4 +1357,5 @@ Block Position: 0 - Add "Multiple connections = yes/no" to catalog resource. - Add new DCR calling sequences everywhere in SD. This will permit simultaneous use of multiple devices by a single job. +- Fix bscan so that it releases the drive when requesting a new tape. diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 8802f16871..b11a446bca 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) @@ -406,9 +406,11 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num); #define Mmsg11(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) #define Mmsg15(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) +class POOL_MEM; /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */ int Mmsg(POOLMEM **msgbuf, const char *fmt,...); int Mmsg(POOLMEM *&msgbuf, const char *fmt,...); +int Mmsg(POOL_MEM &msgbuf, const char *fmt,...); struct JCR; diff --git a/bacula/src/bc_types.h b/bacula/src/bc_types.h index ae356f4c03..f11df93f63 100644 --- a/bacula/src/bc_types.h +++ b/bacula/src/bc_types.h @@ -39,15 +39,6 @@ #define __bc_types_INCLUDED typedef char POOLMEM; -#define mp_chr(x) x -#ifdef xxxxx -#define mp_chr(x) ((char*)(x)) -class POOLMEM { -public: - POOLMEM(); - operator char * const() { return this; } -}; -#endif /* Types */ diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index 081760fbe1..981d0671b5 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -48,7 +48,7 @@ typedef int (DB_RESULT_HANDLER)(void *, int, char **); #ifdef HAVE_SQLITE -#define BDB_VERSION 7 +#define BDB_VERSION 8 #include @@ -146,7 +146,7 @@ SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb); #ifdef HAVE_MYSQL -#define BDB_VERSION 7 +#define BDB_VERSION 8 #include @@ -210,7 +210,7 @@ typedef struct s_db { #ifdef HAVE_POSTGRESQL -#define BDB_VERSION 7 +#define BDB_VERSION 8 #include @@ -302,7 +302,7 @@ POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb); /* Change this each time there is some incompatible * file format change!!!! */ -#define BDB_VERSION 12 /* file version number */ +#define BDB_VERSION 13 /* file version number */ struct s_control { int bdb_version; /* Version number */ @@ -529,6 +529,8 @@ struct MEDIA_DBR { int32_t Recycle; /* recycle yes/no */ int32_t Slot; /* slot in changer */ int32_t InChanger; /* Volume currently in changer */ + uint32_t EndFile; /* Last file on volume */ + uint32_t EndBlock; /* Last block on volume */ char VolStatus[20]; /* Volume status */ /* Extra stuff not in DB */ faddr_t rec_addr; /* found record address */ diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index 991c894fba..4a8b9623a0 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -118,6 +118,8 @@ CREATE TABLE Media ( MediaAddressing TINYINT NOT NULL DEFAULT 0, VolReadTime BIGINT UNSIGNED NOT NULL DEFAULT 0, VolWriteTime BIGINT UNSIGNED NOT NULL DEFAULT 0, + EndFile INTEGER UNSIGNED NOT NULL DEFAULT 0; + EndBlock INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY(MediaId), INDEX (PoolId) ); @@ -181,7 +183,7 @@ CREATE TABLE Version ( ); -- Initialize Version -INSERT INTO Version (VersionId) VALUES (7); +INSERT INTO Version (VersionId) VALUES (8); CREATE TABLE Counters ( Counter TINYBLOB NOT NULL, diff --git a/bacula/src/cats/make_postgresql_tables.in b/bacula/src/cats/make_postgresql_tables.in index f145ae6ed9..47d5d40ca1 100644 --- a/bacula/src/cats/make_postgresql_tables.in +++ b/bacula/src/cats/make_postgresql_tables.in @@ -11,7 +11,7 @@ create table version versionid integer not null ); -INSERT INTO Version (VersionId) VALUES (7); +INSERT INTO Version (VersionId) VALUES (8); create table counters ( @@ -150,6 +150,10 @@ create table media default 0, volwritetime bigint not null default 0, + endfile integer not null + default 0, + endblock integer not null + default 0, primary key (mediaid) ); @@ -255,77 +259,6 @@ create table unsavedfiles -- Make sure we have appropriate permissions --- --- The following alter table commands have been removed --- because they seem to create severe performance problems --- ---alter table pool --- add foreign key (scratchpoolid) --- references pool (poolid) on update cascade on delete cascade; - ---alter table pool --- add foreign key (recyclepoolid) --- references pool (poolid) on update cascade on delete cascade; - ---alter table media --- add foreign key (poolid) --- references pool (poolid) on update cascade on delete cascade; - ---alter table job --- add foreign key (poolid) --- references pool (poolid) on update cascade on delete cascade; - ---alter table job --- add foreign key (filesetid) --- references fileset (filesetid) on update cascade on delete cascade; - ---alter table job --- add foreign key (clientid) --- references client (clientid) on update cascade on delete cascade; - ---alter table file --- add foreign key (jobid) --- references job (jobid) on update cascade on delete cascade; - ---alter table file --- add foreign key (pathid) --- references path (pathid) on update cascade on delete restrict; - ---alter table file --- add foreign key (filenameid) --- references filename (filenameid) on update cascade on delete cascade; - ---alter table jobmedia --- add foreign key (jobid) --- references job (jobid) on update cascade on delete cascade; - ---alter table jobmedia --- add foreign key (mediaid) --- references media (mediaid) on update cascade on delete cascade; - ---alter table basefiles --- add foreign key (jobid) --- references job (jobid) on update cascade on delete cascade; - ---alter table basefiles --- add foreign key (fileid) --- references file (fileid) on update cascade on delete cascade; - ---alter table basefiles --- add foreign key (basejobid) --- references job (jobid) on update cascade on delete cascade; - ---alter table unsavedfiles --- add foreign key (jobid) --- references job (jobid) on update restrict on delete restrict; - ---alter table unsavedfiles --- add foreign key (pathid) --- references path (pathid) on update restrict on delete restrict; - ---alter table unsavedfiles --- add foreign key (filenameid) --- references filename (filenameid) on update restrict on delete restrict; END-OF-DATA then diff --git a/bacula/src/cats/make_sqlite_tables.in b/bacula/src/cats/make_sqlite_tables.in index 93279ef901..23657baef8 100644 --- a/bacula/src/cats/make_sqlite_tables.in +++ b/bacula/src/cats/make_sqlite_tables.in @@ -119,6 +119,8 @@ CREATE TABLE Media ( MediaAddressing TINYINT DEFAULT 0, VolReadTime BIGINT UNSIGNED DEFAULT 0, VolWriteTime BIGINT UNSIGNED DEFAULT 0, + EndFile INTEGER UNSIGNED DEFAULT 0, + EndBlock INTEGER UNSIGNED DEFAULT 0, PRIMARY KEY(MediaId) ); @@ -192,7 +194,7 @@ CREATE TABLE Version ( ); -- Initialize Version -INSERT INTO Version (VersionId) VALUES (7); +INSERT INTO Version (VersionId) VALUES (8); CREATE TABLE Counters ( Counter TEXT NOT NULL, diff --git a/bacula/src/cats/protos.h b/bacula/src/cats/protos.h index 234ebe93d8..22ed9f6de6 100644 --- a/bacula/src/cats/protos.h +++ b/bacula/src/cats/protos.h @@ -53,7 +53,7 @@ int db_create_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *media_dbr); int db_create_client_record(JCR *jcr, B_DB *db, CLIENT_DBR *cr); int db_create_fileset_record(JCR *jcr, B_DB *db, FILESET_DBR *fsr); int db_create_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr); -int db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jr); +bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jr); int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr); /* delete.c */ diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index feb650b573..937df6dab0 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -102,13 +102,13 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) } /* Create a JobMedia record for medium used this job - * Returns: 0 on failure - * 1 on success + * Returns: false on failure + * true on success */ -int +bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jm) { - int stat; + bool ok = true;; int count; db_lock(mdb); @@ -124,7 +124,7 @@ JobId=%d AND MediaId=%d", jm->JobId, jm->MediaId); sql_free_result(mdb); db_unlock(mdb); Dmsg0(0, "Already have JobMedia record\n"); - return 0; + return false; } sql_free_result(mdb); } @@ -140,23 +140,30 @@ JobId=%d AND MediaId=%d", jm->JobId, jm->MediaId); /* Must create it */ 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)", - jm->JobId, jm->MediaId, jm->FirstIndex, jm->LastIndex, - jm->StartFile, jm->EndFile, jm->StartBlock, jm->EndBlock,count); + "INSERT INTO JobMedia (JobId,MediaId,FirstIndex,LastIndex," + "StartFile,EndFile,StartBlock,EndBlock,VolIndex) " + "VALUES (%u,%u,%u,%u,%u,%u,%u,%u,%u)", + jm->JobId, jm->MediaId, jm->FirstIndex, jm->LastIndex, + jm->StartFile, jm->EndFile, jm->StartBlock, jm->EndBlock,count); Dmsg0(300, mdb->cmd); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { - Mmsg2(&mdb->errmsg, _("Create db JobMedia record %s failed. ERR=%s\n"), mdb->cmd, + Mmsg2(&mdb->errmsg, _("Create JobMedia record %s failed: ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); - stat = 0; + ok = false; } else { - stat = 1; + Mmsg(mdb->cmd, + "UPDATE Media SET EndFile=%u, EndBlock=%u WHERE MediaId=%u", + jm->EndFile, jm->EndBlock, jm->MediaId); + if (!UPDATE_DB(jcr, mdb, mdb->cmd)) { + Mmsg2(&mdb->errmsg, _("Update Media record %s failed: ERR=%s\n"), mdb->cmd, + sql_strerror(mdb)); + ok = false; + } } db_unlock(mdb); Dmsg0(300, "Return from JobMedia\n"); - return stat; + return ok; } diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index e7e22d018f..6b27b17ad5 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -377,7 +377,8 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS db_lock(mdb); Mmsg(mdb->cmd, -"SELECT VolumeName,FirstIndex,LastIndex,StartFile,EndFile,StartBlock,EndBlock" +"SELECT VolumeName,FirstIndex,LastIndex,StartFile,JobMedia.EndFile," +"StartBlock,JobMedia.EndBlock" " FROM JobMedia,Media WHERE JobMedia.JobId=%u" " AND JobMedia.MediaId=Media.MediaId ORDER BY VolIndex,JobMediaId", JobId); @@ -401,12 +402,12 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS break; } else { bstrncpy(Vols[i].VolumeName, row[0], MAX_NAME_LENGTH); - Vols[i].FirstIndex = atoi(row[1]); - Vols[i].LastIndex = atoi(row[2]); - Vols[i].StartFile = atoi(row[3]); - Vols[i].EndFile = atoi(row[4]); - Vols[i].StartBlock = atoi(row[5]); - Vols[i].EndBlock = atoi(row[6]); + Vols[i].FirstIndex = str_to_uint64(row[1]); + Vols[i].LastIndex = str_to_uint64(row[2]); + Vols[i].StartFile = str_to_uint64(row[3]); + Vols[i].EndFile = str_to_uint64(row[4]); + Vols[i].StartBlock = str_to_uint64(row[5]); + Vols[i].EndBlock = str_to_uint64(row[6]); } } } @@ -494,7 +495,7 @@ int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[]) if (*num_ids > 0) { id = (uint32_t *)malloc(*num_ids * sizeof(uint32_t)); while ((row = sql_fetch_row(mdb)) != NULL) { - id[i++] = (uint32_t)atoi(row[0]); + id[i++] = str_to_uint64(row[0]); } *ids = id; } @@ -809,13 +810,13 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) 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 " + "Recycle,Slot,FirstWritten,LastWritten,InChanger,EndFile,EndBlock " "FROM Media WHERE MediaId=%d", mr->MediaId); } else { /* find by name */ 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 " + "Recycle,Slot,FirstWritten,LastWritten,InChanger,EndFile,EndBlock " "FROM Media WHERE VolumeName='%s'", mr->VolumeName); } @@ -857,6 +858,8 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) bstrncpy(mr->cLastWritten, row[21]!=NULL?row[21]:"", sizeof(mr->cLastWritten)); mr->LastWritten = (time_t)str_to_utime(mr->cLastWritten); mr->InChanger = str_to_uint64(row[22]); + mr->EndFile = str_to_uint64(row[23]); + mr->EndBlock = str_to_uint64(row[24]); stat = mr->MediaId; } } else { diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index 15e49fb6e7..c539bcb6c0 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -140,14 +140,16 @@ db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," "VolCapacityBytes,VolStatus,Recycle,VolRetention," - "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger " + "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," + "EndFile,EndBlock " "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); } else { 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 " + "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," + "EndFile,EndBlock " "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId); } } else { @@ -180,12 +182,14 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, if (type == VERT_LIST) { if (JobId > 0) { /* do by JobId */ Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," - "FirstIndex,LastIndex,StartFile,EndFile,StartBlock,EndBlock " + "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock," + "JobMedia.EndBlock " "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " "AND JobMedia.JobId=%u", JobId); } else { Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," - "FirstIndex,LastIndex,StartFile,EndFile,StartBlock,EndBlock " + "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock," + "JobMedia.EndBlock " "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); } diff --git a/bacula/src/cats/update_mysql_tables.in b/bacula/src/cats/update_mysql_tables.in index c87955612a..fcffada2af 100755 --- a/bacula/src/cats/update_mysql_tables.in +++ b/bacula/src/cats/update_mysql_tables.in @@ -1,8 +1,9 @@ #!/bin/sh # -# Shell script to update MySQL tables from version 1.32 to 1.33 +# Shell script to update MySQL tables from version 1.34 to 1.35.5 # echo " " +echo "This script will update a Bacula MySQL database from version 7 to 8" echo "Depending on the size of your database," echo "this script may take several minutes to run." echo " " @@ -11,49 +12,11 @@ bindir=@SQL_BINDIR@ if $bindir/mysql $* -f <jobdefs) { + /* Handle Storage alists specifically */ + JOB *jobdefs = job->jobdefs; + for (i=0; i < MAX_STORE; i++) { + if (jobdefs->storage[i]) { + STORE *st; + job->storage[i] = New(alist(10, not_owned_by_alist)); + foreach_alist(st, jobdefs->storage[i]) { + job->storage[i]->append(st); + } + } + } + /* Transfer default items from JobDefs Resource */ for (i=0; job_items[i].name; i++) { char **def_svalue, **svalue; /* string value */ @@ -540,18 +552,9 @@ Without that I don't know who I am :-(\n"), configfile); * Handle alist resources */ } else if (job_items[i].handler == store_alist_res) { - int count = job_items[i].default_value; - def_svalue = (char **)((char *)(job->jobdefs) + offset); - Dmsg4(400, "Job \"%s\", field \"%s\" item %d offset=%u\n", - job->hdr.name, job_items[i].name, i, offset); - svalue = (char **)((char *)job + offset); - if (*svalue) { - Pmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue); - } - while (count--) { - *svalue++ = *def_svalue++; + if (bit_is_set(i, job->jobdefs->hdr.item_present)) { + set_bit(i, job->hdr.item_present); } - set_bit(i, job->hdr.item_present); /* * Handle integer fields * Note, our store_yesno does not handle bitmaped fields diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index ee9fffb5a8..36bd6a21d1 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -144,10 +144,10 @@ int start_storage_daemon_job(JCR *jcr) 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.c_str()); - bash_spaces(media_type.c_str()); - bash_spaces(pool_type.c_str()); - bash_spaces(pool_name.c_str()); + bash_spaces(device_name); + bash_spaces(media_type); + bash_spaces(pool_type); + bash_spaces(pool_name); bnet_fsend(sd, use_device, device_name.c_str(), media_type.c_str(), pool_name.c_str(), pool_type.c_str()); Dmsg1(110, ">stored: %s", sd->msg); diff --git a/bacula/src/lib/alist.h b/bacula/src/lib/alist.h index baeaba3bf1..2e43d564dd 100644 --- a/bacula/src/lib/alist.h +++ b/bacula/src/lib/alist.h @@ -35,7 +35,7 @@ for((*((void **)&(var))=(void*)((list)->first())); (var); (*((void **)&(var))=(void*)((list)->next()))) #ifdef the_easy_way -#define foreach_dlist(var, list) \ +#define foreach_alist(var, list) \ for((void*(var))=(list)->first(); (var); (void *(var))=(list)->next(var)); ) #endif diff --git a/bacula/src/lib/attr.c b/bacula/src/lib/attr.c index 3aee618880..43d590d86f 100644 --- a/bacula/src/lib/attr.c +++ b/bacula/src/lib/attr.c @@ -105,8 +105,8 @@ int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr) Dmsg7(200, "unpack_attr FI=%d Type=%d fname=%s attr=%s lname=%s attrEx=%s ds=%d\n", attr->file_index, attr->type, attr->fname, attr->attr, attr->lname, attr->attrEx, attr->data_stream); - *mp_chr(attr->ofname) = 0; - *mp_chr(attr->olname) = 0; + *attr->ofname = 0; + *attr->olname = 0; return 1; } @@ -155,7 +155,7 @@ void build_attr_output_fnames(JCR *jcr, ATTR *attr) pm_strcpy(attr->olname, jcr->where); add_link = true; } else { - mp_chr(attr->olname)[0] = 0; + attr->olname[0] = 0; add_link = false; } if (win32_client && attr->lname[1] == ':') { @@ -190,7 +190,7 @@ void print_ls_output(JCR *jcr, ATTR *attr) p = encode_time(attr->statp.st_ctime, p); *p++ = ' '; *p++ = ' '; - for (f=mp_chr(attr->ofname); *f && (p-buf) < (int)sizeof(buf)-10; ) { + for (f=attr->ofname; *f && (p-buf) < (int)sizeof(buf)-10; ) { *p++ = *f++; } if (attr->type == FT_LNK) { @@ -199,7 +199,7 @@ void print_ls_output(JCR *jcr, ATTR *attr) *p++ = '>'; *p++ = ' '; /* Copy link name */ - for (f=mp_chr(attr->olname); *f && (p-buf) < (int)sizeof(buf)-10; ) { + for (f=attr->olname; *f && (p-buf) < (int)sizeof(buf)-10; ) { *p++ = *f++; } } diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index ac65544ba8..b1dc54e9ac 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -159,7 +159,7 @@ int32_t bnet_recv(BSOCK * bsock) int32_t pktsiz; ASSERT(bsock != NULL); - mp_chr(bsock->msg)[0] = 0; + bsock->msg[0] = 0; if (bsock->errors || bsock->terminated) { return BNET_HARDEOF; } @@ -222,7 +222,7 @@ int32_t bnet_recv(BSOCK * bsock) bsock->timer_start = watchdog_time; /* set start wait time */ bsock->timed_out = 0; /* now read the actual data */ - if ((nbytes = read_nbytes(bsock, mp_chr(bsock->msg), pktsiz)) <= 0) { + if ((nbytes = read_nbytes(bsock, bsock->msg, pktsiz)) <= 0) { bsock->timer_start = 0; /* clear timer */ if (errno == 0) { bsock->b_errno = ENODATA; @@ -248,7 +248,7 @@ int32_t bnet_recv(BSOCK * bsock) * string that was send to us. Note, we ensured above that the * buffer is at least one byte longer than the message length. */ - mp_chr(bsock->msg)[nbytes] = 0; /* terminate in case it is a string */ + bsock->msg[nbytes] = 0; /* terminate in case it is a string */ sm_check(__FILE__, __LINE__, false); return nbytes; /* return actual length of message */ } @@ -384,7 +384,7 @@ bool bnet_send(BSOCK * bsock) /* send data packet */ bsock->timer_start = watchdog_time; /* start timer */ bsock->timed_out = 0; - rc = write_nbytes(bsock, mp_chr(bsock->msg), bsock->msglen); + rc = write_nbytes(bsock, bsock->msg, bsock->msglen); bsock->timer_start = 0; /* clear timer */ if (rc != bsock->msglen) { bsock->errors++; @@ -797,7 +797,7 @@ bool bnet_fsend(BSOCK * bs, const char *fmt, ...) for (;;) { maxlen = sizeof_pool_memory(bs->msg) - 1; va_start(arg_ptr, fmt); - bs->msglen = bvsnprintf(mp_chr(bs->msg), maxlen, fmt, arg_ptr); + bs->msglen = bvsnprintf(bs->msg, maxlen, fmt, arg_ptr); va_end(arg_ptr); if (bs->msglen > 0 && bs->msglen < (maxlen - 5)) { break; diff --git a/bacula/src/lib/bpipe.c b/bacula/src/lib/bpipe.c index 20cf5bee82..c432f1c6d5 100644 --- a/bacula/src/lib/bpipe.c +++ b/bacula/src/lib/bpipe.c @@ -59,8 +59,8 @@ BPIPE *open_bpipe(char *prog, int wait, const char *mode) mode_write = (mode[0] == 'w' || mode[1] == 'w'); /* Build arguments for running program. */ tprog = get_pool_memory(PM_FNAME); - pm_strcpy(&tprog, prog); - build_argc_argv(mp_chr(tprog), &bargc, bargv, MAX_ARGV); + pm_strcpy(tprog, prog); + build_argc_argv(tprog, &bargc, bargv, MAX_ARGV); #ifdef xxxxxx printf("argc=%d\n", bargc); for (i=0; irfd); + results[0] = 0; + fgets(results, sizeof_pool_memory(results), bpipe->rfd); if (feof(bpipe->rfd)) { stat1 = 0; } else { diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index f81e91923e..a4105affa6 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -309,10 +309,10 @@ void create_pid_file(char *dir, const char *progname, int port) struct stat statp; Mmsg(&fname, "%s/%s.%d.pid", dir, progname, port); - if (stat(mp_chr(fname), &statp) == 0) { + if (stat(fname, &statp) == 0) { /* File exists, see what we have */ *pidbuf = 0; - if ((pidfd = open(mp_chr(fname), O_RDONLY|O_BINARY, 0)) < 0 || + if ((pidfd = open(fname, O_RDONLY|O_BINARY, 0)) < 0 || read(pidfd, &pidbuf, sizeof(pidbuf)) < 0 || sscanf(pidbuf, "%d", &oldpid) != 1) { Emsg2(M_ERROR_TERM, 0, _("Cannot open pid file. %s ERR=%s\n"), fname, strerror(errno)); @@ -323,10 +323,10 @@ void create_pid_file(char *dir, const char *progname, int port) progname, oldpid, fname); } /* He is not alive, so take over file ownership */ - unlink(mp_chr(fname)); /* remove stale pid file */ + unlink(fname); /* remove stale pid file */ } /* Create new pid file */ - if ((pidfd = open(mp_chr(fname), O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, 0640)) >= 0) { + if ((pidfd = open(fname, O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, 0640)) >= 0) { len = sprintf(pidbuf, "%d\n", (int)getpid()); write(pidfd, pidbuf, len); close(pidfd); @@ -353,7 +353,7 @@ int delete_pid_file(char *dir, const char *progname, int port) } del_pid_file_ok = FALSE; Mmsg(&fname, "%s/%s.%d.pid", dir, progname, port); - unlink(mp_chr(fname)); + unlink(fname); free_pool_memory(fname); #endif return 1; @@ -386,7 +386,7 @@ void read_state_file(char *dir, const char *progname, int port) Mmsg(&fname, "%s/%s.%d.state", dir, progname, port); /* If file exists, see what we have */ // Dmsg1(10, "O_BINARY=%d\n", O_BINARY); - if ((sfd = open(mp_chr(fname), O_RDONLY|O_BINARY, 0)) < 0) { + if ((sfd = open(fname, O_RDONLY|O_BINARY, 0)) < 0) { Dmsg3(010, "Could not open state file. sfd=%d size=%d: ERR=%s\n", sfd, sizeof(hdr), strerror(errno)); goto bail_out; @@ -424,7 +424,7 @@ void write_state_file(char *dir, const char *progname, int port) Mmsg(&fname, "%s/%s.%d.state", dir, progname, port); /* Create new state file */ - if ((sfd = open(mp_chr(fname), O_CREAT|O_WRONLY|O_BINARY, 0640)) < 0) { + if ((sfd = open(fname, O_CREAT|O_WRONLY|O_BINARY, 0640)) < 0) { Dmsg2(000, _("Could not create state file. %s ERR=%s\n"), fname, strerror(errno)); Emsg2(M_ERROR, 0, _("Could not create state file. %s ERR=%s\n"), fname, strerror(errno)); goto bail_out; diff --git a/bacula/src/lib/cram-md5.c b/bacula/src/lib/cram-md5.c index 451d0f6d20..bee0751133 100644 --- a/bacula/src/lib/cram-md5.c +++ b/bacula/src/lib/cram-md5.c @@ -64,7 +64,7 @@ int cram_md5_auth(BSOCK *bs, char *password, int ssl_need) } hmac_md5((uint8_t *)chal, strlen(chal), (uint8_t *)password, strlen(password), hmac); bin_to_base64(host, (char *)hmac, 16); - ok = strcmp(mp_chr(bs->msg), host) == 0; + ok = strcmp(bs->msg, host) == 0; if (ok) { Dmsg0(99, "Authenticate OK\n"); } else { @@ -111,7 +111,7 @@ int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need) } hmac_md5((uint8_t *)chal, strlen(chal), (uint8_t *)password, strlen(password), hmac); - bs->msglen = bin_to_base64(mp_chr(bs->msg), (char *)hmac, 16) + 1; + bs->msglen = bin_to_base64(bs->msg, (char *)hmac, 16) + 1; if (!bnet_send(bs)) { Dmsg0(100, "Send response failed.\n"); return 0; @@ -121,7 +121,7 @@ int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need) bmicrosleep(5, 0); return 0; } - if (strcmp(mp_chr(bs->msg), "1000 OK auth\n") == 0) { + if (strcmp(bs->msg, "1000 OK auth\n") == 0) { return 1; } Dmsg1(100, "Bad response: %s\n", bs->msg); diff --git a/bacula/src/lib/mem_pool.c b/bacula/src/lib/mem_pool.c index 439085110f..0a2624243c 100644 --- a/bacula/src/lib/mem_pool.c +++ b/bacula/src/lib/mem_pool.c @@ -15,7 +15,7 @@ * there is enough memory, simply call the check_pool_memory_size() * with the desired size and it will adjust only if necessary. * - * Kern E. Sibbald + * Kern E. Sibbald * * Version $Id$ */ @@ -43,11 +43,11 @@ #include "bacula.h" struct s_pool_ctl { - int32_t size; /* default size */ - int32_t max_size; /* max allocated */ - int32_t max_used; /* max buffers used */ - int32_t in_use; /* number in use */ - struct abufhead *free_buf; /* pointer to free buffers */ + int32_t size; /* default size */ + int32_t max_allocated; /* max allocated */ + int32_t max_used; /* max buffers used */ + int32_t in_use; /* number in use */ + struct abufhead *free_buf; /* pointer to free buffers */ }; /* Bacula Name length plus extra */ @@ -59,30 +59,30 @@ struct s_pool_ctl { * Define default Pool buffer sizes */ static struct s_pool_ctl pool_ctl[] = { - { 256, 256, 0, 0, NULL }, /* PM_NOPOOL no pooling */ - { NLEN, NLEN,0, 0, NULL }, /* PM_NAME Bacula name */ - { 256, 256, 0, 0, NULL }, /* PM_FNAME filename buffers */ - { 512, 512, 0, 0, NULL }, /* PM_MESSAGE message buffer */ - { 1024, 1024, 0, 0, NULL } /* PM_EMSG error message buffer */ + { 256, 256, 0, 0, NULL }, /* PM_NOPOOL no pooling */ + { NLEN, NLEN,0, 0, NULL }, /* PM_NAME Bacula name */ + { 256, 256, 0, 0, NULL }, /* PM_FNAME filename buffers */ + { 512, 512, 0, 0, NULL }, /* PM_MESSAGE message buffer */ + { 1024, 1024, 0, 0, NULL } /* PM_EMSG error message buffer */ }; #else /* This is used ONLY when stress testing the code */ static struct s_pool_ctl pool_ctl[] = { - { 20, 20, 0, 0, NULL }, /* PM_NOPOOL no pooling */ - { NLEN, NLEN,0, 0, NULL }, /* PM_NAME Bacula name */ - { 20, 20, 0, 0, NULL }, /* PM_FNAME filename buffers */ - { 20, 20, 0, 0, NULL }, /* PM_MESSAGE message buffer */ - { 20, 20, 0, 0, NULL } /* PM_EMSG error message buffer */ + { 20, 20, 0, 0, NULL }, /* PM_NOPOOL no pooling */ + { NLEN, NLEN,0, 0, NULL }, /* PM_NAME Bacula name */ + { 20, 20, 0, 0, NULL }, /* PM_FNAME filename buffers */ + { 20, 20, 0, 0, NULL }, /* PM_MESSAGE message buffer */ + { 20, 20, 0, 0, NULL } /* PM_EMSG error message buffer */ }; #endif /* Memory allocation control structures and storage. */ struct abufhead { - int32_t ablen; /* Buffer length in bytes */ - int32_t pool; /* pool */ - struct abufhead *next; /* pointer to next free buffer */ + int32_t ablen; /* Buffer length in bytes */ + int32_t pool; /* pool */ + struct abufhead *next; /* pointer to next free buffer */ }; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; @@ -105,7 +105,7 @@ POOLMEM *sm_get_pool_memory(const char *fname, int lineno, int pool) pool_ctl[pool].free_buf = buf->next; pool_ctl[pool].in_use++; if (pool_ctl[pool].in_use > pool_ctl[pool].max_used) { - pool_ctl[pool].max_used = pool_ctl[pool].in_use; + pool_ctl[pool].max_used = pool_ctl[pool].in_use; } V(mutex); Dmsg3(300, "sm_get_pool_memory reuse %x to %s:%d\n", buf, fname, lineno); @@ -174,8 +174,8 @@ POOLMEM *sm_realloc_pool_memory(const char *fname, int lineno, POOLMEM *obuf, in } ((struct abufhead *)buf)->ablen = size; pool = ((struct abufhead *)buf)->pool; - if (size > pool_ctl[pool].max_size) { - pool_ctl[pool].max_size = size; + if (size > pool_ctl[pool].max_allocated) { + pool_ctl[pool].max_allocated = size; } V(mutex); return (POOLMEM *)(((char *)buf)+HEAD_SIZE); @@ -202,17 +202,17 @@ void sm_free_pool_memory(const char *fname, int lineno, POOLMEM *obuf) pool = buf->pool; pool_ctl[pool].in_use--; if (pool == 0) { - free((char *)buf); /* free nonpooled memory */ - } else { /* otherwise link it to the free pool chain */ + free((char *)buf); /* free nonpooled memory */ + } else { /* otherwise link it to the free pool chain */ #ifdef DEBUG struct abufhead *next; /* Don't let him free the same buffer twice */ for (next=pool_ctl[pool].free_buf; next; next=next->next) { - if (next == buf) { + if (next == buf) { Dmsg4(300, "bad free_pool_memory %x pool=%d from %s:%d\n", buf, pool, fname, lineno); - V(mutex); /* unblock the pool */ - ASSERT(next != buf); /* attempt to free twice */ - } + V(mutex); /* unblock the pool */ + ASSERT(next != buf); /* attempt to free twice */ + } } #endif buf->next = pool_ctl[pool].free_buf; @@ -225,7 +225,7 @@ void sm_free_pool_memory(const char *fname, int lineno, POOLMEM *obuf) #else -/* =================================================================== */ +/* ========= NO SMARTALLOC ========================================= */ POOLMEM *get_pool_memory(int pool) { @@ -284,6 +284,8 @@ int32_t sizeof_pool_memory(POOLMEM *obuf) return ((struct abufhead *)cp)->ablen; } + + /* Realloc pool memory buffer */ POOLMEM *realloc_pool_memory(POOLMEM *obuf, int32_t size) { @@ -301,13 +303,14 @@ POOLMEM *realloc_pool_memory(POOLMEM *obuf, int32_t size) } ((struct abufhead *)buf)->ablen = size; pool = ((struct abufhead *)buf)->pool; - if (size > pool_ctl[pool].max_size) { - pool_ctl[pool].max_size = size; + if (size > pool_ctl[pool].max_allocated) { + pool_ctl[pool].max_allocated = size; } V(mutex); return (POOLMEM *)(((char *)buf)+HEAD_SIZE); } + POOLMEM *check_pool_memory_size(POOLMEM *obuf, int32_t size) { ASSERT(obuf); @@ -329,16 +332,16 @@ void free_pool_memory(POOLMEM *obuf) pool = buf->pool; pool_ctl[pool].in_use--; if (pool == 0) { - free((char *)buf); /* free nonpooled memory */ - } else { /* otherwise link it to the free pool chain */ + free((char *)buf); /* free nonpooled memory */ + } else { /* otherwise link it to the free pool chain */ #ifdef DEBUG struct abufhead *next; /* Don't let him free the same buffer twice */ for (next=pool_ctl[pool].free_buf; next; next=next->next) { - if (next == buf) { - V(mutex); - ASSERT(next != buf); /* attempt to free twice */ - } + if (next == buf) { + V(mutex); + ASSERT(next != buf); /* attempt to free twice */ + } } #endif buf->next = pool_ctl[pool].free_buf; @@ -365,9 +368,9 @@ void close_memory_pool() for (int i=1; i<=PM_MAX; i++) { buf = pool_ctl[i].free_buf; while (buf) { - next = buf->next; - free((char *)buf); - buf = next; + next = buf->next; + free((char *)buf); + buf = next; } pool_ctl[i].free_buf = NULL; } @@ -394,8 +397,8 @@ void print_memory_pool_stats() { Dmsg0(-1, "Pool Maxsize Maxused Inuse\n"); for (int i=0; i<=PM_MAX; i++) - Dmsg4(-1, "%5s %7d %7d %5d\n", pool_name(i), pool_ctl[i].max_size, - pool_ctl[i].max_used, pool_ctl[i].in_use); + Dmsg4(-1, "%5s %7d %7d %5d\n", pool_name(i), pool_ctl[i].max_allocated, + pool_ctl[i].max_used, pool_ctl[i].in_use); Dmsg0(-1, "\n"); } @@ -404,6 +407,7 @@ void print_memory_pool_stats() void print_memory_pool_stats() {} #endif /* DEBUG */ + /* * Concatenate a string (str) onto a pool memory buffer pm * Returns: length of concatenated string @@ -490,6 +494,43 @@ int pm_strcpy(POOL_MEM &pm, const char *str) return len - 1; } +/* ============== CLASS POOL_MEM ============== */ + +/* Return the size of a memory buffer */ +int32_t POOL_MEM::max_size() +{ + int32_t size; + char *cp = mem; + cp -= HEAD_SIZE; + size = ((struct abufhead *)cp)->ablen; + Dmsg1(000, "max_size=%d\n", size); + return size; +} + +void POOL_MEM::realloc_pm(int32_t size) +{ + char *cp = mem; + char *buf; + int pool; + + P(mutex); + cp -= HEAD_SIZE; + buf = (char *)realloc(cp, size+HEAD_SIZE); + if (buf == NULL) { + V(mutex); + Emsg1(M_ABORT, 0, "Out of memory requesting %d bytes\n", size); + } + Dmsg2(000, "Old buf=0x%x new buf=0x%x\n", cp, buf); + ((struct abufhead *)buf)->ablen = size; + pool = ((struct abufhead *)buf)->pool; + if (size > pool_ctl[pool].max_allocated) { + pool_ctl[pool].max_allocated = size; + } + mem = buf+HEAD_SIZE; + V(mutex); + Dmsg3(000, "Old buf=0x%x new buf=0x%x mem=0x%x\n", cp, buf, mem); +} + int POOL_MEM::strcat(const char *str) { int pmlen = strlen(mem); diff --git a/bacula/src/lib/mem_pool.h b/bacula/src/lib/mem_pool.h index 62b508f99f..7d23bb20c8 100644 --- a/bacula/src/lib/mem_pool.h +++ b/bacula/src/lib/mem_pool.h @@ -87,6 +87,8 @@ public: mem = check_pool_memory_size(mem, size); return mem; } + int32_t max_size(); + void realloc_pm(int32_t size); int strcpy(const char *str); int strcat(const char *str); }; diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 0ef3760105..cb0e0613a9 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -456,7 +456,7 @@ void close_msg(JCR *jcr) len = d->max_len+10; line = get_memory(len); rewind(d->fd); - while (fgets(mp_chr(line), len, d->fd)) { + while (fgets(line, len, d->fd)) { fputs(line, bpipe->wfd); } if (!close_wpipe(bpipe)) { /* close write pipe sending mail */ @@ -470,7 +470,7 @@ void close_msg(JCR *jcr) */ if (msgs != daemon_msgs) { /* read what mail prog returned -- should be nothing */ - while (fgets(mp_chr(line), len, bpipe->rfd)) { + while (fgets(line, len, bpipe->rfd)) { Jmsg1(jcr, M_INFO, 0, _("Mail prog: %s"), line); } } @@ -488,7 +488,7 @@ void close_msg(JCR *jcr) rem_temp_file: /* Remove temp file */ fclose(d->fd); - unlink(mp_chr(d->mail_filename)); + unlink(d->mail_filename); free_pool_memory(d->mail_filename); d->mail_filename = NULL; Dmsg0(150, "end mail or mail on error\n"); @@ -668,7 +668,7 @@ void dispatch_message(JCR *jcr, int type, int level, char *msg) if (!d->fd) { POOLMEM *name = get_pool_memory(PM_MESSAGE); make_unique_mail_filename(jcr, name, d); - d->fd = fopen(mp_chr(name), "w+"); + d->fd = fopen(name, "w+"); if (!d->fd) { d->fd = stdout; Jmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", name, strerror(errno)); @@ -987,7 +987,7 @@ Jmsg(JCR *jcr, int type, int level, const char *fmt,...) if (jcr && jcr->JobId == 0 && jcr->dir_bsock) { BSOCK *dir = jcr->dir_bsock; va_start(arg_ptr, fmt); - dir->msglen = bvsnprintf(mp_chr(dir->msg), sizeof_pool_memory(dir->msg), + dir->msglen = bvsnprintf(dir->msg, sizeof_pool_memory(dir->msg), fmt, arg_ptr); va_end(arg_ptr); bnet_send(jcr->dir_bsock); @@ -1098,7 +1098,7 @@ int m_msg(const char *file, int line, POOLMEM **pool_buf, const char *fmt, ...) va_list arg_ptr; int i, len, maxlen; - i = sprintf(mp_chr(*pool_buf), "%s:%d ", file, line); + i = sprintf(*pool_buf, "%s:%d ", file, line); for (;;) { maxlen = sizeof_pool_memory(*pool_buf) - i - 1; @@ -1178,6 +1178,25 @@ int Mmsg(POOLMEM *&pool_buf, const char *fmt, ...) return len; } +int Mmsg(POOL_MEM &pool_buf, const char *fmt, ...) +{ + va_list arg_ptr; + int len, maxlen; + + for (;;) { + maxlen = pool_buf.max_size() - 1; + va_start(arg_ptr, fmt); + len = bvsnprintf(pool_buf.c_str(), maxlen, fmt, arg_ptr); + va_end(arg_ptr); + if (len < 0 || len >= (maxlen-5)) { + pool_buf.realloc_pm(maxlen + maxlen/2); + continue; + } + break; + } + return len; +} + static pthread_mutex_t msg_queue_mutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 40f102437d..f4362acf8b 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -26,103 +26,103 @@ 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 *bstrncpy (char *dest, POOL_MEM &src, int maxlen); -char *bstrncat (char *dest, const char *src, int maxlen); -char *bstrncat (char *dest, POOL_MEM &src, int maxlen); -void *b_malloc (const char *file, int line, size_t size); +char *bstrncpy (char *dest, const char *src, int maxlen); +char *bstrncpy (char *dest, POOL_MEM &src, int maxlen); +char *bstrncat (char *dest, const char *src, int maxlen); +char *bstrncat (char *dest, POOL_MEM &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(); @@ -136,36 +136,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); @@ -175,41 +175,41 @@ 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 bash_spaces (POOL_MEM &pm); -void unbash_spaces (char *str); -void unbash_spaces (POOL_MEM &pm); -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 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 bash_spaces (POOL_MEM &pm); +void unbash_spaces (char *str); +void unbash_spaces (POOL_MEM &pm); +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 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/signal.c b/bacula/src/lib/signal.c index b6ae5eafa1..f0e250f338 100644 --- a/bacula/src/lib/signal.c +++ b/bacula/src/lib/signal.c @@ -93,6 +93,7 @@ extern "C" void signal_handler(int sig) static char *argv[4]; static char pid_buf[20]; static char btpath[400]; + char buf[100]; pid_t pid; int exelen = strlen(exepath); @@ -112,8 +113,17 @@ extern "C" void signal_handler(int sig) strcat(exepath, "/"); } strcat(exepath, exename); - if (chdir(working_directory) !=0) { /* dump in working directory */ - Pmsg2(000, "chdir to %s failed. ERR=%s\n", working_directory, strerror(errno)); + if (!working_directory) { + working_directory = buf; + *buf = 0; + } + if (*working_directory == 0) { + strcpy((char *)working_directory, "/tmp/"); + } + if (chdir(working_directory) != 0) { /* dump in working directory */ + berrno be; + Pmsg2(000, "chdir to %s failed. ERR=%s\n", working_directory, be.strerror()); + strcpy((char *)working_directory, "/tmp/"); } unlink("./core"); /* get rid of any old core file */ sprintf(pid_buf, "%d", (int)main_pid); diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 261292956f..d8c0a72458 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -88,11 +88,21 @@ bash_spaces(char *str) } } -void bash_spaces(POOL_MEM &pm) +/* Convert spaces to non-space character. + * This makes scanf of fields containing spaces easier. + */ +void +bash_spaces(POOL_MEM &pm) { - bash_spaces(pm.c_str()); + char *str = pm.c_str(); + while (*str) { + if (*str == ' ') + *str = 0x1; + str++; + } } + /* Convert non-space characters (0x1) back into spaces */ void unbash_spaces(char *str) @@ -108,11 +118,15 @@ unbash_spaces(char *str) void unbash_spaces(POOL_MEM &pm) { - unbash_spaces(pm.c_str()); + char *str = pm.c_str(); + while (*str) { + if (*str == 0x1) + *str = ' '; + str++; + } } - char *encode_time(time_t time, char *buf) { struct tm tm; diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 915cf6ee65..375145a94f 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -750,11 +750,12 @@ reread: } } while (stat == -1 && (errno == EINTR || errno == EIO) && retry++ < 11); if (stat < 0) { + berrno be; clrerror_dev(dev, -1); - Dmsg1(90, "Read device got: ERR=%s\n", strerror(errno)); + Dmsg1(90, "Read device got: ERR=%s\n", be.strerror()); block->read_len = 0; 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)); + dev->file, dev->block_num, dev->dev_name, be.strerror()); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); if (dev->state & ST_EOF) { /* EOF just seen? */ dev->state |= ST_EOT; /* yes, error => EOT */ diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 6e415d177a..969c99e83e 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -1198,9 +1198,15 @@ bool dir_send_job_status(JCR *jcr) {return 1;} bool dir_ask_sysop_to_mount_volume(DCR *dcr) { DEVICE *dev = dcr->dev; - JCR *jcr = dcr->jcr; - fprintf(stderr, _("Mount Volume \"%s\" on device \"%s\" and press return when ready: "), - jcr->VolumeName, dev_name(dev)); + Dmsg0(20, "Enter dir_ask_sysop_to_mount_volume\n"); + /* Close device so user can use autochanger if desired */ + if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) { + offline_dev(dev); + } + force_close_dev(dev); + fprintf(stderr, "Mount Volume \"%s\" on device %s and press return when ready: ", + dcr->VolumeName, dev_name(dev)); getchar(); - return 1; + return true; } + diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index 4516c626c9..adb7674af9 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -134,6 +134,8 @@ struct VOLUME_CAT_INFO { uint32_t VolCatReads; /* Number of reads this volume */ uint64_t VolCatRBytes; /* Number of bytes read */ uint32_t VolCatRecycles; /* Number of recycles this volume */ + uint32_t EndFile; /* Last file number */ + uint32_t EndBlock; /* Last block number */ int32_t Slot; /* Slot in changer */ bool InChanger; /* Set if vol in current magazine */ uint32_t VolCatMaxJobs; /* Maximum Jobs to write to volume */ diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index e200cc9d2e..d3654939f8 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -100,14 +100,14 @@ bool job_cmd(JCR *jcr) jcr->JobId = JobId; jcr->VolSessionId = newVolSessionId(); jcr->VolSessionTime = VolSessionTime; - bstrncpy(jcr->Job, job.c_str(), sizeof(jcr->Job)); - unbash_spaces(job_name.c_str()); + bstrncpy(jcr->Job, job, sizeof(jcr->Job)); + unbash_spaces(job_name); jcr->job_name = get_pool_memory(PM_NAME); pm_strcpy(jcr->job_name, job_name); - unbash_spaces(client_name.c_str()); + unbash_spaces(client_name); jcr->client_name = get_pool_memory(PM_NAME); pm_strcpy(jcr->client_name, client_name); - unbash_spaces(fileset_name.c_str()); + unbash_spaces(fileset_name); jcr->fileset_name = get_pool_memory(PM_NAME); pm_strcpy(jcr->fileset_name, fileset_name); jcr->JobType = JobType; diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index 7a41338b77..a69fbc1948 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -564,7 +564,7 @@ bool open_attr_spool_file(JCR *jcr, BSOCK *bs) POOLMEM *name = get_pool_memory(PM_MESSAGE); make_unique_spool_filename(jcr, &name, bs->fd); - bs->spool_fd = fopen(mp_chr(name), "w+"); + bs->spool_fd = fopen(name, "w+"); if (!bs->spool_fd) { berrno be; Jmsg(jcr, M_FATAL, 0, _("fopen attr spool file %s failed: ERR=%s\n"), name, @@ -593,7 +593,7 @@ bool close_attr_spool_file(JCR *jcr, BSOCK *bs) V(mutex); make_unique_spool_filename(jcr, &name, bs->fd); fclose(bs->spool_fd); - unlink(mp_chr(name)); + unlink(name); free_pool_memory(name); bs->spool_fd = NULL; bs->spool = false; diff --git a/bacula/src/version.h b/bacula/src/version.h index c67a74e251..87aef8c1f8 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION -#define VERSION "1.35.4" -#define BDATE "21 September 2004" -#define LSMDATE "21Sep04" +#define VERSION "1.35.5" +#define BDATE "22 September 2004" +#define LSMDATE "22Sep04" /* Debug flags */ #undef DEBUG diff --git a/bacula/updatedb/update_mysql_tables_7_to_8 b/bacula/updatedb/update_mysql_tables_7_to_8 new file mode 100755 index 0000000000..f20681ddec --- /dev/null +++ b/bacula/updatedb/update_mysql_tables_7_to_8 @@ -0,0 +1,27 @@ +#!/bin/sh +# +# Shell script to update MySQL tables from version 1.34 to 1.35.5 +# +echo " " +echo "This script will update a Bacula MySQL database from version 7 to 8" +echo "Depending on the size of your database," +echo "this script may take several minutes to run." +echo " " +bindir=/home/kern/bacula/depkgs/sqlite + +if $bindir/mysql $* -f <