[Concept,10/16] ext4l: Add linux/highuid.h and move UID/GID helpers

Message ID 20260119214846.3087611-11-sjg@u-boot.org
State New
Headers
Series ext4l: Move definitions to standard Linux headers |

Commit Message

Simon Glass Jan. 19, 2026, 9:48 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Create include/linux/highuid.h with the low_16_bits(), high_16_bits(),
fs_high2lowuid(), and fs_high2lowgid() macros. These helpers are used
for 16/32-bit UID/GID conversion in filesystem code.

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

 fs/ext4l/ext4_uboot.h   |  7 ++-----
 include/linux/highuid.h | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 5 deletions(-)
 create mode 100644 include/linux/highuid.h
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 6772fd8328f..69c50d406f7 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -864,11 +864,8 @@  static inline unsigned int i_gid_read(const struct inode *inode)
 /* Device encoding helpers are now in linux/kdev_t.h */
 #include <linux/kdev_t.h>
 
-/* UID/GID bit helpers */
-#define low_16_bits(x)		((x) & 0xFFFF)
-#define high_16_bits(x)		(((x) >> 16) & 0xFFFF)
-#define fs_high2lowuid(uid)	((uid) & 0xFFFF)
-#define fs_high2lowgid(gid)	((gid) & 0xFFFF)
+/* UID/GID bit helpers - use linux/highuid.h */
+#include <linux/highuid.h>
 
 /* Inode allocation/state operations */
 extern struct inode *iget_locked(struct super_block *sb, unsigned long ino);
diff --git a/include/linux/highuid.h b/include/linux/highuid.h
new file mode 100644
index 00000000000..9bffa16b0aa
--- /dev/null
+++ b/include/linux/highuid.h
@@ -0,0 +1,19 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * High UID/GID to low UID/GID conversion helpers
+ *
+ * Based on Linux highuid.h
+ */
+#ifndef _LINUX_HIGHUID_H
+#define _LINUX_HIGHUID_H
+
+/*
+ * U-Boot doesn't support 16-bit UIDs/GIDs overflow handling,
+ * so these are simplified versions.
+ */
+#define low_16_bits(x)		((x) & 0xFFFF)
+#define high_16_bits(x)		(((x) >> 16) & 0xFFFF)
+#define fs_high2lowuid(uid)	((uid) & 0xFFFF)
+#define fs_high2lowgid(gid)	((gid) & 0xFFFF)
+
+#endif /* _LINUX_HIGHUID_H */