When building with VisualGDB the compilation fails due to the lack of required include files Dir.h and File.h.
Compiler report:
1>------ Build started: Project: exported-mbed-STM32F429-nucleo, Configuration: Debug VisualGDB ------
1> FileSystem.cpp
1> mbed-os/features/filesystem/FileSystem.cpp: In instantiation of 'class Managed<mbed::File>':
1> mbed-os\features\filesystem\FileSystem.cpp(141,19): note : required from here
1>mbed-os\features\filesystem\FileSystem.cpp(130,7): error : invalid use of incomplete type 'class mbed::File'
1> class Managed : public F {
1> ^~~~~~~
1> mbed-os\features\filesystem\FileSystem.cpp(18):
1> mbed-os\features\filesystem\FileSystem.h(39,7): note : forward declaration of 'class mbed::File'
1> class File;
1> ^~~~
1> mbed-os/features/filesystem/FileSystem.cpp: In member function 'virtual int mbed::FileSystem::open(mbed::FileHandle**, const char*, int)':
1>mbed-os\features\filesystem\FileSystem.cpp(141,19): error : cannot convert 'Managed<mbed::File>*' to 'mbed::File*' in initialization
1> File *f = new Managed<File>;
1> ^~~~~~~~~~~~~
1>mbed-os\features\filesystem\FileSystem.cpp(142,16): error : invalid use of incomplete type 'class mbed::File'
1> int err = f->open(this, path, flags);
1> ^~
1> mbed-os\features\filesystem\FileSystem.cpp(18):
1> mbed-os\features\filesystem\FileSystem.h(39,7): note : forward declaration of 'class mbed::File'
1> class File;
1> ^~~~
1>mbed-os\features\filesystem\FileSystem.cpp(144,16): warning : possible problem detected in invocation of delete operator: [-Wdelete-incomplete]
1> delete f;
1> ^
1>mbed-os\features\filesystem\FileSystem.cpp(141,11): warning : 'f' has incomplete type
1> File *f = new Managed<File>;
1> ^
1> mbed-os\features\filesystem\FileSystem.cpp(18):
1> mbed-os\features\filesystem\FileSystem.h(39,7): note : forward declaration of 'class mbed::File'
1> class File;
1> ^~~~
1> mbed-os\features\filesystem\FileSystem.cpp(144,16): note : neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined
1> delete f;
1> ^
1>mbed-os\features\filesystem\FileSystem.cpp(148,13): error : cannot convert 'mbed::File*' to 'mbed::FileHandle*' in assignment
1> *file = f;
1> ^
1> mbed-os\features\filesystem\FileSystem.cpp(18):
1> mbed-os\features\filesystem\FileSystem.h(39,7): note : class type 'mbed::File' is incomplete
1> class File;
1> ^~~~
1> mbed-os/features/filesystem/FileSystem.cpp: In instantiation of 'class Managed<mbed::Dir>':
1> mbed-os\features\filesystem\FileSystem.cpp(153,18): note : required from here
1>mbed-os\features\filesystem\FileSystem.cpp(130,7): error : invalid use of incomplete type 'class mbed::Dir'
1> class Managed : public F {
1> ^~~~~~~
1> mbed-os\features\filesystem\FileSystem.cpp(18):
1> mbed-os\features\filesystem\FileSystem.h(38,7): note : forward declaration of 'class mbed::Dir'
1> class Dir;
1> ^~~
1> mbed-os/features/filesystem/FileSystem.cpp: In member function 'virtual int mbed::FileSystem::open(mbed::DirHandle**, const char*)':
1>mbed-os\features\filesystem\FileSystem.cpp(153,18): error : cannot convert 'Managed<mbed::Dir>*' to 'mbed::Dir*' in initialization
1> Dir *d = new Managed<Dir>;
1> ^~~~~~~~~~~~
1>mbed-os\features\filesystem\FileSystem.cpp(154,16): error : invalid use of incomplete type 'class mbed::Dir'
1> int err = d->open(this, path);
1> ^~
1> mbed-os\features\filesystem\FileSystem.cpp(18):
1> mbed-os\features\filesystem\FileSystem.h(38,7): note : forward declaration of 'class mbed::Dir'
1> class Dir;
1> ^~~
1>mbed-os\features\filesystem\FileSystem.cpp(156,16): warning : possible problem detected in invocation of delete operator: [-Wdelete-incomplete]
1> delete d;
1> ^
1>mbed-os\features\filesystem\FileSystem.cpp(153,10): warning : 'd' has incomplete type
1> Dir *d = new Managed<Dir>;
1> ^
1> mbed-os\features\filesystem\FileSystem.cpp(18):
1> mbed-os\features\filesystem\FileSystem.h(38,7): note : forward declaration of 'class mbed::Dir'
1> class Dir;
1> ^~~
1> mbed-os\features\filesystem\FileSystem.cpp(156,16): note : neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined
1> delete d;
1> ^
1>mbed-os\features\filesystem\FileSystem.cpp(160,12): error : cannot convert 'mbed::Dir*' to 'mbed::DirHandle*' in assignment
1> *dir = d;
1> ^
1> mbed-os\features\filesystem\FileSystem.cpp(18):
1> mbed-os\features\filesystem\FileSystem.h(38,7): note : class type 'mbed::Dir' is incomplete
1> class Dir;
1> ^~~
1> mbed-os/features/filesystem/FileSystem.cpp: In instantiation of 'int Managed<F>::close() [with F = mbed::Dir]':
1> mbed-os\features\filesystem\FileSystem.cpp(162,1): note : required from here
1>mbed-os\features\filesystem\FileSystem.cpp(133,27): error : incomplete type 'mbed::Dir' used in nested name specifier
1> int err = F::close();
1> ~~~~~~~~^~
1> mbed-os/features/filesystem/FileSystem.cpp: In instantiation of 'int Managed<F>::close() [with F = mbed::File]':
1> mbed-os\features\filesystem\FileSystem.cpp(162,1): note : required from here
1>mbed-os\features\filesystem\FileSystem.cpp(133,27): error : incomplete type 'mbed::File' used in nested name specifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Some block devices (for example I2C EEPROM) can be erased at the byte
level. These aren't really block devices, but fall under the block
device API. For these devices, the fat filesystem needs to use a lower
bound on the block size. In this case we used 512 bytes is used since
it is already a standard.
This function provides a shortcut to reformatting a mounted filesystem.
Also, since this function is a virtual member of the FileSystem class,
the user does not need to know the underlying filesystem to reformat
the underlying storage.
This is only an issue when multiple fatfss are used simultaneously.
Repeated use of a single fatfs instance (even with different storages)
do not show this issue.
Full support requires path prefixes being applied for every function
that takes a path. Note: this is only required filesystems after the
first mounted filesystem. The first filesystem has no penalty.
Unlike the other disk_ioctl options, GET_SECTOR_SIZE is interpreted
as a 16-bit WORD, instead of a 32-bit DWORD. This caused an unaligned
access error on M0 platforms.
At some point the "mount" parameter for "f_mount" was name "force". This
led to a bit of confusion that ended with the default mount function
never calling block device init.
This is fine, since the block device can be manually initialized, but
a better user experience is where the filesystem initializes the block
device for the user.
This is backwards compatible due to the repeatability of the block
device init functions.
In class MBRBlockDevice the tole32 function had used union member
names u32 and u8. The introduction of REALTEK_RTL8195AM cauesd a
conflict with type names in basic_types given they're aliased as
macros to uint32_t and uint8_t respectively.
The old open/opendir functions did not provide a route for errors and
relied on implementations manually setting errno. Updated to return
errors directly.
Required for other representations of FileSystems, ie LocalFileSystem
Introduces FileSystemHandle for the same behaviour as FileHandle and
DirHandle.
Requires the following to hook into file/dir lookup:
```
int open(FileHandle **file, const char *filename, int flags)
int open(DirHandle **dir, const char *path)
```
This hook is provided by the FileSystem class, so requires no changes
from implementations.
This is necessary for support of block devices with >512 byte
blocks, such as most SPI flash parts.
- Enabled support of up to 4096 byte blocks
- Added support for heap-backed buffers using _FS_HEAPBUF
- Necessary to avoid stack overflows
- Avoids over-aggresive allocations of _MAX_SS
- Enabled _FS_TINY to further reduce memory footprint
- Haven't found a downside for this yet except for possible
thread contention
- Implicit MBR still allowed during mount
- maintains storage compatibility
- Not needed
- MBR utility is not exposed through the FAT filesystem,
so the only used partition was always the first. Omitting
the MBR is functionally equivalent
- Saves a few blocks on storage for MBR + offset
for FAT alignment
- Duplicated with MBRBlockDevice
- The implicit MBR actually prevents nesting a FAT filesystem
in the MBRBlockDevice
The standard is intentionally vague on if filesystems must
have '.' and '..' entries, allowing filesystems to omit this
concept completely:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html
However, the '.' and '..' entries are common on FAT filesystems
and in most other filesystems.
This enables '.' and '..' entries in the FAT filesystem.
Should follow same path as FileHandle, although this is less used
and there is currently no route to introduce a hook for a customized
DirHandle in retarget.
As identified by @hasnainvirk, @kjbracey-arm, the FileHandle and
FileBase serve two separate functions and their integration is
limiting for certain use cases.
FileLike is actually the redundant class here, but the multiple
inheritance it provides is used as a hack by the retargeting code
to get at the FileHandle implementation bound to the FileBase name.
It may make more sense for the FileBase to inherit from FileHandle,
(with perhaps a different name), but rather than explore the
possibility, this will just restore the previous hierarchy.
Intention is to make filesystem api and network stack api consistent
as current designs diverge greatly. Attempted to change as little as
possible outside of api structure.
- Remove write set of functions
- Caused confusion with small benefit
- Trivial to add later
- Remove unused error codes
- Initial expirementation indicates most of these may not be useful
- Trivial to add later
- Removed bd_error_t
- Carries to additional type information, int already carries
sufficient connotation
- Trivial to add later
per @c1728p9, @sg-
- Fixing code formatting errors with astyle tool.
- Replaced use of TOOLCHAIN_xxx macros with compiler emitted macros.
- Added const to BlockDevice::get_xxx_size() member functions.
- Added documentation for FAT filesystem thread support.
- Added documentation for fat_filesystem_set_errno().
- Added documentation clarifying the reasons for errno/stat symbol definitions in retarget.h.
- Removed FAT filesystem from mbed 2 testing.
- Fixed FATMisc.h Copyright (c) 2016 year to 2017 as its a new file.
- Removed #ifndef NDEBUG from HeapBlockDevice.cpp.
- Removed unnecessary todo comment in retarget.cpp.
- renaming FATFileSystemSetErrno() fat_file_system_set_errno.
- changing FATFileSystem::format() to be mount fs internally in function, rather than expecting fs to be mounted.
- requested const char *filename change.