filestr_cache: Some more 64-bit sector_t fixes

This isn't strictly needed for FAT32, but the core file cache code
needs to be able to reference >32bit sector addresses.

Change-Id: I57838f1228c1d45f6a8c4755c5d1f9063c13b3dd
This commit is contained in:
Solomon Peachy 2024-11-11 10:36:02 -05:00
parent c67294913f
commit a4fe20a278
4 changed files with 8 additions and 4 deletions

View file

@ -206,7 +206,7 @@ static void handle_truncate(struct filestr_desc * const file, file_size_t size)
while ((s = fileobj_get_next_stream(&file->stream, s)))
{
/* caches with data beyond new extents are invalid */
unsigned long sector = s->cachep->sector;
sector_t sector = s->cachep->sector;
if (sector != INVALID_SECNUM && sector >= filesectors)
filestr_discard_cache(s);

View file

@ -2411,7 +2411,7 @@ void fat_filestr_init(struct fat_filestr *fatstr, struct fat_file *file)
fat_rewind(fatstr);
}
unsigned long fat_query_sectornum(const struct fat_filestr *filestr)
sector_t fat_query_sectornum(const struct fat_filestr *filestr)
{
/* return next sector number to be transferred */
struct bpb * const fat_bpb = FAT_BPB(filestr->fatfilep->volume);

View file

@ -51,7 +51,11 @@
/**
****************************************************************************/
#ifdef STORAGE_64BIT_SECTOR
#define INVALID_SECNUM (0xfffffffffffffffeull) /* sequential, not FAT */
#else
#define INVALID_SECNUM (0xfffffffeul) /* sequential, not FAT */
#endif
#define FAT_MAX_FILE_SIZE (0xfffffffful) /* 2^32-1 bytes */
#define MAX_DIRENTRIES 65536
#define MAX_DIRECTORY_SIZE (MAX_DIRENTRIES*32) /* 2MB max size */
@ -153,7 +157,7 @@ int fat_file_sector_size(const struct fat_file *file);
int fat_closewrite(struct fat_filestr *filestr, uint32_t size,
struct fat_direntry *fatentp);
void fat_filestr_init(struct fat_filestr *filestr, struct fat_file *file);
unsigned long fat_query_sectornum(const struct fat_filestr *filestr);
sector_t fat_query_sectornum(const struct fat_filestr *filestr);
long fat_readwrite(struct fat_filestr *filestr, unsigned long sectorcount,
void *buf, bool write);
void fat_rewind(struct fat_filestr *filestr);

View file

@ -54,8 +54,8 @@ enum filestr_cache_flags
struct filestr_cache
{
sector_t sector; /* file sector that is in buffer */
uint8_t *buffer; /* buffer to hold sector */
unsigned long sector; /* file sector that is in buffer */
unsigned int flags; /* FSC_* bits */
};