From patchwork Wed Jan 21 22:08:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1731 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=1769033371; bh=xt6qnhFKL9WyVTInrzm1Z4esRtHuNW9HQZNyJp230tM=; 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=Iff/cZIO1LYEopOF7d0MIka0OlQrM4c7QXY6IWY0TLU326TWfN4/9UCwtkeMCDu2/ 0TVyx7kcOOPjAHtkp8ElaQGwD1XLepsr0rAxA8HqscHw/SbxFz2ByOdEWJONdLtpgr 2rqMmurrkWEXBhBvLMYK5F+T5I8S75lDgW5rLPBsC9Mfojl+k899gqjFLtsGsZ29u0 LhL+TpO2xL9PJHIY1YNeU35uMH585WmPk3/V8Kxr7bvBVgoRI35PyQ0ddXmlhaLtv3 u+QjzKk2Fozc1J/UcFevFIxEsBMFB1648Z5rcK/PIYF/nmwHXwZVYxf2fbxtdwZjCH akexDB7YU3+2Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5A29D695FF for ; Wed, 21 Jan 2026 15:09:31 -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 Z2U1oRQ2E78b for ; Wed, 21 Jan 2026 15:09:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033371; bh=xt6qnhFKL9WyVTInrzm1Z4esRtHuNW9HQZNyJp230tM=; 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=Iff/cZIO1LYEopOF7d0MIka0OlQrM4c7QXY6IWY0TLU326TWfN4/9UCwtkeMCDu2/ 0TVyx7kcOOPjAHtkp8ElaQGwD1XLepsr0rAxA8HqscHw/SbxFz2ByOdEWJONdLtpgr 2rqMmurrkWEXBhBvLMYK5F+T5I8S75lDgW5rLPBsC9Mfojl+k899gqjFLtsGsZ29u0 LhL+TpO2xL9PJHIY1YNeU35uMH585WmPk3/V8Kxr7bvBVgoRI35PyQ0ddXmlhaLtv3 u+QjzKk2Fozc1J/UcFevFIxEsBMFB1648Z5rcK/PIYF/nmwHXwZVYxf2fbxtdwZjCH akexDB7YU3+2Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 45EFD695FB for ; Wed, 21 Jan 2026 15:09:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033369; bh=rpe9aj4cGN2Er3Ad3UM0v/Jyz0aY9Ueoe3X7fuBlO6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wPi6M1x/XsIEFvueIYhg3UblSJFLE1fPvHo012pNVYS6sYGH7teolPXo2yfln+oZ1 rkM/bc3IVfH7zROCVTuCGXvgkckffg37OiEL1iBDyPoHhNLaN8xXez2tdA08koxe6l ebNkj8ktO/eZPYNtmYQunXxWUCqtaG6tvLrNnclR7gAk0VmgYBO0HwBgeGgCuCZCZg SUJQT4tkMqI5+UwKP/8lUA4ATIyG/CdiXiDn8reJkfNi7UEcGO91w8JOzndODc6U93 LaIilVe7S/4PEsLEioZGXhuH8BejDuXISos+ayV5xxhO/T+P87J6DsF3Q/6Ap2NWGi IP//I6Eki8GdQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3E6BC695FB; Wed, 21 Jan 2026 15:09:29 -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 u4itpatrfIJ9; Wed, 21 Jan 2026 15:09:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033363; bh=4B/v1dmTUhB2hZLbqW3YM8vh0p76lXxzCJZHjJeOsro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a9XpPLpElwzlKrQgZrWYFDgFdciAU3FLkgGnzxFQByys11eKCOryoeWMo0pK9kSKT 7vLubNBSQ80QU4gG+rqvX0BeTg3w03eakVtHuW94rMs3f2s7rL9mZm0Wzu3m0roPjy VhAzco56ZGAgqm7Uiv2C+xdOYuxz/3yKVvyW+teuNCpOtUbS9NLxUg0i81wc7Dxqe/ qUBn+9+noZVEbmZcPpR43vocG42Y4VMeaFsKGGToMSEwXYRqpSUu4uV1AeQdZfxtvY AJ+LAXOuuG01N4Vynl5e1YRewGpx4X0odIpmxYPT12lhlWTl+uPTtN6lPINT5OtZsv Cz3nLwQbc13lw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 51369695F2; Wed, 21 Jan 2026 15:09:23 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 21 Jan 2026 15:08:18 -0700 Message-ID: <20260121220857.2137568-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260121220857.2137568-1-sjg@u-boot.org> References: <20260121220857.2137568-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LSFKU3CBOZEVEO7MY6EJI7YRDN4IRPFQ X-Message-ID-Hash: LSFKU3CBOZEVEO7MY6EJI7YRDN4IRPFQ 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/33] ext4l: Move struct inode and time accessors to linux/fs.h 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 Move the inode structure definition and its time accessor functions from ext4_uboot.h to include/linux/fs.h where they belong according to Linux kernel conventions. This includes: - struct inode definition - inode_get_atime(), inode_get_mtime(), inode_get_ctime() - inode_get_atime_sec(), inode_get_mtime_sec(), inode_get_ctime_sec() - inode_set_atime(), inode_set_mtime(), inode_set_ctime() - inode_set_atime_to_ts(), inode_set_ctime_to_ts() - simple_inode_init_ts() - i_uid_read(), i_gid_read() Add necessary includes to linux/fs.h for inode dependencies (cred.h, rwsem.h, time.h, atomic.h). Co-developed-by: Claude (Anthropic) Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 126 ----------------------------------------- include/linux/fs.h | 129 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 128 insertions(+), 127 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index fb5c7cc8872..6f4ebd7e68b 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -181,105 +181,9 @@ static inline int bdev_read_only(struct block_device *bdev) return bdev ? bdev->read_only : 0; } -#include - #define WHITEOUT_DEV 0 #define WHITEOUT_MODE 0 -struct swap_info_struct; -struct inode_operations; -struct file_operations; - -struct inode { - struct super_block *i_sb; - unsigned long i_ino; - umode_t i_mode; - unsigned int i_nlink; - loff_t i_size; - struct address_space *i_mapping; - struct address_space i_data; - kuid_t i_uid; - kgid_t i_gid; - unsigned long i_blocks; - unsigned int i_generation; - unsigned int i_flags; - unsigned int i_blkbits; - unsigned long i_state; - struct timespec64 i_atime; - struct timespec64 i_mtime; - struct timespec64 i_ctime; - struct list_head i_io_list; - dev_t i_rdev; - const struct inode_operations *i_op; - const struct file_operations *i_fop; - atomic_t i_writecount; /* Count of writers */ - atomic_t i_count; /* Reference count */ - struct rw_semaphore i_rwsem; /* inode lock */ - const char *i_link; /* Symlink target for fast symlinks */ - unsigned short i_write_hint; /* Write life time hint */ - - /* U-Boot: linkage into super_block s_inodes list */ - struct list_head i_sb_list; -}; - -/* Inode time accessors */ -static inline struct timespec64 inode_get_atime(const struct inode *inode) -{ - return inode->i_atime; -} - -static inline struct timespec64 inode_get_mtime(const struct inode *inode) -{ - return inode->i_mtime; -} - -static inline struct timespec64 inode_get_ctime(const struct inode *inode) -{ - return inode->i_ctime; -} - -static inline time_t inode_get_atime_sec(const struct inode *inode) -{ - return inode->i_atime.tv_sec; -} - -static inline time_t inode_get_ctime_sec(const struct inode *inode) -{ - return inode->i_ctime.tv_sec; -} - -static inline time_t inode_get_mtime_sec(const struct inode *inode) -{ - return inode->i_mtime.tv_sec; -} - -static inline void inode_set_ctime(struct inode *inode, time_t sec, long nsec) -{ - inode->i_ctime.tv_sec = sec; - inode->i_ctime.tv_nsec = nsec; -} - -static inline void inode_set_atime(struct inode *inode, time_t sec, long nsec) -{ - inode->i_atime.tv_sec = sec; - inode->i_atime.tv_nsec = nsec; -} - -static inline void inode_set_mtime(struct inode *inode, time_t sec, long nsec) -{ - inode->i_mtime.tv_sec = sec; - inode->i_mtime.tv_nsec = nsec; -} - -static inline void simple_inode_init_ts(struct inode *inode) -{ - struct timespec64 ts = { .tv_sec = 0, .tv_nsec = 0 }; - - inode->i_atime = ts; - inode->i_mtime = ts; - inode->i_ctime = ts; -} - /* * Inode state accessors - simplified for single-threaded U-Boot. * Linux uses READ_ONCE/WRITE_ONCE and lockdep assertions; we use direct access. @@ -450,37 +354,7 @@ struct dx_hash_info { #include #include - -/* Inode time setters - needed for ext4.h */ -static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode, - struct timespec64 ts) -{ - inode->i_atime = ts; - return ts; -} - -static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode, - struct timespec64 ts) -{ - inode->i_ctime = ts; - return ts; -} - -/* Inode version operations - use linux/iversion.h */ #include - -/* Inode credential helpers - i_uid_read, i_gid_read need struct inode */ -static inline unsigned int i_uid_read(const struct inode *inode) -{ - return inode->i_uid.val; -} - -static inline unsigned int i_gid_read(const struct inode *inode) -{ - return inode->i_gid.val; -} - -/* Device encoding helpers are now in linux/kdev_t.h */ #include /* UID/GID bit helpers - use linux/highuid.h */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 3f82a027931..e78ac5f7284 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -11,9 +11,12 @@ #include #include #include +#include +#include +#include +#include /* Forward declarations */ -struct inode; struct buffer_head; struct file; struct folio; @@ -100,6 +103,130 @@ struct address_space_operations { sector_t *); }; +/* Forward declarations for inode */ +struct inode_operations; +struct file_operations; + +/** + * struct inode - filesystem inode + * + * Core filesystem object representing a file, directory, or other entity. + */ +struct inode { + struct super_block *i_sb; + unsigned long i_ino; + umode_t i_mode; + unsigned int i_nlink; + loff_t i_size; + struct address_space *i_mapping; + struct address_space i_data; + kuid_t i_uid; + kgid_t i_gid; + unsigned long i_blocks; + unsigned int i_generation; + unsigned int i_flags; + unsigned int i_blkbits; + unsigned long i_state; + struct timespec64 i_atime; + struct timespec64 i_mtime; + struct timespec64 i_ctime; + struct list_head i_io_list; + dev_t i_rdev; + const struct inode_operations *i_op; + const struct file_operations *i_fop; + atomic_t i_writecount; /* Count of writers */ + atomic_t i_count; /* Reference count */ + struct rw_semaphore i_rwsem; /* inode lock */ + const char *i_link; /* Symlink target for fast symlinks */ + unsigned short i_write_hint; /* Write life time hint */ +#ifdef __UBOOT__ + struct list_head i_sb_list; /* Linkage into super_block s_inodes */ +#endif +}; + +/* Inode time accessors */ +static inline struct timespec64 inode_get_atime(const struct inode *inode) +{ + return inode->i_atime; +} + +static inline struct timespec64 inode_get_mtime(const struct inode *inode) +{ + return inode->i_mtime; +} + +static inline struct timespec64 inode_get_ctime(const struct inode *inode) +{ + return inode->i_ctime; +} + +static inline time_t inode_get_atime_sec(const struct inode *inode) +{ + return inode->i_atime.tv_sec; +} + +static inline time_t inode_get_ctime_sec(const struct inode *inode) +{ + return inode->i_ctime.tv_sec; +} + +static inline time_t inode_get_mtime_sec(const struct inode *inode) +{ + return inode->i_mtime.tv_sec; +} + +static inline void inode_set_ctime(struct inode *inode, time_t sec, long nsec) +{ + inode->i_ctime.tv_sec = sec; + inode->i_ctime.tv_nsec = nsec; +} + +static inline void inode_set_atime(struct inode *inode, time_t sec, long nsec) +{ + inode->i_atime.tv_sec = sec; + inode->i_atime.tv_nsec = nsec; +} + +static inline void inode_set_mtime(struct inode *inode, time_t sec, long nsec) +{ + inode->i_mtime.tv_sec = sec; + inode->i_mtime.tv_nsec = nsec; +} + +static inline void simple_inode_init_ts(struct inode *inode) +{ + struct timespec64 ts = { .tv_sec = 0, .tv_nsec = 0 }; + + inode->i_atime = ts; + inode->i_mtime = ts; + inode->i_ctime = ts; +} + +static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode, + struct timespec64 ts) +{ + inode->i_atime = ts; + return ts; +} + +static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode, + struct timespec64 ts) +{ + inode->i_ctime = ts; + return ts; +} + +/* Inode credential helpers */ +static inline unsigned int i_uid_read(const struct inode *inode) +{ + return inode->i_uid.val; +} + +static inline unsigned int i_gid_read(const struct inode *inode) +{ + return inode->i_gid.val; +} + /* block_device - minimal stub */ struct block_device { struct address_space *bd_mapping;