Pat Suwalski - 2013-12-13

I am attaching a solution to the problem.

The root of the problem is that a lot of the logic behind building the enclosure map and printing the disk list compares directly the adapter channel list with the physical disk enclosure number, like so:

if (device->device[k].enclosure == a->channel[j])

The problem is that one is a uint16_t and the other is a uint8_t. When an enclosure is not present, the value comes back as all-ones. So, the code was trying in numerous places to compare 0xffff with 0xff. Adjusting the struct so both members are uint16_t fixes this.

The patch also changes the output when no enclosure is present to put an asterisk as the enclosure ID in the output.

The output on the same machine now looks like this:

a0       PERC 5/i Integrated      encl:1 ldrv:2  batt:good
a0d0        19GiB RAID 5   1x4  DEGRADED
a0d1      5567GiB RAID 5   1x4  DEGRADED
a0e*s0     1863GiB  a0d0+ online   errs: media:0  other:28
a0e*s1     1863GiB  a0d0+ rebuild  errs: media:0  other:26
a0e*s2     1863GiB  a0d0+ online   errs: media:0  other:28
a0e*s3     1863GiB  a0d0+ online   errs: media:0  other:28