[syslinux] [syslinux:disklib] disklib: make CHS calculation match core/fs/diskio.c

Michal Soltys soltys at ziu.info
Thu Oct 28 14:36:27 PDT 2010


On 10-10-13 23:44, Michal Soltys wrote:
> On 10-10-13 23:30, H. Peter Anvin wrote:
>> On 10/13/2010 08:36 AM, syslinux-bot for Michal Soltys wrote:
>>> Commit-ID: 9c8db7560e2dc83d1191bb2f90b4d4d0ae3d37d6
>>> Gitweb: 
>>> http://syslinux.zytor.com/commit/9c8db7560e2dc83d1191bb2f90b4d4d0ae3d37d6 
>>>
>>> Author: Michal Soltys<soltys at ziu.info>
>>> AuthorDate: Wed, 13 Oct 2010 10:57:36 +0200
>>> Committer: Michal Soltys<soltys at ziu.info>
>>> CommitDate: Wed, 13 Oct 2010 10:57:36 +0200
>>>
>>> disklib: make CHS calculation match core/fs/diskio.c
>>>
>>> Signed-off-by: Michal Soltys<soltys at ziu.info>
>>>
>>
>> I note that this code still:
>>
>> a) duplicates the code between read and write, and
> 
> Oki, I'll shrink it.
> 
>> b) doesn't check for CHS overflow.
>>
> 
> lbacnt set in disk_get_params() is always valid (if function is 
> successful), and it's checked at the very begining of read/write 
> functions (along with other sanity checks).
> 
> CHS check is no longer necessary, as CHS is used only if ebios == 0, and 
> that implies that lbacnt is calculated from valid geometry (cbios == 1) 
> or faked (1/1/1) in which lbacnt == 1.
> 
> I'll update the comments to make it more clear.
> 

The small patch covering above points (without venturing into 
diskio.c yet) is available for pulling.

git://git.hasevolq.net/syslinux.git disklibdev
45e8e56953e74c7bbcfdefd87e519a808e719d1f
disklib: clarify comments, remove redundant code, extra checks

1) The comment in disk_rdwr_common() is made more clear with reference
   to the validation of function arguments.

2) disk_rdwr_common() supports both reading and writing,
   disk_read_sectors() and disk_write_sectors() are tiny wrappers now.

3) disk_get_params() makes additional check regarding returned sector
   size - the value must be a power of 2.

4) disk_rdwr_common()'s initial checks adjusted




More information about the Syslinux mailing list