[fat] improve FAT32 boot record setup

* write primary and secondary boot records
* add offset provision for sector write
* improved detection reports for MBR, FAT16 and FAT32
This commit is contained in:
Pete Batard 2011-12-13 23:29:09 +00:00
parent 36fa9cee23
commit 0600005a09
4 changed files with 85 additions and 50 deletions

View file

@ -71,7 +71,12 @@ int read_sectors(HANDLE hDrive, size_t SectorSize,
return Size;
}
/* Use a bastardized fp that contains a Windows handle and the sector size */
/*
* The following calls use a bastardized fp on Windows that contains:
* fp->_ptr: a Windows handle
* fp->_bufsiz: the sector size
* fp->_cnt: a file offset
*/
int contains_data(FILE *fp, size_t Position,
const void *pData, size_t Len)
{
@ -79,6 +84,7 @@ int contains_data(FILE *fp, size_t Position,
HANDLE hDrive = (HANDLE)fp->_ptr;
size_t SectorSize = (size_t)fp->_bufsiz;
size_t StartSector, EndSector, NumSectors;
Position += (size_t)fp->_cnt;
StartSector = Position/SectorSize;
EndSector = (Position+Len+SectorSize-1)/SectorSize;
@ -107,6 +113,7 @@ int write_data(FILE *fp, size_t Position,
HANDLE hDrive = (HANDLE)fp->_ptr;
size_t SectorSize = (size_t)fp->_bufsiz;
size_t StartSector, EndSector, NumSectors;
Position += (size_t)fp->_cnt;
StartSector = Position/SectorSize;
EndSector = (Position+Len+SectorSize-1)/SectorSize;