264 Commits

Author SHA1 Message Date
Christopher Haster
0347416b89 WIP simplified attribute handling a bit to better match commit regions 2018-04-11 01:29:59 -05:00
Christopher Haster
eb70143469 WIP Clumsy setattrs/getattrs 2018-04-11 01:29:59 -05:00
Christopher Haster
2aee22aa49 WIP custom attributes 2018-04-11 01:29:59 -05:00
Christopher Haster
a82ea60658 WIP added some comments 2018-04-11 01:29:59 -05:00
Christopher Haster
7c0f32dc0b WIP Bumped versions 2018-04-11 01:29:59 -05:00
Christopher Haster
e48a2c488b WIP cleaned up TODOs 2018-04-11 01:29:59 -05:00
Christopher Haster
f37fa75d66 WIP added support for inline files up to 1023 bytes 2018-04-11 01:29:59 -05:00
Christopher Haster
bba71b23f4 WIP Added limits on name/attrs/inline sizes 2018-04-11 01:29:59 -05:00
Christopher Haster
e4a35b78e7 WIP Refactored lfs_dir_set function to umbrella append/update/remove 2018-04-11 01:29:59 -05:00
Christopher Haster
b56d82ff34 WIP Added lfs_dir_get 2018-04-11 01:29:59 -05:00
Christopher Haster
ab9750f5ed WIP moved superblock to entry append 2018-04-11 01:29:59 -05:00
Christopher Haster
2f32222914 WIP fixed bugs 2018-04-11 01:29:59 -05:00
Christopher Haster
7ad2d58ed0 WIP Fixed issue with modifying dir after append in update 2018-04-11 01:29:59 -05:00
Christopher Haster
689159e31d WIP Better implementation of inline files, now with overflowing 2018-04-11 01:29:59 -05:00
Christopher Haster
9a97a97e4c WIP moved asserts out 2018-04-11 01:29:59 -05:00
Christopher Haster
345f7f3235 WIP added hacky taped on inline files 2018-04-11 01:29:59 -05:00
Christopher Haster
a418c2068d WIP Fixed big-endian support 2018-04-11 01:29:59 -05:00
Christopher Haster
d7ed7a41e9 WIP added entry size field 2018-04-11 01:29:59 -05:00
Christopher Haster
960e152261 WIP separated dir_remove for two types of arguments 2018-04-11 01:29:59 -05:00
Christopher Haster
28a5a27bb9 WIP minor improvement to from-memory commits 2018-04-11 01:29:59 -05:00
Christopher Haster
72475f64f6 WIP Allowed taking advantage of empty space earlier in dir search 2018-04-11 01:29:59 -05:00
Christopher Haster
8773d7c81f WIP added callbacks for stuff 2018-04-11 01:29:59 -05:00
Christopher Haster
d636299daf WIP Moved entry tag updates out 2018-04-11 01:29:59 -05:00
Christopher Haster
2d6a37f775 WIP Naive implementation of resizable entries 2018-04-11 01:29:59 -05:00
Christopher Haster
f58408c974 WIP something something flexible updates 2018-04-11 01:29:59 -05:00
Christopher Haster
e1f05ee046 WIP adopted lisp-like dsl for more flexibility 2018-04-11 01:29:59 -05:00
Christopher Haster
f54ad304fc WIP Changed commit DSL to support disk->disk copies 2018-04-11 01:29:59 -05:00
Christopher Haster
2a738463b3 Separated type/struct fields in dir entries
The separation of data-structure vs entry type has been implicit for a
while now, and even taken advantage of to simplify the traverse logic.
2018-04-11 01:29:59 -05:00
Christopher Haster
89a7630d84 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-09 14:37:35 -05:00
Christopher Haster
43eac3083b Renamed test_parallel tests to test_interespersed
The name test_parallel gave off the incorrect impression that these
tests are multithreaded.
2018-04-08 17:31:09 -05:00
Christopher Haster
dbc3cb1798 Fixed Travis rate-limit issue with Github requests
Using credentials avoids rate-limiting based on Travis's IP address
2018-04-08 17:31:09 -05:00
Christopher Haster
93ece2e87a Removed outdated note about moves and powerloss 2018-04-08 17:31:05 -05:00
Christopher Haster
d9c076d909 Removed the uninitialized read for invalid superblocks 2018-03-19 00:39:40 -05:00
Christopher Haster
58f3bb1f08 Merge pull request #37 from jrast/patch-1
Added a note about the callback functions
2018-03-13 00:13:44 -05:00
Christopher Haster
f72f6d6a05 Removed out of date note about endianness 2018-03-12 21:27:39 -05:00
Juerg Rast
5c4ee2109d Added a note about the callback functions
Added a short section about the callback functions, based on the answers
to issue #35 and #36
2018-03-12 21:26:40 -05:00
Christopher Haster
155224600a Fixed Travis issue with deploy stage in PRs 2018-03-12 19:57:57 -05:00
Christopher Haster
9ee112a7cb 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-02-28 23:14:41 -06:00
Christopher Haster
d9c36371e7 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-28 23:13:02 -06:00
Christopher Haster
1476181bd1 Added LFS_CONFIG for user provided configuration of the utils
Suggested by sn00pster, LFS_CONFIG is an opt-in user provided
configuration file that will override the util implementation in
lfs_util.h. This is useful for allowing system-specific overrides
without needing to rely on git merges or other forms of patching
for updates.
2018-02-22 13:39:24 -06:00
Christopher Haster
b2124a5ae5 Fixed multiple deploy steps in Travis 2018-02-20 17:55:30 -06:00
Christopher Haster
949015ad52 Merge pull request #28 from geky/configurables
Add better general support in lfs_utils.h
2018-02-19 17:29:48 -06:00
Christopher Haster
67daf9e2c5 Added cross-compile targets for testing
Using gcc cross compilers and qemu:
- make test CC="arm-linux-gnueabi-gcc --static -mthumb" EXEC="qemu-arm"
- make test CC="powerpc-linux-gnu-gcc --static" EXEC="qemu-ppc"
- make test CC="mips-linux-gnu-gcc --static" EXEC="qemu-mips"

Also separated out Travis jobs and added some size reporting
2018-02-19 01:40:28 -06:00
Christopher Haster
a3fd2d4d6d Added more configurable utils
Note: It's still expected to modify lfs_utils.h when porting littlefs
to a new target/system. There's just too much room for system-specific
improvements, such as taking advantage of CRC hardware.

Rather, encouraging modification of lfs_util.h and making it easy to
modify and debug should result in better integration with the consuming
systems.

This just adds a bunch of quality-of-life improvements that should help
development and integration in littlefs.

- Macros that require no side-effects are all-caps
- System includes are only brought in when needed
- Malloc/free wrappers
- LFS_NO_* checks for quickly disabling things at the command line
- At least a little-bit more docs
2018-02-19 01:40:23 -06:00
Christopher Haster
a0a55fb9e5 Added conversion to/from little-endian on disk
Required to support big-endian processors, with the most notable being
the PowerPC architecture.

On little-endian architectures, these conversions can be optimized out
and have no code impact.

Initial patch provided by gmouchard
2018-02-19 01:39:08 -06:00
Christopher Haster
4f08424b51 Added software implementations of bitwise instructions
This helps significantly with supporting different compilers. Intrinsics for
different compilers can be added as they are found.

Note that for ARMCC, __builtin_ctz is not used. This was the result of a
strange issue where ARMCC only emits __builtin_ctz when passed the
--gnu flag, but __builtin_clz and __builtin_popcount are always emitted.
This isn't a big problem since the ARM instruction set doesn't have a
ctz instruction, and the npw2 based implementation is one of the most
efficient.

Also note that for littefs's purposes, we consider ctz(0) to be
undefined. This lets us save a branch in the software lfs_ctz
implementation.
2018-02-19 01:39:04 -06:00
Christopher Haster
59ce49fa4b Merge pull request #26 from Sim4n6/master
Added a .git ignore file
v1.2
2018-02-08 23:28:55 -06:00
iamatacos
2f8ae344d2 Added a git ignore file with .o .d blocks dir and lfs bin 2018-02-08 02:20:51 -06:00
Christopher Haster
e611cf5050 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 01:52:39 -06:00
Christopher Haster
a25743a82a Fixed some minor error code differences
- Write on read-only file to return LFS_ERR_BADF
- Renaming directory onto file to return LFS_ERR_NOTEMPTY
- Changed LFS_ERR_INVAL in lfs_file_seek to assert
2018-02-04 14:36:36 -06:00