Skip to content

lwip2: lighter implementation #3362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 88 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
aeab73a
add lwip2 as a submodule
d-a-v Jun 17, 2017
6c4f5cc
makefile for lwip2 submodule
d-a-v Jun 17, 2017
c289363
fix lwip2 builder makefile
d-a-v Jun 19, 2017
48b7fe2
+ precompiled lwip2 library with includes
d-a-v Jun 19, 2017
602c1b5
upstream fixes
d-a-v Jul 15, 2017
73f4307
Update axTLS to 5de79d71.
igrr Jul 23, 2017
a377aba
Fixed: urlDecode done before parsing args (#2956)
DottoreTozzi Aug 1, 2017
d997fe5
Move ASSERT() macro file text to PMEM (#3477)
earlephilhower Aug 1, 2017
950bb04
Remove unused ax_port_*alloc() functions (#3482)
earlephilhower Aug 1, 2017
bbd6f75
Replace r_rand with os_random for LWIP_RAND() (#3499)
forkineye Aug 7, 2017
a6cca4f
Manifest for @PlatformIO
ivankravets Aug 1, 2017
157aa31
Integration with @PlatformIO Build System
ivankravets Jun 1, 2017
71495e2
Move debug constant strings to PROGMEM (#3478)
earlephilhower Aug 7, 2017
56cd198
Move MIME type table into PROGMEM to save RAM (#3475)
earlephilhower Aug 7, 2017
1d79311
Removed literal '\n' in ESP8266HTTPUpdateServer response (#3421)
hchahine Aug 7, 2017
5764446
Fix to parse parameters in the URL of a POST with empty content. (#3398)
teejaydub Aug 7, 2017
d68c484
patch for #3462
herrold Jul 26, 2017
6499933
lwip2v2: merge upstream
d-a-v Sep 29, 2017
0a5d445
Functional Interrupts initial
hreintke Dec 8, 2016
d8f9956
Use correct separator in keywords.txt
per1234 Sep 2, 2017
92978a7
Fix exception_causes.rst formatting
nwf Aug 28, 2017
47baf29
Update WString.cpp
adams13x13 Aug 20, 2017
6e883e2
Update spiffs 0.3.7 to and mkspiffs 0.1.3
me-no-dev Sep 6, 2017
e0e3a77
Allow for double quotes in boundary (#3455)
probonopd Sep 12, 2017
36f09dc
link airkiss library
igrr Sep 12, 2017
655f859
Install @PlatformIO Core to user's space
ivankravets Sep 12, 2017
e725dc2
core: mask GPIO interrupts while attaching/detaching ISR handler (#3598)
igrr Sep 13, 2017
150e4e7
tools/sdk: remove conflicting time.o from libmain.a
igrr Sep 15, 2017
4c07926
Digest Authentication in Webserver Library (#3053)
Lan-Hekary Sep 18, 2017
0413d24
axtls: update to 66d530a, fixes #3335
igrr Sep 20, 2017
168e684
WiFiClientSecure: add loadCACert function (#3610)
rudivandrunen Sep 20, 2017
65d60d4
Add the ESP8266WiFiMulti to KEYWORD1 to make it highlight in the ino …
cheng3100 Sep 21, 2017
e928632
Added support for user-supplied DHCP range, with basic sanity checks …
NdK73 Sep 21, 2017
8e44050
Use LED_BUILTIN so that it works w/o attaching external LED (#3452)
probonopd Sep 21, 2017
f1b104e
Update mkspiffs to version 0.2.0
me-no-dev Sep 22, 2017
0c5373b
SPIFFS: update to f5e26c4, fixes #3612 (#3623)
Lan-Hekary Sep 22, 2017
baa63c5
ESP8266HTTPClient: Add PATCH request (#3590)
joextodd Sep 22, 2017
2a6040c
Case-insensitive deviceType compare and skip NOTIFY processing
snosrap Aug 1, 2017
1ab7065
UdpContext: check that pbuf_alloc doesn't return nullptr (#3354)
mblythe86 Sep 22, 2017
8ee9341
ESP8266HTTPClient: update library.properties (#3406)
Natim Sep 22, 2017
4b1c279
Revert SPIFFS_USE_MAGIC_LENGTH to 0 (#3612)
igrr Sep 22, 2017
3a98f62
Revert "Added support for user-supplied DHCP range, with basic sanity…
igrr Sep 25, 2017
14fbe81
Merge branch 'master' of https://github.com/esp8266/Arduino into lwip2v2
d-a-v Sep 29, 2017
5ee5d5f
lwip2: library recompiled with latest updates
d-a-v Sep 29, 2017
7d3ec78
Merge branch 'master' into lwip2v2
d-a-v Oct 3, 2017
8eafda7
Merge branch 'master' into lwip2v2
d-a-v Oct 8, 2017
d8710d2
Fixed comment InterruptLock "disable interrupts"
peternlewis Oct 11, 2017
d56afe5
Fix broken link
cwt137 Oct 9, 2017
019de9c
pgmspace: expand varargs correctly in printf_P (#2819)
igrr Oct 12, 2017
6f42d7b
pgmspace: zero out memory in strncpy_P (#2633)
igrr Oct 12, 2017
82fa801
debug: hexdump arguments should be const
igrr Oct 12, 2017
0f16d1b
provide implementation of _exit (#3698)
igrr Oct 12, 2017
e7ea117
Don't remove persistent WiFi settings when doing scan (#2946)
igrr Oct 12, 2017
49a2fde
sdk: update to v2.1.0-10-g509eae8
igrr May 23, 2017
c034ff5
enable 8M and 16M flash sizes for generic board
igrr May 23, 2017
15c6f8c
WiFiClient,WiFiServer: update to match new err_t definition
igrr Oct 14, 2017
9d7bda1
esptool: update to 0.4.12
igrr Oct 15, 2017
0e1bf08
WiFiUpd: fix warning
igrr Oct 15, 2017
fca2ef7
fix gettimeofday()
Juppit Oct 13, 2017
5690b89
fixes for SDK update
igrr Oct 15, 2017
91684af
fix link from md to rst (#3704)
bscheshir Oct 15, 2017
1515ada
Fix erase size in ESP.eraseConfig
igrr Sep 22, 2017
94a1509
Fix for redirect of HTTP Update, so that it always returns to the roo…
evharten Oct 15, 2017
0dafaaf
Add a workaround-delay in Serial.flush() (#3714)
WereCatf Oct 15, 2017
622e69d
Optimize EEPROM::put (#2487)
ittacco Oct 15, 2017
bd45372
ci: add skip_cleanup for release deployment
igrr Oct 15, 2017
ce08b50
sync lib with master
d-a-v Oct 15, 2017
2b177cb
Merge branch 'master' of https://github.com/esp8266/Arduino
d-a-v Oct 15, 2017
cf7af26
Merge branch 'master' of https://github.com/esp8266/Arduino into lwip2v2
d-a-v Oct 15, 2017
71e942d
update lwip2 include files (now stable-2.0.3) + fix typedef lwip_err_…
d-a-v Oct 17, 2017
fce2677
Merge remote-tracking branch 'esp8266/master' into lwip2v2
d-a-v Oct 22, 2017
fcfcbbe
reduce ram+flash footprint. It is now smaller than lwip1.4 (no sanity…
d-a-v Oct 25, 2017
f2d573f
update lwip2 include files (now stable-2.0.3) + fix typedef lwip_err_…
d-a-v Oct 17, 2017
7023a65
Minimal file with a few ESP8266-specific keywords - github issue #3701
vdeconinck Oct 21, 2017
8d5280e
Update SoftwareSerial to 3.3.0 (#3727)
plerup Oct 22, 2017
4ab9766
Increase version for PlatformIO (#3742)
julian-w Oct 22, 2017
0b3340f
Put WiFi into station mode in examples (#3731)
jes Oct 22, 2017
bcb534c
Make DNSServer debug output like other ESP libs
Sep 22, 2017
48f0381
Make ESP8266mDNS debug output like other ESP libs
Sep 22, 2017
da872a9
allocate HTTPUpload struct on demand (#2557)
Oct 17, 2017
2b5a977
minimize number of exit paths in ESP8266WebServer::handleClient (#2557)
Oct 17, 2017
7fa1286
sdk: update to v2.1.0-14-g33f234f
igrr Oct 30, 2017
fb52539
Merge branch 'master' into lwip2v2
d-a-v Oct 30, 2017
928abeb
Merge branch 'master' of https://github.com/esp8266/Arduino into lwip2v2
d-a-v Oct 30, 2017
d3139b6
restore boards.txt
d-a-v Oct 31, 2017
286b04b
restore liblwip2.a
d-a-v Oct 31, 2017
3362f4b
update lib: upstream fix timezone handling
d-a-v Oct 31, 2017
448867c
sync refs with upstream/linklayer
d-a-v Oct 31, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update spiffs 0.3.7 to and mkspiffs 0.1.3
  • Loading branch information
me-no-dev authored and d-a-v committed Sep 29, 2017
commit 6e883e23cc3f1dd9d3a20b3c52a5b1966d6f71f8
2 changes: 1 addition & 1 deletion cores/esp8266/spiffs/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013-2015 Peter Andersson (pelleplutt1976<at>gmail.com)
Copyright (c) 2013-2017 Peter Andersson (pelleplutt1976<at>gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
80 changes: 73 additions & 7 deletions cores/esp8266/spiffs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# SPIFFS (SPI Flash File System)
**V0.3.4**
**V0.3.7**

Copyright (c) 2013-2016 Peter Andersson (pelleplutt1976 at gmail.com)
[![Build Status](https://travis-ci.org/pellepl/spiffs.svg?branch=master)](https://travis-ci.org/pellepl/spiffs)

Copyright (c) 2013-2017 Peter Andersson (pelleplutt1976 at gmail.com)

For legal stuff, see [LICENSE](https://github.com/pellepl/spiffs/blob/master/LICENSE). Basically, you may do whatever you want with the source. Use, modify, sell, print it out, roll it and smoke it - as long as I won't be held responsible.

Expand All @@ -21,34 +23,98 @@ Spiffs is designed with following characteristics in mind:
- Wear leveling


## BUILDING

`mkdir build; make`

Otherwise, configure the `builddir` variable towards the top of `makefile` as something opposed to the default `build`. Sanity check on the host via `make test` and refer to `.travis.yml` for the official in-depth testing procedure. See the wiki for [integrating](https://github.com/pellepl/spiffs/wiki/Integrate-spiffs) spiffs into projects and [spiffsimg](https://github.com/nodemcu/nodemcu-firmware/tree/master/tools/spiffsimg) from [nodemcu](https://github.com/nodemcu) is a good example on the subject.


## FEATURES

What spiffs does:
- Specifically designed for low ram usage
- Uses statically sized ram buffers, independent of number of files
- Posix-like api: open, close, read, write, seek, stat, etc
- It can be run on any NOR flash, not only SPI flash - theoretically also on embedded flash of an microprocessor
- Multiple spiffs configurations can be run on same target - and even on same SPI flash device
- It can run on any NOR flash, not only SPI flash - theoretically also on embedded flash of a microprocessor
- Multiple spiffs configurations can run on same target - and even on same SPI flash device
- Implements static wear leveling
- Built in file system consistency checks
- Highly configurable

What spiffs does not:
- Presently, spiffs does not support directories. It produces a flat structure. Creating a file with path *tmp/myfile.txt* will create a file called *tmp/myfile.txt* instead of a *myfile.txt* under directory *tmp*.
- It is not a realtime stack. One write operation might take much longer than another.
- Poor scalability. Spiffs is intended for small memory devices - the normal sizes for SPI flashes. Going beyond ~128MB is probably a bad idea. This is a side effect of the design goal to use as little ram as possible.
- It is not a realtime stack. One write operation might last much longer than another.
- Poor scalability. Spiffs is intended for small memory devices - the normal sizes for SPI flashes. Going beyond ~128Mbyte is probably a bad idea. This is a side effect of the design goal to use as little ram as possible.
- Presently, it does not detect or handle bad blocks.
- One configuration, one binary. There's no generic spiffs binary that handles all types of configurations.


## MORE INFO

See the [wiki](https://github.com/pellepl/spiffs/wiki) for configuring, integrating and using spiffs.
See the [wiki](https://github.com/pellepl/spiffs/wiki) for [configuring](https://github.com/pellepl/spiffs/wiki/Configure-spiffs), [integrating](https://github.com/pellepl/spiffs/wiki/Integrate-spiffs), [using](https://github.com/pellepl/spiffs/wiki/Using-spiffs), and [optimizing](https://github.com/pellepl/spiffs/wiki/Performance-and-Optimizing) spiffs.

For design, see [docs/TECH_SPEC](https://github.com/pellepl/spiffs/blob/master/docs/TECH_SPEC).

For a generic spi flash driver, see [this](https://github.com/pellepl/spiflash_driver).

## HISTORY

### 0.3.7
- fixed prevent seeking to negative offsets #158
- fixed file descriptor offsets not updated for multiple fds on same file #157
- fixed cache page not closed for removed files #156
- fixed a lseek bug when seeking exactly to end of a fully indexed first level LUT #148
- fixed wear leveling issue #145
- fixed attempt to write out of bounds in flash #130,
- set file offset when seeking over end #121 (thanks @sensslen)
- fixed seeking in virgin files #120 (thanks @sensslen)
- Optional file metadata #128 (thanks @cesanta)
- AFL testing framework #100 #143 (thanks @pjsg)
- Testframe updates

New API functions:
- `SPIFFS_update_meta, SPIFFS_fupdate_meta` - updates metadata for a file

New config defines:
- `SPIFFS_OBJ_META_LEN` - enable possibility to add extra metadata to files

### 0.3.6
- Fix range bug in index memory mapping #98
- Add index memory mapping #97
- Optimize SPIFFS_read for large files #96
- Add temporal cache for opening files #95
- More robust gc #93 (thanks @dismirlian)
- Fixed a double write of same data in certain cache situations
- Fixed an open bug in READ_ONLY builds
- File not visible in SPIFFS_readdir #90 (thanks @benpicco-tmp)
- Cache load code cleanup #92 (thanks @niclash)
- Fixed lock/unlock asymmetry #88 #87 (thanks @JackJefferson, @dpruessner)
- Testframe updates

New API functions:
- `SPIFFS_ix_map` - map index meta data to memory for a file
- `SPIFFS_ix_unmap` - unmaps index meta data for a file
- `SPIFFS_ix_remap` - changes file offset for index metadata map
- `SPIFFS_bytes_to_ix_map_entries` - utility, get length of needed vector for given amount of bytes
- `SPIFFS_ix_map_entries_to_bytes` - utility, get number of bytes a vector can represent given length

New config defines:
- `SPIFFS_IX_MAP` - enable possibility to map index meta data to memory for reading faster
- `SPIFFS_TEMPORAL_FD_CACHE` - enable temporal cache for opening files faster
- `SPIFFS_TEMPORAL_CACHE_HIT_SCORE` - for tuning the temporal cache

### 0.3.5
- Fixed a bug in fs check
- API returns actual error codes #84) (thanks @Nails)
- Fix compiler warnings for non-gcc #83 #81 (thanks @Nails)
- Unable to recover from full fs #82 (thanks @rojer)
- Define SPIFFS_O_* flags #80
- Problem with long filenames #79 (thanks @psjg)
- Duplicate file name bug fix #74 (thanks @igrr)
- SPIFFS_eof and SPIFFS_tell return wrong value #72 (thanks @ArtemPisarenko)
- Bunch of testframe updates #77 #78 #86 (thanks @dpreussner, @psjg a.o)

### 0.3.4
- Added user callback file func.
- Fixed a stat bug with obj id.
Expand Down
153 changes: 144 additions & 9 deletions cores/esp8266/spiffs/spiffs.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ extern "C" {
#define SPIFFS_ERR_RO_ABORTED_OPERATION -10033
#define SPIFFS_ERR_PROBE_TOO_FEW_BLOCKS -10034
#define SPIFFS_ERR_PROBE_NOT_A_FS -10035
#define SPIFFS_ERR_NAME_TOO_LONG -10036

#define SPIFFS_ERR_IX_MAP_UNMAPPED -10037
#define SPIFFS_ERR_IX_MAP_MAPPED -10038
#define SPIFFS_ERR_IX_MAP_BAD_RANGE -10039

#define SPIFFS_ERR_SEEK_BOUNDS -10040


#define SPIFFS_ERR_INTERNAL -10050

#define SPIFFS_ERR_TEST -10100
Expand Down Expand Up @@ -104,7 +113,7 @@ typedef enum {
SPIFFS_CHECK_FIX_LOOKUP,
SPIFFS_CHECK_DELETE_ORPHANED_INDEX,
SPIFFS_CHECK_DELETE_PAGE,
SPIFFS_CHECK_DELETE_BAD_FILE,
SPIFFS_CHECK_DELETE_BAD_FILE
} spiffs_check_report;

/* file system check callback function */
Expand All @@ -123,15 +132,15 @@ typedef enum {
/* the file has been updated or moved to another page */
SPIFFS_CB_UPDATED,
/* the file has been deleted */
SPIFFS_CB_DELETED,
SPIFFS_CB_DELETED
} spiffs_fileop_type;

/* file system listener callback function */
typedef void (*spiffs_file_callback)(struct spiffs_t *fs, spiffs_fileop_type op, spiffs_obj_id obj_id, spiffs_page_ix pix);

#ifndef SPIFFS_DBG
#define SPIFFS_DBG(...) \
print(__VA_ARGS__)
printf(__VA_ARGS__)
#endif
#ifndef SPIFFS_GC_DBG
#define SPIFFS_GC_DBG(...) printf(__VA_ARGS__)
Expand All @@ -145,20 +154,28 @@ typedef void (*spiffs_file_callback)(struct spiffs_t *fs, spiffs_fileop_type op,

/* Any write to the filehandle is appended to end of the file */
#define SPIFFS_APPEND (1<<0)
#define SPIFFS_O_APPEND SPIFFS_APPEND
/* If the opened file exists, it will be truncated to zero length before opened */
#define SPIFFS_TRUNC (1<<1)
#define SPIFFS_O_TRUNC SPIFFS_TRUNC
/* If the opened file does not exist, it will be created before opened */
#define SPIFFS_CREAT (1<<2)
#define SPIFFS_O_CREAT SPIFFS_CREAT
/* The opened file may only be read */
#define SPIFFS_RDONLY (1<<3)
/* The opened file may only be writted */
#define SPIFFS_O_RDONLY SPIFFS_RDONLY
/* The opened file may only be written */
#define SPIFFS_WRONLY (1<<4)
/* The opened file may be both read and writted */
#define SPIFFS_O_WRONLY SPIFFS_WRONLY
/* The opened file may be both read and written */
#define SPIFFS_RDWR (SPIFFS_RDONLY | SPIFFS_WRONLY)
/* Any writes to the filehandle will never be cached */
#define SPIFFS_O_RDWR SPIFFS_RDWR
/* Any writes to the filehandle will never be cached but flushed directly */
#define SPIFFS_DIRECT (1<<5)
/* If SPIFFS_CREAT and SPIFFS_EXCL are set, SPIFFS_open() shall fail if the file exists */
#define SPIFFS_O_DIRECT SPIFFS_DIRECT
/* If SPIFFS_O_CREAT and SPIFFS_O_EXCL are set, SPIFFS_open() shall fail if the file exists */
#define SPIFFS_EXCL (1<<6)
#define SPIFFS_O_EXCL SPIFFS_EXCL

#define SPIFFS_SEEK_SET (0)
#define SPIFFS_SEEK_CUR (1)
Expand Down Expand Up @@ -283,6 +300,9 @@ typedef struct {
spiffs_obj_type type;
spiffs_page_ix pix;
u8_t name[SPIFFS_OBJ_NAME_LEN];
#if SPIFFS_OBJ_META_LEN
u8_t meta[SPIFFS_OBJ_META_LEN];
#endif
} spiffs_stat;

struct spiffs_dirent {
Expand All @@ -291,6 +311,9 @@ struct spiffs_dirent {
spiffs_obj_type type;
u32_t size;
spiffs_page_ix pix;
#if SPIFFS_OBJ_META_LEN
u8_t meta[SPIFFS_OBJ_META_LEN];
#endif
};

typedef struct {
Expand All @@ -299,6 +322,21 @@ typedef struct {
int entry;
} spiffs_DIR;

#if SPIFFS_IX_MAP

typedef struct {
// buffer with looked up data pixes
spiffs_page_ix *map_buf;
// precise file byte offset
u32_t offset;
// start data span index of lookup buffer
spiffs_span_ix start_spix;
// end data span index of lookup buffer
spiffs_span_ix end_spix;
} spiffs_ix_map;

#endif

// functions

#if SPIFFS_USE_MAGIC && SPIFFS_USE_MAGIC_LENGTH && SPIFFS_SINGLETON==0
Expand Down Expand Up @@ -375,8 +413,8 @@ s32_t SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode mode);
* @param fs the file system struct
* @param path the path of the new file
* @param flags the flags for the open command, can be combinations of
* SPIFFS_APPEND, SPIFFS_TRUNC, SPIFFS_CREAT, SPIFFS_RD_ONLY,
* SPIFFS_WR_ONLY, SPIFFS_RDWR, SPIFFS_DIRECT
* SPIFFS_O_APPEND, SPIFFS_O_TRUNC, SPIFFS_O_CREAT, SPIFFS_O_RDONLY,
* SPIFFS_O_WRONLY, SPIFFS_O_RDWR, SPIFFS_O_DIRECT, SPIFFS_O_EXCL
* @param mode ignored, for posix compliance
*/
spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_flags flags, spiffs_mode mode);
Expand Down Expand Up @@ -496,6 +534,24 @@ s32_t SPIFFS_close(spiffs *fs, spiffs_file fh);
*/
s32_t SPIFFS_rename(spiffs *fs, const char *old, const char *newPath);

#if SPIFFS_OBJ_META_LEN
/**
* Updates file's metadata
* @param fs the file system struct
* @param path path to the file
* @param meta new metadata. must be SPIFFS_OBJ_META_LEN bytes long.
*/
s32_t SPIFFS_update_meta(spiffs *fs, const char *name, const void *meta);

/**
* Updates file's metadata
* @param fs the file system struct
* @param fh file handle of the file
* @param meta new metadata. must be SPIFFS_OBJ_META_LEN bytes long.
*/
s32_t SPIFFS_fupdate_meta(spiffs *fs, spiffs_file fh, const void *meta);
#endif

/**
* Returns last error of last file operation.
* @param fs the file system struct
Expand Down Expand Up @@ -648,6 +704,85 @@ s32_t SPIFFS_tell(spiffs *fs, spiffs_file fh);
*/
s32_t SPIFFS_set_file_callback_func(spiffs *fs, spiffs_file_callback cb_func);

#if SPIFFS_IX_MAP

/**
* Maps the first level index lookup to a given memory map.
* This will make reading big files faster, as the memory map will be used for
* looking up data pages instead of searching for the indices on the physical
* medium. When mapping, all affected indicies are found and the information is
* copied to the array.
* Whole file or only parts of it may be mapped. The index map will cover file
* contents from argument offset until and including arguments (offset+len).
* It is valid to map a longer range than the current file size. The map will
* then be populated when the file grows.
* On garbage collections and file data page movements, the map array will be
* automatically updated. Do not tamper with the map array, as this contains
* the references to the data pages. Modifying it from outside will corrupt any
* future readings using this file descriptor.
* The map will no longer be used when the file descriptor closed or the file
* is unmapped.
* This can be useful to get faster and more deterministic timing when reading
* large files, or when seeking and reading a lot within a file.
* @param fs the file system struct
* @param fh the file handle of the file to map
* @param map a spiffs_ix_map struct, describing the index map
* @param offset absolute file offset where to start the index map
* @param len length of the mapping in actual file bytes
* @param map_buf the array buffer for the look up data - number of required
* elements in the array can be derived from function
* SPIFFS_bytes_to_ix_map_entries given the length
*/
s32_t SPIFFS_ix_map(spiffs *fs, spiffs_file fh, spiffs_ix_map *map,
u32_t offset, u32_t len, spiffs_page_ix *map_buf);

/**
* Unmaps the index lookup from this filehandle. All future readings will
* proceed as normal, requiring reading of the first level indices from
* physical media.
* The map and map buffer given in function SPIFFS_ix_map will no longer be
* referenced by spiffs.
* It is not strictly necessary to unmap a file before closing it, as closing
* a file will automatically unmap it.
* @param fs the file system struct
* @param fh the file handle of the file to unmap
*/
s32_t SPIFFS_ix_unmap(spiffs *fs, spiffs_file fh);

/**
* Moves the offset for the index map given in function SPIFFS_ix_map. Parts or
* all of the map buffer will repopulated.
* @param fs the file system struct
* @param fh the mapped file handle of the file to remap
* @param offset new absolute file offset where to start the index map
*/
s32_t SPIFFS_ix_remap(spiffs *fs, spiffs_file fh, u32_t offs);

/**
* Utility function to get number of spiffs_page_ix entries a map buffer must
* contain on order to map given amount of file data in bytes.
* See function SPIFFS_ix_map and SPIFFS_ix_map_entries_to_bytes.
* @param fs the file system struct
* @param bytes number of file data bytes to map
* @return needed number of elements in a spiffs_page_ix array needed to
* map given amount of bytes in a file
*/
s32_t SPIFFS_bytes_to_ix_map_entries(spiffs *fs, u32_t bytes);

/**
* Utility function to amount of file data bytes that can be mapped when
* mapping a file with buffer having given number of spiffs_page_ix entries.
* See function SPIFFS_ix_map and SPIFFS_bytes_to_ix_map_entries.
* @param fs the file system struct
* @param map_page_ix_entries number of entries in a spiffs_page_ix array
* @return amount of file data in bytes that can be mapped given a map
* buffer having given amount of spiffs_page_ix entries
*/
s32_t SPIFFS_ix_map_entries_to_bytes(spiffs *fs, u32_t map_page_ix_entries);

#endif // SPIFFS_IX_MAP


#if SPIFFS_TEST_VISUALISATION
/**
* Prints out a visualization of the filesystem.
Expand Down
Loading