From patchwork Thu Jan 8 18:51:25 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1351 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=1767898365; bh=H/qMZ0E7x9asS+WBt1hEq7NJ0nsFtqHhI4QutfsT41Y=; 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=KyZ7Vu6h6mr/EBXnavDsaSAhPfCJjTuMeNtJLxp3F7KOSEMO5lY3oJ6iJZtQQSbVH 0pYB0U0vXSOcFVLyyH0xdElzEuuYxrLVFpfPtFhRldbMGaiQ2DLOqHdlfLpYCL/ygW OOOSuo5/bCrbhmch8PaZHSEjaE8+IpV3yXwLrJLPno4bJ+gJgMpF6KqgephrdTA0zz 9ZEDt4jhd8bAlMfF9CuLlXE4v3uXV25XMiENeosh3cN6DTF79LNXnCCr9nunllKjNi tnvAdBxCw5tMwjYeRuFZ8YbFtl+0bsWa+t7+ZZWVNcWcvwR28RQH7jMptRc5unFlKp lm/c5G7KTIrgw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6460B691C4 for ; Thu, 8 Jan 2026 11:52:45 -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 qtoIqN_rMmAI for ; Thu, 8 Jan 2026 11:52:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898365; bh=H/qMZ0E7x9asS+WBt1hEq7NJ0nsFtqHhI4QutfsT41Y=; 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=KyZ7Vu6h6mr/EBXnavDsaSAhPfCJjTuMeNtJLxp3F7KOSEMO5lY3oJ6iJZtQQSbVH 0pYB0U0vXSOcFVLyyH0xdElzEuuYxrLVFpfPtFhRldbMGaiQ2DLOqHdlfLpYCL/ygW OOOSuo5/bCrbhmch8PaZHSEjaE8+IpV3yXwLrJLPno4bJ+gJgMpF6KqgephrdTA0zz 9ZEDt4jhd8bAlMfF9CuLlXE4v3uXV25XMiENeosh3cN6DTF79LNXnCCr9nunllKjNi tnvAdBxCw5tMwjYeRuFZ8YbFtl+0bsWa+t7+ZZWVNcWcvwR28RQH7jMptRc5unFlKp lm/c5G7KTIrgw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4A397691CE for ; Thu, 8 Jan 2026 11:52:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898363; bh=YRdhr5fjitmnsql04uhU0ywrVHZjq7VBz0UxuIlo3M8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qAvSweULJ/tT9X8fAjpb3T/u5m3iHiE/x0WojYIB6NnF5UnLrGddRko0srnr6y/Az ErzTgn5Xi6tplJ45Rf3vMGB+wmuXpwzaObAOqKAo88Gu+cKqg6w1rICmS0Qv3o/QrA GphjFPJZ6AStRm/X6zYlmgR+DkOoq7w/+kEdJWCfXBmH1JCYY48glFZOzqq8qZhzJj xcxn2C3+4mtKpJuKijx68yuN01csa6CyCaY2lPu3/CGmdus4/Ah6RYjk4wIaohyNrQ FjKWwnbUpKbbhgYPwq5Fe6iQU/BbEsFUK9/X2rUFxtOy1hNAKVVC4zRpMUAtkMQ0aS LOoxGHHkSJW5g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 163A069101; Thu, 8 Jan 2026 11:52:43 -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 xC6rAxaAbWtp; Thu, 8 Jan 2026 11:52:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898362; bh=zuh2AqEOh1fh3n6/+dsH1rLZ0njWW500hk0M8qyKicE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tl+PND3z2ZQkE5RzUpA9bia2dGBb2s6vA1BXmUUCfBDVDmqXCywB2LIdLdK6LZS8K C7Gj2tH6B8b+yVq19IBhgY6CKL6/+/+VtWWz+KGw1FHRM+dUQyt/KyxYB5PMGP3dmY JH4iCo5sCpyhAwx5+UT3u6krGY4jC0Dpm3zK/xvVChqLShJ6O/vkx3nbHon9H1njnn hltUruwwxTJ6LbUrgl8/+LHaNzra/5G87D9bMv5KCD/aGXLB2f/13/CzGfKLAhB8UH GNmCiL2RcxhNLDC23ISa4IXyCCAu3bVDzt0Hp2rTtZnlx1QdPZCPuzbMfshtCCEWKN BKvmmzArfpugQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 502AE69057; Thu, 8 Jan 2026 11:52:42 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 11:51:25 -0700 Message-ID: <20260108185149.1995917-11-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: DU2JPDEQ3K2QTS26LQN7ICXPDBAFMMUG X-Message-ID-Hash: DU2JPDEQ3K2QTS26LQN7ICXPDBAFMMUG 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 10/21] ext4l: Make extended attributes (xattr) optional 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 CONFIG_EXT4_XATTR to allow disabling support for extended attributes. This saves about 14K on Thumb2 (e.g. firefly-rk3288). When disabled, inline stub functions return -EOPNOTSUPP or 0 as appropriate. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/Kconfig | 10 ++++++ fs/ext4l/Makefile | 5 +-- fs/ext4l/ext4_uboot.h | 2 ++ fs/ext4l/super.c | 2 +- fs/ext4l/xattr.h | 83 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 3 deletions(-) diff --git a/fs/ext4l/Kconfig b/fs/ext4l/Kconfig index 7bb1cbe7537..ee7b9bb2dd6 100644 --- a/fs/ext4l/Kconfig +++ b/fs/ext4l/Kconfig @@ -78,3 +78,13 @@ config EXT4_MOVE_EXTENT This adds about 1.5K to the image size. Not needed for U-Boot. If unsure, say N. + +config EXT4_XATTR + bool "Enable ext4 extended attributes support" + depends on FS_EXT4L + help + Enable support for extended attributes (xattrs) on ext4 + filesystems. This is required for ACLs, security labels, + and user-defined attributes. + + This adds about 14K to the image size. If unsure, say N. diff --git a/fs/ext4l/Makefile b/fs/ext4l/Makefile index 262384b6bbb..720181908f8 100644 --- a/fs/ext4l/Makefile +++ b/fs/ext4l/Makefile @@ -9,10 +9,11 @@ obj-y := interface.o support.o stub.o obj-y += balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \ extents_status.o file.o fsmap.o fsync.o hash.o ialloc.o \ indirect.o inline.o inode.o mballoc.o mmp.o namei.o \ - page-io.o readpage.o super.o symlink.o xattr.o \ - xattr_hurd.o xattr_trusted.o xattr_user.o fast_commit.o orphan.o + page-io.o readpage.o super.o symlink.o fast_commit.o orphan.o # Optional features obj-$(CONFIG_EXT4_RESIZE) += resize.o obj-$(CONFIG_EXT4_MIGRATE) += migrate.o obj-$(CONFIG_EXT4_MOVE_EXTENT) += move_extent.o +obj-$(CONFIG_EXT4_XATTR) += xattr.o xattr_hurd.o xattr_trusted.o \ + xattr_user.o diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index a34f5d74dfa..4a7e41a75a1 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -420,9 +420,11 @@ struct super_block; struct buffer_head; struct qstr; +#ifdef CONFIG_EXT4_XATTR int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, struct buffer_head *block_bh, size_t value_len, bool is_create); +#endif /* ext4_init_security is provided by xattr.h */ /* inode state stubs */ diff --git a/fs/ext4l/super.c b/fs/ext4l/super.c index b2c95118220..d3e1b85ac5d 100644 --- a/fs/ext4l/super.c +++ b/fs/ext4l/super.c @@ -5421,7 +5421,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) needs_recovery = 0; } - if (!test_opt(sb, NO_MBCACHE)) { + if (!test_opt(sb, NO_MBCACHE) && IS_ENABLED(CONFIG_EXT4_XATTR)) { sbi->s_ea_block_cache = ext4_xattr_create_cache(); if (!sbi->s_ea_block_cache) { ext4_msg(sb, KERN_ERR, diff --git a/fs/ext4l/xattr.h b/fs/ext4l/xattr.h index 1fedf44d4fb..f7b6de1743e 100644 --- a/fs/ext4l/xattr.h +++ b/fs/ext4l/xattr.h @@ -175,6 +175,7 @@ static inline void ext4_write_unlock_xattr(struct inode *inode, int *save) up_write(&EXT4_I(inode)->xattr_sem); } +#ifdef CONFIG_EXT4_XATTR extern ssize_t ext4_listxattr(struct dentry *, char *, size_t); extern int ext4_xattr_get(struct inode *, int, const char *, void *, size_t); @@ -216,6 +217,88 @@ __xattr_check_inode(struct inode *inode, struct ext4_xattr_ibody_header *header, #define xattr_check_inode(inode, header, end) \ __xattr_check_inode((inode), (header), (end), __func__, __LINE__) +#else /* !CONFIG_EXT4_XATTR */ + +static inline ssize_t ext4_listxattr(struct dentry *d, char *b, size_t s) +{ + return -EOPNOTSUPP; +} + +static inline int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, + struct ext4_xattr_inode_array **array, + int extra_credits) +{ + return 0; +} + +static inline void ext4_xattr_inode_array_free(struct ext4_xattr_inode_array *a) +{ +} + +static inline void ext4_evict_ea_inode(struct inode *inode) +{ +} + +#define ext4_xattr_handlers NULL + +static inline struct mb_cache *ext4_xattr_create_cache(void) +{ + return NULL; +} + +static inline void ext4_xattr_destroy_cache(struct mb_cache *c) +{ +} + +static inline int +__xattr_check_inode(struct inode *inode, struct ext4_xattr_ibody_header *header, + void *end, const char *function, unsigned int line) +{ + return 0; +} + +#define xattr_check_inode(inode, header, end) \ + __xattr_check_inode((inode), (header), (end), __func__, __LINE__) + +static inline int __ext4_xattr_set_credits(struct super_block *sb, + struct inode *inode, + struct buffer_head *block_bh, + size_t value_len, bool is_create) +{ + return 0; +} + +static inline int ext4_expand_extra_isize_ea(struct inode *inode, + int new_extra_isize, + struct ext4_inode *raw_inode, + handle_t *handle) +{ + return 0; +} + +static inline int ext4_xattr_ibody_find(struct inode *inode, + struct ext4_xattr_info *i, + struct ext4_xattr_ibody_find *is) +{ + return -EOPNOTSUPP; +} + +static inline int ext4_xattr_ibody_get(struct inode *inode, int name_index, + const char *name, void *buffer, + size_t buffer_size) +{ + return -EOPNOTSUPP; +} + +static inline int ext4_xattr_ibody_set(handle_t *handle, struct inode *inode, + struct ext4_xattr_info *i, + struct ext4_xattr_ibody_find *is) +{ + return -EOPNOTSUPP; +} + +#endif /* CONFIG_EXT4_XATTR */ + #ifdef CONFIG_EXT4_FS_SECURITY extern int ext4_init_security(handle_t *handle, struct inode *inode, struct inode *dir, const struct qstr *qstr);