From 599d205e47a7430dfed1c37263fa565597b6597f Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 14 Oct 2024 15:54:45 +0200 Subject: [PATCH] Update littlefs2 to v0.5.0 --- Cargo.toml | 8 ++++---- src/admin.rs | 7 +++++-- src/config.rs | 2 +- src/migrations.rs | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ebb1222..b5aa712 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,8 @@ cbor-smol = { version = "0.5.0", features = ["heapless-v0-7", "heapless-bytes-v0 ctaphid-dispatch = "0.1" delog = "0.1" iso7816 = "0.1" -littlefs2 = "0.4" +littlefs2 = { version = "0.5", optional = true } +littlefs2-core = { version = "0.1", features = ["heapless-bytes03"] } serde = { version = "1.0.180", default-features = false } strum_macros = "0.25.2" trussed = "0.1" @@ -39,11 +40,10 @@ log-warn = [] log-error = [] # Utils to test migration -migration-tests = [] +migration-tests = ["dep:littlefs2"] [patch.crates-io] ctaphid-dispatch = { git = "https://github.com/trussed-dev/ctaphid-dispatch.git", rev = "57cb3317878a8593847595319aa03ef17c29ec5b" } -littlefs2 = { git = "https://github.com/trussed-dev/littlefs2.git", rev = "ebd27e49ca321089d01d8c9b169c4aeb58ceeeca" } -trussed = { git = "https://github.com/Nitrokey/trussed.git", tag = "v0.1.0-nitrokey.18" } +trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "046478b7a4f6e2315acf9112d98308379c2e3eee" } trussed-manage = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "manage-v0.1.0" } trussed-se050-manage = { git = "https://github.com/Nitrokey/trussed-se050-backend.git", tag = "se050-manage-v0.1.0" } diff --git a/src/admin.rs b/src/admin.rs index 3c9a1fd..85b3580 100644 --- a/src/admin.rs +++ b/src/admin.rs @@ -5,7 +5,7 @@ use core::{convert::TryInto, marker::PhantomData, time::Duration}; use ctaphid_dispatch::app::{self as hid, Command as HidCommand, Message}; use ctaphid_dispatch::command::VendorCommand; #[cfg(feature = "factory-reset")] -use littlefs2::path::PathBuf; +use littlefs2_core::PathBuf; use serde::Deserialize; use trussed::store::Store; use trussed::try_syscall; @@ -449,6 +449,10 @@ where response.push(FACTORY_RESET_APP_FAILED_PARSE).ok(); return Ok(()); }; + let Ok(path) = PathBuf::try_from(client) else { + response.push(FACTORY_RESET_APP_FAILED_PARSE).ok(); + return Ok(()); + }; let Some((_, flag)) = self.config().reset_client_id(client) else { response.push(FACTORY_RESET_APP_NOT_ALLOWED).ok(); @@ -460,7 +464,6 @@ where response.push(FACTORY_RESET_NOT_CONFIRMED).ok(); return Ok(()); } - let path = PathBuf::from(client); match self.config.reset_client_config(client) { crate::config::ResetConfigResult::Changed => { diff --git a/src/config.rs b/src/config.rs index 7b9bd1d..0bb70c5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,7 +5,7 @@ use core::{ }; use cbor_smol::{cbor_deserialize, cbor_serialize_to}; -use littlefs2::{path, path::Path}; +use littlefs2_core::{path, Path}; use serde::{de::DeserializeOwned, Serialize}; use strum_macros::FromRepr; use trussed::{ diff --git a/src/migrations.rs b/src/migrations.rs index 519549c..5c19aac 100644 --- a/src/migrations.rs +++ b/src/migrations.rs @@ -1,11 +1,11 @@ -use littlefs2::object_safe::DynFilesystem; +use littlefs2_core::DynFilesystem; #[derive(Debug)] pub struct Migrator { /// The function performing the migration /// /// First argument is the Internal Filesystem, second argument is the External - pub migrate: fn(&dyn DynFilesystem, &dyn DynFilesystem) -> Result<(), littlefs2::io::Error>, + pub migrate: fn(&dyn DynFilesystem, &dyn DynFilesystem) -> Result<(), littlefs2_core::Error>, /// The version of the storage for which the migration needs to be run pub version: u32,