The current maximum archive-id in posix copytool is
limited to id < LL_HSM_MAX_ARCHIVE. However, the Lustre HSM
implementation checks as follows for the maximum:
if (id > LL_HSM_MAX_ARCHIVE) then flag ERROR.
Thus the number of archive id's is in the
range 0,1,..,32 = LL_HSM_MAX_ARCHIVE, and therefore
32 = LL_HSM_MAX_ARCHIVE should be included.
Note, archive-id = 0 is reserved to specify to listen to
ANY archive id and is use as default when no archive-id
option is provided.
Test-Parameters: trivial testlist=sanity-hsm
Signed-off-by: Thomas Stibor <t.stibor@gsi.de>
Change-Id: I6289c8c0e7d86b05f1f2d821b7f6b3127e5fa352
Reviewed-on: https://review.whamcloud.com/30171
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
int o_verbose;
int o_copy_xattrs;
int o_archive_cnt;
int o_verbose;
int o_copy_xattrs;
int o_archive_cnt;
- int o_archive_id[LL_HSM_MAX_ARCHIVE];
+ int o_archive_id[LL_HSM_MAX_ARCHIVE + 1];
int o_report_int;
unsigned long long o_bandwidth;
size_t o_chunk_size;
int o_report_int;
unsigned long long o_bandwidth;
size_t o_chunk_size;
while ((c = getopt_long(argc, argv, "A:b:c:f:hiMp:qru:v",
long_opts, NULL)) != -1) {
switch (c) {
while ((c = getopt_long(argc, argv, "A:b:c:f:hiMp:qru:v",
long_opts, NULL)) != -1) {
switch (c) {
- case 'A':
- if ((opt.o_archive_cnt >= LL_HSM_MAX_ARCHIVE) ||
- (atoi(optarg) >= LL_HSM_MAX_ARCHIVE)) {
- rc = -E2BIG;
+ case 'A': {
+ char *end = NULL;
+ int val = strtol(optarg, &end, 10);
+
+ if (*end != '\0') {
+ rc = -EINVAL;
+ CT_ERROR(rc, "invalid archive-id: '%s'",
+ optarg);
+ return rc;
+ }
+
+ if (opt.o_archive_cnt > LL_HSM_MAX_ARCHIVE ||
+ val > LL_HSM_MAX_ARCHIVE) {
+ rc = -EINVAL;
CT_ERROR(rc, "archive number must be less"
CT_ERROR(rc, "archive number must be less"
- "than %zu", LL_HSM_MAX_ARCHIVE);
+ " than %zu", LL_HSM_MAX_ARCHIVE + 1);
- opt.o_archive_id[opt.o_archive_cnt] = atoi(optarg);
+ opt.o_archive_id[opt.o_archive_cnt] = val;
opt.o_archive_cnt++;
break;
opt.o_archive_cnt++;
break;
case 'b': /* -b and -c have both a number with unit as arg */
case 'c':
unit = ONE_MB;
case 'b': /* -b and -c have both a number with unit as arg */
case 'c':
unit = ONE_MB;