[Concept,03/11] ext4l: Extract uaccess.h declarations into their own file
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Create include/linux/uaccess.h with stub implementations for user-space
access functions. In U-Boot there's no user/kernel separation, so these
are simple memory copies.
Includes:
- copy_from_user()
- copy_to_user()
- get_user() / put_user()
- access_ok()
Update compat.h to include uaccess.h and remove the duplicate
declaration.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
include/linux/compat.h | 3 +--
include/linux/uaccess.h | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 2 deletions(-)
create mode 100644 include/linux/uaccess.h
@@ -13,6 +13,7 @@
#include <linux/err.h>
#include <linux/export.h>
#include <linux/kernel.h>
+#include <linux/uaccess.h>
#ifdef CONFIG_XEN
#include <xen/events.h>
@@ -239,8 +240,6 @@ typedef unsigned long blkcnt_t;
struct work_struct {};
-unsigned long copy_from_user(void *dest, const void *src,
- unsigned long count);
typedef unused_t spinlock_t;
typedef int wait_queue_head_t;
new file mode 100644
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _LINUX_UACCESS_H
+#define _LINUX_UACCESS_H
+
+#include <linux/types.h>
+#include <string.h>
+
+/*
+ * Stub definitions for Linux kernel user-space access functions.
+ * In U-Boot there's no user/kernel separation, so these are simple copies.
+ */
+
+static inline unsigned long copy_from_user(void *to, const void *from,
+ unsigned long n)
+{
+ memcpy(to, from, n);
+ return 0;
+}
+
+static inline unsigned long copy_to_user(void *to, const void *from,
+ unsigned long n)
+{
+ memcpy(to, from, n);
+ return 0;
+}
+
+#define get_user(x, ptr) ({ x = *(ptr); 0; })
+#define put_user(x, ptr) ({ *(ptr) = x; 0; })
+
+#define access_ok(addr, size) 1
+
+#endif /* _LINUX_UACCESS_H */