From: Kern Sibbald Date: Sat, 26 Sep 2009 14:46:06 +0000 (+0200) Subject: Implement store_size32 and store_size64 X-Git-Tag: Release-5.0.0~299^2~16 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5b6583c38af78bdd11114c43644ba940c2fc34e9;p=bacula%2Fbacula Implement store_size32 and store_size64 --- diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index f6f4225f07..86e73503a9 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -755,6 +755,7 @@ static bool check_resources() job_items[i].handler == store_jobtype || job_items[i].handler == store_level || job_items[i].handler == store_int32 || + job_items[i].handler == store_size32 || job_items[i].handler == store_migtype || job_items[i].handler == store_replace) { def_ivalue = (uint32_t *)((char *)(job->jobdefs) + offset); @@ -767,7 +768,7 @@ static bool check_resources() * Handle 64 bit integer fields */ } else if (job_items[i].handler == store_time || - job_items[i].handler == store_size || + job_items[i].handler == store_size64 || job_items[i].handler == store_int64) { def_lvalue = (int64_t *)((char *)(job->jobdefs) + offset); Dmsg5(400, "Job \"%s\", field \"%s\" def_lvalue=%" lld " item %d offset=%u\n", diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 0819e76abc..0517e4a9ab 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -314,7 +314,7 @@ RES_ITEM job_items[] = { {"enabled", store_bool, ITEM(res_job.enabled), 0, ITEM_DEFAULT, true}, {"spoolattributes",store_bool, ITEM(res_job.SpoolAttributes), 0, ITEM_DEFAULT, false}, {"spooldata", store_bool, ITEM(res_job.spool_data), 0, ITEM_DEFAULT, false}, - {"spoolsize", store_size, ITEM(res_job.spool_size), 0, 0, 0}, + {"spoolsize", store_size64, ITEM(res_job.spool_size), 0, 0, 0}, {"rerunfailedlevels", store_bool, ITEM(res_job.rerun_failed_levels), 0, ITEM_DEFAULT, false}, {"prefermountedvolumes", store_bool, ITEM(res_job.PreferMountedVolumes), 0, ITEM_DEFAULT, true}, {"runbeforejob", store_short_runscript, ITEM(res_job.RunScripts), 0, 0, 0}, @@ -386,13 +386,13 @@ static RES_ITEM pool_items[] = { {"maximumvolumes", store_pint32, ITEM(res_pool.max_volumes), 0, 0, 0}, {"maximumvolumejobs", store_pint32, ITEM(res_pool.MaxVolJobs), 0, 0, 0}, {"maximumvolumefiles", store_pint32, ITEM(res_pool.MaxVolFiles), 0, 0, 0}, - {"maximumvolumebytes", store_size, ITEM(res_pool.MaxVolBytes), 0, 0, 0}, + {"maximumvolumebytes", store_size64, ITEM(res_pool.MaxVolBytes), 0, 0, 0}, {"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}, {"migrationtime", store_time, ITEM(res_pool.MigrationTime), 0, 0, 0}, - {"migrationhighbytes", store_size, ITEM(res_pool.MigrationHighBytes), 0, 0, 0}, - {"migrationlowbytes", store_size, ITEM(res_pool.MigrationLowBytes), 0, 0, 0}, + {"migrationhighbytes", store_size64, ITEM(res_pool.MigrationHighBytes), 0, 0, 0}, + {"migrationlowbytes", store_size64, ITEM(res_pool.MigrationLowBytes), 0, 0, 0}, {"nextpool", store_res, ITEM(res_pool.NextPool), R_POOL, 0, 0}, {"storage", store_alist_res, ITEM(res_pool.storage), R_STORAGE, 0, 0}, {"autoprune", store_bool, ITEM(res_pool.AutoPrune), 0, ITEM_DEFAULT, true}, diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index 44ef2e0c35..b39eedf6bf 100644 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -206,11 +206,12 @@ static void init_resource(CONFIG *config, int type, RES_ITEM *items, int pass) } else if (items[i].handler == store_bool) { *(bool *)(items[i].value) = items[i].default_value != 0; } else if (items[i].handler == store_pint32 || - items[i].handler == store_int32) { + items[i].handler == store_int32 || + items[i].handler == store_size32) { *(uint32_t *)(items[i].value) = items[i].default_value; } else if (items[i].handler == store_int64) { *(int64_t *)(items[i].value) = items[i].default_value; - } else if (items[i].handler == store_size) { + } else if (items[i].handler == store_size64) { *(uint64_t *)(items[i].value) = (uint64_t)items[i].default_value; } else if (items[i].handler == store_time) { *(utime_t *)(items[i].value) = (utime_t)items[i].default_value; @@ -627,7 +628,7 @@ void store_int64(LEX *lc, RES_ITEM *item, int index, int pass) } /* Store a size in bytes */ -void store_size(LEX *lc, RES_ITEM *item, int index, int pass) +static void store_size(LEX *lc, RES_ITEM *item, int index, int pass, bool size32) { int token; uint64_t uvalue; @@ -656,7 +657,11 @@ void store_size(LEX *lc, RES_ITEM *item, int index, int pass) scan_err1(lc, _("expected a size number, got: %s"), lc->str); return; } - *(uint64_t *)(item->value) = uvalue; + if (size32) { + *(uint32_t *)(item->value) = (uint32_t)uvalue; + } else { + *(uint64_t *)(item->value) = uvalue; + } break; default: scan_err1(lc, _("expected a size, got: %s"), lc->str); @@ -669,6 +674,18 @@ void store_size(LEX *lc, RES_ITEM *item, int index, int pass) Dmsg0(900, "Leave store_size\n"); } +/* Store a size in bytes */ +void store_size32(LEX *lc, RES_ITEM *item, int index, int pass) +{ + store_size(lc, item, index, pass, true /* 32 bit */); +} + +/* Store a size in bytes */ +void store_size64(LEX *lc, RES_ITEM *item, int index, int pass) +{ + store_size(lc, item, index, pass, false /* not 32 bit */); +} + /* Store a time period in seconds */ void store_time(LEX *lc, RES_ITEM *item, int index, int pass) diff --git a/bacula/src/lib/parse_conf.h b/bacula/src/lib/parse_conf.h index 99d61ee369..c4711ed643 100644 --- a/bacula/src/lib/parse_conf.h +++ b/bacula/src/lib/parse_conf.h @@ -230,7 +230,8 @@ void store_int64(LEX *lc, RES_ITEM *item, int index, int pass); void store_bit(LEX *lc, RES_ITEM *item, int index, int pass); void store_bool(LEX *lc, RES_ITEM *item, int index, int pass); void store_time(LEX *lc, RES_ITEM *item, int index, int pass); -void store_size(LEX *lc, RES_ITEM *item, int index, int pass); +void store_size64(LEX *lc, RES_ITEM *item, int index, int pass); +void store_size32(LEX *lc, RES_ITEM *item, int index, int pass); void store_defs(LEX *lc, RES_ITEM *item, int index, int pass); void store_label(LEX *lc, RES_ITEM *item, int index, int pass); diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index 46d0d4a0f4..813a94c151 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -153,15 +153,15 @@ static RES_ITEM dev_items[] = { {"maximumrewindwait", store_time, ITEM(res_dev.max_rewind_wait), 0, ITEM_DEFAULT, 5 * 60}, {"minimumblocksize", store_pint32, ITEM(res_dev.min_block_size), 0, 0, 0}, {"maximumblocksize", store_maxblocksize, ITEM(res_dev.max_block_size), 0, 0, 0}, - {"maximumvolumesize", store_size, ITEM(res_dev.max_volume_size), 0, 0, 0}, - {"maximumfilesize", store_size, ITEM(res_dev.max_file_size), 0, ITEM_DEFAULT, 1000000000}, - {"volumecapacity", store_size, ITEM(res_dev.volume_capacity), 0, 0, 0}, + {"maximumvolumesize", store_size64, ITEM(res_dev.max_volume_size), 0, 0, 0}, + {"maximumfilesize", store_size64, ITEM(res_dev.max_file_size), 0, ITEM_DEFAULT, 1000000000}, + {"volumecapacity", store_size64, ITEM(res_dev.volume_capacity), 0, 0, 0}, {"maximumconcurrentjobs", store_pint32, ITEM(res_dev.max_concurrent_jobs), 0, 0, 0}, {"spooldirectory", store_dir, ITEM(res_dev.spool_directory), 0, 0, 0}, - {"maximumspoolsize", store_size, ITEM(res_dev.max_spool_size), 0, 0, 0}, - {"maximumjobspoolsize", store_size, ITEM(res_dev.max_job_spool_size), 0, 0, 0}, + {"maximumspoolsize", store_size64, ITEM(res_dev.max_spool_size), 0, 0, 0}, + {"maximumjobspoolsize", store_size64, ITEM(res_dev.max_job_spool_size), 0, 0, 0}, {"driveindex", store_pint32, ITEM(res_dev.drive_index), 0, 0, 0}, - {"maximumpartsize", store_size, ITEM(res_dev.max_part_size), 0, ITEM_DEFAULT, 0}, + {"maximumpartsize", store_size64, ITEM(res_dev.max_part_size), 0, ITEM_DEFAULT, 0}, {"mountpoint", store_strname,ITEM(res_dev.mount_point), 0, 0, 0}, {"mountcommand", store_strname,ITEM(res_dev.mount_command), 0, 0, 0}, {"unmountcommand", store_strname,ITEM(res_dev.unmount_command), 0, 0, 0}, @@ -250,13 +250,10 @@ static void store_devtype(LEX *lc, RES_ITEM *item, int index, int pass) */ static void store_maxblocksize(LEX *lc, RES_ITEM *item, int index, int pass) { - lex_get_token(lc, T_PINT32); - if (lc->pint32_val <= MAX_BLOCK_LENGTH) { - *(uint32_t *)(item->value) = lc->pint32_val; - scan_to_eol(lc); - set_bit(index, res_all.hdr.item_present); - } else { - scan_err2(lc, _("Maximum Block Size configured value %u is greater than allowed maximum: %u"), lc->pint32_val, MAX_BLOCK_LENGTH ); + store_size32(lc, item, index, pass); + if (*(uint32_t *)(item->value) > MAX_BLOCK_LENGTH) { + scan_err2(lc, _("Maximum Block Size configured value %u is greater than allowed maximum: %u"), + *(uint32_t *)(item->value), MAX_BLOCK_LENGTH ); } }