From patchwork Thu Jan 8 18:51:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1358 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=1767898394; bh=mT91N8aGoPbRN3ZsRF9u3qx5mc0vLSWbcbbnlbNeHtM=; 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=GQqf3OR/6AI6ZJv4W4cWuDENLhk2OiGg3MsQ7ujnh55zHsPYdOS6jTkjZEaGV5GSO UwC9Pms2vVvLMwYaUIPxamOoISpjDBc1A4BooaYCt+Qst78pgAHMcqPT1TaEZ0Tkku mDDARbN86xpr1cxCC/UNWyhqnQObWDalDHfzMccr+KhjUVuS42qUfZmEudVZT85G+5 h8/hD2EsihcnA5b6feZU7DDwsMHRinIYM+aq/12D6clMDBZoy4FwSRx+wYnEZF1P1L XlEITpFO3HQXwK8fWVfM5Rq24u59IX4YY+QYoQy7d2QCZJEntr51JdCXxOyq/pOPUJ bB2/4iNGZ919g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 52633691C8 for ; Thu, 8 Jan 2026 11:53:14 -0700 (MST) 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 mF4FzliY4isg for ; Thu, 8 Jan 2026 11:53:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898394; bh=mT91N8aGoPbRN3ZsRF9u3qx5mc0vLSWbcbbnlbNeHtM=; 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=GQqf3OR/6AI6ZJv4W4cWuDENLhk2OiGg3MsQ7ujnh55zHsPYdOS6jTkjZEaGV5GSO UwC9Pms2vVvLMwYaUIPxamOoISpjDBc1A4BooaYCt+Qst78pgAHMcqPT1TaEZ0Tkku mDDARbN86xpr1cxCC/UNWyhqnQObWDalDHfzMccr+KhjUVuS42qUfZmEudVZT85G+5 h8/hD2EsihcnA5b6feZU7DDwsMHRinIYM+aq/12D6clMDBZoy4FwSRx+wYnEZF1P1L XlEITpFO3HQXwK8fWVfM5Rq24u59IX4YY+QYoQy7d2QCZJEntr51JdCXxOyq/pOPUJ bB2/4iNGZ919g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3D437691CC for ; Thu, 8 Jan 2026 11:53:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898392; bh=P/sFLS8QNeczOX/IW+GrnpT+yphoZLlHRAb9W6qkjE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uJLdKXwGPTZ5KaXPALsuRo7X8lLrKIL8Y3LtkAd22nHx9CEXKfz0jurBrvZ8mzn0i dYymXCE31eux8ApXHlbuOy2XB+x0Fko9/c5RFrpX3qk2bmvCrDMd2eYXFyh2vNMOhf 5jTlCxLPF24ksFq1SOkYfvQ58WPzrgCW3hfW4lkYP2xk2WGpb4VLqillITqB9FMvUs Dzp53MT0hKrEr1qR2IVUKk3r/Wy2td9n4mRStWj7sfrMgOZW5J4d2CfbiUXbI6edXL jHfN4TlbOCLmeXuePKjQrYymPT/fLxDu/CfvKPqf5EWFV8u4tjUWOb4fjUNN7hBup3 90IckzwnLJhPw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9D482691C4; Thu, 8 Jan 2026 11:53:12 -0700 (MST) 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 JH-sG6QyTv7F; Thu, 8 Jan 2026 11:53:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898387; bh=Jz54C3bOgq0JkHqvBChSweT+yhq7uIyWc7HpQDecBp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ItdtLcyGYRkE8weIst6sRVOErXsWaVICV7wqVfFYGs56lDhQstpAD70Kiy09y1xMu J5jcj2cjB9qAQeixxHMmNHESGB/u4F+8CBUV7KgHs9G2XexG0TS1kBf1ix/ajwK8zu bYqDsxSIJa9SF+jczK7hWerm8ItYi4vfDNqWk+rALUkGmPaYuiWuN/p6iqFs4Kt9e7 YsDgMA441sAN1MHMW+tCqgXrnktJR+9ev4Ch/rlrMLeckB5we46JsG77CeoF5ydx0J hwE3gbKMf+34n8nqpUWufN3+E/Bg5/Z/+oZwHgxRLmcYYOHzumTqNZWzF4FCqVBQTd 2R9XRLBSXa6Og== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9778169057; Thu, 8 Jan 2026 11:53:07 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 11:51:32 -0700 Message-ID: <20260108185149.1995917-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260108185149.1995917-1-sjg@u-boot.org> References: <20260108185149.1995917-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XYN5EKWYNPRBVXZEXD6Q4VW4XYI26S5C X-Message-ID-Hash: XYN5EKWYNPRBVXZEXD6Q4VW4XYI26S5C 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: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 17/21] ext4l: Exclude write functions from read-only builds 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 The inode_operations structs contain function pointers for write operations (create, unlink, mkdir, rename, setattr, etc.). Even when CONFIG_EXT4_WRITE is disabled, these function pointers cause the linker to include much of the write-related code. Add an EXT4_WR_OP() macro that returns the function pointer when CONFIG_EXT4_WRITE is enabled, or NULL when disabled. Apply this macro to write operation entries in structs ext4_dir_inode_operations, ext4_special_inode_operations, ext4_file_inode_operations and the symlink inode_operations structs. This reduces ext4l code size by about 15K on Thumb2 when write-support is disabled. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4.h | 11 +++++++++++ fs/ext4l/file.c | 2 +- fs/ext4l/namei.c | 28 ++++++++++++++-------------- fs/ext4l/symlink.c | 6 +++--- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/fs/ext4l/ext4.h b/fs/ext4l/ext4.h index 8d4e20e538a..9c182ad0d89 100644 --- a/fs/ext4l/ext4.h +++ b/fs/ext4l/ext4.h @@ -22,6 +22,17 @@ #include #include +/* + * Macro for write operation function pointers in inode_operations structs. + * When CONFIG_EXT4_WRITE is disabled, these return NULL so the linker + * doesn't pull in the write functions. + */ +#ifdef CONFIG_EXT4_WRITE +#define EXT4_WR_OP(func) (func) +#else +#define EXT4_WR_OP(func) NULL +#endif + /* * The fourth extended filesystem constants/structures */ diff --git a/fs/ext4l/file.c b/fs/ext4l/file.c index 8cbc8c5f785..6f775c498cf 100644 --- a/fs/ext4l/file.c +++ b/fs/ext4l/file.c @@ -966,7 +966,7 @@ const struct file_operations ext4_file_operations = { /* U-Boot simplified inode operations */ const struct inode_operations ext4_file_inode_operations = { - .setattr = ext4_setattr, + .setattr = EXT4_WR_OP(ext4_setattr), .getattr = ext4_file_getattr, .listxattr = ext4_listxattr, .fiemap = ext4_fiemap, diff --git a/fs/ext4l/namei.c b/fs/ext4l/namei.c index bede355d497..b8b6016a136 100644 --- a/fs/ext4l/namei.c +++ b/fs/ext4l/namei.c @@ -4199,30 +4199,30 @@ static int ext4_rename2(struct mnt_idmap *idmap, * directories can handle most operations... */ const struct inode_operations ext4_dir_inode_operations = { - .create = ext4_create, + .create = EXT4_WR_OP(ext4_create), .lookup = ext4_lookup, - .link = ext4_link, - .unlink = ext4_unlink, - .symlink = ext4_symlink, - .mkdir = ext4_mkdir, - .rmdir = ext4_rmdir, - .mknod = ext4_mknod, - .tmpfile = ext4_tmpfile, - .rename = ext4_rename2, - .setattr = ext4_setattr, + .link = EXT4_WR_OP(ext4_link), + .unlink = EXT4_WR_OP(ext4_unlink), + .symlink = EXT4_WR_OP(ext4_symlink), + .mkdir = EXT4_WR_OP(ext4_mkdir), + .rmdir = EXT4_WR_OP(ext4_rmdir), + .mknod = EXT4_WR_OP(ext4_mknod), + .tmpfile = EXT4_WR_OP(ext4_tmpfile), + .rename = EXT4_WR_OP(ext4_rename2), + .setattr = EXT4_WR_OP(ext4_setattr), .getattr = ext4_getattr, .listxattr = ext4_listxattr, .get_inode_acl = ext4_get_acl, - .set_acl = ext4_set_acl, + .set_acl = EXT4_WR_OP(ext4_set_acl), .fiemap = ext4_fiemap, .fileattr_get = ext4_fileattr_get, - .fileattr_set = ext4_fileattr_set, + .fileattr_set = EXT4_WR_OP(ext4_fileattr_set), }; const struct inode_operations ext4_special_inode_operations = { - .setattr = ext4_setattr, + .setattr = EXT4_WR_OP(ext4_setattr), .getattr = ext4_getattr, .listxattr = ext4_listxattr, .get_inode_acl = ext4_get_acl, - .set_acl = ext4_set_acl, + .set_acl = EXT4_WR_OP(ext4_set_acl), }; diff --git a/fs/ext4l/symlink.c b/fs/ext4l/symlink.c index 2e4d0942a3b..dd3b82b5da2 100644 --- a/fs/ext4l/symlink.c +++ b/fs/ext4l/symlink.c @@ -115,21 +115,21 @@ static const char *ext4_get_link(struct dentry *dentry, struct inode *inode, const struct inode_operations ext4_encrypted_symlink_inode_operations = { .get_link = ext4_encrypted_get_link, - .setattr = ext4_setattr, + .setattr = EXT4_WR_OP(ext4_setattr), .getattr = ext4_encrypted_symlink_getattr, .listxattr = ext4_listxattr, }; const struct inode_operations ext4_symlink_inode_operations = { .get_link = ext4_get_link, - .setattr = ext4_setattr, + .setattr = EXT4_WR_OP(ext4_setattr), .getattr = ext4_getattr, .listxattr = ext4_listxattr, }; const struct inode_operations ext4_fast_symlink_inode_operations = { .get_link = simple_get_link, - .setattr = ext4_setattr, + .setattr = EXT4_WR_OP(ext4_setattr), .getattr = ext4_getattr, .listxattr = ext4_listxattr, };