]> git.sur5r.net Git - bacula/bacula/commitdiff
Add MaxVolBytes to Pool
authorKern Sibbald <kern@sibbald.com>
Fri, 22 Nov 2002 11:34:52 +0000 (11:34 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 22 Nov 2002 11:34:52 +0000 (11:34 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@206 91ce42f0-d328-0410-95d8-f526ca767f89

15 files changed:
bacula/ChangeLog
bacula/kernstodo
bacula/src/cats/cats.h
bacula/src/cats/make_mysql_tables.in
bacula/src/cats/make_sqlite_tables.in
bacula/src/cats/sql_create.c
bacula/src/cats/sql_get.c
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/query.sql
bacula/src/dird/ua_cmds.c
bacula/src/lib/parse_conf.c
bacula/src/lib/protos.h
bacula/src/lib/util.c
bacula/src/version.h

index 63f0f771001cfb0eb32ab566b2d219a5b0a3814d..33086159af0d747dc4ea5757d601c82d39dc5061 100644 (file)
@@ -1,5 +1,6 @@
 
-2002-mm-dd Version 1.27 (20Nov02) not yet released
+2002-mm-dd Version 1.27 (22Nov02) not yet released
+
 General: from kes21Nov02
 - Another change in the database. You MUST either re-initialize
   your database or use the appropriate ./alter_xxx_tables in
@@ -30,6 +31,8 @@ Changes submitted this submission:
 - Throw away any response longer than MAXSTRING.
 - Added a number of additional error checks on subroutine return statuses.
 - Replaced as many lld's with edit_uint64 as I could find.
+22Nov02:
+- Added MaxVolBytes to Pool record - had forgotten it. Updated DB version.
 
 General: from kes18Nov02
 - Did a number of cleanups of string copying to limit the length
index f91896693ccad97585386956d24059b718a702ed..15cc6460a7b85c19ccef681609b39dc78c29b04d 100644 (file)
@@ -1,5 +1,5 @@
                  Kern's ToDo List
-                 18 November 2002
+                 21 November 2002
 
 Documentation to do:
 - Document to have patience when SD first starts.
@@ -17,11 +17,11 @@ Testing to do:
 - make sure that update of volume new parameters works
 
 For 1.27 release:
-- drive MaxVolJobs, VolUseDuration from media record
-  rather than Resource.
-
+- Fix intmax_t on FreeBSD.
 
 After 1.27
+- Make Job err if WriteBootstrap fails.
+- Flush all the daemon messages at the end of every job.
 - Check if both CatalogFiles and UseCatalog are set to SD.
 - Check if we can bump Bacula FD priorty in Win2000
 - Implement FileOptions.
@@ -601,3 +601,5 @@ Done: (see kernsdone for more)
 - Make gethostbyname() thread safe in bnet.c
 - Add ORDER BY JobId to list of Jobs in query.sql, and in
   ua_output.c (list command).
+- drive MaxVolJobs, VolUseDuration from media record
+  rather than Resource.
index cd19edecdc1d6d61e1fc0333147fff74cde0eb5d..e14b8081825923de5da89e0b813980ed9896c0e0 100644 (file)
@@ -48,7 +48,7 @@ typedef int (DB_RESULT_HANDLER)(void *, int, char **);
 
 #ifdef HAVE_SQLITE
 
-#define BDB_VERSION 4
+#define BDB_VERSION 5
 
 #include <sqlite.h>
 
@@ -134,7 +134,7 @@ extern void my_sqlite_free_table(B_DB *mdb);
 
 #ifdef HAVE_MYSQL
 
-#define BDB_VERSION 4
+#define BDB_VERSION 5
 
 #include <mysql.h>
 
@@ -362,6 +362,7 @@ typedef struct {
    utime_t  VolUseDuration;           /* time in secs volume can be used */
    uint32_t MaxVolJobs;               /* Max Jobs on Volume */
    uint32_t MaxVolFiles;              /* Max files on Volume */
+   uint64_t MaxVolBytes;              /* Max bytes on Volume */
    char PoolType[MAX_NAME_LENGTH];             
    char LabelFormat[MAX_NAME_LENGTH];
    /* Extra stuff not in DB */
index e3f4c03ff49c1e80cb4845dcad11535cc6a80596..82ed241d3ad7cde069d084508b6fe72a02b82bbd 100644 (file)
@@ -127,6 +127,7 @@ CREATE TABLE Pool (
    VolUseDuration BIGINT UNSIGNED NOT NULL,
    MaxVolJobs INTEGER UNSIGNED NOT NULL,
    MaxVolFiles INTEGER UNSIGNED NOT NULL,
+   MaxVolBytes BIGINT UNSIGNED NOT NULL,
    AutoPrune TINYINT DEFAULT 0,
    Recycle TINYINT DEFAULT 0,
    PoolType ENUM('Backup', 'Copy', 'Cloned', 'Archive', 'Migration') NOT NULL,
index 8bac3c7a6a13c7b6e600c5a4180680a4afbdbeec..2695230b8d1a13c6f30701dba4894d1e4dd31622 100644 (file)
@@ -112,6 +112,7 @@ CREATE TABLE Media (
    VolUseDuration BIGINT UNSIGNED DEFAULT 0,
    MaxVolJobs INTEGER UNSIGNED DEFAULT 0,
    MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
+   MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
    PRIMARY KEY(MediaId)
    );
 
index 251f80c0179716e2a47bb8650969ef49edd29529..dd7e5adc57ee1e67aa71137ff7c42865cbe9618f 100644 (file)
@@ -162,7 +162,7 @@ int
 db_create_pool_record(B_DB *mdb, POOL_DBR *pr)
 {
    int stat;
-   char ed1[30], ed2[30];
+   char ed1[30], ed2[30], ed3[50];
 
    Dmsg0(200, "In create pool\n");
    db_lock(mdb);
@@ -186,8 +186,8 @@ db_create_pool_record(B_DB *mdb, POOL_DBR *pr)
    Mmsg(&mdb->cmd, 
 "INSERT INTO Pool (Name,NumVols,MaxVols,UseOnce,UseCatalog,\
 AcceptAnyVolume,AutoPrune,Recycle,VolRetention,VolUseDuration,\
-MaxVolJobs,MaxVolFiles,PoolType,LabelFormat) \
-VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,'%s','%s')", 
+MaxVolJobs,MaxVolFiles,MaxVolBytes,PoolType,LabelFormat) \
+VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s','%s')", 
                  pr->Name,
                  pr->NumVols, pr->MaxVols,
                  pr->UseOnce, pr->UseCatalog,
@@ -196,6 +196,7 @@ VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,'%s','%s')",
                  edit_uint64(pr->VolRetention, ed1),
                  edit_uint64(pr->VolUseDuration, ed2),
                  pr->MaxVolJobs, pr->MaxVolFiles,
+                 edit_uint64(pr->MaxVolBytes, ed3),
                  pr->PoolType, pr->LabelFormat);
    Dmsg1(200, "Create Pool: %s\n", mdb->cmd);
    if (!INSERT_DB(mdb, mdb->cmd)) {
index 40ff866f39300ab312eeabf2c0097b18ba8ebbe5..1f56e4023a07401f21e7950a2ddb5b764967a0b2 100644 (file)
@@ -483,12 +483,12 @@ int db_get_pool_record(B_DB *mdb, POOL_DBR *pdbr)
       Mmsg(&mdb->cmd, 
 "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,\
 AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,\
-PoolType,LabelFormat FROM Pool WHERE Pool.PoolId=%d", pdbr->PoolId);
+MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.PoolId=%d", pdbr->PoolId);
    } else {                          /* find by name */
       Mmsg(&mdb->cmd, 
 "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,\
 AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,\
-PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name);
+MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name);
    }  
 
    if (QUERY_DB(mdb, mdb->cmd)) {
@@ -516,8 +516,9 @@ PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name);
            pdbr->VolUseDuration = (utime_t)strtod(row[10], NULL);
            pdbr->MaxVolJobs = atoi(row[11]);
            pdbr->MaxVolFiles = atoi(row[12]);
-            bstrncpy(pdbr->PoolType, row[13]!=NULL?row[13]:"", sizeof(pdbr->PoolType));
-            bstrncpy(pdbr->LabelFormat, row[14]!=NULL?row[14]:"", sizeof(pdbr->LabelFormat));
+           pdbr->MaxVolBytes = (uint64_t)strtod(row[13], NULL);
+            bstrncpy(pdbr->PoolType, row[13]!=NULL?row[14]:"", sizeof(pdbr->PoolType));
+            bstrncpy(pdbr->LabelFormat, row[14]!=NULL?row[15]:"", sizeof(pdbr->LabelFormat));
            stat = pdbr->PoolId;
         }
       }
index f6dc17c82d34589823d30260de5050d213136fdb..3397cbaebf220618c10f36a2ad9aba53cc4d891a 100644 (file)
@@ -236,6 +236,7 @@ static struct res_items pool_items[] = {
    {"maximumvolumes",  store_pint,  ITEM(res_pool.max_volumes),     0, 0,        0},
    {"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_yesno, ITEM(res_pool.accept_any_volume), 1, ITEM_DEFAULT,     1},
    {"catalogfiles",    store_yesno, ITEM(res_pool.catalog_files),   1, ITEM_DEFAULT,  1},
    {"volumeretention", store_time,  ITEM(res_pool.VolRetention),    0, ITEM_DEFAULT, 60*60*24*365},
index 87ecba0c3c632432177bd167ef8f15ef1ce859b1..bb5c7b5a758fd18bf68999af8fe30d1af5b682bf 100644 (file)
@@ -248,8 +248,9 @@ struct s_res_pool {
    uint32_t max_volumes;              /* max number of volumes */
    utime_t VolRetention;              /* volume retention period in seconds */
    utime_t VolUseDuration;            /* duration volume can be used */
-   uint32_t MaxVolJobs;               /* Maximum jobs on the volume */
-   uint32_t MaxVolFiles;              /* Maximum files on the volume */
+   uint32_t MaxVolJobs;               /* Maximum jobs on the Volume */
+   uint32_t MaxVolFiles;              /* Maximum files on the Volume */
+   uint64_t MaxVolBytes;              /* Maximum bytes on the Volume */
    int   AutoPrune;                   /* default for pool auto prune */
    int   Recycle;                     /* default for media recycle yes/no */
 };
index 59c5b822d5fd3a6f7c6b360804d646d544e52a4a..5f86b0d9ae1e813525481df408f626e6b70f475a 100644 (file)
@@ -11,9 +11,9 @@ SELECT max(JobId) AS Jobs,sum(JobFiles) AS Files,
 SELECT Job.JobId, StartTime AS JobStartTime, VolumeName, Client.Name AS ClientName
  FROM Job,File,Path,Filename,Media,JobMedia,Client
  WHERE File.JobId=Job.JobId
- AND Path.Path="%1"
- AND Filename.Name="%2"
- AND Client.Name="%3"
+ AND Path.Path='%1'
+ AND Filename.Name='%2'
+ AND Client.Name='%3'
  AND Path.PathId=File.PathId
  AND Filename.FilenameId=File.FilenameId
  AND JobMedia.JobId=Job.JobId
@@ -28,9 +28,9 @@ SELECT Job.JobId, StartTime AS JobStartTime, VolumeName, Client.Name AS ClientNa
 SELECT Job.JobId, StartTime AS JobStartTime, VolumeName, Client.Name AS ClientName
  FROM Job,File,Path,Filename,Media,JobMedia,Client
  WHERE File.JobId=Job.JobId
- AND Path.Path="%1"
- AND Filename.Name="%2"
- AND Client.Name="%3"
+ AND Path.Path='%1'
+ AND Filename.Name='%2'
+ AND Client.Name='%3'
  AND Path.PathId=File.PathId
  AND Filename.FilenameId=File.FilenameId
  AND JobMedia.JobId=Job.JobId
@@ -38,30 +38,24 @@ SELECT Job.JobId, StartTime AS JobStartTime, VolumeName, Client.Name AS ClientNa
  AND Client.ClientId=Job.ClientId
  ORDER BY Job.StartTime DESC LIMIT 5;
 #
-:List total files/bytes by Job:
-SELECT count(*) AS Jobs, sum(JobFiles) AS Files,
- sum(JobBytes) AS Bytes, Name AS Job
- FROM Job GROUP by Name
-#
-:List total files/bytes by Volume:
-SELECT count(*) AS Jobs, sum(JobFiles) AS Files,
- sum(JobBytes) AS Bytes, VolumeName
- FROM Job,JobMedia,Media
- WHERE JobMedia.JobId=Job.JobId
- AND JobMedia.MediaId=Media.MediaId
- GROUP by VolumeName;  
-#
 :List last 20 Full Backups for a Client:
 *Enter Client name:
 Select Job.JobId,Client.Name as Client,StartTime,JobFiles,JobBytes,
 JobMedia.StartFile as VolFile, VolumeName
  FROM Client,Job,JobMedia,Media
- WHERE Client.Name="%1"
+ WHERE Client.Name='%1'
  AND Client.ClientId=Job.ClientId
  AND Level='F' AND JobStatus='T'
  AND JobMedia.JobId=Job.JobId AND JobMedia.MediaId=Media.MediaId
  ORDER BY JobId DESC LIMIT 20;
 #
+:List Volume Attributes for a selected Volume:
+*Enter Volume name:
+SELECT Slot,MaxVolBytes,VolCapacityBytes,VolStatus,Recycle,VolRetention,
+ VolUseDuration,MaxVolJobs,MaxVolFiles
+ FROM Media   
+ WHERE Volumename='%1';
+#
 :List Volumes used by selected JobId:
 *Enter JobId:
 SELECT Job.JobId,VolumeName 
@@ -93,7 +87,7 @@ CREATE TABLE temp2 (JobId INTEGER UNSIGNED NOT NULL,
 # Select last Full save
 INSERT INTO temp SELECT Job.JobId,JobTDate,Job.ClientId,Job.Level,
    StartTime,VolumeName,JobMedia.StartFile,VolSessionId,VolSessionTime
- FROM Client,Job,JobMedia,Media WHERE Client.Name="%1"
+ FROM Client,Job,JobMedia,Media WHERE Client.Name='%1'
  AND Client.ClientId=Job.ClientId
  AND Level='F' AND JobStatus='T'
  AND JobMedia.JobId=Job.JobId 
@@ -127,3 +121,17 @@ SELECT Job.JobId as JobId, Client.Name as Client,
  AND JobStatus='T' AND Job.JobId=File.JobId
  AND Path.PathId=File.PathId AND Filename.FilenameId=File.FilenameId
  AND Filename.Name='%1' ORDER BY Job.JobId LIMIT 20;
+#
+:List total files/bytes by Job:
+SELECT count(*) AS Jobs, sum(JobFiles) AS Files,
+ sum(JobBytes) AS Bytes, Name AS Job
+ FROM Job GROUP by Name
+#
+:List total files/bytes by Volume:
+SELECT count(*) AS Jobs, sum(JobFiles) AS Files,
+ sum(JobBytes) AS Bytes, VolumeName
+ FROM Job,JobMedia,Media
+ WHERE JobMedia.JobId=Job.JobId
+ AND JobMedia.MediaId=Media.MediaId
+ GROUP by VolumeName;  
+
index 999745f491912cabd72949ff044ea24e4dc0cca5..a47d2a85744b032c2fc6a12db4783a63778ea6a8 100644 (file)
@@ -265,6 +265,7 @@ getVolName:
    mr.VolUseDuration = pr.VolUseDuration;
    mr.MaxVolJobs = pr.MaxVolJobs;
    mr.MaxVolFiles = pr.MaxVolFiles;
+   mr.MaxVolBytes = pr.MaxVolBytes;
    for (i=startnum; i < num+startnum; i++) { 
       sprintf(mr.VolumeName, name, i);
       mr.Slot = slot++;
@@ -480,6 +481,7 @@ int create_pool(B_DB *db, POOL *pool)
    pr.VolUseDuration = pool->VolUseDuration;
    pr.MaxVolJobs = pool->MaxVolJobs;
    pr.MaxVolFiles = pool->MaxVolFiles;
+   pr.MaxVolBytes = pool->MaxVolBytes;
    pr.AutoPrune = pool->AutoPrune;
    if (pool->label_format) {
       strcpy(pr.LabelFormat, pool->label_format);
@@ -614,13 +616,14 @@ static int update_volume(UAContext *ua)
       add_prompt(ua, _("Volume Use Duration"));
       add_prompt(ua, _("Maximum Volume Jobs"));
       add_prompt(ua, _("Maximum Volume Files"));
+      add_prompt(ua, _("Maximum Volume Bytes"));
       add_prompt(ua, _("Recycle Flag"));
       add_prompt(ua, _("Slot"));
       add_prompt(ua, _("Done"));
       switch (do_prompt(ua, _("Select parameter to modify"), NULL, 0)) {
       case 0:                        /* Volume Status */
         /* Modify Volume Status */
-         bsendmsg(ua, _("Current value is: %s\n"), mr.VolStatus);
+         bsendmsg(ua, _("Current Volume status is: %s\n"), mr.VolStatus);
          start_prompt(ua, _("Possible Values are:\n"));
          add_prompt(ua, "Append");      /* Better not translate these as */
          add_prompt(ua, "Archive");     /* They are known in the database code */
@@ -640,11 +643,13 @@ static int update_volume(UAContext *ua)
            mr.VolStatus, mr.MediaId);
         if (!db_sql_query(ua->db, query, NULL, NULL)) {  
             bsendmsg(ua, "%s", db_strerror(ua->db));
-        }       
+        } else {
+            bsendmsg(ua, _("New Volume status is: %s\n"), mr.VolStatus);
+        }
         free_pool_memory(query);
         break;
       case 1:                        /* Retention */
-         bsendmsg(ua, _("Current value is: %s\n"),
+         bsendmsg(ua, _("Current retention seconds is: %s\n"),
            edit_utime(mr.VolRetention, ed1));
          if (!get_cmd(ua, _("Enter Volume Retention period: "))) {
            return 0;
@@ -658,12 +663,15 @@ static int update_volume(UAContext *ua)
            edit_uint64(mr.VolRetention, ed1), mr.MediaId);
         if (!db_sql_query(ua->db, query, NULL, NULL)) {  
             bsendmsg(ua, "%s", db_strerror(ua->db));
-        }       
+        } else {
+            bsendmsg(ua, _("New retention seconds is: %s\n"),
+              edit_utime(mr.VolRetention, ed1));
+        }
         free_pool_memory(query);
         break;
 
       case 2:                        /* Use Duration */
-         bsendmsg(ua, _("Current value is: %s\n"),
+         bsendmsg(ua, _("Current use duration is: %s\n"),
            edit_utime(mr.VolUseDuration, ed1));
          if (!get_cmd(ua, _("Enter Volume Use Duration: "))) {
            return 0;
@@ -677,13 +685,16 @@ static int update_volume(UAContext *ua)
            edit_uint64(mr.VolUseDuration, ed1), mr.MediaId);
         if (!db_sql_query(ua->db, query, NULL, NULL)) {  
             bsendmsg(ua, "%s", db_strerror(ua->db));
-        }       
+        } else {
+            bsendmsg(ua, _("New use duration is: %s\n"),
+              edit_utime(mr.VolUseDuration, ed1));
+        }
         free_pool_memory(query);
         break;
 
       case 3:                        /* Max Jobs */
         int32_t maxjobs;
-         bsendmsg(ua, _("Current value is: %u\n"), mr.MaxVolJobs);
+         bsendmsg(ua, _("Current max jobs is: %u\n"), mr.MaxVolJobs);
          if (!get_cmd(ua, _("Enter new Maximum Jobs: "))) {
            return 0;
         }
@@ -698,14 +709,14 @@ static int update_volume(UAContext *ua)
         if (!db_sql_query(ua->db, query, NULL, NULL)) {  
             bsendmsg(ua, "%s", db_strerror(ua->db));
         } else {
-            bsendmsg(ua, "New value is: %u\n", maxjobs);
+            bsendmsg(ua, _("New max jobs is: %u\n"), maxjobs);
         }
         free_pool_memory(query);
         break;
 
       case 4:                        /* Max Files */
         int32_t maxfiles;
-         bsendmsg(ua, _("Current value is: %u\n"), mr.MaxVolFiles);
+         bsendmsg(ua, _("Current max files is: %u\n"), mr.MaxVolFiles);
          if (!get_cmd(ua, _("Enter new Maximum Files: "))) {
            return 0;
         }
@@ -720,15 +731,36 @@ static int update_volume(UAContext *ua)
         if (!db_sql_query(ua->db, query, NULL, NULL)) {  
             bsendmsg(ua, "%s", db_strerror(ua->db));
         } else {
-            bsendmsg(ua, "New value is: %u\n", maxfiles);
+            bsendmsg(ua, _("New max files is: %u\n"), maxfiles);
+        }
+        free_pool_memory(query);
+        break;
+
+      case 5:                        /* Max Bytes */
+        uint64_t maxbytes;
+         bsendmsg(ua, _("Current value is: %s\n"), edit_uint64(mr.MaxVolBytes, ed1));
+         if (!get_cmd(ua, _("Enter new Maximum Bytes: "))) {
+           return 0;
+        }
+        if (!size_to_uint64(ua->cmd, strlen(ua->cmd), &maxbytes)) {
+            bsendmsg(ua, _("Invalid byte size specification.\n"));
+           break;
+        } 
+        query = get_pool_memory(PM_MESSAGE);
+         Mmsg(&query, "UPDATE Media SET MaxVolBytes=%s WHERE MediaId=%u",
+           edit_uint64(maxbytes, ed1), mr.MediaId);
+        if (!db_sql_query(ua->db, query, NULL, NULL)) {  
+            bsendmsg(ua, "%s", db_strerror(ua->db));
+        } else {
+            bsendmsg(ua, _("New Max bytes is: %s\n"), edit_uint64(maxbytes, ed1));
         }
         free_pool_memory(query);
         break;
 
 
-      case 5:                        /* Recycle */
+      case 6:                        /* Recycle */
         int recycle;
-         bsendmsg(ua, _("Current value is: %s\n"),
+         bsendmsg(ua, _("Current recycle flag is: %s\n"),
             mr.Recycle==1?_("yes"):_("no"));
          if (!get_cmd(ua, _("Enter new Recycle status: "))) {
            return 0;
@@ -746,13 +778,16 @@ static int update_volume(UAContext *ua)
            recycle, mr.MediaId);
         if (!db_sql_query(ua->db, query, NULL, NULL)) {  
             bsendmsg(ua, "%s", db_strerror(ua->db));
-        }       
+        } else {       
+            bsendmsg(ua, _("New recycle flag is: %s\n"),
+               mr.Recycle==1?_("yes"):_("no"));
+        }
         free_pool_memory(query);
         break;
 
-      case 6:                        /* Slot */
+      case 7:                        /* Slot */
         int slot;
-         bsendmsg(ua, _("Current value is: %d\n"), mr.Slot);
+         bsendmsg(ua, _("Current Slot is: %d\n"), mr.Slot);
          if (!get_cmd(ua, _("Enter new Slot: "))) {
            return 0;
         }
@@ -771,7 +806,7 @@ static int update_volume(UAContext *ua)
         if (!db_sql_query(ua->db, query, NULL, NULL)) {  
             bsendmsg(ua, "%s", db_strerror(ua->db));
         } else {
-            bsendmsg(ua, "New value is: %d\n", slot);
+            bsendmsg(ua, "New Slot is: %d\n", slot);
         }
         free_pool_memory(query);
         break;
@@ -814,10 +849,13 @@ static int update_pool(UAContext *ua)
    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;
    pr.MaxVolJobs = pool->MaxVolJobs;
    pr.MaxVolFiles = pool->MaxVolFiles;
+   pr.MaxVolBytes = pool->MaxVolBytes;
+
    if (pool->label_format) {
       strcpy(pr.LabelFormat, pool->label_format);
    } else {
@@ -1265,6 +1303,7 @@ gotVol:
       mr.VolUseDuration = pr.VolUseDuration;
       mr.MaxVolJobs = pr.MaxVolJobs;
       mr.MaxVolFiles = pr.MaxVolFiles;
+      mr.MaxVolBytes = pr.MaxVolBytes;
       if (db_create_media_record(ua->db, &mr)) {
          bsendmsg(ua, _("Media record for Volume=%s successfully created.\n"),
            mr.VolumeName);
index d1bf98d8b5ea3c36182b9f9a9aa526d5ddf54200..78b37d22344bff1211755a5dcef8ee5be4791d92 100755 (executable)
@@ -453,22 +453,9 @@ void store_int64(LEX *lc, struct res_items *item, int index, int pass)
 /* Store a size in bytes */
 void store_size(LEX *lc, struct res_items *item, int index, int pass)
 {
-   int token, i, ch;
-   double value;
-   int mod[]  = {'*', 'k', 'm', 'g', 0}; /* first item * not used */
-   uint64_t mult[] = {1,            /* byte */
-                     1024,          /* kilobyte */
-                     1048576,       /* megabyte */
-                     1073741824};   /* gigabyte */
-
-#ifdef we_have_a_compiler_that_works
-   int mod[]  = {'*', 'k', 'm', 'g', 't', 0};
-   uint64_t mult[] = {1,            /* byte */
-                     1024,          /* kilobyte */
-                     1048576,       /* megabyte */
-                     1073741824,    /* gigabyte */
-                     1099511627776};/* terabyte */
-#endif
+   int token;
+   double dvalue;
+   uint64_t uvalue;
 
    Dmsg0(400, "Enter store_size\n");
    token = lex_get_token(lc, T_ALL);
@@ -476,42 +463,18 @@ void store_size(LEX *lc, struct res_items *item, int index, int pass)
    switch (token) {
    case T_NUMBER:
       Dmsg2(400, "size num=:%s: %f\n", lc->str, strtod(lc->str, NULL)); 
-      value = strtod(lc->str, NULL);
+      dvalue = strtod(lc->str, NULL);
       if (errno != 0 || token < 0) {
          scan_err1(lc, "expected a size number, got: %s", lc->str);
       }
-      *(uint64_t *)(item->value) = (uint64_t)value;
+      *(uint64_t *)(item->value) = (uint64_t)dvalue;
       break;
    case T_IDENTIFIER:
    case T_UNQUOTED_STRING:
-      /* Look for modifier */
-      ch = lc->str[lc->str_len - 1];
-      i = 0;
-      if (B_ISALPHA(ch)) {
-        if (B_ISUPPER(ch)) {
-           ch = tolower(ch);
-        }
-        while (mod[++i] != 0) {
-           if (ch == mod[i]) {
-              lc->str_len--;
-              lc->str[lc->str_len] = 0; /* strip modifier */
-              break;
-           }
-        }
-      }
-      if (mod[i] == 0 || !is_a_number(lc->str)) {
-         scan_err1(lc, "expected a size number, got: %s", lc->str);
-      }
-      Dmsg3(400, "size str=:%s: %f i=%d\n", lc->str, strtod(lc->str, NULL), i);
-
-      value = (uint64_t)strtod(lc->str, NULL);
-      Dmsg1(400, "Int value = %d\n", (int)value);
-      if (errno != 0 || value < 0) {
+      if (!size_to_uint64(lc->str, lc->str_len, &uvalue)) {
          scan_err1(lc, "expected a size number, got: %s", lc->str);
       }
-      *(uint64_t *)(item->value) = (uint64_t)(value * mult[i]);
-      Dmsg2(400, "Full value = %f %" lld "\n", strtod(lc->str, NULL) * mult[i],
-         value *mult[i]);
+      *(uint64_t *)(item->value) = uvalue;
       break;
    default:
       scan_err1(lc, "expected a size, got: %s", lc->str);
index 2d19d305fcabfc44b439acd19fcbff109c574a3a..6466074891ee03b1350b39f1c5dcfd204660b684 100644 (file)
  */
 
 /* 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);
 
 /* bmisc.c */
-char     *bstrncpy               (char *dest, const char *src, int maxlen);
-char     *bstrncat               (char *dest, const char *src, int maxlen);
-void     *b_malloc               (char *file, int line, size_t size);
+char    *bstrncpy               (char *dest, const char *src, int maxlen);
+char    *bstrncat               (char *dest, const char *src, int maxlen);
+void    *b_malloc               (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, size_t size, const  char  *format, ...);
-int       bvsnprintf             (char *str, size_t size, const char  *format, va_list ap);
-int       pool_sprintf           (char *pool_buf, char *fmt, ...);
-void      create_pid_file        (char *dir, char *progname, int port);
-int       delete_pid_file        (char *dir, char *progname, int port);
+void    *brealloc               (void *buf, size_t size);
+void    *bcalloc                (size_t size1, size_t size2);
+int      bsnprintf              (char *str, size_t size, const  char  *format, ...);
+int      bvsnprintf             (char *str, size_t size, const char  *format, va_list ap);
+int      pool_sprintf           (char *pool_buf, char *fmt, ...);
+void     create_pid_file        (char *dir, char *progname, int port);
+int      delete_pid_file        (char *dir, char *progname, int port);
 
 
 /* bnet.c */
-int32_t    bnet_recv             (BSOCK *bsock);
-int        bnet_send             (BSOCK *bsock);
-int        bnet_fsend              (BSOCK *bs, char *fmt, ...);
-int        bnet_set_buffer_size    (BSOCK *bs, uint32_t size, int rw);
-int        bnet_sig                (BSOCK *bs, int sig);
-BSOCK *    bnet_connect            (void *jcr, int retry_interval,
-               int max_retry_time, char *name, char *host, char *service, 
-               int port, int verbose);
-int        bnet_wait_data         (BSOCK *bsock, int sec);
-void       bnet_close            (BSOCK *bsock);
-BSOCK *    init_bsock            (void *jcr, int sockfd, char *who, char *ip, int port);
-BSOCK *    dup_bsock             (BSOCK *bsock);
-void       term_bsock            (BSOCK *bsock);
-char *     bnet_strerror         (BSOCK *bsock);
-char *     bnet_sig_to_ascii     (BSOCK *bsock);
-int        bnet_wait_data        (BSOCK *bsock, int sec);
-int        bnet_despool          (BSOCK *bsock);
-int        is_bnet_stop          (BSOCK *bsock);
-int        is_bnet_error         (BSOCK *bsock);
+int32_t    bnet_recv            (BSOCK *bsock);
+int       bnet_send             (BSOCK *bsock);
+int       bnet_fsend              (BSOCK *bs, char *fmt, ...);
+int       bnet_set_buffer_size    (BSOCK *bs, uint32_t size, int rw);
+int       bnet_sig                (BSOCK *bs, int sig);
+BSOCK *    bnet_connect           (void *jcr, int retry_interval,
+              int max_retry_time, char *name, char *host, char *service, 
+              int port, int verbose);
+int       bnet_wait_data         (BSOCK *bsock, int sec);
+void      bnet_close            (BSOCK *bsock);
+BSOCK *    init_bsock           (void *jcr, int sockfd, char *who, char *ip, int port);
+BSOCK *    dup_bsock            (BSOCK *bsock);
+void      term_bsock            (BSOCK *bsock);
+char *    bnet_strerror         (BSOCK *bsock);
+char *    bnet_sig_to_ascii     (BSOCK *bsock);
+int       bnet_wait_data        (BSOCK *bsock, int sec);
+int       bnet_despool          (BSOCK *bsock);
+int       is_bnet_stop          (BSOCK *bsock);
+int       is_bnet_error         (BSOCK *bsock);
 
 
 /* cram-md5.c */
 int cram_md5_get_auth(BSOCK *bs, char *password);
 int cram_md5_auth(BSOCK *bs, char *password);
 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            ();
 
 /* lex.c */
-LEX *     lex_close_file         (LEX *lf);
-LEX *     lex_open_file          (LEX *lf, char *fname, LEX_ERROR_HANDLER *scan_error);
-int       lex_get_char           (LEX *lf);
-void      lex_unget_char         (LEX *lf);
-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, char *fname, LEX_ERROR_HANDLER *scan_error);
+int      lex_get_char           (LEX *lf);
+void     lex_unget_char         (LEX *lf);
+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[], char *name);
-void       init_msg              (void *jcr, MSGS *msg);
-void       term_msg              (void);
-void       close_msg             (void *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                  (void *jcr, int type, int level, char *fmt, ...);
-void       dispatch_message      (void *jcr, int type, int level, char *buf);
-void       init_console_msg      (char *wd);
-void       free_msgs_res         (MSGS *msgs);
-int        open_spool_file       (void *jcr, BSOCK *bs);
-int        close_spool_file      (void *vjcr, BSOCK *bs);
+void      my_name_is            (int argc, char *argv[], char *name);
+void      init_msg              (void *jcr, MSGS *msg);
+void      term_msg              (void);
+void      close_msg             (void *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                  (void *jcr, int type, int level, char *fmt, ...);
+void      dispatch_message      (void *jcr, int type, int level, char *buf);
+void      init_console_msg      (char *wd);
+void      free_msgs_res         (MSGS *msgs);
+int       open_spool_file       (void *jcr, BSOCK *bs);
+int       close_spool_file      (void *vjcr, BSOCK *bs);
 
 
 /* bnet_server.c */
-void       bnet_thread_server(char *bind_addr, int port, int max_clients, workq_t *client_wq, 
-                   void handle_client_request(void *bsock));
-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(char *bind_addr, int port, int max_clients, workq_t *client_wq, 
+                  void handle_client_request(void *bsock));
+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);
 
 /* 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);
 
 /* util.c */
-void             lcase                   (char *str);
-void             bash_spaces             (char *str);
-void             unbash_spaces           (char *str);
-void             strip_trailing_junk     (char *str);
-void             strip_trailing_slashes  (char *dir);
-int              skip_spaces             (char **msg);
-int              skip_nonspaces          (char **msg);
-int              fstrsch                 (char *a, char *b);
-char *           encode_time             (time_t time, char *buf);
-char *           encode_mode             (mode_t mode, char *buf);
-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              do_shell_expansion      (char *name);
-int              is_a_number             (const char *num);
-int              is_buf_zero             (char *buf, int len);
-int              duration_to_utime       (char *str, utime_t *value);
-char             *edit_utime             (utime_t val, char *buf);
-void             jobstatus_to_ascii      (int JobStatus, char *msg, int maxlen);
-void             pm_strcat               (POOLMEM **pm, char *str);
-void             pm_strcpy               (POOLMEM **pm, char *str);
-int              run_program             (char *prog, int wait, POOLMEM *results);
-char *           job_type_to_str         (int type);
-char *           job_status_to_str       (int stat);
-char *           job_level_to_str        (int level);
-void             makeSessionKey          (char *key, char *seed, int mode);
+void            lcase                   (char *str);
+void            bash_spaces             (char *str);
+void            unbash_spaces           (char *str);
+void            strip_trailing_junk     (char *str);
+void            strip_trailing_slashes  (char *dir);
+int             skip_spaces             (char **msg);
+int             skip_nonspaces          (char **msg);
+int             fstrsch                 (char *a, char *b);
+char *          encode_time             (time_t time, char *buf);
+char *          encode_mode             (mode_t mode, char *buf);
+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             do_shell_expansion      (char *name);
+int             is_a_number             (const char *num);
+int             is_buf_zero             (char *buf, int len);
+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);
+void            jobstatus_to_ascii      (int JobStatus, char *msg, int maxlen);
+void            pm_strcat               (POOLMEM **pm, char *str);
+void            pm_strcpy               (POOLMEM **pm, char *str);
+int             run_program             (char *prog, int wait, POOLMEM *results);
+char *          job_type_to_str         (int type);
+char *          job_status_to_str       (int stat);
+char *          job_level_to_str        (int level);
+void            makeSessionKey          (char *key, char *seed, int mode);
 
 
 
index 57fd42cd501f47cd5d7a6efd6a6541fc43bc0796..5fed0e9e91a8ff08d2b89e14c1d69470e50f82fa 100644 (file)
@@ -130,6 +130,63 @@ char *edit_utime(utime_t val, char *buf)
    return buf;
 }
 
+/*
+ * Convert a size size in bytes to uint64_t
+ * Returns 0: if error
+          1: if OK, and value stored in value
+ */
+int size_to_uint64(char *str, int str_len, uint64_t *rtn_value)
+{
+   int i, ch;
+   double value;
+   int mod[]  = {'*', 'k', 'm', 'g', 0}; /* first item * not used */
+   uint64_t mult[] = {1,            /* byte */
+                     1024,          /* kilobyte */
+                     1048576,       /* megabyte */
+                     1073741824};   /* gigabyte */
+
+#ifdef we_have_a_compiler_that_works
+   int mod[]  = {'*', 'k', 'm', 'g', 't', 0};
+   uint64_t mult[] = {1,            /* byte */
+                     1024,          /* kilobyte */
+                     1048576,       /* megabyte */
+                     1073741824,    /* gigabyte */
+                     1099511627776};/* terabyte */
+#endif
+
+   Dmsg0(400, "Enter sized to uint64\n");
+
+   /* Look for modifier */
+   ch = str[str_len - 1];
+   i = 0;
+   if (B_ISALPHA(ch)) {
+      if (B_ISUPPER(ch)) {
+        ch = tolower(ch);
+      }
+      while (mod[++i] != 0) {
+        if (ch == mod[i]) {
+           str_len--;
+           str[str_len] = 0; /* strip modifier */
+           break;
+        }
+      }
+   }
+   if (mod[i] == 0 || !is_a_number(str)) {
+      return 0;
+   }
+   Dmsg3(400, "size str=:%s: %f i=%d\n", str, strtod(str, NULL), i);
+
+   value = (uint64_t)strtod(str, NULL);
+   Dmsg1(400, "Int value = %d\n", (int)value);
+   if (errno != 0 || value < 0) {
+      return 0;
+   }
+   *rtn_value = (uint64_t)(value * mult[i]);
+   Dmsg2(400, "Full value = %f %" lld "\n", strtod(str, NULL) * mult[i],
+       value *mult[i]);
+   return 1;
+}
+
 /*
  * Check if specified string is a number or not.
  *  Taken from SQLite, cool, thanks.
index 45ffa96f4a9d0f71ca21963400260100caa937f0..3b76368cdbe30c770376ef7dfb07a07d140e1bab 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #define VERSION "1.27"
 #define VSTRING "1"
-#define DATE    "20 November 2002"
-#define LSMDATE "20Nov02"
+#define DATE    "22 November 2002"
+#define LSMDATE "22Nov02"
 
 /* Debug flags */
 #define DEBUG 1