From patchwork Fri Apr 3 14:04:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2090 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225160; bh=4+AFOhdrgBtpJDuoQ5AwLbINLHbeGVdOsIUHTKOt/CQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=CZpBxQj3h/y1yxCapdbwSuckIxhW/YbSWEIudoX0i+7dlPwLbwFn86mU35WfvPs0a 3WUbnyFX5KFyTg/6/DWqLCWjEFmlcxfNS5QZjVs/jByyFVQO4dmNnwvqmeQCebuK1p oLCeuPfXjCSYawhbu9OErzKZIKcikZa0CEHuB6hdzwP55x3Zt3Pi9QrsiPN+gPRdGo cdjS0ypsamcV1yu/LBolcp68E+lEOyD/datbC0i04DQhfhtIuAnob8HUwCuBc6HtsV EF4wnyF9KXnOa37XMw+HY0M/ko0aYaIIfcYp4dnvszN1WHuK8/8PfPNbvlOORGY+8S kohjhetK9l+Uw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DC0CB6A35E for ; Fri, 3 Apr 2026 08:06:00 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id JNakDijMDLZB for ; Fri, 3 Apr 2026 08:06:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225158; bh=4+AFOhdrgBtpJDuoQ5AwLbINLHbeGVdOsIUHTKOt/CQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=J63Pnr5mSK8fSHZGa9hCnGGl9fREMTwkz2Eiie/gQ1O7nFzJh1Jc79mY425ZYf99i FYz0luLcj5/1EK051BNBlnwndr2TFwj5wHfOtmQ25cKZyWfK1x2oyEqif0A4Qw3/Xq tXb0zwkI1ow5dmlkAHq9420/McIXywQ93aesC2WX9ZW82COWNi0f8OiqxOeSmQ4cG5 tAvsC/0CKbni0/cY3Uco8ztu4YVxvtQLF/tLguKS9HjJhs/DUzy2NTqmGzEg1Z8rOU BmioODA74OFnWFTGY84xkiR/J21LfsngbuXTUVPpQUgDtjUHAnaWHaN5MV3zySUHBh lIHRt10jdnuFA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C0E846A35F for ; Fri, 3 Apr 2026 08:05:58 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225155; bh=B1VBEzHcb54AV7T0jqO9Zo7/mwqELQftJ8qYKgwzK6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DNCM3YIyqXASNvnRnx5CBQm/9hHx6qZ7WmWSASbS40naM/thOgOyZBmDbtvlVm/HO jZvijXrpWAAHJomuFl3Pxm+54U3JHVRVC62BWEg/fWu+XyaHNCrw/UwBI3SPesueqh Kru4qGMLkegCvg/PnnwracJDKVnzLPCsA/QMDO4euRVH7RGDHdZku0cncx7RetIMxd sHqT3/UtdBEVKjsmYjA0DTeu8Ft7PBT9WPeyXx47MM2N6BmgHPliBXpt2SGB/gnqlY MO0eDEIvLZD4TuUinZ2tt1AdbwbpZENjsWG/A74tecabUn/RFC1Y8dzrAIQGKQml9X NFvHZVDF7gt8A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 805716A347; Fri, 3 Apr 2026 08:05:55 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id yGq9uB3tuPSC; Fri, 3 Apr 2026 08:05:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225154; bh=S5VVvVsgs7dnYEUXiYuR8AX0k2o+ewgbN6878QEojok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eZJotTLCMRurDDfW7xX0lbqVNYNQn6gdrefy0/mj/sYwY0LQaasOTPyU2pugkrIzx NMocQ5MVIevBeQ0eZ4MDyxzJHTWv8wr/xOwnxPawO/QTrqWPtTU4R02yS3YXTryn0v kQpesr+BNrp2baJYJOJ5JIgDc+SSCED4wc2108JNkE3MXGR8ZtfEau3RZRauOw0KjA n7kwnV/8auhh3I7RCkBmZ41DPzdNwY/TlO0AiODfvKWhn2y9NTgPvCDGoE7Tpxz/V6 BmANLIpUrlr19AJXVVjn54SPA7JdmSZ/XPVev80i5w8xW41jwc0HWzrOpvVUOGjjnG oNBqq+r0oyeYg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9F8AD6A34E; Fri, 3 Apr 2026 08:05:54 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 3 Apr 2026 08:04:28 -0600 Message-ID: <20260403140523.1998228-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260403140523.1998228-1-sjg@u-boot.org> References: <20260403140523.1998228-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: OQVPHKTEANZIGLUCLNBPOFCP3W7O7S7Z X-Message-ID-Hash: OQVPHKTEANZIGLUCLNBPOFCP3W7O7S7Z X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/34] vfs: Add UCLASS_MOUNT for the virtual filesystem List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 --- 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 diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index a08a838303b..76113ce711e 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -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 diff --git a/fs/Kconfig b/fs/Kconfig index 13f7d084c09..6a55bd71adc 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -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 diff --git a/fs/Makefile b/fs/Makefile index 969888a81da..ffb6bbce737 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -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/ diff --git a/fs/mount-uclass.c b/fs/mount-uclass.c new file mode 100644 index 00000000000..4cfc1d0ed02 --- /dev/null +++ b/fs/mount-uclass.c @@ -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 + */ + +#include +#include + +UCLASS_DRIVER(mount) = { + .name = "mount", + .id = UCLASS_MOUNT, + .per_device_auto = sizeof(struct vfsmount), +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 6425ee88fa7..de79343904d 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -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 */ diff --git a/include/vfs.h b/include/vfs.h new file mode 100644 index 00000000000..7c31caace25 --- /dev/null +++ b/include/vfs.h @@ -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 + */ + +#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