-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
- 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
Kern's ToDo List
- 18 November 2002
+ 21 November 2002
Documentation to do:
- Document to have patience when SD first starts.
- 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.
- 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.
#ifdef HAVE_SQLITE
-#define BDB_VERSION 4
+#define BDB_VERSION 5
#include <sqlite.h>
#ifdef HAVE_MYSQL
-#define BDB_VERSION 4
+#define BDB_VERSION 5
#include <mysql.h>
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 */
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,
VolUseDuration BIGINT UNSIGNED DEFAULT 0,
MaxVolJobs INTEGER UNSIGNED DEFAULT 0,
MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
+ MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
PRIMARY KEY(MediaId)
);
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);
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,
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)) {
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)) {
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;
}
}
{"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},
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 */
};
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
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
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
# 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
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;
+
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++;
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);
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 */
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;
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;
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;
}
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;
}
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;
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;
}
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;
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 {
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);
/* 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);
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);
*/
/* 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);
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.
/* */
#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