+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
- 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.
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
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
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
- 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.
/* Bacula common configuration defines */
-#undef TRUE
-#undef FALSE
+#undef TRUE
+#undef FALSE
#define TRUE 1
#define FALSE 0
#endif
#ifdef PROTOTYPES
-# define __PROTO(p) p
+# define __PROTO(p) p
#else
-# define __PROTO(p) ()
+# define __PROTO(p) ()
#endif
#ifdef DEBUG
#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
* 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
*/
/* 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)
#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)
/* 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)
/* 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)
#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)
/* 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)
#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;
#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 */
#ifdef HAVE_SQLITE
-#define BDB_VERSION 7
+#define BDB_VERSION 8
#include <sqlite.h>
#ifdef HAVE_MYSQL
-#define BDB_VERSION 7
+#define BDB_VERSION 8
#include <mysql.h>
#ifdef HAVE_POSTGRESQL
-#define BDB_VERSION 7
+#define BDB_VERSION 8
#include <libpq-fe.h>
/* 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 */
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 */
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)
);
);
-- Initialize Version
-INSERT INTO Version (VersionId) VALUES (7);
+INSERT INTO Version (VersionId) VALUES (8);
CREATE TABLE Counters (
Counter TINYBLOB NOT NULL,
versionid integer not null
);
-INSERT INTO Version (VersionId) VALUES (7);
+INSERT INTO Version (VersionId) VALUES (8);
create table counters
(
default 0,
volwritetime bigint not null
default 0,
+ endfile integer not null
+ default 0,
+ endblock integer not null
+ default 0,
primary key (mediaid)
);
-- 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
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)
);
);
-- Initialize Version
-INSERT INTO Version (VersionId) VALUES (7);
+INSERT INTO Version (VersionId) VALUES (8);
CREATE TABLE Counters (
Counter TEXT NOT NULL,
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 */
}
/* 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);
sql_free_result(mdb);
db_unlock(mdb);
Dmsg0(0, "Already have JobMedia record\n");
- return 0;
+ return false;
}
sql_free_result(mdb);
}
/* 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;
}
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);
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]);
}
}
}
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;
}
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);
}
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 {
"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 {
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");
}
#!/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 " "
if $bindir/mysql $* -f <<END-OF-DATA
USE bacula;
-ALTER TABLE Media ADD COLUMN InChanger TINYINT NOT NULL DEFAULT 0;
-ALTER TABLE Media ADD COLUMN MediaAddressing TINYINT NOT NULL DEFAULT 0;
-ALTER TABLE Media ADD COLUMN VolReadTime BIGINT UNSIGNED NOT NULL DEFAULT 0;
-ALTER TABLE Media ADD COLUMN VolWriteTime BIGINT UNSIGNED NOT NULL DEFAULT 0;
-
-ALTER TABLE Pool ADD COLUMN Enabled TINYINT DEFAULT 1;
-ALTER TABLE Pool ADD COLUMN ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool;
-ALTER TABLE Pool ADD COLUMN RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool;
-
-DROP TABLE BaseFiles;
-
-
-CREATE TABLE BaseFiles (
- BaseId INTEGER UNSIGNED AUTO_INCREMENT,
- JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
- FileId INTEGER UNSIGNED NOT NULL REFERENCES File,
- FileIndex INTEGER UNSIGNED,
- PRIMARY KEY(BaseId)
- );
-
-DROP TABLE UnsavedFiles;
-
-CREATE TABLE UnsavedFiles (
- UnsavedId INTEGER UNSIGNED AUTO_INCREMENT,
- JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
- PathId INTEGER UNSIGNED NOT NULL REFERENCES Path,
- FilenameId INTEGER UNSIGNED NOT NULL REFERENCES Filename,
- PRIMARY KEY (UnsavedId)
- );
-
-DROP TABLE BaseFiles;
-
-CREATE TABLE BaseFiles (
- BaseId INTEGER UNSIGNED AUTO_INCREMENT,
- BaseJobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
- JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
- FileId INTEGER UNSIGNED NOT NULL REFERENCES File,
- FileIndex INTEGER UNSIGNED,
- PRIMARY KEY(BaseId)
- );
+ALTER TABLE Media ADD COLUMN EndFile INTEGER UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE Media ADD COLUMN EndBlock INTEGER UNSIGNED NOT NULL DEFAULT 0;
DELETE FROM Version;
-INSERT INTO Version (VersionId) VALUES (7);
+INSERT INTO Version (VersionId) VALUES (8);
END-OF-DATA
then
#!/bin/sh
#
-# Shell script to update PostgreSQL tables
+# Shell script to update PostgreSQL tables from version 1.34 to 1.35.5
#
echo " "
+echo "This script will update a Bacula PostgreSQL database from version 7 to 8"
echo "Depending on the size of your database,"
echo "this script may take several minutes to run."
echo " "
if $bindir/psql $* -f - <<END-OF-DATA
\c bacula
+ALTER TABLE Media ADD COLUMN EndFile integer not null default 0;
+ALTER TABLE Media ADD COLUMN EndBlock integer not null default 0;
+
DELETE FROM Version;
-INSERT INTO Version (VersionId) VALUES (7);
+INSERT INTO Version (VersionId) VALUES (8);
END-OF-DATA
then
#!/bin/sh
#
-# shell script to update SQLite from version 1.32 to 1.33
+# shell script to update SQLite from version 1.34 to 1.35.5
#
echo " "
+echo "This script will update a Bacula SQLite database from version 7 to 8"
echo "Depending on the size of your database,"
echo "this script may take several minutes to run."
echo " "
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)
);
VolMounts, VolBytes, VolErrors, VolWrites,
VolCapacityBytes, VolStatus, Recycle,
VolRetention, VolUseDuration, MaxVolJobs,
- MaxVolFiles, MaxVolBytes, 0, 0, 0, 0
+ MaxVolFiles, MaxVolBytes, InChanger, MediaAddressing,
+ VolReadTime, VolWriteTime, 0, 0
FROM 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)
);
VolRetention, VolUseDuration, MaxVolJobs,
MaxVolFiles, MaxVolBytes,
InChanger, MediaAddressing,
- VolReadTime, VolWriteTime)
+ VolReadTime, VolWriteTime,
+ EndFile, EndBlock)
SELECT * FROM Media_backup;
DROP TABLE Media_backup;
-CREATE INDEX inx8 ON Media (PoolId);
-
-CREATE TABLE Pool_backup (
- PoolId INTEGER UNSIGNED AUTOINCREMENT,
- Name VARCHAR(128) NOT NULL,
- NumVols INTEGER UNSIGNED DEFAULT 0,
- MaxVols INTEGER UNSIGNED DEFAULT 0,
- UseOnce TINYINT DEFAULT 0,
- UseCatalog TINYINT DEFAULT 1,
- AcceptAnyVolume TINYINT DEFAULT 0,
- VolRetention BIGINT UNSIGNED DEFAULT 0,
- VolUseDuration BIGINT UNSIGNED DEFAULT 0,
- MaxVolJobs INTEGER UNSIGNED DEFAULT 0,
- MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
- MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
- AutoPrune TINYINT DEFAULT 0,
- Recycle TINYINT DEFAULT 0,
- PoolType VARCHAR(20) NOT NULL,
- LabelFormat VARCHAR(128) NOT NULL,
- Enabled TINYINT DEFAULT 1,
- ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
- RecyclePoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
- UNIQUE (Name),
- PRIMARY KEY (PoolId)
- );
-
-INSERT INTO Pool_backup SELECT
- PoolId,
- Name,
- NumVols,
- MaxVols,
- UseOnce,
- UseCatalog,
- AcceptAnyVolume,
- VolRetention,
- VolUseDuration,
- MaxVolJobs,
- MaxVolFiles,
- MaxVolBytes,
- AutoPrune,
- Recycle,
- PoolType,
- LabelFormat, 1, 0, 0
- FROM Pool;
-
-DROP TABLE Pool;
-
-CREATE TABLE Pool (
- PoolId INTEGER UNSIGNED AUTOINCREMENT,
- Name VARCHAR(128) NOT NULL,
- NumVols INTEGER UNSIGNED DEFAULT 0,
- MaxVols INTEGER UNSIGNED DEFAULT 0,
- UseOnce TINYINT DEFAULT 0,
- UseCatalog TINYINT DEFAULT 1,
- AcceptAnyVolume TINYINT DEFAULT 0,
- VolRetention BIGINT UNSIGNED DEFAULT 0,
- VolUseDuration BIGINT UNSIGNED DEFAULT 0,
- MaxVolJobs INTEGER UNSIGNED DEFAULT 0,
- MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
- MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
- AutoPrune TINYINT DEFAULT 0,
- Recycle TINYINT DEFAULT 0,
- PoolType VARCHAR(20) NOT NULL,
- LabelFormat VARCHAR(128) NOT NULL,
- Enabled TINYINT DEFAULT 1,
- ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
- RecyclePoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
- UNIQUE (Name),
- PRIMARY KEY (PoolId)
- );
-
-INSERT INTO Pool (
- PoolId,
- Name,
- NumVols,
- MaxVols,
- UseOnce,
- UseCatalog,
- AcceptAnyVolume,
- VolRetention,
- VolUseDuration,
- MaxVolJobs,
- MaxVolFiles,
- MaxVolBytes,
- AutoPrune,
- Recycle,
- PoolType,
- LabelFormat, Enabled, ScratchPoolId, RecyclePoolId)
- SELECT * FROM Pool_backup;
-
-DROP TABLE Pool_backup;
-
-
-DROP TABLE BaseFiles;
-
-CREATE TABLE BaseFiles (
- BaseId INTEGER UNSIGNED AUTOINCREMENT,
- BaseJobId INTEGER UNSIGNED REFERENCES Job NOT NULL,
- JobId INTEGER UNSIGNED REFERENCES Job NOT NULL,
- FileId INTEGER UNSIGNED REFERENCES File NOT NULL,
- FileIndex INTEGER UNSIGNED,
- PRIMARY KEY(BaseId)
- );
-
COMMIT;
DELETE FROM Version;
-INSERT INTO Version (VersionId) VALUES (7);
+INSERT INTO Version (VersionId) VALUES (8);
END-OF-DATA
int i;
if (job->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 */
* 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
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);
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
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;
}
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] == ':') {
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) {
*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++;
}
}
int32_t pktsiz;
ASSERT(bsock != NULL);
- mp_chr(bsock->msg)[0] = 0;
+ bsock->msg[0] = 0;
if (bsock->errors || bsock->terminated) {
return BNET_HARDEOF;
}
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;
* 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 */
}
/* 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++;
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;
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; i<bargc; i++) {
return ENOENT;
}
if (results) {
- mp_chr(results)[0] = 0;
- fgets(mp_chr(results), sizeof_pool_memory(results), bpipe->rfd);
+ results[0] = 0;
+ fgets(results, sizeof_pool_memory(results), bpipe->rfd);
if (feof(bpipe->rfd)) {
stat1 = 0;
} else {
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));
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);
}
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;
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;
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;
}
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 {
}
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;
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);
* 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$
*/
#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 */
* 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;
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);
}
((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);
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;
#else
-/* =================================================================== */
+/* ========= NO SMARTALLOC ========================================= */
POOLMEM *get_pool_memory(int pool)
{
return ((struct abufhead *)cp)->ablen;
}
+
+
/* Realloc pool memory buffer */
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);
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;
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;
}
{
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");
}
void print_memory_pool_stats() {}
#endif /* DEBUG */
+
/*
* Concatenate a string (str) onto a pool memory buffer pm
* Returns: length of concatenated string
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);
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);
};
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 */
*/
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);
}
}
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");
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));
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);
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;
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;
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();
/* 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);
/* 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 */
static char *argv[4];
static char pid_buf[20];
static char btpath[400];
+ char buf[100];
pid_t pid;
int exelen = strlen(exepath);
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);
}
}
-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)
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;
}
} 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 */
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;
}
+
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 */
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;
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,
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;
/* */
#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
--- /dev/null
+#!/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 <<END-OF-DATA
+USE bacula;
+
+ALTER TABLE Media ADD COLUMN EndFile INTEGER UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE Media ADD COLUMN EndBlock INTEGER UNSIGNED NOT NULL DEFAULT 0;
+
+DELETE FROM Version;
+INSERT INTO Version (VersionId) VALUES (8);
+
+END-OF-DATA
+then
+ echo "Update of Bacula MySQL tables succeeded."
+else
+ echo "Update of Bacula MySQL tables failed."
+fi
+exit 0
--- /dev/null
+#!/bin/sh
+#
+# Shell script to update PostgreSQL tables from version 1.34 to 1.35.5
+#
+echo " "
+echo "This script will update a Bacula PostgreSQL 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/psql $* -f - <<END-OF-DATA
+\c bacula
+
+ALTER TABLE Media ADD COLUMN EndFile integer not null default 0;
+ALTER TABLE Media ADD COLUMN EndBlock integer not null default 0;
+
+DELETE FROM Version;
+INSERT INTO Version (VersionId) VALUES (8);
+
+END-OF-DATA
+then
+ echo "Update of Bacula PostgreSQL tables succeeded."
+else
+ echo "Update of Bacula PostgreSQL tables failed."
+fi
+exit 0
--- /dev/null
+#!/bin/sh
+#
+# shell script to update SQLite from version 1.34 to 1.35.5
+#
+echo " "
+echo "This script will update a Bacula SQLite 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
+cd /home/kern/bacula/working
+
+$bindir/sqlite $* bacula.db <<END-OF-DATA
+
+BEGIN TRANSACTION;
+CREATE TEMPORARY TABLE Media_backup (
+ MediaId INTEGER UNSIGNED AUTOINCREMENT,
+ VolumeName VARCHAR(128) NOT NULL,
+ Slot INTEGER DEFAULT 0,
+ PoolId INTEGER UNSIGNED REFERENCES Pool NOT NULL,
+ MediaType VARCHAR(128) NOT NULL,
+ FirstWritten DATETIME DEFAULT 0,
+ LastWritten DATETIME DEFAULT 0,
+ LabelDate DATETIME DEFAULT 0,
+ VolJobs INTEGER UNSIGNED DEFAULT 0,
+ VolFiles INTEGER UNSIGNED DEFAULT 0,
+ VolBlocks INTEGER UNSIGNED DEFAULT 0,
+ VolMounts INTEGER UNSIGNED DEFAULT 0,
+ VolBytes BIGINT UNSIGNED DEFAULT 0,
+ VolErrors INTEGER UNSIGNED DEFAULT 0,
+ VolWrites INTEGER UNSIGNED DEFAULT 0,
+ VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
+ VolStatus VARCHAR(20) NOT NULL,
+ Recycle TINYINT DEFAULT 0,
+ VolRetention BIGINT UNSIGNED DEFAULT 0,
+ VolUseDuration BIGINT UNSIGNED DEFAULT 0,
+ MaxVolJobs INTEGER UNSIGNED DEFAULT 0,
+ MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
+ MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
+ InChanger TINYINT DEFAULT 0,
+ 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)
+ );
+
+INSERT INTO Media_backup 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, MediaAddressing,
+ VolReadTime, VolWriteTime, 0, 0
+ FROM Media;
+
+
+DROP TABLE Media;
+
+CREATE TABLE Media (
+ MediaId INTEGER UNSIGNED AUTOINCREMENT,
+ VolumeName VARCHAR(128) NOT NULL,
+ Slot INTEGER DEFAULT 0,
+ PoolId INTEGER UNSIGNED REFERENCES Pool NOT NULL,
+ MediaType VARCHAR(128) NOT NULL,
+ FirstWritten DATETIME DEFAULT 0,
+ LastWritten DATETIME DEFAULT 0,
+ LabelDate DATETIME DEFAULT 0,
+ VolJobs INTEGER UNSIGNED DEFAULT 0,
+ VolFiles INTEGER UNSIGNED DEFAULT 0,
+ VolBlocks INTEGER UNSIGNED DEFAULT 0,
+ VolMounts INTEGER UNSIGNED DEFAULT 0,
+ VolBytes BIGINT UNSIGNED DEFAULT 0,
+ VolErrors INTEGER UNSIGNED DEFAULT 0,
+ VolWrites INTEGER UNSIGNED DEFAULT 0,
+ VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
+ VolStatus VARCHAR(20) NOT NULL,
+ Recycle TINYINT DEFAULT 0,
+ VolRetention BIGINT UNSIGNED DEFAULT 0,
+ VolUseDuration BIGINT UNSIGNED DEFAULT 0,
+ MaxVolJobs INTEGER UNSIGNED DEFAULT 0,
+ MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
+ MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
+ InChanger TINYINT DEFAULT 0,
+ 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)
+ );
+
+INSERT INTO Media (
+ MediaId, VolumeName, Slot, PoolId,
+ MediaType, FirstWritten, LastWritten,
+ LabelDate, VolJobs, VolFiles, VolBlocks,
+ VolMounts, VolBytes, VolErrors, VolWrites,
+ VolCapacityBytes, VolStatus, Recycle,
+ VolRetention, VolUseDuration, MaxVolJobs,
+ MaxVolFiles, MaxVolBytes,
+ InChanger, MediaAddressing,
+ VolReadTime, VolWriteTime,
+ EndFile, EndBlock)
+ SELECT * FROM Media_backup;
+
+DROP TABLE Media_backup;
+
+COMMIT;
+
+DELETE FROM Version;
+INSERT INTO Version (VersionId) VALUES (8);
+
+END-OF-DATA