Suppress spurious warning on 1022 cylinder LBA partition and optimise a bit

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1110 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Luchezar Georgiev 2005-02-02 07:47:34 +00:00
parent 304aaa1428
commit 30ac4c1a01

View File

@ -348,6 +348,13 @@ void printCHS(char *title, struct CHS *chs)
printf("%s%4u-%u-%u", title, chs->Cylinder, chs->Head, chs->Sector); printf("%s%4u-%u-%u", title, chs->Cylinder, chs->Head, chs->Sector);
} }
STATIC VOID printStartEnd(struct CHS *chs, struct CHS *end)
{
printCHS(" start ", chs);
printCHS(", end ", end);
printf("\n");
}
/* /*
reason for this modules existence: reason for this modules existence:
@ -807,66 +814,45 @@ BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry,
return TRUE; return TRUE;
} }
BOOL is_suspect(struct CHS *chs, struct CHS *pEntry_chs) STATIC void warning_suspect(char *partitionName, struct CHS *chs,
struct CHS *pEntry_chs)
{ {
/* Valid entry: if (pEntry_chs->Cylinder != (chs->Cylinder & 0x3FF)
entry == chs || // partition entry equal to computed values || pEntry_chs->Head != chs->Head
(chs->Cylinder > 1023 && // or LBA partition || pEntry_chs->Sector != chs->Sector)
(entry->Cylinder == 1023 || {
entry->Cylinder == (0x3FF & chs->Cylinder))) printf("WARNING: %s", partitionName);
*/ printCHS(" has CHS=", chs);
return !((pEntry_chs->Cylinder == chs->Cylinder && printCHS(", not ", pEntry_chs);
pEntry_chs->Head == chs->Head && printf("\n");
pEntry_chs->Sector == chs->Sector) || memcpy(pEntry_chs, chs, sizeof(struct CHS));
chs->Cylinder > 1023u && }
(pEntry_chs->Cylinder == 1023 ||
pEntry_chs->Cylinder == (0x3ff & chs->Cylinder)));
} }
void print_warning_suspect(char *partitionName, UBYTE fs, struct CHS *chs, int ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type,
struct CHS *pEntry_chs)
{
printf("WARNING: using suspect partition %s FS %02x:", partitionName, fs);
printCHS(" with calculated values ", chs);
printCHS(" instead of ", pEntry_chs);
printf("\n");
memcpy(pEntry_chs, chs, sizeof(struct CHS));
}
BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type,
struct PartTableEntry * pEntry, ULONG startSector, struct PartTableEntry * pEntry, ULONG startSector,
int partitionsToIgnore, int extendedPartNo) int partitionsToIgnore, int extendedPartNo)
{ {
int i; int i;
struct CHS chs, end; struct CHS chs, end;
ULONG partitionStart; ULONG partitionStart;
char partitionName[12]; char partitionName[28];
for (i = 0; i < 4; i++, pEntry++) for (i = 0; i < 4; i++, pEntry++)
{ {
if (pEntry->FileSystem == 0) if (pEntry->FileSystem == 0
continue; || partitionsToIgnore & (1 << i)
|| IsExtPartition(pEntry->FileSystem)
if (partitionsToIgnore & (1 << i)) || scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable
continue; || !IsFATPartition(pEntry->FileSystem))
if (IsExtPartition(pEntry->FileSystem))
continue;
if (scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable)
continue; continue;
partitionStart = startSector + pEntry->RelSect; partitionStart = startSector + pEntry->RelSect;
if (!IsFATPartition(pEntry->FileSystem)) sprintf(partitionName, "partition %s:%d FS %02x",
{ extendedPartNo ? "Ext" : "Pri",
continue; extendedPartNo ? extendedPartNo : i + 1,
} pEntry->FileSystem);
if (extendedPartNo)
sprintf(partitionName, "Ext:%d", extendedPartNo);
else
sprintf(partitionName, "Pri:%d", i + 1);
/* /*
some sanity checks, that partition some sanity checks, that partition
@ -876,39 +862,25 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type,
LBA_to_CHS(&end, partitionStart + pEntry->NumSect - 1, driveParam); LBA_to_CHS(&end, partitionStart + pEntry->NumSect - 1, driveParam);
/* some FDISK's enter for partitions /* some FDISK's enter for partitions
> 8 GB cyl = 1023, other (cyl&1023) > 8 GB cyl = 1022 or 1023, other (cyl&1023)
*/ */
if (!IsLBAPartition(pEntry->FileSystem))
if (is_suspect(&chs, &pEntry->Begin))
{ {
print_warning_suspect(partitionName, pEntry->FileSystem, &chs, warning_suspect(partitionName, &chs, &pEntry->Begin);
&pEntry->Begin); warning_suspect(partitionName, &end, &pEntry->End);
} }
if (pEntry->NumSect == 0)
if (is_suspect(&end, &pEntry->End))
{ {
if (pEntry->NumSect == 0) printf("Not using %s with 0 sectors\n", partitionName);
{ continue;
printf("Not using partition %s with 0 sectors\n", partitionName);
continue;
}
print_warning_suspect(partitionName, pEntry->FileSystem, &end,
&pEntry->End);
} }
if (chs.Cylinder > 1023 || end.Cylinder > 1023) if (chs.Cylinder > 1023 || end.Cylinder > 1023)
{ {
if (!(driveParam->descflags & DF_LBA)) if (!(driveParam->descflags & DF_LBA))
{ {
printf printf("Can't use LBA %s without LBA support", partitionName);
("can't use LBA partition without LBA support - part %s FS %02x", printStartEnd(&chs, &end);
partitionName, pEntry->FileSystem);
printCHS(" start ", &chs);
printCHS(", end ", &end);
printf("\n");
continue; continue;
} }
@ -916,13 +888,10 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type,
&& !IsLBAPartition(pEntry->FileSystem)) && !IsLBAPartition(pEntry->FileSystem))
{ {
printf printf
("WARNING: Partition ID does not suggest LBA - part %s FS %02x.\n" ("WARNING: %s is not LBA\n"
"Please run FDISK to correct this - using LBA to access partition.\n", "Please run FDISK to correct this - using LBA to access partition.\n",
partitionName, pEntry->FileSystem); partitionName);
printStartEnd(&chs, &end);
printCHS(" start ", &chs);
printCHS(", end ", &end);
printf("\n");
pEntry->FileSystem = (pEntry->FileSystem == FAT12 ? FAT12_LBA : pEntry->FileSystem = (pEntry->FileSystem == FAT12 ? FAT12_LBA :
pEntry->FileSystem == FAT32 ? FAT32_LBA : pEntry->FileSystem == FAT32 ? FAT32_LBA :
/* pEntry->FileSystem == FAT16 ? */ /* pEntry->FileSystem == FAT16 ? */
@ -931,11 +900,9 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type,
/* else its a diagnostic message only */ /* else its a diagnostic message only */
#ifdef DEBUG #ifdef DEBUG
printf("found and using LBA partition %s FS %02x", printf("found and using LBA %s",
partitionName, pEntry->FileSystem); partitionName);
printCHS(" start ", &chs); printStartEnd(&chs, &end);
printCHS(", end ", &end);
printf("\n");
#endif #endif
} }