From patchwork Sat Apr 11 00:36:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2160 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=1775867831; bh=1H6hmnXtkeuYHM7eZLXMMEOo74aDVIly9WHFRD2ARCU=; 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=sHQNvu/TQc3ewbUFI7+masLVOhNcKF+9dbSlPW0cMIW8ZxQjEQ+1WfKlF7mKPt/G5 duGjo8e8N5vCnAmcaUMjOSbH3vGOE2xABgAeUfq4LsNMLMU1p2hyoVLjiCT+Me4Ept V/eTju8CBFLT2ZNv8J2RmOEWKWmSTH12+cxAmJ0ysvmwiT2sI4uNKWqAxJX6moUj+T RHndal98PH3b6YKn9uRRUlKpTNOP5c7Pnp6iUCCigfBBbn7/1UMPPGBBDjKD7lXKhW EvA2E8T6/rzFQqwExXaj+gNfAj4lqaog5UT53MQjxdvEgY1yXkdAFT0xEDi09S1aSi l/joROXBXdt7g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C6E896A42D for ; Fri, 10 Apr 2026 18:37:11 -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 v_O6lRDBeuX2 for ; Fri, 10 Apr 2026 18:37:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775867830; bh=1H6hmnXtkeuYHM7eZLXMMEOo74aDVIly9WHFRD2ARCU=; 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=CICZBrpdnKfTxyphiKJ+zs6Y/7OhjU7vbfGofkS92PLtdn0s56jNYz1JSYy/AHPqp LCdnKTyR+/GytdzhXndmZB/OB34J3U8Xm4urgAYOrdylIkeTGrH1BrVFc+laNY+uWI oJCuxUzOSYYwJhTvBTMZXciQAkFtkFv+NWHXdZsozzRdqdoXGPXsGZqRpUpl8DFBOJ vROp+l3MCTDTqYiSXJaJ5Dwn7WDV85tmgwIlQIllG5et+P3IWlAzsPILqTkcnN2riv A7uPrc0x0P3UvZnv3vWopyMReKgZ9JS4B9oK2pwYCo08fbQ26PTVDNo7/8gErKHnqH WfARg3SLCm5pQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 57CA96A42F for ; Fri, 10 Apr 2026 18:37:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775867827; bh=Yy9D+eEcXPiOWz7b9dfHlzpTawBS/dTsoJjHlhshsk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wn6EYOAbBwSDvfFl+HzfJTU+2ef/ewwRpQSFoKUxmWEnt0zzzYIT6tGkh2BDYmD+y bAEQf7eJZSIyKvMFluyPtwefSajivibMK8YbS9vNAhJZo9f3482GIFZBEg/GU+esPM fwgypmjOtltIu1PrNBgbSGtwWsKZ2TeADCEORcdm3o7NtybU9HpMW8mJkfWhu/p49S hegF9RR1+zLSBFLBAs1Ci44zYNFCynJ67zKkSGnx027HRdsfTUF/8rfpMgaciUXHvq PMjjxGwsYI6b1BmYZ2/tZZ7A316L7enYAytbdkf+la8TX+LxwuZNnj1v6e8w/YjrFE +O/yFX2ZNK9YQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C7D556A42B; Fri, 10 Apr 2026 18:37: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 pWGfNNuaeK-D; Fri, 10 Apr 2026 18:37:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775867825; bh=qMGg73Yt+nW/oqJHQMWAK4RD8AdPGP7UM5bwlGQYPzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wR05GntpqAATK0RENlHC/TRjDIPmXmojR9k9RGfCejkfFpQMj5bWIxUMNQSq0FVzu mdwrK2xaZSBUOYvUPqLfhTCMWpTm5goi7VXPwMNL70Dt+yCM27z7wdkwtn7VM3ng7G Jn/iDv15+sTCNQmxNH8BdmACV23Z8r7RCvHhXrVxN+RNozkoedc/ZIV0+/jYTCyoP9 V9CQ+ZOkuuIlRTzpROT/bGDghcRJjpTzOW5g1DoV2W9B/VgUmQpqgBQIcW15W4k0yn LyCvuQyOWK9EPbwXQLCVPMkL9jvWtg0mE2/Dstdm9adr8ypAL2x6jdd813j5l4kr0c 0qGndpuayztag== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 491E16A425; Fri, 10 Apr 2026 18:37:05 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 10 Apr 2026 18:36:37 -0600 Message-ID: <20260411003647.2592586-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260411003647.2592586-1-sjg@u-boot.org> References: <20260411003647.2592586-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FXPOXBV63IMWAFB2WL2ZMASVVXGLZRE2 X-Message-ID-Hash: FXPOXBV63IMWAFB2WL2ZMASVVXGLZRE2 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 5/8] ext4l: Thread state through path resolution 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 Path resolution is the core operation underlying every file access: ls, read, write, mkdir, unlink, rename and symlink following all go through ext4l_resolve_path_internal(). Add a struct ext4l_state parameter so it uses per-mount state instead of the global, replacing direct references to efs.mounted, efs.sb and efs.sb->s_root with the state pointer. The public ext4l_resolve_path() wrapper still passes the global for now; it will be converted when the remaining public functions are updated. Signed-off-by: Simon Glass --- fs/ext4l/fs.c | 16 +++++++++++++--- fs/ext4l/interface.c | 20 +++++++++++--------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/fs/ext4l/fs.c b/fs/ext4l/fs.c index e9be9d80798..ceb09ca85e6 100644 --- a/fs/ext4l/fs.c +++ b/fs/ext4l/fs.c @@ -21,6 +21,15 @@ #include #include +/** + * struct ext4l_fs_priv - Private data for ext4l UCLASS_FS devices + * + * @state: Per-mount state + */ +struct ext4l_fs_priv { + struct ext4l_state state; +}; + /** * struct ext4l_dir_priv - Private info for ext4l directory devices * @@ -119,9 +128,10 @@ static const struct fs_ops ext4l_vfs_ops = { }; U_BOOT_DRIVER(ext4_fs) = { - .name = "ext4_fs", - .id = UCLASS_FS, - .ops = &ext4l_vfs_ops, + .name = "ext4_fs", + .id = UCLASS_FS, + .ops = &ext4l_vfs_ops, + .priv_auto = sizeof(struct ext4l_fs_priv), }; /* ext4l directory driver */ diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 5a7d65fafdc..b53da76c7cf 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -500,13 +500,15 @@ static int ext4l_read_symlink(struct inode *inode, char *target, size_t max_len) /** * ext4l_resolve_path_internal() - Resolve path with symlink following * + * @state: Per-mount state * @path: Path to resolve * @inodep: Output inode pointer * @depth: Current recursion depth (for symlink loop detection) * Return: 0 on success, negative on error */ -static int ext4l_resolve_path_internal(const char *path, struct inode **inodep, - int depth) +static int ext4l_resolve_path_internal(struct ext4l_state *state, + const char *path, + struct inode **inodep, int depth) { struct inode *dir; struct dentry *dentry, *result; @@ -517,12 +519,12 @@ static int ext4l_resolve_path_internal(const char *path, struct inode **inodep, if (depth > 8) return -ELOOP; - if (!efs.mounted) { + if (!state->mounted) { ext4_debug("ext4l_resolve_path: filesystem not mounted\n"); return -ENODEV; } - dir = efs.sb->s_root->d_inode; + dir = state->sb->s_root->d_inode; if (!path || !*path || (strcmp(path, "/") == 0)) { *inodep = dir; @@ -564,7 +566,7 @@ static int ext4l_resolve_path_internal(const char *path, struct inode **inodep, } dentry->d_name.name = ".."; dentry->d_name.len = 2; - dentry->d_sb = efs.sb; + dentry->d_sb = state->sb; dentry->d_parent = NULL; result = ext4_lookup(dir, dentry, 0); @@ -599,7 +601,7 @@ static int ext4l_resolve_path_internal(const char *path, struct inode **inodep, dentry->d_name.name = component; dentry->d_name.len = strlen(component); - dentry->d_sb = efs.sb; + dentry->d_sb = state->sb; dentry->d_parent = NULL; result = ext4_lookup(dir, dentry, 0); @@ -674,8 +676,8 @@ static int ext4l_resolve_path_internal(const char *path, struct inode **inodep, free(path_copy); /* Recursively resolve the new path */ - ret = ext4l_resolve_path_internal(new_path, inodep, - depth + 1); + ret = ext4l_resolve_path_internal(state, new_path, + inodep, depth + 1); free(new_path); return ret; } @@ -697,7 +699,7 @@ static int ext4l_resolve_path_internal(const char *path, struct inode **inodep, */ static int ext4l_resolve_path(const char *path, struct inode **inodep) { - return ext4l_resolve_path_internal(path, inodep, 0); + return ext4l_resolve_path_internal(&efs, path, inodep, 0); } /**