5 Commits

Author SHA1 Message Date
Simon Glass
2b66e2f9d3 fs: Reuse a directory device when accessing the same dir
At present a new directory device is created for every access to a
directory. This means that a new device is always created when 'ls' is
used.

Where the directory being accessed matches an existing device, this is
not necessary.

Check that path against existing directories and reuse the device if
possible.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 15:14:47 +02:00
Simon Glass
5ab90a9307 virtio: Plumb virtio-fs into the legacy filesystem code
Add compatibility function to support a single virtio-fs via the normal
'ls' and 'load' commands. Other commands are not supported for now.

Add a workaround for the fact that virtiofs does not use a block device.
The existing filesystem layer does not support non-block filesystems -
sandbox's hostfs mostly bypasses this code.

Make sure that sandbox does not try to mount a virtio-fs as this does
not work at present. It will require either a fake driver for virtio-fs
which connects to host files, or possibly something involving FUSE.

Series-to: concept
Cover-letter:
virtio: Support virtio-fs
This series introduces support for virtio-fs, a filesystem which
provides access to host files from within a QEMU guest OS.

A new filesystem driver is created with support for the three uclasses
(FS, DIR, FILE). A compatibility layer is added as well, so that the
existing cmdline work as expected.

Only listing directories and reading files are supported so far.

Since sandbox works by using a NULL blk_desc, a workaround is added for
now. Once we switch commands (and bootstd!) over to the new filesystem
approach, this will go away.

It is possible to test this using something like:

   ./scripts/build-qemu -a x86  -rs -D .

then within U-Boot:

   ls virtio 0
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-30 11:57:41 -06:00
Simon Glass
4ae46c7db4 fs: Add support for a directory
Filesystems can have a number of directories within them. U-Boot only
worries about directories that have been accessed. Add the concept of
a directory, with the filesystem as parent.

Note that this is not a hierarchical device structure, so UCLASS_DIR
devices always have a UCLASS_FS as the parent.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 12:30:56 -06:00
Simon Glass
d347548467 fs: Add simple sandbox test
Add a simple test of a filesystem on sandbox.
2025-06-28 12:30:56 -06:00
Simon Glass
48655e4aa9 fs: Add support for a filesystem
The existing filesystem support is fairly basic. It supports access to
only one filesystem at a time, does not allow caching, does not have an
equivalent of Linux's VFS and uses global variables to keep track of
which one is in use.

As a starting point to improving this, provide a filesystem uclass. For
now it only includes operations to mount and unmount.

Provide a bootdev so that it is possible to locate bootflows on a
filesystem.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 12:30:56 -06:00