Hi!
2-Фев-2005 07:47 [EMAIL PROTECTED] (Luchezar Georgiev) wrote to
[EMAIL PROTECTED]:
LG> Suppress spurious warning on 1022 cylinder LBA partition and optimise a bit
Details, please.
LG> +++ initdisk.c 2 Feb 2005 07:47:34 -0000 1.33.2.5
LG> - /* Valid entry:
LG> - entry == chs || // partition entry equal to computed values
LG> - (chs->Cylinder > 1023 && // or LBA partition
LG> - (entry->Cylinder == 1023 ||
To support 1022, here you may replace ==1023 by >=1022.
LG> - entry->Cylinder == (0x3FF & chs->Cylinder)))
LG> - */
LG> - return !((pEntry_chs->Cylinder == chs->Cylinder &&
LG> - pEntry_chs->Head == chs->Head &&
LG> - pEntry_chs->Sector == chs->Sector) ||
LG> - chs->Cylinder > 1023u &&
LG> - (pEntry_chs->Cylinder == 1023 ||
LG> - pEntry_chs->Cylinder == (0x3ff & chs->Cylinder)));
LG> + if (pEntry_chs->Cylinder != (chs->Cylinder & 0x3FF)
LG> + || pEntry_chs->Head != chs->Head
LG> + || pEntry_chs->Sector != chs->Sector)
Non-equal replacement. But see below (*).
LG> +STATIC void warning_suspect(char *partitionName, struct CHS *chs,
LG> + struct CHS *pEntry_chs)
STATIC void warning_suspect(CStr partitionName, const struct CHS *chs,
>---------------------------^^^^----------------^^^^^
struct CHS *pEntry_chs)
LG> + if (pEntry->FileSystem == 0
LG> + || partitionsToIgnore & (1 << i)
LG> + || IsExtPartition(pEntry->FileSystem)
LG> + || scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable
LG> + || !IsFATPartition(pEntry->FileSystem))
LG> continue;
Last condition (!IsFATPartition()) includes also IsExtPartition() and
==0 checks, thus, IsExtPartition() and ==0 checks may be removed:
if (partitionsToIgnore & (1 << i)
|| scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable
|| !IsFATPartition(pEntry->FileSystem))
continue;
LG> /* some FDISK's enter for partitions
LG> - > 8 GB cyl = 1023, other (cyl&1023)
LG> + > 8 GB cyl = 1022 or 1023, other (cyl&1023)
Bart earlier explains this and gives link to URL with details, but
decised to remain only ==1023 check.
LG> */
LG> - if (is_suspect(&chs, &pEntry->Begin))
LG> + if (!IsLBAPartition(pEntry->FileSystem))
LG> {
LG> - print_warning_suspect(partitionName, pEntry->FileSystem, &chs,
LG> - &pEntry->Begin);
LG> + warning_suspect(partitionName, &chs, &pEntry->Begin);
LG> + warning_suspect(partitionName, &end, &pEntry->End);
LG> }
Non-equal replacement: here checked only non-LBA partitions ((*) this
explains condition simplification in warning_suspect()), LBA partitions
doesn't checked at all (neither 1023, nor 1022), even if they completely
inside 1023 cylinder. If this replacement valid, it should be commented.
LG> + if (pEntry->NumSect == 0)
LG> {
LG> + printf("Not using %s with 0 sectors\n", partitionName);
LG> + continue;
LG> }
This check should be moved above, before LBA_to_CHS() calls.
Well, my edition for this function (note: partitionStart replaced by
startSector):
______________O\_/_________________________________\_/O______________
for (i = 0; i < 4; i++, pEntry++)
{
if (partitionsToIgnore & (1 << i)
|| scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable
|| !IsFATPartition(pEntry->FileSystem))
continue;
sprintf(partitionName, "partition %s:%d (ID %02x)",
>-------------------------------------------^^^^^^^^^
extendedPartNo ? "Ext" : "Pri",
extendedPartNo ? extendedPartNo : i + 1,
pEntry->FileSystem);
/* sanity checks, that partition structure is OK */
if (pEntry->NumSect == 0)
{
printf("Not using %s with 0 sectors\n", partitionName);
continue;
}
startSector += pEntry->RelSect;
LBA_to_CHS(&chs, startSector, driveParam);
LBA_to_CHS(&end, startSector + pEntry->NumSect - 1, driveParam);
>--------------------^^^^^^^^^^^
/* For LBA partitions above 1023 cylinder only NumSect field is used:
into 10-bit field for cylinder in partition entry usually placed
low 10-bit of real value or some fake value (like 1022 or 1023).
Thus, we skip CHS validness check for LBA partitions, even if
they completely lie below 1024 cylinder.
*/
if (!IsLBAPartition(pEntry->FileSystem))
{
warning_suspect(partitionName, &chs, &pEntry->Begin);
warning_suspect(partitionName, &end, &pEntry->End);
}
if (chs.Cylinder > 1023 || end.Cylinder > 1023)
{
[...]
DosDefinePartition(driveParam, startSector, pEntry, extendedPartNo, i);
>----------------------------------^^^^^^^^^^^
_____________________________________________________________________
O/~\ /~\O
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Freedos-kernel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel