From patchwork Fri Apr 3 14:04:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2096 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=1775225174; bh=ZkJbr370FfVNxX6PqVNPprLDUPuazJsW8LNAxOIhM3o=; 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=D9DmQ153mNmajr63HT1PQ+YavSjaEp1j9/R7owjx5KX05E4TF1j6Op/1f3BB1DQSJ rdNwLvZbMKbUJcQMfKKGVQq8v2rz3BZAtmmuTkp+PjcD6aNPqgPhMdKuLkoD1CIXCA Pyq7gZp/jWh++foMgjQfq8H/5wuo1lNgUUjHYPuxvRs2Me7PHgQp0tlxs0xV2PzCuu pXdlQ7B4n59O+07sciJ/ZFM3N9pMxyLTjYPO7qEipiNSRy17SF9h6VMXqGW5Oqu6tD htaKvIyyTLc8XLKnGVTnIn85qTmJziOHBMOVDAe/I6dMA1kaXspX7vjUJHiRetaUbb 7J35P1bcWjZcA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 355D96A379 for ; Fri, 3 Apr 2026 08:06:14 -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 veLlXXt8aWLF for ; Fri, 3 Apr 2026 08:06:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225169; bh=ZkJbr370FfVNxX6PqVNPprLDUPuazJsW8LNAxOIhM3o=; 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=HUzSR2gJ0RPbwR+rna85R0qPTwZ2KXlfWgNQqLgbDM4Kawf7jDxhbBzRj2q+aYAY6 melHO/wHCu2TXqn1w+TUQ0J3w00EtZfSR5ju2h6SmLPh38VRRNG45V7exDZmtErqd6 tCpQV3CLAtc51nzGyyCehTt+YV3PosIJSbr/eKuCDZut3scvFQDziKeNpcFfUlCmgt 4o9n9+KFWgc63UGSflq6tDFGluipKLWJK72Z0JucYLf6mZ55kb5YCS8hQZKAUBJjqG 6AJbykry9g7gG3JbO/5CuyLxi4ktXJcv8nNzoTWUoAOjoKarbbklF2uifl1SJa7Sfa 65osnqBhRQ9wQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1B6106A366 for ; Fri, 3 Apr 2026 08:06:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225167; bh=mff6/bIO1uQv5fcjGu/BloLS7R6LJiehvwAs4kD5NbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sw7rJ3W2ZJNcdrCdhKSdCXDij/jxDltPpyOiGpZ1Kj0Axe3a4N1TDEWot3GZJGz+/ W0pKhNHhi7m1sLmIX/7SBovB4STOvKiCK0L2Jx7u89CndayVhYXrVjf3fJhAQ3KQbV 0zNk56VOBd3/ka5G16d1tkD3XDBLnxCGv7W/DbpvaEKoNt84krP/M53nmSqHpqQr5k DQZMDRmhaRcpe/dyJxDMlNP8i2KioHhDlgkyx6UunH95lmYx9NRTj7VRN99XJZILAs yryg8dH/EiphVITPASY/fU1NlhqIulxq4dviydjjOEpbHmylrhDXQ4fxImiZbr5yPq 1v+ZBwuxQhVZA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0DD286A365; Fri, 3 Apr 2026 08:06:07 -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 aGRxMu_qmrtn; Fri, 3 Apr 2026 08:06:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225159; bh=fxaORihxlHWPpc9ww1gZxcloicpYMYZANzVJ+IZT3aM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XU9ZOhUNcOope2gglt0LBbj74+TPio/CU1+/AYrFXkRBbGHEgpHpiZPo4910syIO8 QRIIP84huqFStuOSetilnYE8guIKr7uu1blxrpT74j9YPHyT3YPrE2y70Pg/6/NCOY gliwuwD6MMRpcBcI6SxLq5UdZR9/chxXTKhO2RMYBaj1z9mHH1P9mLWSQJIGWBQZUS RJAtpvC5tZf7rw8JgaYFsSeOzoGP3WLIewbRWuIHku/bCaazVof0aD7Ur8CVeV50G2 ufl6NKIj8GATGrgTKbODfIV7Bt/QnfgUVcpQG7dUu8XGMQSwL9xtTBbZhKD01l0REI rktmgAWWDanXA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5E37F6A368; Fri, 3 Apr 2026 08:05:59 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 3 Apr 2026 08:04:33 -0600 Message-ID: <20260403140523.1998228-12-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: QFCGBGHMZCG2ID4PGQHO3DI6H3ZB53FT X-Message-ID-Hash: QFCGBGHMZCG2ID4PGQHO3DI6H3ZB53FT 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 11/34] vfs: Filter dir lookup to skip non-DIR children 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 fs_lookup_dir() iterates all children of an FS device looking for a cached directory but does not filter by uclass. With the addition of the MOUNT uclass, a non-directory child whose uclass-private data is misinterpreted as struct dir_uc_priv can cause a false path match. Add a UCLASS_DIR check to skip non-directory children. Signed-off-by: Simon Glass --- fs/fs-uclass.c | 2 ++ fs/vfs.c | 7 +++++++ fs/vfs_dir.c | 10 ++++++++++ include/vfs.h | 8 ++++++++ 4 files changed, 27 insertions(+) diff --git a/fs/fs-uclass.c b/fs/fs-uclass.c index 6bb50bb2543..2525067f166 100644 --- a/fs/fs-uclass.c +++ b/fs/fs-uclass.c @@ -61,6 +61,8 @@ int fs_lookup_dir(struct udevice *dev, const char *path, struct udevice **dirp) if (!device_active(dir)) continue; + if (device_get_uclass_id(dir) != UCLASS_DIR) + continue; priv = dev_get_uclass_priv(dir); log_debug("dir %s '%s' '%s'\n", dir->name, path, priv->path); diff --git a/fs/vfs.c b/fs/vfs.c index c42e60b4dc6..db1aa84bfd6 100644 --- a/fs/vfs.c +++ b/fs/vfs.c @@ -311,6 +311,13 @@ int vfs_umount_path(struct udevice *vfs, const char *path) return vfs_umount(mnt_dev); } +bool vfs_is_mount_point(struct udevice *dir) +{ + struct udevice *mnt; + + return !find_mount(dir, &mnt); +} + void vfs_print_mounts(void) { struct vfsmount *mnt; diff --git a/fs/vfs_dir.c b/fs/vfs_dir.c index 87a4193516e..5c3b5a2952b 100644 --- a/fs/vfs_dir.c +++ b/fs/vfs_dir.c @@ -13,6 +13,7 @@ #include #include #include +#include #include static int vfs_rootfs_dir_open(struct udevice *dev, @@ -81,8 +82,17 @@ static struct dir_ops vfs_rootfs_dir_ops = { .close = vfs_rootfs_dir_close, }; +static int vfs_rootfs_dir_remove(struct udevice *dev) +{ + if (vfs_is_mount_point(dev)) + return log_msg_ret("drm", -EBUSY); + + return 0; +} + U_BOOT_DRIVER(vfs_rootfs_dir) = { .name = "vfs_rootfs_dir", .id = UCLASS_DIR, .ops = &vfs_rootfs_dir_ops, + .remove = vfs_rootfs_dir_remove, }; diff --git a/include/vfs.h b/include/vfs.h index d7b6449b088..6673f9a5ef1 100644 --- a/include/vfs.h +++ b/include/vfs.h @@ -112,6 +112,14 @@ int vfs_umount_path(struct udevice *vfs, const char *path); int vfs_find_mount(struct udevice *vfs, const char *path, struct udevice **mntp, const char **subpathp); +/** + * vfs_is_mount_point() - Check whether a directory is a mount point + * + * @dir: UCLASS_DIR device to check + * Return: true if this directory has an active mount, false otherwise + */ +bool vfs_is_mount_point(struct udevice *dir); + /** * vfs_print_mounts() - Print all current mounts */