|
to 不点大人
if (mem == -1ULL)
{
query_block_entries = -1; /* query block list only */
blocklist_func (to_drive, flags);
if (errnum)
return 0;
if (query_block_entries != 1 && mem == -1ULL)
return ! (errnum = ERR_NON_CONTIGUOUS);
start_sector = map_start_sector; /* in big 2048-byte sectors */
//sector_count = map_num_sectors;
sector_count = (filemax + 0x1ff) >> SECTOR_BITS; /* in small 512-byte sectors */
====================================
if (start_sector == part_start && part_start && sector_count == 1)
sector_count = part_length;
}
之后“
bytes_needed = sector_count << SECTOR_BITS;
if (bios_drive_map.to_drive == 0xFF && !(bios_drive_map.to_cylinder & 0x4000))
{
unsigned long long drvbase, drvend;
drvbase = (bios_drive_map.start_sector << SECTOR_BITS);
drvend = (bios_drive_map.sector_count << SECTOR_BITS) + drvbase;
=================================
drvend = ((drvend+4095)&(-4096ULL));/* 4KB alignment, round up */
============================
drvbase &= (-4096ULL); /* 4KB alignment, round down */
sector_count = (filemax + 0x1ff) >> SECTOR_BITS
取整时已经多取了字节。(实际这种取整的方式也不好,filemax 如果很大,+0x1ff会越界)
之后:
(bios_drive_map.sector_count << SECTOR_BITS)
这时计算有差错不?
[ 本帖最后由 zw2312914 于 2012-2-23 03:07 编辑 ] |
|