Commit Graph

205 Commits

Author SHA1 Message Date
Christopher Haster
48cc58e25c WIP Tweaked results from find-like functions 2018-07-11 07:18:30 -05:00
Christopher Haster
92d957ab40 WIP Consolidated get functions into one 2018-07-11 05:52:50 -05:00
Freddie Chopin
7e67f9324e Use PRIu32 and PRIx32 format specifiers to fix warnings
When using "%d" or "%x" with uint32_t types, arm-none-eabi-gcc reports
warnings like below:

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

In file included from lfs.c:8:
lfs_util.h:45:12: warning: format '%d' expects argument of type 'int', but argument 4 has type 'lfs_block_t' {aka 'long unsigned int'} [-Wformat=]
     printf("lfs debug:%d: " fmt "\n", __LINE__, __VA_ARGS__)
            ^~~~~~~~~~~~~~~~
lfs.c:2512:21: note: in expansion of macro 'LFS_DEBUG'
                     LFS_DEBUG("Found partial move %d %d",
                     ^~~~~~~~~
lfs.c:2512:55: note: format string is defined here
                     LFS_DEBUG("Found partial move %d %d",
                                                      ~^
                                                      %ld

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

Fix this by replacing "%d" and "%x" with `"%" PRIu32` and `"%" PRIx32`.
2018-07-11 12:32:21 +02:00
Christopher Haster
5152b973f0 WIP Moved findscan into fetch as primitive 2018-07-11 04:00:34 -05:00
Christopher Haster
eed1eec5fd Fixed information leaks through reused caches
As a shortcut, littlefs never bother to zero any of the buffers is used.
It didn't need to because it would always write out the entirety of the
data it needed.

Unfortunately, this, combined with the extra padding used to align
buffers to the nearest prog size, would lead to uninitialized data
getting written out to disk.

This means unrelated file data could be written to different parts of
storage, or worse, information leaked from the malloc calls could be
written out to disk unnecessarily.

found by rojer
2018-07-10 11:18:46 -05:00
Christopher Haster
43e6aadef6 WIP consolidated find/parent scanning functions 2018-07-09 17:29:40 -05:00
Christopher Haster
0276e00fac WIP reclaimed 0x3ff as invalid id 2018-07-09 14:53:55 -05:00
Christopher Haster
5b9755f141 WIP restructured tags for more flexible bit encoding 2018-07-09 14:13:31 -05:00
Christopher Haster
f5488f7192 WIP changed type to be retrieved from name not struct 2018-07-09 13:09:23 -05:00
Christopher Haster
2947006660 WIP removed old move logic 2018-07-09 11:47:04 -05:00
Christopher Haster
d5f0e236b8 WIP fixed bug with globals poisoning from dirs
Needs to be cleaned up
2018-07-08 14:21:29 -05:00
Christopher Haster
0d3350665e WIP Fixed issues around wrong ids after bad commits 2018-07-04 01:35:04 -05:00
Damien George
51346b8bf4 Fixed shadowed variable warnings
- Fixed shadowed variable warnings in lfs_dir_find.
- Fixed unused parameter warnings when LFS_NO_MALLOC is enabled.
- Added extra warning flags to CFLAGS.
- Updated tests so they don't shadow the "size" variable for -Wshadow
2018-07-02 10:29:19 -05:00
Christopher Haster
5064cf82fd WIP switched back to deorphan for remove
Utilizing moves wouldn't have worked for rename anyways, and it requires
additional code for much less traveled code path (directory removes)
2018-07-01 22:29:42 -05:00
Christopher Haster
6beff502e9 Changed license to BSD-3-Clause
For better compatibility with GPL v2

With permissions from:
- aldot
- Sim4n6
- jrast
2018-06-21 11:41:43 -05:00
Christopher Haster
ff13345e96 WIP Restructured tags for better support for global things 2018-05-29 20:08:42 -05:00
Christopher Haster
82948861d2 WIP TEMP move work 2018-05-29 12:35:23 -05:00
Christopher Haster
e9bf206c54 WIP Adopted ISDIR as internal error for root as argument 2018-05-29 01:22:09 -05:00
Christopher Haster
2223bef125 WIP Restructured metadata dir structures 2018-05-29 01:11:26 -05:00
Christopher Haster
d56f326dfb WIP better structure for dir/file lists 2018-05-29 00:51:21 -05:00
Christopher Haster
09b69c5b2a WIP name updates 2018-05-28 19:49:20 -05:00
Christopher Haster
a848b0ebbd WIP almost got move working 2018-05-28 17:46:32 -05:00
Christopher Haster
6cda0442ea WIP made basic tests pass
(format/dirs/files/seek/truncate/interspersed/paths)
2018-05-28 09:43:51 -05:00
Christopher Haster
0e0f015fbd WIP WIP yes two wips 2018-05-28 02:08:16 -05:00
Christopher Haster
fbd25ac533 WIP minor change to fix rename issue 2018-05-27 11:46:22 -05:00
Christopher Haster
de0b719b56 WIP progress so far 2018-05-27 10:15:28 -05:00
Christopher Haster
ca9e43158d WIP fixed enough things to pass basic file testing 2018-05-26 13:50:06 -05:00
Christopher Haster
cd045ed2eb WIP Moved move things into a better place 2018-05-25 19:22:19 -05:00
Christopher Haster
39267fd8b2 WIP file stuff 2018-05-22 23:57:19 -05:00
Christopher Haster
6c2c7e3f3d WIP more progressed 2018-05-22 21:58:14 -05:00
Christopher Haster
2759f012c0 WIP progressed more 2018-05-21 00:56:20 -05:00
Christopher Haster
f4d6ca5552 WIP fixed up dir find 2018-05-20 14:01:11 -05:00
Christopher Haster
57fbc52cfc WIP added wip journalling things for dirs 2018-05-19 18:25:47 -05:00
Christopher Haster
c5e2b335d6 Added error when opening multiple files with a statically allocated buffer
Opening multiple files simultaneously is not supported without dynamic memory,
but the previous behaviour would just let the files overwrite each other, which
could lead to bad errors down the line

found by husigeza
2018-04-30 03:37:10 -05:00
Christopher Haster
015b86bc51 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-22 07:26:31 -05:00
Christopher Haster
c8323112ee WIP Added tests over entries + attributes 2018-04-16 02:37:32 -05:00
Christopher Haster
9637b96069 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 14:38:25 -05:00
Christopher Haster
7d3c2be49a WIP Fixed big-endian support 2018-04-11 01:29:59 -05:00
Christopher Haster
6af43aec5b Added lfs_fs_size function for finding a count of used blocks
This has existed for some time in the form of the lfs_traverse
function, however lfs_traverse is relatively unconventional and
has proven to not have been the most intuitive for users.
2018-04-11 01:29:59 -05:00
Christopher Haster
9af404db09 WIP added file/fs set/get attr implementations 2018-04-11 01:29:59 -05:00
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
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