]> git.sur5r.net Git - bacula/bacula/commitdiff
- ========= Remove Accept Any Volume ========= directive.
authorKern Sibbald <kern@sibbald.com>
Sat, 24 Jun 2006 07:53:36 +0000 (07:53 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 24 Jun 2006 07:53:36 +0000 (07:53 +0000)
- Major cleanup and simplification of regress using shell functions
  (more tests to be converted to new format)
- Add detection of 64 bit Irix as indicated by user.
- Increment catalog database id from 9 to 10.
- Add a few of the new database fields to the various C++
  structures.
- Implement code to fill in the most important new fields (e.g.
  Media Enable).
- Ensure that most of the new fields are in create/get/insert/update.
  More work to be done.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3067 91ce42f0-d328-0410-95d8-f526ca767f89

35 files changed:
bacula/autoconf/bacula-macros/os.m4
bacula/kernstodo
bacula/kes-1.39
bacula/src/cats/cats.h
bacula/src/cats/make_mysql_tables.in
bacula/src/cats/make_postgresql_tables.in
bacula/src/cats/make_sqlite3_tables.in
bacula/src/cats/make_sqlite_tables.in
bacula/src/cats/sql_find.c
bacula/src/cats/sql_get.c
bacula/src/cats/sql_list.c
bacula/src/cats/sql_update.c
bacula/src/cats/update_mysql_tables.in
bacula/src/cats/update_postgresql_tables.in
bacula/src/cats/update_sqlite3_tables.in
bacula/src/cats/update_sqlite_tables.in
bacula/src/console/console_conf.c
bacula/src/dird/autoprune.c
bacula/src/dird/bacula-dir.conf.in
bacula/src/dird/catreq.c
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/newvol.c
bacula/src/dird/next_vol.c
bacula/src/dird/protos.h
bacula/src/dird/recycle.c
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_dotcmds.c
bacula/src/dird/ua_label.c
bacula/src/dird/ua_prune.c
bacula/src/filed/filed_conf.c
bacula/src/gnome2-console/console_conf.c
bacula/src/lib/bsys.c
bacula/src/stored/stored_conf.c
bacula/src/wx-console/console_conf.c

index 0b1a3573c9b5b9ba6867912844e8669c2e86fbf4..25cfc69b65bc1d25c1e50b2b401f1cbc624fb757 100644 (file)
@@ -134,7 +134,7 @@ else
         BA_CONDITIONAL(HAVE_SGI_OS, $FALSEPRG)
 fi
 
-if test $HAVE_UNAME=yes -a x`uname -s` = xIRIX
+if test $HAVE_UNAME=yes -a x`uname -s` = xIRIX -o x`uname -s` = xIRIX64
 then
         BA_CONDITIONAL(HAVE_IRIX_OS, $TRUEPRG)
         AC_DEFINE(HAVE_IRIX_OS)
index 7f1169c55fd3f6653d319f389a854addf617b6c9..af6ae94c72605a1959c4477a8172d4fc490f1fa9 100644 (file)
@@ -42,6 +42,17 @@ For 1.39:
   Volume marked as purged.
 - Print warning message if LANG environment variable does not specify
   UTF-8.
+- New dot commands from Arno.
+  .update volume [enabled|disabled|*see below]
+  .show device=xxx lists information from one storage device, including 
+     devices (I'm not even sure that information exists in the DIR...)
+  .move eject device=xxx mostly the same as 'unmount xxx' but perhaps with 
+     better machine-readable output like "Ok" or "Error busy"
+  .move eject device=xxx toslot=yyy the same as above, but with a new 
+     target slot. The catalog should be updated accordingly.
+  .move transfer device=xxx fromslot=yyy toslot=zzz
+
+
 === Migration from David ===
 What I'd like to see: 
 
index 8570c3da75bd53bd6f9a9f6e0562c43556825071..750b5d8616c66075ad21b482ff85861609f64939 100644 (file)
@@ -2,6 +2,18 @@
                         Kern Sibbald
 
 General:
+24Jun06
+- ========= Remove Accept Any Volume ========= directive.
+- Major cleanup and simplification of regress using shell functions
+  (more tests to be converted to new format)   
+- Add detection of 64 bit Irix as indicated by user.
+- Increment catalog database id from 9 to 10.
+- Add a few of the new database fields to the various C++
+  structures.
+- Implement code to fill in the most important new fields (e.g.
+  Media Enable).
+- Ensure that most of the new fields are in create/get/insert/update.
+  More work to be done.
 22Jun06
 - Update some very old licenses in src/cats.
 - Modify the database format for handling Migration jobs:
index 598d514a057aebabe79806e8b4d44d3a715f7e36..c4766fc55cedceab5d0d02af7f8852ca8ac44d67 100644 (file)
@@ -67,7 +67,7 @@ typedef int (DB_RESULT_HANDLER)(void *, int, char **);
 
 #ifdef HAVE_SQLITE
 
-#define BDB_VERSION 9
+#define BDB_VERSION 10
 
 #include <sqlite.h>
 
@@ -175,7 +175,7 @@ SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb);
 #ifdef HAVE_SQLITE3
 
 
-#define BDB_VERSION 9
+#define BDB_VERSION 10
 
 #include <sqlite3.h>
 
@@ -290,7 +290,7 @@ SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb);
 
 #ifdef HAVE_MYSQL
 
-#define BDB_VERSION 9
+#define BDB_VERSION 10
 
 #include <mysql.h>
 
@@ -355,7 +355,7 @@ struct B_DB {
 
 #ifdef HAVE_POSTGRESQL
 
-#define BDB_VERSION 9
+#define BDB_VERSION 10
 
 #include <libpq-fe.h>
 
@@ -564,6 +564,7 @@ struct JOB_DBR {
    char cSchedTime[MAX_TIME_LENGTH];
    char cStartTime[MAX_TIME_LENGTH];
    char cEndTime[MAX_TIME_LENGTH];
+   char cRealEndTime[MAX_TIME_LENGTH];
    /* Extra stuff not in DB */
    int limit;                         /* limit records to display */
    faddr_t rec_addr;
@@ -703,9 +704,10 @@ struct MEDIA_DBR {
    char VolumeName[MAX_NAME_LENGTH];  /* Volume name */
    char MediaType[MAX_NAME_LENGTH];   /* Media type */
    DBId_t PoolId;                     /* Pool id */
-   time_t   FirstWritten;             /* Time Volume first written */
+   time_t   FirstWritten;             /* Time Volume first written this usage */
    time_t   LastWritten;              /* Time Volume last written */
    time_t   LabelDate;                /* Date/Time Volume labeled */
+   time_t   InitialWrite;             /* Date/Time Volume first written */
    int32_t  LabelType;                /* Label (Bacula/ANSI/IBM) */
    uint32_t VolJobs;                  /* number of jobs on this medium */
    uint32_t VolFiles;                 /* Number of files */
@@ -726,16 +728,17 @@ struct MEDIA_DBR {
    uint32_t MaxVolFiles;              /* Max files on Volume */
    int32_t  Recycle;                  /* recycle yes/no */
    int32_t  Slot;                     /* slot in changer */
+   int32_t  Enabled;                  /* 0=disabled, 1=enabled, 2=archived */
    int32_t  InChanger;                /* Volume currently in changer */
    DBId_t   StorageId;                /* Storage record Id */
    uint32_t EndFile;                  /* Last file on volume */
    uint32_t EndBlock;                 /* Last block on volume */
+   uint32_t RecycleCount;             /* Number of times recycled */
    char     VolStatus[20];            /* Volume status */
    DBId_t   DeviceId;                 /* Device where Vol last written */
    DBId_t   LocationId;               /* Where Volume is -- user defined */
    DBId_t   ScratchPoolId;            /* Where to move if scratch */
    DBId_t   RecyclePoolId;            /* Where to move when recycled */
-   int32_t  Enabled;                  /* disabled=0, enabled=1, archived=2 */
    /* Extra stuff not in DB */
    faddr_t rec_addr;                  /* found record address */
    /* Since the database returns times as strings, this is how we pass
@@ -744,6 +747,7 @@ struct MEDIA_DBR {
    char    cFirstWritten[MAX_TIME_LENGTH]; /* FirstWritten returned from DB */
    char    cLastWritten[MAX_TIME_LENGTH];  /* LastWritten returned from DB */
    char    cLabelDate[MAX_TIME_LENGTH];    /* LabelData returned from DB */
+   char    cInitialWrite[MAX_TIME_LENGTH]; /* InitialWrite returned from DB */
    bool    set_first_written;                
    bool    set_label_date;
 };
index 1baf407e1944734e0f6b6a58de9f4858df85db67..541e2d8863116e52c5eb0b66ce3e95a6142b0363 100644 (file)
@@ -306,7 +306,7 @@ CREATE TABLE Version (
    );
 
 -- Initialize Version           
-INSERT INTO Version (VersionId) VALUES (9);
+INSERT INTO Version (VersionId) VALUES (10);
 
 END-OF-DATA
 then
index 13d14d425515a73d825edbb5aa0ca739fe0d3a26..37fb52813e098bd5195fa49bed790997dbf59e05 100644 (file)
@@ -156,7 +156,7 @@ CREATE TABLE media
     endfile          integer     not null default 0,
     endblock         bigint      not null default 0,
     LocationId       integer              default 0,
-    recyclcount       integer    not null default 0,
+    recyclecount      integer    not null default 0,
     initialwrite      timestamp   without time zone,
     scratchpoolid     integer default 0,
     recyclepoolid     integer default 0,
@@ -336,7 +336,7 @@ INSERT INTO Status (JobStatus,JobStatusLong) VALUES
    ('p', 'Waiting on higher priority jobs');
 
 
-INSERT INTO Version (VersionId) VALUES (9);
+INSERT INTO Version (VersionId) VALUES (10);
 
 -- Make sure we have appropriate permissions
 
index a70a8fcc95d74108cc16233340e3208bf49f2589..12c635fd5585f14771f51cc90b5b7e47b002aa63 100644 (file)
@@ -325,7 +325,7 @@ INSERT INTO Status (JobStatus,JobStatusLong) VALUES
 
 
 -- Initialize Version           
-INSERT INTO Version (VersionId) VALUES (9);
+INSERT INTO Version (VersionId) VALUES (10);
 
 
 PRAGMA default_synchronous = OFF;
index a70a8fcc95d74108cc16233340e3208bf49f2589..12c635fd5585f14771f51cc90b5b7e47b002aa63 100644 (file)
@@ -325,7 +325,7 @@ INSERT INTO Status (JobStatus,JobStatusLong) VALUES
 
 
 -- Initialize Version           
-INSERT INTO Version (VersionId) VALUES (9);
+INSERT INTO Version (VersionId) VALUES (10);
 
 
 PRAGMA default_synchronous = OFF;
index 92f6a2bd227ca274723d9d4a0bf60b6ffc27c100..e11a0e0c5fa3d0588606fe4b106e7d4abeeacdac 100644 (file)
@@ -277,7 +277,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr
           "FirstWritten,LastWritten,VolStatus,InChanger,VolParts,"
           "LabelType "
           "FROM Media WHERE PoolId=%s AND MediaType='%s' AND VolStatus IN ('Full',"
-          "'Recycle','Purged','Used','Append') "
+          "'Recycle','Purged','Used','Append') AND Enabled=1 "
           "ORDER BY LastWritten LIMIT 1", 
           edit_int64(mr->PoolId, ed1), mr->MediaType);
      item = 1;
@@ -301,12 +301,14 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr
           "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
           "FirstWritten,LastWritten,VolStatus,InChanger,VolParts,"
           "LabelType "
-          "FROM Media WHERE PoolId=%s AND MediaType='%s' AND VolStatus='%s' "
+          "FROM Media WHERE PoolId=%s AND MediaType='%s' AND Enabled=1 "
+          "AND VolStatus='%s' "
           "%s "
           "%s LIMIT %d",
           edit_int64(mr->PoolId, ed1), mr->MediaType,
           mr->VolStatus, changer, order, item);
    }
+   Dmsg1(100, "fnextvol=%s\n", mdb->cmd);
    if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
       db_unlock(mdb);
       return 0;
@@ -361,6 +363,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr
    mr->InChanger = str_to_int64(row[20]);
    mr->VolParts = str_to_int64(row[21]);
    mr->LabelType = str_to_int64(row[22]);
+   mr->Enabled = 1;   /* ensured via query */
    sql_free_result(mdb);
 
    db_unlock(mdb);
index 567a18cd131c03dc81f80ec0228117d74e63e68c..4068dfbaec4d3447e64de421878812562b9c8aba 100644 (file)
@@ -274,7 +274,7 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
     } else {
       Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime,"
 "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus,"
-"Type,Level,ClientId,Name "
+"Type,Level,ClientId,Name,PriorJobId,RealEndTime "
 "FROM Job WHERE JobId=%s", 
           edit_int64(jr->JobId, ed1));
     }
@@ -304,6 +304,8 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    jr->JobLevel = (int)*row[11];
    jr->ClientId = str_to_uint64(row[12]!=NULL?row[12]:(char *)"");
    bstrncpy(jr->Name, row[13]!=NULL?row[13]:"", sizeof(jr->Name));
+   jr->PriorJobId = str_to_uint64(row[14]!=NULL?row[14]:(char *)"");
+   bstrncpy(jr->cRealEndTime, row[15]!=NULL?row[15]:"", sizeof(jr->cRealEndTime));
    sql_free_result(mdb);
 
    db_unlock(mdb);
@@ -860,7 +862,9 @@ bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
          "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
          "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,"
          "MaxVolFiles,Recycle,Slot,FirstWritten,LastWritten,InChanger,"
-         "EndFile,EndBlock,VolParts,LabelType,LabelDate,StorageId "
+         "EndFile,EndBlock,VolParts,LabelType,LabelDate,StorageId,"
+         "Enabled,LocationId,RecycleCount,InitialWrite,"
+         "ScratchPoolId,RecyclePoolId "
          "FROM Media WHERE MediaId=%s", 
          edit_int64(mr->MediaId, ed1));
    } else {                           /* find by name */
@@ -868,7 +872,9 @@ bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
          "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
          "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,"
          "MaxVolFiles,Recycle,Slot,FirstWritten,LastWritten,InChanger,"
-         "EndFile,EndBlock,VolParts,LabelType,LabelDate,StorageId "
+         "EndFile,EndBlock,VolParts,LabelType,LabelDate,StorageId,"
+         "Enabled,LocationId,RecycleCount,InitialWrite,"
+         "ScratchPoolId,RecyclePoolId "
          "FROM Media WHERE VolumeName='%s'", mr->VolumeName);
    }
 
@@ -917,6 +923,14 @@ bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
             bstrncpy(mr->cLabelDate, row[27]!=NULL?row[27]:"", sizeof(mr->cLabelDate));
             mr->LabelDate = (time_t)str_to_utime(mr->cLabelDate);
             mr->StorageId = str_to_int64(row[28]);
+            mr->Enabled = str_to_int64(row[29]);
+            mr->LocationId = str_to_int64(row[30]);
+            mr->RecycleCount = str_to_int64(row[31]);
+            bstrncpy(mr->cInitialWrite, row[32]!=NULL?row[32]:"", sizeof(mr->cInitialWrite));
+            mr->InitialWrite = (time_t)str_to_utime(mr->cInitialWrite);
+            mr->ScratchPoolId = str_to_int64(row[33]);
+            mr->RecyclePoolId = str_to_int64(row[34]);
+            
             ok = true;
          }
       } else {
index f61e751e309efd84086869b96a82489e93238aaf..ff71728cc332a181b4e5518197f91141a3b87966 100644 (file)
@@ -148,27 +148,29 @@ db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
          Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId,"
             "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs,"
             "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites,"
-            "VolCapacityBytes,VolStatus,Recycle,VolRetention,"
+            "VolCapacityBytes,VolStatus,Enabled,Recycle,VolRetention,"
             "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger,"
-            "EndFile,EndBlock,VolParts,LabelType,StorageId"
+            "EndFile,EndBlock,VolParts,LabelType,StorageId,DeviceId,"
+            "LocationId,RecycleCount,InitialWrite,ScratchPoolId,RecyclePoolId"
             " 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,"
+            "VolCapacityBytes,VolStatus,Enabled,Recycle,VolRetention,"
             "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger,"
-            "EndFile,EndBlock,VolParts,LabelType,StorageId"
+            "EndFile,EndBlock,VolParts,LabelType,StorageId,DeviceId,"
+            "LocationId,RecycleCount,InitialWrite,ScratchPoolId,RecyclePoolId"
             " FROM Media WHERE Media.PoolId=%s ORDER BY MediaId", 
             edit_int64(mdbr->PoolId, ed1));
       }
    } else {
       if (mdbr->VolumeName[0] != 0) {
-         Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus,"
+         Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus,Enabled,"
             "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten "
             "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName);
       } else {
-         Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus,"
+         Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus,Enabled,"
             "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten "
             "FROM Media WHERE Media.PoolId=%s ORDER BY MediaId", 
             edit_int64(mdbr->PoolId, ed1));
index c7cd9c80edf3f31004988aae8f93a2790181705d..736d94fb31ef44277bf438fe74ef1e8143cdeeba 100644 (file)
@@ -302,8 +302,9 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    time_t ttime;
    struct tm tm;
    int stat;
-   char ed1[50], ed2[50], ed3[50], ed4[50]; 
-   char ed5[50], ed6[50], ed7[50], ed8[50];
+   char ed1[50], ed2[50],  ed3[50],  ed4[50]; 
+   char ed5[50], ed6[50],  ed7[50],  ed8[50];
+   char ed9[50], ed10[50], ed11[50];
 
 
    Dmsg1(100, "update_media: FirstWritten=%d\n", mr->FirstWritten);
@@ -346,7 +347,8 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
         "VolWrites=%u,MaxVolBytes=%s,VolStatus='%s',"
         "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s,VolParts=%d,"
         "LabelType=%d,StorageId=%s,PoolId=%s,VolRetention=%s,VolUseDuration=%s,"
-        "MaxVolJobs=%d,MaxVolFiles=%d"
+        "MaxVolJobs=%d,MaxVolFiles=%d,Enabled=%d,LocationId=%s,"
+        "ScratchPoolId=%s,RecyclePoolId=%s,RecycleCount=%d"
         " WHERE VolumeName='%s'",
         mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
         mr->VolMounts, mr->VolErrors, mr->VolWrites,
@@ -361,6 +363,10 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
         edit_uint64(mr->VolRetention, ed7),
         edit_uint64(mr->VolUseDuration, ed8),
         mr->MaxVolJobs, mr->MaxVolFiles,
+        mr->Enabled, edit_uint64(mr->LocationId, ed9),
+        edit_uint64(mr->ScratchPoolId, ed10),
+        edit_uint64(mr->RecyclePoolId, ed11),
+        mr->RecycleCount,
         mr->VolumeName);
 
    Dmsg1(400, "%s\n", mdb->cmd);
index a892e392d07704c131cec36d9f43cbd15ade89ce..534eac78592b02b2cde56d7bcfaed879cbec09dc 100755 (executable)
@@ -36,7 +36,7 @@ CREATE TABLE Location (
 
 
 DELETE FROM Version;
-INSERT INTO Version (VersionId) VALUES (9);
+INSERT INTO Version (VersionId) VALUES (10);
 
 END-OF-DATA
 then
index b99f1fa05651cf6c18fc9853c82279153e5e90ac..88d4ed00d4fd976887ae766b01580451052bd4b4 100755 (executable)
@@ -35,8 +35,6 @@ UPDATE job SET PriorJobId=0;
 
 ALTER TABLE jobmedia DROP COLUMN Stripe;
 
-
-
 CREATE TABLE Location (
    LocationId SERIAL NOT NULL,
    Location TEXT NOT NULL,
@@ -45,7 +43,8 @@ CREATE TABLE Location (
 );
 
 
-INSERT INTO version (versionId) VALUES (9);
+DELETE FROM version;
+INSERT INTO version (versionId) VALUES (10);
 
 vacuum;
 
index 802a6b5f492cfe5a28775405d738e767c7c91bbc..d0871e5b3a6564778c61fd62145fc1dbde8fa507 100755 (executable)
@@ -222,7 +222,7 @@ CREATE TABLE Location (
  
 
 DELETE FROM Version;
-INSERT INTO Version (VersionId) VALUES (9);
+INSERT INTO Version (VersionId) VALUES (10);
 
 COMMIT;
 
index 802a6b5f492cfe5a28775405d738e767c7c91bbc..d0871e5b3a6564778c61fd62145fc1dbde8fa507 100755 (executable)
@@ -222,7 +222,7 @@ CREATE TABLE Location (
  
 
 DELETE FROM Version;
-INSERT INTO Version (VersionId) VALUES (9);
+INSERT INTO Version (VersionId) VALUES (10);
 
 COMMIT;
 
index 10dae2d3052b4da2729c950d847ddf5966617a88..8112adfac3c082293ec11a1c6882adad735a12d3 100644 (file)
@@ -82,7 +82,7 @@ static RES_ITEM cons_items[] = {
    {"tlscacertificatedir", store_dir,  ITEM(res_cons.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate", store_dir,       ITEM(res_cons.tls_certfile), 0, 0, 0},
    {"tlskey",         store_dir,       ITEM(res_cons.tls_keyfile), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 
@@ -99,7 +99,7 @@ static RES_ITEM dir_items[] = {
    {"tlscacertificatedir", store_dir,  ITEM(res_dir.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate", store_dir,       ITEM(res_dir.tls_certfile), 0, 0, 0},
    {"tlskey",         store_dir,       ITEM(res_dir.tls_keyfile), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /*
index e0214080d93d2f46c993b1d90c8b18bc7ed70666..0995b74ab67cd0a61d3d45d1065846b98bea6c62 100644 (file)
@@ -117,6 +117,10 @@ int prune_volumes(JCR *jcr)
       if (jcr->jr.PoolId != mr.PoolId) {
          continue;
       }
+      /* Don't prune archived volumes */
+      if (mr.Enabled == 2) {
+         continue;
+      }
       /* Prune only Volumes with status "Full", or "Used" */
       if (strcmp(mr.VolStatus, "Full")   == 0 ||
           strcmp(mr.VolStatus, "Used")   == 0) {
index 6b9283ea7b4d7413ee597dd3e6a62a59fda2d8e6..a6211b4ca978691f31e893774f761708af944ed9 100644 (file)
@@ -273,7 +273,6 @@ Pool {
   Recycle = yes                       # Bacula can automatically recycle Volumes
   AutoPrune = yes                     # Prune expired volumes
   Volume Retention = 365 days         # one year
-  Accept Any Volume = yes             # write on any volume in the pool
 }
 
 #
index 06ed35937b67a571390dbbfaaf11dbc71315a811..02514e8d498e435eca1f8e31edb7ee05410aa41e 100644 (file)
@@ -221,6 +221,9 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       if (label || mr.LabelDate == 0) {
          mr.LabelDate = jcr->start_time;
          mr.set_label_date = true;
+         if (mr.InitialWrite == 0) {
+            mr.InitialWrite = jcr->start_time;
+         }
          Dmsg2(400, "label=%d labeldate=%d\n", label, mr.LabelDate);
       } else {
          /*
index 77f59a8853d57c3f1428cbeed749a16831d43e45..8bd16ae9eb5978636c5c7e1495fc356498264f49 100644 (file)
@@ -332,7 +332,6 @@ static RES_ITEM pool_items[] = {
    {"maximumvolumejobs", store_pint,  ITEM(res_pool.MaxVolJobs),    0, 0,       0},
    {"maximumvolumefiles", store_pint, ITEM(res_pool.MaxVolFiles),   0, 0,       0},
    {"maximumvolumebytes", store_size, ITEM(res_pool.MaxVolBytes),   0, 0,       0},
-   {"acceptanyvolume", store_bool,    ITEM(res_pool.accept_any_volume), 0, ITEM_DEFAULT, true},
    {"catalogfiles",    store_bool,    ITEM(res_pool.catalog_files),  0, ITEM_DEFAULT, true},
    {"volumeretention", store_time,    ITEM(res_pool.VolRetention),   0, ITEM_DEFAULT, 60*60*24*365},
    {"volumeuseduration", store_time,  ITEM(res_pool.VolUseDuration), 0, 0, 0},
@@ -799,9 +798,9 @@ next_run:
    case R_POOL:
       sendit(sock, _("Pool: name=%s PoolType=%s\n"), res->res_pool.hdr.name,
               res->res_pool.pool_type);
-      sendit(sock, _("      use_cat=%d use_once=%d acpt_any=%d cat_files=%d\n"),
+      sendit(sock, _("      use_cat=%d use_once=%d cat_files=%d\n"),
               res->res_pool.use_catalog, res->res_pool.use_volume_once,
-              res->res_pool.accept_any_volume, res->res_pool.catalog_files);
+              res->res_pool.catalog_files);
       sendit(sock, _("      max_vols=%d auto_prune=%d VolRetention=%s\n"),
               res->res_pool.max_volumes, res->res_pool.AutoPrune,
               edit_utime(res->res_pool.VolRetention, ed1, sizeof(ed1)));
index 0108c6a997687ab76117f38b56256e65ac49f72a..23ff69d42d5571aa829a4682725121813c1fe984 100644 (file)
@@ -429,7 +429,6 @@ public:
    bool  use_catalog;                 /* maintain catalog for media */
    bool  catalog_files;               /* maintain file entries in catalog */
    bool  use_volume_once;             /* write on volume only once */
-   bool  accept_any_volume;           /* accept any volume */
    bool  purge_oldest_volume;         /* purge oldest volume */
    bool  recycle_oldest_volume;       /* attempt to recycle oldest volume */
    bool  recycle_current_volume;      /* attempt recycle of current volume */
index 354c5ddec2455f97c57a7eee4d6c6d933276b496..6a542caa4d7b5f0e0b40baf2429359e494a792be 100644 (file)
@@ -83,6 +83,7 @@ bool newVolume(JCR *jcr, MEDIA_DBR *mr)
          goto bail_out;
       }
       pr.NumVols++;
+      mr->Enabled = 1;
       if (db_create_media_record(jcr, jcr->db, mr) &&
          db_update_pool_record(jcr, jcr->db, &pr)) {
          db_unlock(jcr->db);
index 4b09c70ff4a9633887c6a40f02003cf160178996..129a8cbde0b87512866ca5b2dc7e1a965f61bd64 100644 (file)
@@ -62,14 +62,15 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create)
        *  1. Look for volume with "Append" status.
        */
       ok = db_find_next_volume(jcr, jcr->db, index, InChanger, mr);
-      Dmsg2(100, "catreq after find_next_vol ok=%d FW=%d\n", ok, mr->FirstWritten);
+      Dmsg4(100, "after find_next_vol index=%d ok=%d InChanger=%d Vstat=%s\n",
+            index, ok, InChanger, mr->VolStatus);
 
       if (!ok) {
          /*
           * 2. Try finding a recycled volume
           */
          ok = find_recycled_volume(jcr, InChanger, mr);
-         Dmsg2(100, "find_recycled_volume %d FW=%d\n", ok, mr->FirstWritten);
+         Dmsg2(100, "find_recycled_volume ok=%d FW=%d\n", ok, mr->FirstWritten);
          if (!ok) {
             /*
              * 3. Try recycling any purged volume
index 212abb247af84a62e598a3a355cd0025e52399d5..a687bb40657e784553e6cc34746f08c6ceef1f8e 100644 (file)
@@ -219,7 +219,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row);
 /* ua_prune.c */
 int prune_files(UAContext *ua, CLIENT *client);
 int prune_jobs(UAContext *ua, CLIENT *client, int JobType);
-int prune_volume(UAContext *ua, MEDIA_DBR *mr);
+bool prune_volume(UAContext *ua, MEDIA_DBR *mr);
 
 /* ua_purge.c */
 bool mark_media_purged(UAContext *ua, MEDIA_DBR *mr);
index b8d0fc9d5615fa9776c3852e3135f591ad697427..74b2a30d1e0adbc4db9025104abe60809b62b946 100644 (file)
@@ -70,7 +70,7 @@ bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
    const char *select =
           "SELECT MediaId,LastWritten FROM Media "
           "WHERE PoolId=%s AND Recycle=1 AND VolStatus='Purged' "
-          "AND MediaType='%s' %s"
+          "AND Enabled=1 AND MediaType='%s' %s"
           "ORDER BY LastWritten ASC,MediaId LIMIT 1";
 
    Dmsg0(100, "Enter recycle_oldest_purged_volume\n");
index 29feea937e5124b6f240893bb1b96f8f0855a52c..9b19f765c7aa17fbf0cecf6b1c16999dddc87f3f 100644 (file)
@@ -186,6 +186,7 @@ void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr)
    mr->MaxVolFiles = pr->MaxVolFiles;
    mr->MaxVolBytes = pr->MaxVolBytes;
    mr->LabelType = pr->LabelType;
+   mr->Enabled = 1;
 }
 
 
@@ -316,6 +317,7 @@ getVolName:
       mr.Slot = Slot++;
       mr.InChanger = InChanger;
       mr.StorageId = store->StorageId;
+      mr.Enabled = 1;
       Dmsg1(200, "Create Volume %s\n", mr.VolumeName);
       if (!db_create_media_record(ua->jcr, ua->db, &mr)) {
          bsendmsg(ua, "%s", db_strerror(ua->db));
@@ -483,7 +485,6 @@ void set_pooldbr_from_poolres(POOL_DBR *pr, POOL *pool, e_pool_op op)
    pr->LabelType = pool->LabelType;
    pr->UseOnce = pool->use_volume_once;
    pr->UseCatalog = pool->use_catalog;
-   pr->AcceptAnyVolume = pool->accept_any_volume;
    pr->Recycle = pool->Recycle;
    pr->VolRetention = pool->VolRetention;
    pr->VolUseDuration = pool->VolUseDuration;
index 5ddfd9e561a8ba61d199998ecab2c4058f111d1d..613d17c7ed91c215c2f85c8210a6f992c9751b6c 100644 (file)
@@ -342,7 +342,6 @@ static int defaultscmd(UAContext *ua, const char *cmd)
        bsendmsg(ua, "pool_type=%s", pool->pool_type);
        bsendmsg(ua, "label_format=%s", pool->label_format?pool->label_format:"");
        bsendmsg(ua, "use_volume_once=%d", pool->use_volume_once);
-       bsendmsg(ua, "accept_any_volume=%d", pool->accept_any_volume);
        bsendmsg(ua, "purge_oldest_volume=%d", pool->purge_oldest_volume);
        bsendmsg(ua, "recycle_oldest_volume=%d", pool->recycle_oldest_volume);
        bsendmsg(ua, "recycle_current_volume=%d", pool->recycle_current_volume);
index 9e2b7f46b5b0418daf5cc6edc5135ee39c40f7ed..1452489736ee4cfa01811f40f8a6c899228c3139 100644 (file)
@@ -682,6 +682,7 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
          mr->VolBytes = 1;               /* flag indicating Volume labeled */
          mr->InChanger = 1;
          mr->StorageId = ua->jcr->store->StorageId;
+         mr->Enabled = 1;
          if (db_create_media_record(ua->jcr, ua->db, mr)) {
             bsendmsg(ua, _("Catalog record for Volume \"%s\", Slot %d  successfully created.\n"),
             mr->VolumeName, mr->Slot);
index e074407e648b235ee9c323c5d350ccda1c0a910f..e6d65dd51225cc011e7216ae57787e5e5dd5d00b 100644 (file)
@@ -470,16 +470,21 @@ bail_out:
 /*
  * Prune a given Volume
  */
-int prune_volume(UAContext *ua, MEDIA_DBR *mr)
+bool prune_volume(UAContext *ua, MEDIA_DBR *mr)
 {
    POOLMEM *query = get_pool_memory(PM_MESSAGE);
    struct s_count_ctx cnt;
    struct s_file_del_ctx del;
-   int i, stat = 0;
+   int i;          
+   bool ok = false;
    JOB_DBR jr;
    utime_t now, period;
    char ed1[50];
 
+   if (mr->Enabled == 2) {
+      return false;                   /* Cannot prune archived volumes */
+   }
+
    db_lock(ua->db);
    memset(&jr, 0, sizeof(jr));
    memset(&del, 0, sizeof(del));
@@ -501,7 +506,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr)
       if (strcmp(mr->VolStatus, "Append") == 0 && verbose) {
          bsendmsg(ua, _("There are no Jobs associated with Volume \"%s\". Prune not needed.\n"),
             mr->VolumeName);
-         stat = 1;
+         ok = true;
          goto bail_out;
       }
       /* If volume not already purged, do so */
@@ -509,7 +514,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr)
          bsendmsg(ua, _("There are no Jobs associated with Volume \"%s\". Marking it purged.\n"),
             mr->VolumeName);
       }
-      stat = mark_media_purged(ua, mr);
+      ok = mark_media_purged(ua, mr);
       goto bail_out;
    }
 
@@ -583,11 +588,11 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr)
    }
    if (cnt.count == 0) {
       Dmsg0(200, "Volume is purged.\n");
-      stat = mark_media_purged(ua, mr);
+      ok = mark_media_purged(ua, mr);
    }
 
 bail_out:
    db_unlock(ua->db);
    free_pool_memory(query);
-   return stat;
+   return ok;
 }
index a58a8fef66917116b67ff9a7ad9b3c6d4b7cb448..e20709827dd6c89f7f4aa22c5a4b1721775641d1 100644 (file)
@@ -100,7 +100,7 @@ static RES_ITEM cli_items[] = {
    {"tlscacertificatedir",   store_dir,       ITEM(res_client.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate",        store_dir,       ITEM(res_client.tls_certfile), 0, 0, 0},
    {"tlskey",                store_dir,       ITEM(res_client.tls_keyfile), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /* Directors that can use our services */
@@ -119,7 +119,7 @@ static RES_ITEM dir_items[] = {
    {"tlskey",               store_dir,       ITEM(res_dir.tls_keyfile), 0, 0, 0},
    {"tlsdhfile",            store_dir,       ITEM(res_dir.tls_dhfile), 0, 0, 0},
    {"tlsallowedcn",         store_alist_str, ITEM(res_dir.tls_allowed_cns), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /* Message resource */
index fa9561ff65d84d6df233e5e2cfa367046a06b713..090189ad98ae74b0d9f4651d2480095427c29411 100644 (file)
@@ -75,7 +75,7 @@ static RES_ITEM dir_items[] = {
    {"tlscacertificatedir", store_dir,  ITEM(dir_res.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate", store_dir,       ITEM(dir_res.tls_certfile), 0, 0, 0},
    {"tlskey",         store_dir,       ITEM(dir_res.tls_keyfile), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 static RES_ITEM con_items[] = {
@@ -88,7 +88,7 @@ static RES_ITEM con_items[] = {
    {"tlscacertificatedir", store_dir,  ITEM(con_res.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate", store_dir,       ITEM(con_res.tls_certfile), 0, 0, 0},
    {"tlskey",         store_dir,       ITEM(con_res.tls_keyfile), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 static RES_ITEM con_font_items[] = {
@@ -96,7 +96,7 @@ static RES_ITEM con_font_items[] = {
    {"description", store_str,      ITEM(con_font.hdr.desc), 0, 0, 0},
    {"font",        store_str,      ITEM(con_font.fontface), 0, 0, 0},
    {"requiressl",  store_bit,    ITEM(con_font.require_ssl), 1, ITEM_DEFAULT, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 
index 5f4775fddbfe49ef3d045018a8e516a2d0a1d4d2..7ccfa0f9b3544838f99978b5120e04fb9b01222a 100644 (file)
@@ -367,7 +367,8 @@ void _v(char *file, int line, pthread_mutex_t *m)
 {
    int errstat;
 
-   if ((errstat=pthread_mutex_tryunlock(m)) == 0) {
+   /* Note, this trylock *should* fail if the mutex is locked */
+   if ((errstat=pthread_mutex_trylock(m)) == 0) {
       berrno be;
       e_msg(file, line, M_ERROR, 0, _("Mutex unlock not locked. ERR=%s\n"),
            be.strerror(errstat));
index 6d3db5e30ed3c2968979beb1fba81af2bbf79edc..51b7dd76b7e9fe57a3862a707921f5547ebfa187 100644 (file)
@@ -70,7 +70,7 @@ static RES_ITEM store_items[] = {
    {"tlskey",                store_dir,       ITEM(res_store.tls_keyfile), 0, 0, 0},
    {"tlsdhfile",             store_dir,       ITEM(res_store.tls_dhfile), 0, 0, 0},
    {"tlsallowedcn",          store_alist_str, ITEM(res_store.tls_allowed_cns), 0, 0, 0},
-   {NULL, NULL, 0, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 
@@ -89,7 +89,7 @@ static RES_ITEM dir_items[] = {
    {"tlskey",               store_dir,       ITEM(res_dir.tls_keyfile), 0, 0, 0},
    {"tlsdhfile",            store_dir,       ITEM(res_dir.tls_dhfile), 0, 0, 0},
    {"tlsallowedcn",         store_alist_str, ITEM(res_dir.tls_allowed_cns), 0, 0, 0},
-   {NULL, NULL, 0, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /* Device definition */
@@ -146,7 +146,7 @@ static RES_ITEM dev_items[] = {
    {"writepartcommand",      store_strname,ITEM(res_dev.write_part_command), 0, 0, 0},
    {"freespacecommand",      store_strname,ITEM(res_dev.free_space_command), 0, 0, 0},
    {"labeltype",             store_label,  ITEM(res_dev.label_type), 0, 0, 0},
-   {NULL, NULL, 0, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /* Autochanger definition */
@@ -156,7 +156,7 @@ static RES_ITEM changer_items[] = {
    {"device",            store_alist_res, ITEM(res_changer.device),   R_DEVICE, ITEM_REQUIRED, 0},
    {"changerdevice",     store_strname,   ITEM(res_changer.changer_name),    0, ITEM_REQUIRED, 0},
    {"changercommand",    store_strname,   ITEM(res_changer.changer_command), 0, ITEM_REQUIRED, 0},
-   {NULL, NULL, 0, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 
index b6c05f7151c080624a8eb50cb8942f4de59df569..fad7061772ceb6732641efba56e06a11dd3c2b3e 100644 (file)
@@ -20,7 +20,7 @@
  *     Kern Sibbald, January MM, September MM
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -87,7 +87,7 @@ static RES_ITEM cons_items[] = {
    {"tlscacertificatedir", store_dir,  ITEM(res_cons.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate", store_dir,       ITEM(res_cons.tls_certfile), 0, 0, 0},
    {"tlskey",         store_dir,       ITEM(res_cons.tls_keyfile), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 
@@ -104,7 +104,7 @@ static RES_ITEM dir_items[] = {
    {"tlscacertificatedir", store_dir,  ITEM(res_dir.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate", store_dir,       ITEM(res_dir.tls_certfile), 0, 0, 0},
    {"tlskey",         store_dir,       ITEM(res_dir.tls_keyfile), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /*