Index: branches/azimutz/CleanCut/i386/libsaio/disk.c =================================================================== --- branches/azimutz/CleanCut/i386/libsaio/disk.c (revision 367) +++ branches/azimutz/CleanCut/i386/libsaio/disk.c (revision 368) @@ -77,7 +77,6 @@ #include "efi.h" #include "efi_tables.h" -#define BPS 512 /* sector size of the device */ #define PROBEFS_SIZE BPS * 4 /* buffer size for filesystem probe */ #define CD_BPS 2048 /* CD-ROM block size */ #define N_CACHE_SECS (BIOS_LEN / BPS) /* Must be a multiple of 4 for CD-ROMs */ @@ -1697,7 +1696,7 @@ if(!p || !(*p)) return 0; // this volume must not be renamed, or option is malformed p+= strlen(str); // skip the "hd(n,m) " field - // multiple aliases can be found separated by a semicolon + // multiple aliases can be found separated by a semicolon. while(*p && *p != ';' && q<(szAlias+MAX_ALIAS_SIZE)) *q++=*p++; *q='\0'; Index: branches/azimutz/CleanCut/i386/libsaio/saio_types.h =================================================================== --- branches/azimutz/CleanCut/i386/libsaio/saio_types.h (revision 367) +++ branches/azimutz/CleanCut/i386/libsaio/saio_types.h (revision 368) @@ -147,6 +147,7 @@ char * i_buf; /* file load address */ }; +#define BPS 512 /* sector size of the device */ #define F_READ 0x1 /* file opened for reading */ #define F_WRITE 0x2 /* file opened for writing */ #define F_ALLOC 0x4 /* buffer allocated */ Index: branches/azimutz/CleanCut/i386/libsaio/msdos.c =================================================================== --- branches/azimutz/CleanCut/i386/libsaio/msdos.c (revision 367) +++ branches/azimutz/CleanCut/i386/libsaio/msdos.c (revision 368) @@ -54,8 +54,7 @@ #include "msdos.h" #define LABEL_LENGTH 11 -#define MAX_DOS_BLOCKSIZE 2048 -#define MAX_CACHE_BLOCKSIZE 32768 +#define MSDOS_CACHE_BLOCKSIZE BPS * 2 #define CLUST_FIRST 2/* reserved cluster range */ #define CLUST_RSRVD32 0x0ffffff8 /* reserved cluster range */ @@ -152,7 +151,7 @@ if (msdoscurrent == ih) { - CacheInit(ih, msdosclustersize); + CacheInit(ih, MSDOS_CACHE_BLOCKSIZE); return 0; } @@ -222,25 +221,34 @@ msdosclustersize = msdosbps * spc; msdoscurrent = ih; - - CacheInit(ih, msdosclustersize); + + CacheInit(ih, MSDOS_CACHE_BLOCKSIZE); free (buf); return 0; } static int -readSectorAligned(CICell ih, off_t readOffset, char *buf, int size) +readSector(CICell ih, off_t readOffset, char *buf, int size) { - long long sectorOffset = (uint64_t)readOffset / msdosclustersize * msdosclustersize; - long relOffset = readOffset % msdosclustersize; - char *cacheBuffer; + // Caching only FAT entries (4 bytes) by utlizing the cache with sector aligned read requests. + if (size < BPS) + { + long long sectorOffset = (uint64_t)readOffset / BPS * BPS; + long relOffset = readOffset % BPS; + char *cacheBuffer; + + cacheBuffer = malloc(MSDOS_CACHE_BLOCKSIZE); + CacheRead(ih, cacheBuffer, sectorOffset, MSDOS_CACHE_BLOCKSIZE, true); + bcopy(cacheBuffer + relOffset, buf, size); + free(cacheBuffer); + } + else + { + Seek(ih, readOffset); + Read(ih, (long)buf, size); + } - cacheBuffer = malloc(msdosclustersize); - CacheRead(ih, cacheBuffer, sectorOffset, msdosclustersize, true); - bcopy(cacheBuffer + relOffset, buf, size); - free(cacheBuffer); - - return 0; + return 0; } static int @@ -279,7 +287,8 @@ /* Read in "cluster" */ if (buf) { - readSectorAligned(ih, readOffset, (char *)buf, size); + Seek(ih, readOffset); + Read(ih, (long)buf, size); } /* Find first sector of FAT */ @@ -289,7 +298,7 @@ readOffset += ((uint64_t)*cluster * (uint64_t)msdosfatbits) / 8; /* Read one sector of the FAT */ - readSectorAligned(ih, readOffset, tmpbuf, 4); + readSector(ih, readOffset, tmpbuf, 4); switch (msdosfatbits) { case 32: