From: Simon Glass <sjg@chromium.org>
Add the mount uclass which tracks filesystem mount points. Each mount
device holds a struct vfsmount with the mount point name and a
reference to the mounted UCLASS_FS device.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
configs/sandbox_defconfig | 1 +
fs/Kconfig | 7 +++++++
fs/Makefile | 1 +
fs/mount-uclass.c | 18 ++++++++++++++++++
include/dm/uclass-id.h | 1 +
include/vfs.h | 31 +++++++++++++++++++++++++++++++
6 files changed, 59 insertions(+)
create mode 100644 fs/mount-uclass.c
create mode 100644 include/vfs.h
@@ -113,6 +113,7 @@ CONFIG_CMD_WDT=y
CONFIG_CMD_WRITE=y
CONFIG_CMD_AXI=y
CONFIG_CMD_CAT=y
+CONFIG_VFS=y
CONFIG_CMD_SETEXPR_FMT=y
CONFIG_CMD_XXD=y
CONFIG_CMD_DHCP6=y
@@ -29,6 +29,13 @@ config FILE
(UCLASS_FS). Note that a UCLASS_FILE device is only created when it
is opened.
+config VFS
+ bool "Virtual filesystem support"
+ depends on FS && DIR
+ help
+ Provides a virtual filesystem layer with a mount table and
+ unified path namespace. Includes a root filesystem at "/".
+
config FS_LEGACY
def_bool y
help
@@ -8,6 +8,7 @@ obj-$(CONFIG_$(PHASE_)FS_LEGACY) += fs_legacy.o fs_internal.o
obj-$(CONFIG_$(PHASE_)FS) += fs-uclass.o
obj-$(CONFIG_$(PHASE_)DIR) += dir-uclass.o
obj-$(CONFIG_$(PHASE_)FILE) += file-uclass.o
+obj-$(CONFIG_$(PHASE_)VFS) += mount-uclass.o
ifdef CONFIG_XPL_BUILD
obj-$(CONFIG_SPL_FS_FAT) += fat/
new file mode 100644
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Virtual Filesystem layer
+ *
+ * Manages a mount table using UCLASS_MOUNT devices, providing unified
+ * path resolution across mounted filesystems. Inspired by the Linux VFS.
+ *
+ * Copyright 2026 Simon Glass <sjg@chromium.org>
+ */
+
+#include <dm.h>
+#include <vfs.h>
+
+UCLASS_DRIVER(mount) = {
+ .name = "mount",
+ .id = UCLASS_MOUNT,
+ .per_device_auto = sizeof(struct vfsmount),
+};
@@ -105,6 +105,7 @@ enum uclass_id {
UCLASS_MISC, /* Miscellaneous device */
UCLASS_MMC, /* SD / MMC card or chip */
UCLASS_MOD_EXP, /* RSA Mod Exp device */
+ UCLASS_MOUNT, /* Filesystem mount point */
UCLASS_MOUSE, /* Mouse, trackpad or other pointing device */
UCLASS_MTD, /* Memory Technology Device (MTD) device */
UCLASS_MUX, /* Multiplexer device */
new file mode 100644
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Virtual Filesystem layer for U-Boot
+ *
+ * Provides a unified path namespace with mount points, inspired by the
+ * Linux VFS but heavily cut down for U-Boot's needs.
+ *
+ * Copyright 2026 Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __VFS_H
+#define __VFS_H
+
+struct udevice;
+
+/**
+ * struct vfsmount - A mount point in the VFS
+ *
+ * This is the UCLASS_MOUNT per-device uclass-private data. All mount
+ * devices are children of the VFS root FS device. Each links a mount-point
+ * directory to a UCLASS_FS device.
+ *
+ * @dir: UCLASS_DIR device that is the mount point
+ * @target: UCLASS_FS device that is mounted here
+ */
+struct vfsmount {
+ struct udevice *dir;
+ struct udevice *target;
+};
+
+#endif