2 Star 0 Fork 0

mirrors_ARMmbed/littlefs-fuse

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

The little filesystem in user-space

A FUSE wrapper that puts the littlefs in user-space.

FUSE - https://github.com/libfuse/libfuse
littlefs - https://github.com/geky/littlefs

This project allows you to mount littlefs directly in a host PC. This allows you to easily debug an embedded system using littlefs on removable storage, or even debug littlefs itself, since the block device can be viewed in a hex-editor simultaneously.

littlefs-fuse uses FUSE to interact with the host OS kernel, which means it can be compiled into a simple user program without kernel modifications. This comes with a performance penalty, but works well for the littlefs, since littlefs is intended for embedded systems.

Currently littlefs-fuse has been tested on the following OSs:

Usage on Linux

littlefs-fuse requires FUSE version 2.6 or higher, you can find your FUSE version with:

fusermount -V

In order to build against FUSE, you will need the package libfuse-dev:

sudo apt-get install libfuse-dev

Once you have cloned littlefs-fuse, you can compile the program with make:

make

This should have built the lfs program in the top-level directory.

From here we will need a block device. If you don't have removable storage handy, you can use a file-backed block device with Linux's loop devices:

sudo chmod a+rw /dev/loop0                  # make loop device user accessible
dd if=/dev/zero of=image bs=512 count=2048  # create a 1MB image
losetup /dev/loop0 image                    # attach the loop device

littlefs-fuse has two modes of operation, formatting and mounting.

To format a block device, pass the --format flag. Note! This will erase any data on the block device!

./lfs --format /dev/loop0

To mount, run littlefs-fuse with a block device and a mountpoint:

mkdir mount
./lfs /dev/loop0 mount

Once mounted, the littlefs filesystem will be accessible through the mountpoint. You can now use the littlefs like you would any other filesystem:

cd mount
echo "hello" > hi.txt
ls
cat hi.txt

After using littlefs, you can unmount and detach the loop device:

cd ..
umount mount
sudo losetup -d /dev/loop0

Usage on FreeBSD

littlefs-fuse requires FUSE version 2.6 or higher, you can find your FUSE version with:

pkg info fusefs-libs | grep Version

Once you have cloned littlefs-fuse, you can compile the program with make:

gmake

This should have built the lfs program in the top-level directory.

From here we will need a block device. If you don't have removable storage handy, you can use a file-backed block device with FreeBSD's loop devices:

dd if=/dev/zero of=imageBSD bs=1m count=1   # create a 1 MB image
sudo mdconfig -at vnode -f image            # attach the loop device
sudo chmod 666 /dev/mdX                     # make loop device user accessible,
                                            # where mdX is device created with mdconfig command

littlefs-fuse has two modes of operation, formatting and mounting.

To format a block device, pass the --format flag. Note! This will erase any data on the block device!

./lfs --format /dev/md0

To mount, run littlefs-fuse with a block device and a mountpoint:

mkdir mount
./lfs /dev/md0 mount

Once mounted, the littlefs filesystem will be accessible through the mountpoint. You can now use the littlefs like you would any other filesystem:

cd mount
echo "hello" > hi.txt
ls
cat hi.txt

After using littlefs, you can unmount and detach the loop device:

cd ..
umount mount
sudo mdconfig -du 0

Limitations

As an embedded filesystem, littlefs is designed to be simple. By default, this comes with a number of limitations compared to more PC oriented filesystems:

  • No timestamps, this will cause some programs, such as make to fail
  • No user permissions, this is why all of the files show up bright green in ls, all files are accessible by anyone
  • No symbolic links or special device files, currently only regular and directory file-types are implemented

Tips

If the littlefs was formatted with different geometry than the physical block device, you can override what littlefs-fuse detects. lfs -h lists all available options:

./lfs --block_size=512 --format /dev/loop0
./lfs --block_size=512 /dev/loop0 mount

You can run littlefs-fuse in debug mode to get a log of the kernel interactions with littlefs-fuse. Any printfs in the littlefs driver will end up here:

./lfs -d /dev/loop0 mount

You can even run littlefs-fuse in gdb to debug the filesystem under user operations. Note! When gdb is halted this will freeze any programs interacting with the filesystem!

make DEBUG=1 clean all                # build with debug info
gdb --args ./lfs -d /dev/loop0 mount  # run with gdb

Using xxd or other hex-editory is very useful for inspecting the block device while debugging. You can even run xxd from inside gdb using gdb's ! syntax:

dd if=/dev/loop0 bs=512 count=1 skip=0 | xxd -g1
Copyright (c) 2022, the littlefs authors. Copyright (c) 2017, Arm Limited. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of ARM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

A FUSE wrapper that puts the littlefs in user-space 展开 收起
README
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_ARMmbed/littlefs-fuse.git
git@gitee.com:mirrors_ARMmbed/littlefs-fuse.git
mirrors_ARMmbed
littlefs-fuse
littlefs-fuse
master

搜索帮助