Skip to content

Commit 7f1a5e8

Browse files
Add unstable-littlefs-patched feature
In #27, we updated littlefs to a patched version that backports a change from littlefs v2.11 (filesystem shrinking) and adds a feature that has not been merged upstream yet (config flag to disable block count check on mount). To be able to cut a new release without rolling out these changes to all users, this patch adds the new unstable-littlefs-patched feature that enables these changes.
1 parent 1cfd35c commit 7f1a5e8

File tree

7 files changed

+27
-7
lines changed

7 files changed

+27
-7
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ jobs:
4141
cargo check --all-features
4242
4343
- name: Build
44-
run: cargo build --release --verbose
44+
run: |
45+
cargo build --release
46+
cargo build --release --features unstable-littlefs
4547
4648
- name: Run clippy
4749
if: matrix.target == 'x86_64-unknown-linux-gnu'

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "littlefs"]
22
path = littlefs
3+
url = https://github.com/ARMmbed/littlefs
4+
[submodule "littlefs-patched"]
5+
path = littlefs-patched
36
url = https://github.com/trussed-dev/littlefs

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010

1111
- Derive `Default` if possible
12+
- Add `unstable-littlefs-patched` feature. Enabling this feature may break semantic versioning guarantees. If this feature is enabled, a patched version of littlefs ([v2.9-trussed.1](https://github.com/trussed-dev/littlefs/releases/tag/v2.9-trussed.1)) is used with the following changes from v2.9.3:
13+
- [Add config flag to disable block count check on mount](https://github.com/trussed-dev/littlefs/commit/5328ae4b2ad95088a8079c0dfbc623df45598a88)
14+
- [Add support for shrinking a filesystem](https://github.com/trussed-dev/littlefs/commit/9a6ef46eb43e7edfdfdba04e50c602a8173b456c)
1215

1316
## [0.3.1] - 2025-02-27
1417

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ trace = []
1919
malloc = []
2020
software-intrinsics = []
2121
multiversion = []
22+
23+
# unstable features -- enabling one of the following features may break semantic versioning guarantees
24+
25+
# use a patched version of littlefs: https://github.com/trussed-dev/littlefs/releases/tag/v2.9-trussed.1
26+
unstable-littlefs-patched = []

build.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ use std::env;
22
use std::path::PathBuf;
33

44
fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
let littlefs_path = if cfg!(feature = "unstable-littlefs-patched") {
6+
"littlefs-patched"
7+
} else {
8+
"littlefs"
9+
};
510
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
611

712
// Patch lfs.h to remove the lfs_util import because clang fails to locate the
@@ -10,8 +15,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1015
// which comes as a distribution with these utils.
1116
// Turns out lfs_utils is not used in lfs.h, and clang properly finds stdint.h and stdbool,
1217
// but not string.h
13-
let lfs_h = std::fs::read_to_string("littlefs/lfs.h").expect("Reading lfs.h succeeds");
14-
println!("cargo::rerun-if-changed=littlefs/lfs.h");
18+
let lfs_h =
19+
std::fs::read_to_string(format!("{littlefs_path}/lfs.h")).expect("Reading lfs.h succeeds");
20+
println!("cargo::rerun-if-changed={littlefs_path}/lfs.h");
1521
let out_lfs_h = out_path.join("lfs.h");
1622
std::fs::write(
1723
&out_lfs_h,
@@ -29,9 +35,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2935
.flag("-DLFS_NO_WARN")
3036
.flag("-DLFS_NO_ERROR")
3137
.include(&out_path)
32-
.include("littlefs")
33-
.file("littlefs/lfs.c")
34-
.file("littlefs/lfs_util.c")
38+
.include(littlefs_path)
39+
.file(format!("{littlefs_path}/lfs.c"))
40+
.file(format!("{littlefs_path}/lfs_util.c"))
3541
.file("string.c");
3642

3743
#[cfg(feature = "software-intrinsics")]

littlefs

littlefs-patched

Submodule littlefs-patched added at 5328ae4

0 commit comments

Comments
 (0)