[Concept,04/10] ext4l: Add xattr_trusted.c

Message ID 20251220232355.845414-5-sjg@u-boot.org
State New
Headers
Series ext4l: Add more ext4 files to the build (part D) |

Commit Message

Simon Glass Dec. 20, 2025, 11:23 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Add xattr_trusted.c to the ext4l build with necessary changes:

- Update xattr_trusted.c includes to use ext4_uboot.h
- Add xattr.h include to ialloc.c for ext4_init_security
- Remove duplicate ext4_init_security declaration from ext4_uboot.h
  (now provided by xattr.h inline stub)
- Add ext4_xattr_get and ext4_xattr_set stubs

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/Makefile        |  4 +++-
 fs/ext4l/ext4_uboot.h    |  7 +------
 fs/ext4l/ialloc.c        |  1 +
 fs/ext4l/stub.c          | 17 +++++++++++++----
 fs/ext4l/xattr_trusted.c |  3 +--
 5 files changed, 19 insertions(+), 13 deletions(-)
  

Patch

diff --git a/fs/ext4l/Makefile b/fs/ext4l/Makefile
index c5adb121f77..cfb1413ba30 100644
--- a/fs/ext4l/Makefile
+++ b/fs/ext4l/Makefile
@@ -6,5 +6,7 @@ 
 obj-y := interface.o stub.o
 
 obj-y	+= balloc.o bitmap.o block_validity.o ext4_jbd2.o extents.o \
-		extents_status.o hash.o ialloc.o indirect.o \
+		extents_status.o hash.o ialloc.o \
+		indirect.o \
+		xattr_trusted.o \
 		orphan.o
diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 6c328a5abf1..32b497deadc 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -390,12 +390,7 @@  struct qstr;
 int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode,
 			     struct buffer_head *block_bh, size_t value_len,
 			     bool is_create);
-/* ext4_init_security - stub for files that don't include xattr.h */
-static inline int ext4_init_security(void *handle, struct inode *inode,
-				     struct inode *dir, const struct qstr *qstr)
-{
-	return 0;
-}
+/* ext4_init_security is provided by xattr.h */
 
 /* inode state stubs */
 #define is_bad_inode(inode)			(0)
diff --git a/fs/ext4l/ialloc.c b/fs/ext4l/ialloc.c
index 3d9edbcc1c3..d72204a5d02 100644
--- a/fs/ext4l/ialloc.c
+++ b/fs/ext4l/ialloc.c
@@ -16,6 +16,7 @@ 
 #include "ext4_uboot.h"
 #include "ext4.h"
 #include "ext4_jbd2.h"
+#include "xattr.h"
 
 /*
  * ialloc.c contains the inodes allocation and deallocation routines
diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c
index 5a3eda0ad2e..41550bc48bc 100644
--- a/fs/ext4l/stub.c
+++ b/fs/ext4l/stub.c
@@ -388,12 +388,21 @@  int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode,
 	return 0;
 }
 
-struct qstr;
+/* ext4_init_security stub is provided by xattr.h */
 
-int ext4_init_security(void *handle, struct inode *inode, struct inode *dir,
-		       const struct qstr *qstr)
+/*
+ * Stubs for xattr_trusted.c
+ */
+int ext4_xattr_get(struct inode *inode, int name_index, const char *name,
+		   void *buffer, size_t buffer_size)
 {
-	return 0;
+	return -1;
+}
+
+int ext4_xattr_set(struct inode *inode, int name_index, const char *name,
+		   const void *value, size_t value_len, int flags)
+{
+	return -1;
 }
 
 /*
diff --git a/fs/ext4l/xattr_trusted.c b/fs/ext4l/xattr_trusted.c
index 9811eb0ab27..57ef5caa588 100644
--- a/fs/ext4l/xattr_trusted.c
+++ b/fs/ext4l/xattr_trusted.c
@@ -7,8 +7,7 @@ 
  */
 
 #include <linux/string.h>
-#include <linux/capability.h>
-#include <linux/fs.h>
+#include "ext4_uboot.h"
 #include "ext4_jbd2.h"
 #include "ext4.h"
 #include "xattr.h"