diff --git a/usr.bin/ctlstat/ctlstat.c b/usr.bin/ctlstat/ctlstat.c --- a/usr.bin/ctlstat/ctlstat.c +++ b/usr.bin/ctlstat/ctlstat.c @@ -402,12 +402,16 @@ continue; \ for (iotype = 0; iotype < CTL_STATS_NUM_TYPES; iotype++) { \ int lun = stats[i].item; \ + const char *target; \ if (lun >= targdata.ntargets) \ - errx(1, "LUN %u out of range", lun); \ + /* LUN is not associated with any target */ \ + target = ""; \ + else \ + target = targdata.targets[lun]; \ printf("iscsi_target_" #field "{" \ "lun=\"%u\",target=\"%s\",type=\"%s\"} %" PRIu64 \ "\n", \ - lun, targdata.targets[lun], iotypes[iotype], \ + lun, target, iotypes[iotype], \ stats[i].field[iotype]); \ } \ } \ @@ -421,14 +425,18 @@ uint64_t us; \ struct timespec ts; \ int lun = stats[i].item; \ + const char *target; \ if (lun >= targdata.ntargets) \ - errx(1, "LUN %u out of range", lun); \ + /* LUN is not associated with any target */ \ + target = ""; \ + else \ + target = targdata.targets[lun]; \ bintime2timespec(&stats[i].field[iotype], &ts); \ us = ts.tv_sec * 1000000 + ts.tv_nsec / 1000; \ printf("iscsi_target_" #field "{" \ "lun=\"%u\",target=\"%s\",type=\"%s\"} %" PRIu64 \ "\n", \ - lun, targdata.targets[lun], iotypes[iotype], us); \ + lun, target, iotypes[iotype], us); \ } \ } \