Skip to content

Conversation

kasjer
Copy link
Contributor

@kasjer kasjer commented Sep 30, 2025

This is start of a rework of file system related code.

There was a few drawbacks in current implementation of file system especially disk related (this does not touch FCB).

  • disk interface read and write used 32 bit byte addresses limiting usage to SD cards up to 4GB which is not much in current era. Now disk interface will use block address (instead of bytes) so it is more consistent with how disks are accessed (SD cards)
  • filesystem ops is now split to filesystem and filesystem ops (only functions), so same file system ops can be used by several file systems (few partitions or two SD cards)
  • code adds mount points so file systems can be mounted and unmouted
  • disk interface that is currently used for FAT only will be used also to expose SD cards to USB
  • Code adds cli command for mount points

Now fs cli commands are register at link time to
reduce memory footprint.
No change in functionality.

Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Disk interface tightly coupled to file system
and could not be used for exposing disk to something
else then code in fs/fs.

With this change new disk_listener interface allows
code to be informed about disks being inserted
and removed.

Listeners in turn can mount file systems from disk
or for example expose disk to USB host via MSC.

Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
File system was represented by fs_ops that consisted of
bunch of file system functions, name, and pointer to
link file system ops in chain.

Most of the date was constant and there is was no reason
to waste RAM for callback pointer.

This introduce file_system object that has ops but
can be extended to hold file system specific data.

Same file system ops can be used for more then one file
system.
File system can be mounted and that what littlefs and other
file systems will.

This change mostly changes filesystem_ops to const in most
places.

Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
This updates littlefs to use fs_mount instead
of fs_register.

Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
This updates nffs to use fs_mount instead
of fs_register.

Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
This adds command to show mounted file systems

Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
This adds file disk listener that can mount fatfs
disk (like sdcard) if it contains FAT data.

Fixes problem with accessing disk grater then 2GB.
Previous disk interface (that is now removed) used
32 bit to address bytes of disk.
Now disk access uses sectors as it the code for disk.

Further more file name conversion from sd0: to 0: is
now removed. FATFS driver wants to use 0: volumes
and mynewt wanted to have sd0:
Now disk will be mounted as 0: removing need for
conversion and heap allocations.

Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant