From: Simon Glass <simon.glass@canonical.com> Add stub headers for Linux kernel interfaces that ext4 code expects: - capability.h: stub capability checks (always return true) - cred.h: stub credential types and macros - file.h: stub file descriptor helpers - path.h: basic path structure definition - security.h: stub LSM hooks (no-ops) - seq_file.h: stub seq_file interface These provide minimal definitions to allow ext4 code to compile. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/capability.h | 27 +++++++++++++++++++ include/linux/cred.h | 53 ++++++++++++++++++++++++++++++++++++++ include/linux/file.h | 29 +++++++++++++++++++++ include/linux/path.h | 13 ++++++++++ include/linux/security.h | 39 ++++++++++++++++++++++++++++ include/linux/seq_file.h | 18 +++++++++++++ 6 files changed, 179 insertions(+) create mode 100644 include/linux/capability.h create mode 100644 include/linux/cred.h create mode 100644 include/linux/file.h create mode 100644 include/linux/path.h create mode 100644 include/linux/security.h create mode 100644 include/linux/seq_file.h diff --git a/include/linux/capability.h b/include/linux/capability.h new file mode 100644 index 00000000000..1192c8a4033 --- /dev/null +++ b/include/linux/capability.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * This is <linux/capability.h> + * + * Andrew G. Morgan <morgan@kernel.org> + * Alexander Kjeldaas <astor@guardian.no> + * with help from Aleph1, Roland Buresund and Andrew Main. + * + * Stub definitions for Linux kernel capabilities. + * U-Boot doesn't implement capability checks. + */ +#ifndef _LINUX_CAPABILITY_H +#define _LINUX_CAPABILITY_H + +#define CAP_SYS_RESOURCE 24 + +static inline bool capable(int cap) +{ + return true; +} + +static inline bool ns_capable(void *ns, int cap) +{ + return true; +} + +#endif /* _LINUX_CAPABILITY_H */ diff --git a/include/linux/cred.h b/include/linux/cred.h new file mode 100644 index 00000000000..a5afc267ba0 --- /dev/null +++ b/include/linux/cred.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Credentials management - see Documentation/security/credentials.rst + * + * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + */ +#ifndef _LINUX_CRED_H +#define _LINUX_CRED_H + +#include <linux/types.h> + +/* + * Stub definitions for Linux kernel credentials. + * U-Boot doesn't implement user credentials. + */ + +typedef struct { + uid_t val; +} kuid_t; + +typedef struct { + gid_t val; +} kgid_t; + +struct cred { + kuid_t uid; + kgid_t gid; + kuid_t fsuid; + kgid_t fsgid; +}; + +#define current_cred() NULL +#define current_uid() ((kuid_t){0}) +#define current_gid() ((kgid_t){0}) +#define current_fsuid() ((kuid_t){0}) +#define current_fsgid() ((kgid_t){0}) + +#define from_kuid(ns, uid) ((uid).val) +#define from_kgid(ns, gid) ((gid).val) +#define make_kuid(ns, uid) ((kuid_t){uid}) +#define make_kgid(ns, gid) ((kgid_t){gid}) + +#define uid_eq(a, b) ((a).val == (b).val) +#define gid_eq(a, b) ((a).val == (b).val) +#define uid_valid(uid) ((uid).val != (uid_t)-1) +#define gid_valid(gid) ((gid).val != (gid_t)-1) + +#define GLOBAL_ROOT_UID ((kuid_t){0}) +#define GLOBAL_ROOT_GID ((kgid_t){0}) +#define INVALID_UID ((kuid_t){-1}) +#define INVALID_GID ((kgid_t){-1}) + +#endif /* _LINUX_CRED_H */ diff --git a/include/linux/file.h b/include/linux/file.h new file mode 100644 index 00000000000..74859204979 --- /dev/null +++ b/include/linux/file.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Wrapper functions for accessing the file_struct fd array. + */ +#ifndef _LINUX_FILE_H +#define _LINUX_FILE_H + +/* + * Stub definitions for Linux kernel file handling. + */ + +struct file; +struct fd { + struct file *file; + unsigned int flags; +}; + +#define EMPTY_FD ((struct fd){ NULL, 0 }) + +static inline struct fd fdget(unsigned int fd) +{ + return EMPTY_FD; +} + +static inline void fdput(struct fd fd) +{ +} + +#endif /* _LINUX_FILE_H */ diff --git a/include/linux/path.h b/include/linux/path.h new file mode 100644 index 00000000000..27cc071026a --- /dev/null +++ b/include/linux/path.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LINUX_PATH_H +#define _LINUX_PATH_H + +struct dentry; +struct vfsmount; + +struct path { + struct vfsmount *mnt; + struct dentry *dentry; +}; + +#endif /* _LINUX_PATH_H */ diff --git a/include/linux/security.h b/include/linux/security.h new file mode 100644 index 00000000000..876b70bc1c8 --- /dev/null +++ b/include/linux/security.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Linux Security plug + * + * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com> + * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com> + * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com> + * Copyright (C) 2001 James Morris <jmorris@intercode.com.au> + * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group) + * Copyright (C) 2016 Mellanox Techonologies + * + * Stub definitions for Linux Security Module (LSM) hooks. + * U-Boot doesn't implement security modules. + */ +#ifndef _LINUX_SECURITY_H +#define _LINUX_SECURITY_H + +struct inode; +struct dentry; + +static inline int security_inode_init_security(struct inode *inode, + struct inode *dir, + void *name, void *value, + void *len) +{ + return -EOPNOTSUPP; +} + +#define security_inode_create(dir, dentry, mode) 0 +#define security_inode_link(old, dir, new) 0 +#define security_inode_unlink(dir, dentry) 0 +#define security_inode_symlink(dir, dentry, name) 0 +#define security_inode_mkdir(dir, dentry, mode) 0 +#define security_inode_rmdir(dir, dentry) 0 +#define security_inode_mknod(dir, dentry, mode, dev) 0 +#define security_inode_rename(od, odent, nd, ndent, f) 0 +#define security_inode_setattr(dentry, attr) 0 + +#endif /* _LINUX_SECURITY_H */ diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h new file mode 100644 index 00000000000..fb5dbf97708 --- /dev/null +++ b/include/linux/seq_file.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LINUX_SEQ_FILE_H +#define _LINUX_SEQ_FILE_H + +/* + * Stub definitions for seq_file interface. + * U-Boot doesn't use /proc filesystem. + */ + +struct seq_file { + void *private; +}; + +#define seq_printf(m, fmt, ...) do { } while (0) +#define seq_puts(m, s) do { } while (0) +#define seq_putc(m, c) do { } while (0) + +#endif /* _LINUX_SEQ_FILE_H */ -- 2.43.0