Commit Graph

165 Commits (046cf1dc580cf3d98796aec920c93e38e4d5d3d9)

Author SHA1 Message Date
Senthil Ramakrishnan 5ef6728c08 Splitting MBED_ERROR macros to support ones with/without error value argument 2018-05-23 12:21:28 -05:00
Senthil Ramakrishnan d4fe75731d Adding mbed prefixes to all macros and functions to avoid namespace conflicts 2018-05-23 12:21:10 -05:00
Senthil Ramakrishnan 147d9cac4e Test application/cases optimization for some low memory targets, macro changes and test fixes 2018-05-23 12:21:10 -05:00
Senthil Ramakrishnan 2e28dd95e1 Change set_error/set_error_fatal to warning/error, add itm support and other changes 2018-05-23 12:21:08 -05:00
Senthil Ramakrishnan 9041b475c6 Error handling/logging implementation and tests 2018-05-23 12:21:07 -05:00
Cruz Monrreal eb9435b52e
Merge pull request #6772 from ARMmbed/g-littlefs-eilseq
littlefs: Map LFS_ERR_CORRUPT to EILSEQ
2018-05-23 10:12:19 -05:00
Martin Kojtal 02af950f62
Merge pull request #6336 from geky/fat-errors
fatfs: Update error code mapping
2018-05-22 14:27:01 +02:00
Martin Kojtal fc2f7fff95
Merge pull request #6757 from davidsaada/david_buffered_bd
Implement BufferedBlockDevice
2018-05-22 14:25:51 +02:00
Cruz Monrreal cd1ff94db2
Merge pull request #6866 from geky/fat-erase-disk
fatfs: Add erase disk to format
2018-05-21 17:14:14 -05:00
Cruz Monrreal 4b721583b5
Merge pull request #6559 from davidsaada/david_flash_sim_bd
Implement FlashSimBlockDevice - flash simulated block device over RAM
2018-05-17 21:54:34 -05:00
Christopher Haster 5efda4b922 fatfs: Fixed ENOTEMPTY error for removing a directory 2018-05-17 10:26:32 -05:00
Christopher Haster 6d4190bd0b fatfs: Update error code mapping
A lot of the error codes in fatfs were mapped incorrectly. This patch
revisits the error code mapping to try to correct these mistakes.
2018-05-17 10:26:32 -05:00
Christopher Haster 2697ebeb21 littlefs: Map LFS_ERR_CORRUPT to EILSEQ
Previously EBAD (invalid exchange), mapping the error CORRUPT to EILSEQ
(illegal byte sequence) makes more sense as a description of the type of
error.
2018-05-14 14:13:26 -05:00
David Saada df7fb1667d Implement BufferedBlockDevice
Block device allowing smaller read and program sizes for the underlying BD,
using a cache.
2018-05-14 19:25:41 +03:00
Christopher Haster e77d57e0bc fatfs: Added erase disk to format
Right now, many users are trying out many different filesystems.
Unfortunately, this can leave partially written filesystems on disk
in various states.

A very common pattern for using embedded filesystems is to attempt
a mount, and on failure, format the storage with the filesystem.

Unfortunately, this simply doesn't work if you try to change the
filesystem being used on a piece of storage. Filesystems don't always
use the same regions of storage, and can leave enough metadata lying
around from old filesystems to trick a different mount into thinking a
valid filesystem exists on disk. The filesystems we have were never
designed to check for malicious modification and can't protect against
arbitrary changes.

That being said, it's caused enough problems for users, so as a
workaround this patch adds a disk erase to the FAT filesystem format.
The most common error happens when you use LittleFS, followed by FAT,
followed again by LittleFS.

No other combination of filesystem usage has shown a similar failure,
but it is possible after extensive filesystem use, so it is still
suggested to force a format of the storage when changing filesystems.
2018-05-14 10:54:01 -05:00
David Saada c3e39996b1 Implement FlashSimBlockDevice - flash simulated block device adaptor 2018-05-08 16:15:25 +03:00
Martin Kojtal 1a5a2f0134
Merge pull request #6774 from geky/littlefs-fix-trailing-dots
littlefs: Fix issue with trailing dots in file paths
2018-05-03 16:26:47 +01:00
Christopher Haster b56bdf18cd littlefs: Fixed issue with trailing dots in file paths
Paths such as the following were causing issues:
/tea/hottea/.
/tea/hottea/..

Unfortunately the existing structure for path lookup didn't make it very
easy to introduce proper handling in this case without duplicating the
entire skip logic for paths. So the lfs_dir_find function had to be
restructured a bit.

One odd side-effect of this is that now lfs_dir_find includes the
initial fetch operation. This kinda breaks the fetch -> op pattern of
the dir functions, but does come with a nice code size reduction.
2018-04-30 03:42:53 -05:00
Christopher Haster a97a47978a mbr: Added assertions for overlapping partitions 2018-04-22 08:28:06 -05:00
Christopher Haster 9e03b24120 littlefs: Fixed lookahead overflow and removed unbounded lookahead pointers
As pointed out by davidefer, the lookahead pointer modular arithmetic
does not work around integer overflow when the pointer size is not a
multiple of the block count.

To avoid overflow problems, the easy solution is to stop trying to
work around integer overflows and keep the lookahead offset inside the
block device. To make this work, the ack was modified into a resetable
counter that is decremented every block allocation.

As a plus, quite a bit of the allocation logic ended up simplified.
2018-04-11 22:34:40 -05:00
Christopher Haster 47bee2343c littlefs: Fixed issue with lookahead trusting old lookahead blocks
One of the big simplifications in littlefs's implementation is the
complete lack of tracking free blocks, allowing operations to simply
drop blocks that are no longer in use.

However, this means the lookahead buffer can easily contain outdated
blocks that were previously deleted. This is usually fine, as littlefs
will rescan the storage if it can't find a free block in the lookahead
buffer, but after changes that caused littlefs to more conservatively
respect the alloc acks (e611cf5), any scanned blocks after an ack would
be incorrectly trusted.

The fix is to eagerly scan ahead in the lookahead when we allocate so
that alloc acks are better able to discredit old lookahead blocks. Since
usually alloc acks are tightly coupled to allocations of one or two blocks,
this allows littlefs to properly rescan every set of allocations.

This may still be a concern if there is a long series of worn out
blocks, but in the worst case littlefs will conservatively avoid using
blocks it's not sure about.

Found by davidefer
2018-04-11 14:41:01 -05:00
Jimmy Brisson 64df0ddee8
Merge pull request #6408 from davidsaada/david_erase_size_addr
Add overloaded get_erase_size API with address parameter to BlockDevice
2018-03-29 11:59:28 -05:00
David Saada a6048005d7 Add overloaded get_erase_size API with address parameter to all block devices 2018-03-23 00:34:45 +02:00
Cruz Monrreal 7ab4b064e5
Merge pull request #6338 from geky/fix-littlefs-dir-chain
littlefs: Fix issue updating dir struct when extended dir chain
2018-03-20 14:33:26 -05:00
Cruz Monrreal a3d8c8fe16
Merge pull request #6363 from deepikabhavnani/seek_fix
dir seek fixed - dptr was not updated before checking
2018-03-20 14:21:49 -05:00
Cruz Monrreal 9cac3b2f6b
Merge pull request #6149 from bmcdonnell-ionx/typos
Fix typos in the files
2018-03-15 10:53:03 -05:00
Deepika 351aaa8acd dir seek fixed - dptr was not updated before checking 2018-03-14 14:40:08 -05:00
Christopher Haster 7f17a9b8da littlefs: Fixed issue updating dir struct when extended dir chain
Like most of the lfs_dir_t functions, lfs_dir_append is responsible for
updating the lfs_dir_t struct if the underlying directory block is
moved. This property makes handling worn out blocks much easier by
removing the amount of state that needs to be considered during a
directory update.

However, extending the dir chain is a bit of a corner case. It's not
changing the old block, but callers of lfs_dir_append do assume the
"entry" will reside in "dir" after lfs_dir_append completes.

This issue only occurs when creating files, since mkdir does not use
the entry after lfs_dir_append. Unfortunately, the tests against
extending the directory chain were all made using mkdir.

Found by schouleu
2018-03-12 15:52:32 -05:00
Christopher Haster 17f7c8cd5b fatfs: Revert "Update error code mapping"
This reverts commits:
b40ff8af15
b548fd8a39
2018-03-09 15:27:03 -06:00
Cruz Monrreal c4354fa645
Merge pull request #6179 from geky/lfs-update
littlefs: Update to version 1.3
2018-03-01 13:42:47 -06:00
Christopher Haster 687304455e littlefs: Updated error codes in tests to match version update 2018-02-28 19:56:13 -06:00
Cruz Monrreal b7c2b1f510
Merge pull request #6120 from ARMmbed/g-fat-errors
fatfs: Update error code mapping
2018-02-26 14:46:33 -06:00
Christopher Haster 436e4706ed littlefs: Add littlefs.intrinsics to override intrinsics support
Enables intrinsics for bit operations such as ctz, popc, and le32
conversion. Can be disabled to help debug toolchain issues. Has
proven to be surprisingly useful.
2018-02-23 17:51:42 -06:00
Christopher Haster afc3306d25 littlefs: Adopted MBED_ASSERT and littlefs.enable_assert
Much like the logging functions, assertions can be enabled, disabled
and forced with the littlefs.enable_assert config option. Integrates
with the new LFS_ASSERT macro.
2018-02-23 17:45:24 -06:00
Cruz Monrreal II b40ff8af15 Moved return statements to their own line 2018-02-23 11:23:13 -06:00
Christopher Haster 453a1b6815 Merge commit '451c3d137fbd49ce5e00e765af66c16bb5169ee9' into lfs-update 2018-02-22 18:43:04 -06:00
Christopher Haster f67a795ef0 littlefs: Fixed handling of root as target for create operations
Before this patch, when calling lfs_mkdir or lfs_file_open with root
as the target, littlefs wouldn't find the path properly and happily
run into undefined behaviour.

The fix is to populate a directory entry for root in the lfs_dir_find
function. As an added plus, this allowed several special cases around
root to be completely dropped.
2018-02-22 15:56:24 -06:00
Brendan McDonnell 7094e13891 revert typos in external sources 2018-02-21 19:08:28 -05:00
Brendan McDonnell c4f10aafee typos 2018-02-20 20:11:19 -05:00
Cruz Monrreal e66cc74b8f
Merge pull request #6046 from geky/fix-lookahead-noack-pop
littlefs: Fix incorrect lookahead population before ack
2018-02-20 13:19:13 -06:00
Christopher Haster b548fd8a39 fatfs: Update error code mapping
A lot of the error codes in fatfs were mapped incorrectly. This patch
revisits the error code mapping to try to correct these mistakes
2018-02-16 00:29:22 -06:00
Christopher Haster db965c1652
mbr: Added note about limitations 2018-02-14 10:31:14 -06:00
Christopher Haster 5b09daf0f9 mbr: Added checks for extended partitions 2018-02-13 14:03:02 -06:00
Christopher Haster 70cfef8630 fatfs: Removed extra MBR block
Regression after ChanFS update: Due to parameter changes in the f_mkfs
function, the option to use a separate block for MBR (FDISK) was turned
back on. This should be off as it conflicts with an explicit MBR when
using the MBRBlockDevice.
2018-02-12 17:16:10 -06:00
Christopher Haster df1896b6c0 littlefs: Fix incorrect lookahead population before ack
Rather than tracking all in-flight blocks blocks during a lookahead,
littlefs uses an ack scheme to mark the first allocated block that
hasn't reached the disk yet. littlefs assumes all blocks since the
last ack are bad or in-flight, and uses this to know when it's out
of storage.

However, these unacked allocations were still being populated in the
lookahead buffer. If the whole block device fits in the lookahead
buffer, _and_ littlefs managed to scan around the whole storage while
an unacked block was still in-flight, it would assume the block was
free and misallocate it.

The fix is to only fill the lookahead buffer up to the last ack.
The internal free structure was restructured to simplify the runtime
calculation of lookahead size.
2018-02-08 18:53:19 -06:00
Brendan McDonnell 88cd13b115 cast to resolve signed/unsigned comparison compiler warning in FATFileSystem::dir_seek() 2018-02-05 15:16:02 -05:00
Cruz Monrreal 5cd30b965c
Merge pull request #5925 from geky/bd-erase-value
bd: Add get_erase_value function to the block device API
2018-01-31 12:13:54 -06:00
Amanda Butler e6949db802 bd: Copy edit BlockDevices
Copy edit SlicingBlockDevice.h
Copy edit ReadOnlyBlockDevice.h
Copy edit ProfilingBlockDevice.h
Copy edit ObservingBlockDevice.h
Copy edit MBRBlockDevice.h
Copy edit ExhaustibleBlockDevice.h
Copy edit ChainingBlockDevice.h
Copy edit BlockDevice.h

Copy edit files for active voice and consistent tense.
2018-01-29 18:45:36 -06:00
Christopher Haster 88aad81345 bd: Adopted the get_erase_value function in the util block devices 2018-01-29 15:33:02 -06:00
Christopher Haster 7707c8b8b8 bd: Added get_erase_value function to the block device API
Default implementation returns -1 and is backwards compatible
2018-01-29 15:31:07 -06:00