Update littlefs2 to v0.5.0

This commit is contained in:
Robin Krahl
2025-03-06 09:55:34 +01:00
committed by sosthene-nitrokey
parent 370d724b6b
commit 4fc8f32ce1
4 changed files with 17 additions and 18 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ use core::convert::TryFrom;
use hex_literal::hex;
use littlefs2::{path, path::Path};
use littlefs2_core::{path, Path};
macro_rules! enum_subset {
(
+9 -9
View File
@@ -5,13 +5,13 @@ use flexiber::EncodableHeapless;
use heapless::Vec;
use heapless_bytes::Bytes;
use iso7816::Status;
use littlefs2::{path, path::Path};
use littlefs2_core::path;
use trussed::Client;
use trussed::{
api::reply::Metadata,
config::MAX_MESSAGE_LENGTH,
syscall, try_syscall,
types::{KeyId, KeySerialization, Location, Mechanism, PathBuf, StorageAttributes},
types::{KeyId, KeySerialization, Location, Mechanism, Path, PathBuf, StorageAttributes},
};
use trussed_chunked::utils;
@@ -544,7 +544,7 @@ impl Persistent {
pub const PIN_RETRIES_DEFAULT: u8 = 3;
// hmm...!
pub const PUK_RETRIES_DEFAULT: u8 = 5;
const FILENAME: &'static [u8] = b"persistent-state.cbor";
const FILENAME: &'static Path = path!("persistent-state.cbor");
const DEFAULT_PIN: Pin = Pin(*b"123456\xff\xff");
const DEFAULT_PUK: Puk = Puk(*b"12345678");
@@ -901,7 +901,7 @@ impl Persistent {
options: &crate::Options,
) -> Result<Self, Status> {
// todo: can't seem to combine load + initialize without code repetition
let data = load_if_exists(client, options.storage, &PathBuf::from(Self::FILENAME))?;
let data = load_if_exists(client, options.storage, Self::FILENAME)?;
let Some(bytes) = data else {
return Self::initialize(client, options);
};
@@ -930,11 +930,11 @@ impl Persistent {
fn load_if_exists(
client: &mut impl crate::Client,
location: Location,
path: &PathBuf,
path: &Path,
) -> Result<Option<Bytes<MAX_MESSAGE_LENGTH>>, Status> {
match try_syscall!(client.read_file(location, path.clone())) {
match try_syscall!(client.read_file(location, path.into())) {
Ok(r) => Ok(Some(r.data)),
Err(_) => match try_syscall!(client.entry_metadata(location, path.clone())) {
Err(_) => match try_syscall!(client.entry_metadata(location, path.into())) {
Ok(Metadata { metadata: None }) => Ok(None),
Ok(Metadata {
metadata: Some(_metadata),
@@ -1057,11 +1057,11 @@ impl ContainerStorage {
}
fn path_key(self) -> PathBuf {
PathBuf::from(self.path_key_str())
PathBuf::try_from(self.path_key_str()).unwrap()
}
fn path(self) -> PathBuf {
PathBuf::from(self.path_key_str().strip_suffix(".key").unwrap())
PathBuf::try_from(self.path_key_str().strip_suffix(".key").unwrap()).unwrap()
}
fn default(self) -> Option<Vec<u8, MAX_MESSAGE_LENGTH>> {
+3 -3
View File
@@ -11,7 +11,7 @@ pub mod dispatch {
service::ServiceResources,
types::{Bytes, Context, Location},
};
use trussed_auth::{AuthBackend, AuthContext, AuthExtension, MAX_HW_KEY_LEN};
use trussed_auth::{AuthBackend, AuthContext, AuthExtension, FilesystemLayout, MAX_HW_KEY_LEN};
use trussed_chunked::ChunkedExtension;
use trussed_hpke::HpkeExtension;
#[cfg(feature = "rsa")]
@@ -86,14 +86,14 @@ pub mod dispatch {
impl Dispatch {
pub fn new() -> Self {
Self {
auth: AuthBackend::new(Location::Internal),
auth: AuthBackend::new(Location::Internal, FilesystemLayout::V0),
staging: StagingBackend::new(),
}
}
pub fn with_hw_key(hw_key: Bytes<MAX_HW_KEY_LEN>) -> Self {
Self {
auth: AuthBackend::with_hw_key(Location::Internal, hw_key),
auth: AuthBackend::with_hw_key(Location::Internal, hw_key, FilesystemLayout::V0),
staging: StagingBackend::new(),
}
}