Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions src/driver.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! The `Storage`, `Read`, `Write` and `Seek` driver.
#![allow(non_camel_case_types)]

#[allow(deprecated)]
use generic_array::ArrayLength;

use crate::io::Result;
Expand Down Expand Up @@ -46,9 +47,11 @@ pub trait Storage {
/// littlefs uses a read cache, a write cache, and one cache per per file.
/// Must be a multiple of `READ_SIZE` and `WRITE_SIZE`.
/// Must be a factor of `BLOCK_SIZE`.
#[allow(deprecated)]
type CACHE_SIZE: ArrayLength<u8>;

/// Size of the lookahead buffer used by littlefs, measured in multiples of 8 bytes.
#[allow(deprecated)]
type LOOKAHEAD_SIZE: ArrayLength<u64>;

///// Maximum length of a filename plus one. Stored in superblock.
Expand Down
16 changes: 5 additions & 11 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use generic_array::typenum::marker_traits::Unsigned;
use littlefs2_sys as ll;

// so far, don't need `heapless-bytes`.
#[allow(deprecated)]
pub type Bytes<SIZE> = generic_array::GenericArray<u8, SIZE>;

pub use littlefs2_core::{Attribute, DirEntry, FileOpenFlags, FileType, Metadata};
Expand Down Expand Up @@ -47,6 +48,7 @@ struct Cache<Storage: driver::Storage> {
read: UnsafeCell<Bytes<Storage::CACHE_SIZE>>,
write: UnsafeCell<Bytes<Storage::CACHE_SIZE>>,
// lookahead: aligned::Aligned<aligned::A4, Bytes<Storage::LOOKAHEAD_SIZE>>,
#[allow(deprecated)]
lookahead: UnsafeCell<generic_array::GenericArray<u64, Storage::LOOKAHEAD_SIZE>>,
}

Expand Down Expand Up @@ -118,17 +120,9 @@ impl<Storage: driver::Storage> Allocation<Storage> {
debug_assert!(cache_size > 0);
debug_assert!(lookahead_size > 0);

// cache must be multiple of read
debug_assert!(read_size <= cache_size);
debug_assert!(cache_size % read_size == 0);

// cache must be multiple of write
debug_assert!(write_size <= cache_size);
debug_assert!(cache_size % write_size == 0);

// block must be multiple of cache
debug_assert!(cache_size <= block_size);
debug_assert!(block_size % cache_size == 0);
debug_assert!(cache_size.is_multiple_of(read_size));
debug_assert!(cache_size.is_multiple_of(write_size));
debug_assert!(block_size.is_multiple_of(cache_size));

let cache = Cache::new();

Expand Down