summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2024-11-11 10:36:02 -0500
committerSolomon Peachy <pizza@shaftnet.org>2024-11-11 10:38:58 -0500
commita4fe20a27806fe5cf40a2b62aec484a7fa3d09d1 (patch)
treeadc39782d3bfc221f59acf5cee1249687ddf75ce
parentc67294913fefa15dddfbde0b0a7cd09da8863aa8 (diff)
downloadrockbox-a4fe20a278.tar.gz
rockbox-a4fe20a278.zip
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
-rw-r--r--firmware/common/file.c2
-rw-r--r--firmware/drivers/fat.c2
-rw-r--r--firmware/export/fat.h6
-rw-r--r--firmware/include/file_internal.h2
4 files changed, 8 insertions, 4 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c
index 845fa44309..fe65f0fdd5 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -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);
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 7d6adcbe65..380139afcb 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -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);
diff --git a/firmware/export/fat.h b/firmware/export/fat.h
index 4ff93bcc3a..208a6e8a5b 100644
--- a/firmware/export/fat.h
+++ b/firmware/export/fat.h
@@ -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);
diff --git a/firmware/include/file_internal.h b/firmware/include/file_internal.h
index ec0c5d28f0..e1af0d5449 100644
--- a/firmware/include/file_internal.h
+++ b/firmware/include/file_internal.h
@@ -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 */
};