diff --git a/source/fatfile.c b/source/fatfile.c index 0132204..d24f54e 100644 --- a/source/fatfile.c +++ b/source/fatfile.c @@ -43,6 +43,8 @@ #include "filetime.h" #include "lock.h" +#include + int _FAT_open_r (struct _reent *r, void *fileStruct, const char *path, int flags, int mode) { PARTITION* partition = NULL; bool fileExists; diff --git a/source/fatfile.h b/source/fatfile.h index 0b26455..448a5ee 100644 --- a/source/fatfile.h +++ b/source/fatfile.h @@ -55,16 +55,16 @@ struct _FILE_STRUCT { uint32_t currentPosition; FILE_POSITION rwPosition; FILE_POSITION appendPosition; - bool read; - bool write; - bool append; - bool inUse; - bool modified; DIR_ENTRY_POSITION dirEntryStart; // Points to the start of the LFN entries of a file, or the alias for no LFN DIR_ENTRY_POSITION dirEntryEnd; // Always points to the file's alias entry PARTITION* partition; struct _FILE_STRUCT* prevOpenFile; // The previous entry in a double-linked list of open files struct _FILE_STRUCT* nextOpenFile; // The next entry in a double-linked list of open files + bool read; + bool write; + bool append; + bool inUse; + bool modified; }; typedef struct _FILE_STRUCT FILE_STRUCT; diff --git a/source/partition.c b/source/partition.c index 84addd8..3384c06 100644 --- a/source/partition.c +++ b/source/partition.c @@ -222,6 +222,7 @@ PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cach // There are currently no open files on this partition partition->openFileCount = 0; + partition->firstOpenFile = NULL; return partition; } diff --git a/source/partition.h b/source/partition.h index b3d18d1..b0cfea7 100644 --- a/source/partition.h +++ b/source/partition.h @@ -51,7 +51,6 @@ typedef struct { const DISC_INTERFACE* disc; CACHE* cache; // Info about the partition - bool readOnly; // If this is set, then do not try writing to the disc FS_TYPE filesysType; uint64_t totalSize; sec_t rootDirStart; @@ -67,6 +66,7 @@ typedef struct { int openFileCount; struct _FILE_STRUCT* firstOpenFile; // The start of a linked list of files mutex_t lock; // A lock for partition operations + bool readOnly; // If this is set, then do not try writing to the disc } PARTITION; /*