]> git.sur5r.net Git - bacula/bacula/commitdiff
- Incremented the release number because this version requires
authorKern Sibbald <kern@sibbald.com>
Wed, 22 Sep 2004 19:51:07 +0000 (19:51 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 22 Sep 2004 19:51:07 +0000 (19:51 +0000)
  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

39 files changed:
bacula/ChangeLog
bacula/ReleaseNotes
bacula/kernstodo
bacula/src/baconfig.h
bacula/src/bc_types.h
bacula/src/cats/cats.h
bacula/src/cats/make_mysql_tables.in
bacula/src/cats/make_postgresql_tables.in
bacula/src/cats/make_sqlite_tables.in
bacula/src/cats/protos.h
bacula/src/cats/sql_create.c
bacula/src/cats/sql_get.c
bacula/src/cats/sql_list.c
bacula/src/cats/update_mysql_tables.in
bacula/src/cats/update_postgresql_tables.in
bacula/src/cats/update_sqlite_tables.in
bacula/src/dird/dird.c
bacula/src/dird/msgchan.c
bacula/src/lib/alist.h
bacula/src/lib/attr.c
bacula/src/lib/bnet.c
bacula/src/lib/bpipe.c
bacula/src/lib/bsys.c
bacula/src/lib/cram-md5.c
bacula/src/lib/mem_pool.c
bacula/src/lib/mem_pool.h
bacula/src/lib/message.c
bacula/src/lib/protos.h
bacula/src/lib/signal.c
bacula/src/lib/util.c
bacula/src/stored/block.c
bacula/src/stored/bscan.c
bacula/src/stored/dev.h
bacula/src/stored/job.c
bacula/src/stored/spool.c
bacula/src/version.h
bacula/updatedb/update_mysql_tables_7_to_8 [new file with mode: 0755]
bacula/updatedb/update_postgresql_tables_7_to_8 [new file with mode: 0755]
bacula/updatedb/update_sqlite_tables_7_to_8 [new file with mode: 0755]

index 967eaeb087dd64baa37c845911c3feaa654b2101..d142365931a4dedf7984994d4bd9abeadd0eb36e 100644 (file)
@@ -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
index d2c531623e0dbc1fea404e32f8172c434ecd940d..8490f444d3f7a5b761e870263e86d692e0d1f563 100644 (file)
@@ -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
index 963aadbf6cacceab4e3f9e6c7f5c4e7f1c327d69..66f8605c7f90e9a193bb0edcb9b062aaf63c88b5 100644 (file)
@@ -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.
 
index 8802f16871a28be971cf9efe4cf28c0e9d9f0ef7..b11a446bca2c563d411f34d5370f45a49d4b4478 100644 (file)
@@ -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
 #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
 
@@ -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;
index ae356f4c03a6f0834dabdaabf95355265cfaf796..f11df93f632337ae79b3f127c7b0149d4c7b7ff6 100644 (file)
 #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 */
index 081760fbe12bbfb1371040a2e3438ccddd33d8f1..981d0671b57a513bccf48fe18cb0120e2340001e 100644 (file)
@@ -48,7 +48,7 @@ typedef int (DB_RESULT_HANDLER)(void *, int, char **);
 
 #ifdef HAVE_SQLITE
 
-#define BDB_VERSION 7
+#define BDB_VERSION 8
 
 #include <sqlite.h>
 
@@ -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 <mysql.h>
 
@@ -210,7 +210,7 @@ typedef struct s_db {
 
 #ifdef HAVE_POSTGRESQL
 
-#define BDB_VERSION 7
+#define BDB_VERSION 8
 
 #include <libpq-fe.h>
 
@@ -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 */
index 991c894fba518bd1341e36215180ecefeb698682..4a8b9623a020993e744a104ee218262ebc1d50b7 100644 (file)
@@ -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,
index f145ae6ed9c94dae13b5e04300e0ff64607a2060..47d5d40ca115304be5e294fa8b3fe4e86c1eba78 100644 (file)
@@ -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
index 93279ef901d72e94d1e9696a4da09a941512c61d..23657baef860cd8bdca823f7a38dc449628908ac 100644 (file)
@@ -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,     
index 234ebe93d85f395c14589202e1d0ebc1c25dab88..22ed9f6de655490457f6f61dc8c9fcf0a181013c 100644 (file)
@@ -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 */
index feb650b573835cd17384587619ca6841c6cc6b4b..937df6dab0e4c80ed4bff8d4923f7fdf4bd4de7a 100644 (file)
@@ -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;
 }
 
 
index e7e22d018f9cbd1b4652cea7b1d25db735e3565a..6b27b17ad55abf322af8203f85dd19fb605e7da6 100644 (file)
@@ -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 {
index 15e49fb6e739c2219294ccd3dda476c60c14de4f..c539bcb6c0286f1516fb5247923d095a249b4d3d 100644 (file)
@@ -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");
       }
 
index c87955612abc36f463f0396c69c32105e7e8f281..fcffada2af4fb642fe35a2509f18e791ed238f27 100755 (executable)
@@ -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 <<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
index d44e26e937d5e2380cbd6f821fc6c3b305e21ce0..d78bdca9e795ead68a9b0dbf0f342389e9fe4f6c 100755 (executable)
@@ -1,8 +1,9 @@
 #!/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 " "
@@ -11,8 +12,11 @@ bindir=@SQL_BINDIR@
 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
index 8c89385368b65cf1ee96f68570969c47fa73ad2d..c17478767a7a55db2deeb14290cf1987c1363e4f 100755 (executable)
@@ -1,8 +1,9 @@
 #!/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 " "
@@ -41,6 +42,8 @@ CREATE TEMPORARY TABLE Media_backup (
    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)
    );
 
@@ -51,7 +54,8 @@ INSERT INTO Media_backup SELECT
    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;
 
 
@@ -85,6 +89,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)
    );
 
@@ -97,118 +103,15 @@ INSERT INTO Media (
    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
index 6e36523d4e24cfa5eeaaf990d0dbd1f095580a8e..dda2443f7b38b4262de3f4662549c9b5a685fce4 100644 (file)
@@ -492,6 +492,18 @@ Without that I don't know who I am :-(\n"), configfile);
       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 */
@@ -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
index ee9fffb5a855780e44017f5ac473d55b50b29be1..36bd6a21d167f8bae93304f9e1b94ff631157b76 100644 (file)
@@ -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);
index baeaba3bf1e4db943a5a71a52364510db9f74c43..2e43d564dd29bc9bfa7076b38d1e238fa7b6b498 100644 (file)
@@ -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
 
index 3aee618880df32d60c4699e1c3ad430f3ba50464..43d590d86f174684b963803650c707e24be6a77e 100644 (file)
@@ -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++;
       }
    }
index ac65544ba82cdc4a1de78e5eef48b4e84536e3cd..b1dc54e9ac4ef971dc606751f9906957fb783c26 100644 (file)
@@ -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;
index 20cf5bee82f0572e83006b5e594bcee8b43622f7..c432f1c6d5057e0aafee629bb6308eaa2f208cf8 100644 (file)
@@ -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; i<bargc; i++) {
@@ -261,8 +261,8 @@ int run_program(char *prog, int wait, POOLMEM *results)
       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 {
index f81e91923e172db69a0322119e3f3b9ba18d3444..a4105affa6084c1ad864be60ff5ce80cd72b6de3 100644 (file)
@@ -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;
index 451d0f6d2048f8a0e777f80ce412d52879266a28..bee075113372cdaf8b371c2e48ed14ecb000350d 100644 (file)
@@ -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);
index 439085110ffeef15fb8a9348dbd7b4214c9cb09e..0a2624243c2afc1c804cd7b87cf39426f1b1a80d 100644 (file)
@@ -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$
  */
 #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);
index 62b508f99f610e61d54d7eb6c4b957e2ac1500ce..7d23bb20c873549127cbb4f0ae25f2c9f8f7eaf9 100644 (file)
@@ -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);
 };
index 0ef376010560722923f1a396895e594dd148ac47..cb0e0613a97501aebaa9986c8fc3dff70f4abdc4 100755 (executable)
@@ -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;
 
index 40f102437dbc1145caa3971db9d8aa3b0817f2f9..f4362acf8b9c6d8660fb3c2dbfd74cdf29b5a821 100644 (file)
 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 */
index b6ae5eafa190c8a410ba68892f1a58e2080d9cb8..f0e250f338f4e9386a620f95339ca0f624a56c4f 100644 (file)
@@ -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);
index 261292956f7bb1c6243df25b49b71cbe669bfbdd..d8c0a7245848162881bf4bbd6dde5f6a4c11300a 100644 (file)
@@ -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;
index 915cf6ee65b649a1da733e7f6fa849918e02b883..375145a94f37815cfe821eddcb9de6efe817dc43 100644 (file)
@@ -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 */
index 6e415d177aa516b51b4905b559dcda435026deba..969c99e83ec81d96896ce44ea667cf8eee3656c7 100644 (file)
@@ -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;
 }
+
index 4516c626c90e3252583b050ec604b650d8b49f15..adb7674af9be0eb03a0d7a1b3a39f9d329f463a5 100644 (file)
@@ -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 */
index e200cc9d2ec7d5da9f7c9468af6da3f4a3d47a92..d3654939f838826ec526b667f3cfb51f8da4b389 100644 (file)
@@ -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;
index 7a41338b7727cdfedcec865833bb02e0f0439eab..a69fbc19483635f980e93810df7d9d0b7a931d5c 100644 (file)
@@ -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;
index c67a74e251839cc9adc2c5965c0ae743ddef2a81..87aef8c1f87926340b1acdeeb2102fdc3a0277a3 100644 (file)
@@ -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 (executable)
index 0000000..f20681d
--- /dev/null
@@ -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 <<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
diff --git a/bacula/updatedb/update_postgresql_tables_7_to_8 b/bacula/updatedb/update_postgresql_tables_7_to_8
new file mode 100755 (executable)
index 0000000..03f2407
--- /dev/null
@@ -0,0 +1,27 @@
+#!/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
diff --git a/bacula/updatedb/update_sqlite_tables_7_to_8 b/bacula/updatedb/update_sqlite_tables_7_to_8
new file mode 100755 (executable)
index 0000000..6c66df3
--- /dev/null
@@ -0,0 +1,117 @@
+#!/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