From patchwork Tue Dec 16 21:18:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 918 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=1765919923; bh=Wm+eNycprvVZ8NwYek+KTL+iqqNhh7m6HBOLepgRvkU=; 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=AGh55uzb4VidB7O3cgJuWYCltK328TdPU5DH/+isk5y6Bx0p7Oq4EFfFIW0Rwz8hN ClxznKon8SikhdkNvkzRr59MpwCuDfvW3/ULQu2uh8yLM3hPGge0Vfq1c2tdQ/wMlf yqr55MUyc421EDyUiFmsPpPWpMoV0pMgbCEYs81eYsEM+B3aeusBuXAglmToEM9K2Q 5gPPuAmuNWy9bCDPCMMZUFAoSbLxK+dnbzBslQTU8Qmy9MuKC1tQB8RgnkBeSeauoS VKN1k8QNGNV19nwzFI2uU5XsbEOa9BI8ULooaHvEt1rVjSVP0IDV4Opuw5UJA1oLfD Kb9OtufCYwOaA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 28D3A68B94 for ; Tue, 16 Dec 2025 14:18: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 10024) with ESMTP id Ir7L2OyHYFl9 for ; Tue, 16 Dec 2025 14:18:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765919923; bh=Wm+eNycprvVZ8NwYek+KTL+iqqNhh7m6HBOLepgRvkU=; 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=AGh55uzb4VidB7O3cgJuWYCltK328TdPU5DH/+isk5y6Bx0p7Oq4EFfFIW0Rwz8hN ClxznKon8SikhdkNvkzRr59MpwCuDfvW3/ULQu2uh8yLM3hPGge0Vfq1c2tdQ/wMlf yqr55MUyc421EDyUiFmsPpPWpMoV0pMgbCEYs81eYsEM+B3aeusBuXAglmToEM9K2Q 5gPPuAmuNWy9bCDPCMMZUFAoSbLxK+dnbzBslQTU8Qmy9MuKC1tQB8RgnkBeSeauoS VKN1k8QNGNV19nwzFI2uU5XsbEOa9BI8ULooaHvEt1rVjSVP0IDV4Opuw5UJA1oLfD Kb9OtufCYwOaA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1872D68AEE for ; Tue, 16 Dec 2025 14:18:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765919919; bh=z+Ul+mD9q9xXmdW3q93ihdN3WSUoHaaa/Nj2WOeozkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UpD62IeSoYV6IKC8KNFFpJrqAWYceG9x7EB/9mgH4JV6PEqFCE8D8wrEvUyO60YnZ D5itoar6asfUNmeg+xV3hYHIa2cF/hGUFuMP1ahxYl+u69jJo8ZQOl3c7kKIktfjgz pkyvo7/+r35zkPpycetz0Dh62dFAc0DIX1DAFKFxrPvBm+F8jDaTsWmgFsdIUeHUT+ iTnaUX8sLys3tKeULwk/+L45EIJ7OZVi5ch2uRDeRN7an1VWTZjUFxGH/j537bQoYQ xOTB7NZEPDqIZDfC+q0/8y2ap82jxVKObgYsHN0w7ykaZz3c+HesF6/9lD42xDfzLK weqsm06HsHo5w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EF95768AF5; Tue, 16 Dec 2025 14:18:39 -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 uEaiuBt_LJEm; Tue, 16 Dec 2025 14:18:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765919919; bh=hyjooeiJ/0petKZ0eWObMvoj8gpO3Q7g1hRen6qCKk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FJJdYEtS2YsbH44QYRGpdPzecjCzLwXHuYqez5mpIgfD0pK8F2yCfHkE2XOT9+o/d lcUerDWvZCTdGoRKBa43ne7vxBNMRBZzzXhG7oO73NjfbUEDuLd42UVIJ/AXPfaSUP kUADUCbegQW3p/ZiO/gWa9LsWjepQ59kwwKIx7+0LBZbf/4rxuIgKZhZdA2UYq2oqx pC566tgbv9t37K0Yc7oi38jJC2teDSth5NXaU3Bwmu9lwvuiG0nsUxlLfKcx11UQoX 9TlFpoOqFVKR5y2OwMPFU+e5QIvoUxlsiLR33uZBBYmDgzRDd7D0Rf7TKTROqSXzg1 /XtReVFEfwnoA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 14E4F68AD5; Tue, 16 Dec 2025 14:18:39 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 16 Dec 2025 14:18:05 -0700 Message-ID: <20251216211817.4131167-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251216211817.4131167-1-sjg@u-boot.org> References: <20251216211817.4131167-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CXYWVWKVUBRL3U5X2BFGU66O2OUQYQFV X-Message-ID-Hash: CXYWVWKVUBRL3U5X2BFGU66O2OUQYQFV 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/11] ext4l: Add some stub headers for Linux code 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 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 Signed-off-by: Simon Glass --- 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 + * + * Andrew G. Morgan + * Alexander Kjeldaas + * 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 + +/* + * 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 + * Copyright (C) 2001 Greg Kroah-Hartman + * Copyright (C) 2001 Networks Associates Technology, Inc + * Copyright (C) 2001 James Morris + * 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 */