Commit Graph

134 Commits (25321961fbe0b000ae6d2061da6f0d0c9923c0f6)

Author SHA1 Message Date
Jimmy Brisson 27533ff16e
Merge pull request #5375 from kegilbert/chainingbd-address-iter-fix
ChainingBlockDevice: changing blocks address fix
2017-10-30 10:09:51 -05:00
Kevin Gilbert b9d2dbafcf Resolve doxygen warning in filesystems 2017-10-27 18:18:04 -05:00
Kevin Gilbert 84e3110b6f Replace second SlicingBD ctor with default arg
Replace second ctor in SlicingBlockDevice with default parameter for the end address in first ctor
2017-10-26 11:49:35 -05:00
Kevin Gilbert a746f95a8b Change address subtraction when moving through block devices to be the size of the entire block device not the block size 2017-10-24 18:31:46 -05:00
Kevin Gilbert 1cfaa4a4e6 Add additional information on the block parameter in the HeapBlockDevice ctor 2017-10-17 19:03:39 -05:00
Kevin Gilbert 86fa6771bd Add erase to example
Use defined blocksize constant
2017-10-10 17:19:24 -05:00
Kevin Gilbert 37b3b40e2a Update HeapBlockDevice example in header file to compile 2017-10-10 16:19:13 -05:00
Jimmy Brisson 5a018585c6 Merge pull request #5183 from geky/fix-dir-open-failures
fs: Fix dir open during failure condition
2017-09-28 13:59:28 -05:00
Jimmy Brisson 79440ae17b Merge pull request #4994 from 0x6d61726b/patch-1
missing includes for filesystem.cpp (build with VisualGDB fails)
2017-09-25 10:11:43 -05:00
Christopher Haster a6b3b55eb9 fs: Fix dir open during failure condition
Should leave the Dir in an openable state, currently does not
since it thinks it's in use by the fs it failed to open on.
2017-09-22 18:39:52 -05:00
Christopher Haster ee88097cb6 fatfs: Adopted the trim function in the FAT filesystem 2017-09-05 11:16:15 -05:00
Christopher Haster 6e1b9e153c bd: Added trim function to let filesystems give erase hints to FTLs 2017-09-05 11:16:15 -05:00
Christopher Haster e798c5359e bd: Changed BlockDevice erase to default as no-op
This should help with confusion around devices that don't have
a physical erase operation, such as SD cards and spinny disks.
2017-09-05 11:16:15 -05:00
Martin Kojtal 3f347ed290 Merge pull request #4843 from geky/fat-min-block
fatfs: Add lower bound to block sizes
2017-09-04 16:52:05 +01:00
0x6d61726b 4434569719 Build with external tool fails: missing includes
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 ==========
2017-08-30 17:21:53 +02:00
Christopher Haster 626256e104 fatfs: Added some asserts on block device geometry 2017-08-28 14:54:33 -05:00
Christopher Haster a153dc625c fatfs: Changed documentation of format to emphasize byte clusters 2017-08-28 14:54:24 -05:00
Jimmy Brisson a457fe3bdd Merge pull request #4908 from geky/fs-reformat
fs: Add FileSystem::reformat
2017-08-21 10:38:00 -05:00
Christopher Haster f927996275 fatfs: Added lower bound to block sizes
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.
2017-08-15 12:59:52 -05:00
Christopher Haster 0f8dffb7a4 fs: Added FileSystem::reformat
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.
2017-08-14 17:05:40 -05:00
Christopher Haster d61073783c bd: Added ProfilingBlockDevice for measuring higher-level applications 2017-07-31 10:19:39 -05:00
Martin Kojtal 1849370100 Merge pull request #4652 from geky/fat-fix-unaligned-ioctl
fatfs: Fix unaligned access in disk_ioctl
2017-07-13 16:49:01 +02:00
Christopher Haster 1775e1f782 fatfs: Added full support for multiple fs volume prefixes
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.
2017-06-29 16:56:14 -05:00
Jimmy Brisson 9f829ffe26 Merge pull request #4559 from geky/fat-remove-fat_filesystem_set_errno
fatfs: Remove unused fat_filesystem_set_errno function
2017-06-29 11:06:22 -05:00
Christopher Haster a9f5d886fb fatfs: Fix unaligned access in disk_ioctl
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.
2017-06-27 15:44:04 -05:00
Christopher Haster f2c93c7724 bd: Add asserts on initialization in HeapBlockDevice 2017-06-21 13:51:57 -05:00
Christopher Haster adc3d75936 bd: Fix missing init in MBRBlockDevice 2017-06-21 13:33:40 -05:00
Christopher Haster d7fe4ff599 fatfs: Fixed initialization of block device in mount/unmount functions
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.
2017-06-14 16:35:15 -05:00
Christopher Haster f158d81aab fatfs: Removed unused fat_filesystem_set_errno function
At some point this was replaced by fat_error_remap
2017-06-14 15:29:30 -05:00
Deepika 6ee4c7e219 Fix doxygen warnings in 'features/filesystem' 2017-06-08 15:48:21 -05:00
Sam Grove 6002bdd533 Merge pull request #4439 from sg-/proper-realtek-fix
Proper fix for 1fa30b7403
2017-06-06 16:00:55 -05:00
Sam Grove 02bf926ffb Proper fix for 1fa30b7403
Replace #define with typedef
2017-06-04 11:26:21 -05:00
Sam Grove 0da63eef2b Merge pull request #4087 from geky/localfs-fslike-fix
LocalFileSystem: Repair the FileSystemLike hooks
2017-06-04 08:35:26 -05:00
Sam Grove 1fa30b7403 Resolve conflict in builtin type names
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.
2017-06-03 18:12:28 -05:00
Christopher Haster 0fc5ce2b5e LocalFileSystem: Moved away from deprecated open functions
The old open/opendir functions did not provide a route for errors and
relied on implementations manually setting errno. Updated to return
errors directly.
2017-06-03 13:18:02 -05:00
Christopher Haster eed1cec5d8 FileSystem: Provided default implementations for all non-file operations 2017-06-03 13:18:01 -05:00
Christopher Haster 5d6fc713fb FileSystem: Reintegrated FileSystemLike interface
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.
2017-06-03 13:17:37 -05:00
Christopher Haster c0aa841ffd FAT: Added support for block sizes of 512-4096 bytes
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
2017-06-03 07:10:48 +01:00
Kevin Bracey 533910cb87 Correct return type of FileHandle::size()
File size should be off_t, not size_t.
2017-05-31 15:02:11 +03:00
Christopher Haster 3ee77e36f7 FAT: Fixed volume count check when formatted without MBR
This saves 64 blocks (32KB when used with 512B blocks) and drops
the minimum storage size from 64KB to 32KB.
2017-05-25 14:24:17 -05:00
Christopher Haster 3f92a15960 FAT: Added support for multiple active filesystems
- Increased _VOLUMES to 4
- Fixed a few issues in the FATFileSystem's _fsid
- Added tests for multiple partitions of fatfs
2017-05-24 11:18:47 -05:00
Christopher Haster d1468a68ab FAT: Removed implicit MBR from FAT filesystem during format
- 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
2017-05-23 11:56:00 -05:00
Christopher Haster 590a40d9bf bd: Added MBRBlockDevice for handling a master boot record on a block device 2017-05-23 11:55:57 -05:00
Christopher Haster fd80dcc51b Filesystem: Include '.' and '..' in directory iteration
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.
2017-04-13 14:30:57 -05:00
Christopher Haster 18bab4e024 Filesystem: Fixed typo in param naming 2017-03-14 11:04:22 -05:00
Christopher Haster 90fc0b9c47 FileSystem: Reverted deprecation of DirHandle
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.
2017-03-14 11:02:34 -05:00
Christopher Haster 61c9683644 Filesystem: Moved retarget related file interfaces into platform 2017-03-14 11:02:34 -05:00
Christopher Haster 77243ef46b Filesystem: Revert deprecation of FileHandle
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.
2017-03-14 11:02:34 -05:00
Christopher Haster 31e0875cd1 bd: Fix missing const attributes on functions 2017-03-01 16:11:40 -06:00
Christopher Haster c4649afba5 Filesystem: Last minute changes due to feedback on directory iteration
- Changed to use dirent structure type
- Fixed memory leak in closedir
2017-02-24 12:03:14 -06:00
Christopher Haster b9122c73f9 Filesystem: Integrate error handling between c++/posix layers 2017-02-24 12:03:09 -06:00
Christopher Haster c6b1fcbfa5 Filesystem: Integrate filesystem classes with common mbed.h entry point 2017-02-24 11:56:45 -06:00
Christopher Haster eea5c9f08a Filesystem: Integration with retarget code 2017-02-24 11:55:37 -06:00
Christopher Haster e5197ceaca Filesystem: Initial integration with the FATFileSystem 2017-02-24 11:53:17 -06:00
Christopher Haster ee3e920ed1 Filesystem: Moved toolchain-specific types into retarget.h 2017-02-24 11:42:32 -06:00
Christopher Haster a5245e32fe Filesystem: Created prototypical filesystem class
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.
2017-02-24 11:41:34 -06:00
Christopher Haster 2cf67734c4 Filesystem: Remove invalid write to unallocated memory in heap block device 2017-02-23 20:41:38 -06:00
Simon Hughes 410c2f8dc0 STORAGE: rebased with master and fixed FATFileSystem.cpp merge conflicts. 2017-02-23 16:50:34 +00:00
Simon Hughes 9a1966fadb STORAGE: fixes for BlockDevice test cases. 2017-02-23 16:39:51 +00:00
Christopher Haster ea5ac4bb4d Storage: Last minute changes to the block device api
- 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-
2017-02-23 16:39:49 +00:00
Simon Hughes 840c77793b STORAGE: Pull request 3762 review feedback changes.
- 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.
2017-02-23 16:39:42 +00:00
Simon Hughes b8e31c8156 Removal of SD card driver (SDBlockDevice module) and related test cases (moved into https://github.com/ARMmbed/sd-driver repository). 2017-02-23 16:39:36 +00:00
Simon Hughes 3e35d4bb81 STORAGE: added test case to write/check n x 25kB files storing ~250kB data. 2017-02-23 16:39:32 +00:00
Christopher Haster cbcc445f54 Added d_type member of dirent struct to readdir 2017-02-23 16:39:25 +00:00
Simon Hughes 2b96c74f84 STORAGE: Pull Request 3704 requested minor changes including:
- 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.
2017-02-23 16:39:21 +00:00
Simon Hughes fdadb8cc66 STORAGE: moved toolchain_support.h into platform/retarget.h 2017-02-23 16:39:18 +00:00
Simon Hughes 860d7f03f2 STORAGE: fixing error handling for fopen() and other upper edge filesystem API methods.
- integrated work with new block api.
- Conflicts: features/filesystem/fat/FATFileSystem.cpp
2017-02-23 16:39:11 +00:00
Simon Hughes 0b7a2ca030 STORAGE: fixes for merging in format test with new block device implementation of format. 2017-02-23 16:38:22 +00:00
Simon Hughes 01baa72ab9 STORAGE: change FATFileSystem::format() to include allocation_unit argument, to facilitate fixing of inconsistent file systems.
Conflicts:
	features/filesystem/fat/FATFileSystem.cpp
	features/filesystem/fat/FATFileSystem.h
2017-02-23 16:38:19 +00:00
Simon Hughes 4f5e94c746 STORAGE: test case fixes to support ARMCC and IAR toolchains.
Conflicts:
	features/TESTS/filesystem/fopen/fopen.cpp
2017-02-23 16:38:15 +00:00
Christopher Haster 0176450c5a bd: Adopted the block storage api in the FATFileSystem 2017-02-23 16:37:13 +00:00
Christopher Haster ba5e1427fc bd: Added utility block device classes
- ChainingBlockDevice
- SlicingBlockDevice
2017-02-23 16:36:27 +00:00
Christopher Haster 03a332c5eb bd: Adopted the block device api in the SDBlockDevice 2017-02-23 16:36:25 +00:00
Christopher Haster 4633d3129d bd: Adopted the block device api in the HeapBlockDevice
Port of MemBlockDevice from mbed 2
2017-02-23 16:36:22 +00:00
Christopher Haster 99698379ef bd: Added prototype block device api 2017-02-23 16:36:20 +00:00
Simon D Hughes aefb03ccd6 ARMCC temporary fixes for undefined errno symbols. 2017-02-23 16:36:16 +00:00
Simon D Hughes 29f8d838d0 STORAGE: updated filesystem readme.md. 2017-02-23 16:36:10 +00:00
Simon Hughes 8378af044f Updated filesystem README.md. 2017-02-23 16:36:06 +00:00
Simon Hughes 0c87537f10 Added errno codes to retarget, mkdir() and ftell() tests. 2017-02-23 16:36:03 +00:00
Christopher Haster 39a1eddb93 Filesystem: Added EEXIST reporting to mkdir through errno 2017-02-23 16:34:56 +00:00
Simon Hughes 912044b829 FILESYSTEM: fopen() and basic test improvements. 2017-02-23 16:30:50 +00:00
Christopher Haster 9299a88e8f Filesystem: Add support for stat
Provided through FileSystemLike::stat
2017-02-23 16:30:42 +00:00
Simon Hughes 7514476e2f FILESYSTEM: Fix to only build SDFileSystem if DEVICE_SPI defined, to build correctly for targets that dont have SPI interfaces. 2017-02-23 16:30:30 +00:00
Simon Hughes 4acf33f436 FILESYSTEM: moved FAT filesystem implemenation to features/filesystem subdir, and fs-fat tests to features/TESTS. 2017-02-23 16:30:21 +00:00