fs: Provide information about non-block filesystems

The existing disk and partition code assumes a block device.

Sandbox provides access to host files and does not operate through a
block device. This is currently handled with special-case logic.

We want to add virtio-fs support, which is also not a block device. It
is not easy to have these two co-exist, so add a new type field to
struct disk_partition to indicate the type.

This is a work-around to deal with the fact that the type needs to be
set by blk_get_device_part_str() in such a way that it is visible to
fs_readdir()

There is a global fs_type in disk/part.c but this is not available in
the fs/ code.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-06-25 06:23:03 -06:00
parent 8630e568b2
commit b3cbdc4951
3 changed files with 8 additions and 1 deletions

View File

@@ -477,7 +477,8 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
if (!strcmp(ifname, "hostfs")) {
strcpy((char *)info->type, BOOT_PART_TYPE);
strcpy((char *)info->name, "Host filesystem");
info->fs_type = IS_ENABLED(CONFIG_SANDBOX) ? FS_TYPE_SANDBOX :
FS_TYPE_SEMIHOSTING;
return 0;
}
#endif

View File

@@ -483,7 +483,11 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
if (!fs_dev_desc && !info->null_dev_desc_ok)
continue;
if (fs_partition.fs_type &&
fs_partition.fs_type != info->fstype)
continue;
log_debug("probe %s\n", info->name);
if (!info->probe(fs_dev_desc, &fs_partition)) {
fs_type = info->fstype;
fs_dev_part = part;

View File

@@ -7,6 +7,7 @@
#define _PART_H
#include <blk.h>
#include <fs_common.h>
#include <ide.h>
#include <u-boot/uuid.h>
#include <linker_lists.h>
@@ -84,6 +85,7 @@ struct disk_partition {
#ifdef CONFIG_DOS_PARTITION
uchar sys_ind; /* partition type */
#endif
enum fs_type_t fs_type; /* type used for hostfs and virtio-fs */
};
/* Accessors for struct disk_partition field ->uuid */