Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lfs.h
AgeCommit message (Collapse)Author
2017-04-23Added support for full seek operationsChristopher Haster
A rather involved upgrade for both files and directories, seek and related functions are now completely supported: - lfs_file_seek - lfs_file_tell - lfs_file_rewind - lfs_file_size - lfs_dir_seek - lfs_dir_tell - lfs_dir_rewind This change also highlighted the concern that lfs_off_t is unsigned, whereas off_t is traditionally signed. Unfortunately, lfs_off_t is already used intensively through the codebase, so in focusing on moving forward and avoiding getting bogged down by details, I'm going to keep it as is and use the signed type lfs_soff_t where necessary.
2017-04-23Added correct handling of file syncing around overwritesChristopher Haster
Now all of the open flags are correctly handled Even annoying cases where we can't trust the blocks that are already on file, such as appending existing files and writing to the middle of files.
2017-04-23Removed a layer of indirection for index-list lookupChristopher Haster
Files are now stored directly in the index-list, instead of being referenced by pointers that used to live there. This somewhat reduces the complexity around handling files, while still keeping the O(logn) lookup cost.
2017-04-23Cleaned up block allocatorChristopher Haster
Removed scanning for stride - Adds complexity with questionable benefit - Can be added as an optimization later Fixed handling around device boundaries and where lookahead may not be a factor of the device size (consider small devices with only a few blocks) Added support for configuration with optional dynamic memory as found in the caching configuration
2017-04-23Added optional block-level cachingChristopher Haster
This adds caching of the most recent read/program blocks, allowing support of devices that don't have byte-level read+writes, along with reduced device access on devices that do support byte-level read+writes. Note: The current implementation is a bit eager to drop caches where it simplifies the cache layer. This layer is already complex enough. Note: It may be worthwhile to add a compile switch for caching to reduce code size, note sure. Note: This does add a dependency on malloc, which could have a porting layer, but I'm just using the functions from stdlib for now. These can be overwritten with noops if the user controls the system, and keeps things simple for now.
2017-04-22Simplified configChristopher Haster
Before, the lfs had multiple paths to determine config options: - lfs_config struct passed during initialization - lfs_bd_info struct passed during block device initialization - compile time options This allowed different developers to provide their own needs to the filesystem, such as the block device capabilities and the higher level user's own tweaks. However, this comes with additional complexity and action required when the configurations are incompatible. For now, this has been reduced to all information (including block device function pointers) being passed through the lfs_config struct. We just defer more complicated handling of configuration options to the top level user. This simplifies configuration handling and gives the top level user the responsibility to handle configuration, which they probably would have wanted to do anyways.
2017-04-18Restructured directory codeChristopher Haster
After quite a bit of prototyping, settled on the following functions: - lfs_dir_alloc - create a new dir - lfs_dir_fetch - load and check a dir pair from disk - lfs_dir_commit - save a dir pair to disk - lfs_dir_shift - shrink a dir pair to disk - lfs_dir_append - add a dir entry, creating dirs if needed - lfs_dir_remove - remove a dir entry, dropping dirs if needed Additionally, followed through with a few other tweaks
2017-04-18Added support for renaming dirs/filesChristopher Haster
2017-04-18Moved to brute-force deorphan without parent pointersChristopher Haster
Removing the dependency to the parent pointer solves many issues with non-atomic updates of children's parent pointers with respect to any move operations. However, this comes with an embarrassingly terrible runtime as the only other option is to exhaustively check every dir entry to find a child's parent. Fortunately, deorphaning should be a relatively rare operation.
2017-04-18Added the lfs_stat functionChristopher Haster
2017-04-18Added full dir list and rudimentary block allocatorChristopher Haster
In writing the initial allocator, I ran into the rather difficult problem of trying to iterate through the entire filesystem cheaply and with only constant memory consumption (which prohibits recursive functions). The solution was to simply thread all directory blocks onto a massive linked-list that spans the entire filesystem. With the linked-list it was easy to create a traverse function for all blocks in use on the filesystem (which has potential for other utility), and add the rudimentary block allocator using a bit-vector. While the linked-list may add complexity (especially where needing to maintain atomic operations), the linked-list helps simplify what is currently the most expensive operation in the filesystem, with no cost to space (the linked-list can reuse the pointers used for chained directory blocks).
2017-03-26Added dir tests, test fixes, configChristopher Haster
2017-03-26Added a rudimentary test frameworkChristopher Haster
Tests can be found in 'tests/test_blah.sh' Tests can be run with 'make test'
2017-03-26Restructured the major interfaces of the filesystemChristopher Haster
2017-03-26Revised free-list structure to adopt a lazy scanning allocator of sortsChristopher Haster
The free-list structure, while efficient for allocations, had one big issue: complexity. Storing free blocks as a simple fifo made sense when dealing with a single file, but as soon as you have two files open for writing, updating the free list atomicly when the two files can not necessarily even be written atomicly proved problematic. It's a solvable problem, but requires many writes to keep track of everything. Now changing direction to pursue a more "drop it on the floor" strategy. Since allocated blocks are tracked by the filesystem, we can simply subtract from all available blocks the blocks we know of to allocate new blocks. This is very expensive (O(blocks in use * blocks on device)), but greatly simplifies any interactions that result in deallocated blocks. Additionally, it's impossible to corrupt the free list structure during a power failure. Anything blocks that aren't tracked are simply "dropped on the floor", and can be allocated later. There's still a bit of work around the actually allocator to make it run in a somewhat reasonable frame of time while still avoiding dynamic allocations. Currently looking at a bit-vector of free blocks so at least strides of blocks can be skipped in a single filesystem iteration.
2017-03-20Added support for the basic file operationChristopher Haster
Missing seek, but these are the core filesystem operations provided by this filesystem: - Read a file - Append to a file Additional work is needed around freeing the previous file, so right now it's limited to appending to existing files, a real append only filesystem. Unfortunately the overhead of the free list with multiple open files is becoming tricky.
2017-03-20Added limited support for directoriesChristopher Haster
This comes with a lot of scafolding put into place around the core of the filesystem. Added operations: - append an entry to a directory - find an entry in a directory - iterate over entries in a directory Some to do: - Chaining multiple directory blocks - Recursion on directory operations
2017-03-20Added better handling for metadata pairsChristopher Haster
The core algorithim that backs this filesystem's goal of fault tolerance is the alternating of "metadata pairs". Backed by a simple core function for reading and writing, makes heavy use of c99 designated initializers for passing info about multiple chunks in an erase block.
2017-03-20Added initial superblock definitionChristopher Haster
Really started working out how the internal structure of the driver will be organized. There are a few hazy lines between the intended data structures with the goal of code reuse, so the function boundaries may end up a bit weird.
2017-02-27Adopted ctz skip-list structure earlier than expectedChristopher Haster
The primary data structure backing the little fs was planned to be a little ctz based skip-list for O(logn) lookup and O(1) append. Was initially planning to start with a simple linked list of index blocks, but was having trouble implementing the free-list on top of the structure. Went ahead and adopted the skip-list structure since it may have actually been easier.
2017-02-27Initial commit of progress, minimal formatting niave free listChristopher Haster