Re: [PATCH] Fix cdrom profile enumeration.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 15, 2010 at 1:43 AM, Martin Pitt <martin.pitt@xxxxxxxxxx> wrote:
> Hello Mike,
>
> mike@xxxxxxxxxxxxx [2010-04-14 20:38 -0500]:
>> -     for (i = 12; i < profiles[11]; i += 4) {
>> +     profiles_end = 12 + profiles[11];
>> +     for (i = 12; i < profiles_end; i += 4) {
>
> (This could just be written as "i < 12 + profiles[11]" for simplicity)

I started with that, but GCC was giving me a warning, so I changed it
to what is currently in the patch.  The profiles array is an array of
bytes, so we just needed to either store or cast it as something
larger.

>
> Do you have some pointers which document this structure, in particular
> whether it's really the count and not the last offset? I searched for
> some minutes, but didn't find anything. It would be nice to add a
> reference to the spec to the code.
>

The document I referenced was [1].  Section 10.6.2.1 states that the
"Additional Length field shall be set to ((number of Profile
Descriptors) * 4)."  The size of the feature header is 8 bytes, and we
assume that feature 0 (the profile list) directly follows this.  This
adds 4 bytes, which is how you get the 12 byte start.  You can see
that the size of each profile descriptor is 4 bytes, so it follows
that this is an offset from 12.

In my testing, the git version would not enumerate all available
profiles, whereas this patch would.  I think this went unnoticed
because there is a second set of code (cd_capability_compat) that
checks for what types of media the drive supports, so the information
was still available.

Mike

[1] http://www.t10.org/ftp/t10/document.97/97-263r0.pdf
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux