[Concept,04/12] linux: Add statfs.h header with kstatfs struct

Message ID 20260118133734.4.796271526d07541b732e7b97de733563613fa131@changeid
State New
Headers
Series ext4l: Continue reducing ext4_uboot.h size with more headers |

Commit Message

Simon Glass Jan. 18, 2026, 8:37 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Create linux/statfs.h with the kstatfs structure for filesystem
statistics reporting.

Update ext4_uboot.h to use the new header instead of duplicating
the structure definition.

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

---

 fs/ext4l/ext4_uboot.h  | 17 ++---------------
 include/linux/statfs.h | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 15 deletions(-)
 create mode 100644 include/linux/statfs.h
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 185951ac4c1..f686364a761 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -1300,21 +1300,8 @@  static inline __kernel_fsid_t uuid_to_fsid(const u8 *uuid)
 	return fsid;
 }
 
-/* kstatfs for statfs */
-struct kstatfs {
-	long f_type;
-	long f_bsize;
-	u64 f_blocks;
-	u64 f_bfree;
-	u64 f_bavail;
-	u64 f_files;
-	u64 f_ffree;
-	__kernel_fsid_t f_fsid;
-	long f_namelen;
-	long f_frsize;
-	long f_flags;
-	long f_spare[4];
-};
+/* kstatfs - use linux/statfs.h */
+#include <linux/statfs.h>
 
 /* struct seq_file is in linux/seq_file.h */
 
diff --git a/include/linux/statfs.h b/include/linux/statfs.h
new file mode 100644
index 00000000000..bdc3f9b9e87
--- /dev/null
+++ b/include/linux/statfs.h
@@ -0,0 +1,42 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Filesystem statistics definitions for U-Boot
+ *
+ * Based on Linux statfs.h
+ */
+#ifndef _LINUX_STATFS_H
+#define _LINUX_STATFS_H
+
+#include <linux/types.h>
+
+/**
+ * struct kstatfs - kernel filesystem statistics
+ * @f_type: filesystem type
+ * @f_bsize: optimal transfer block size
+ * @f_blocks: total data blocks in filesystem
+ * @f_bfree: free blocks in filesystem
+ * @f_bavail: free blocks available to unprivileged user
+ * @f_files: total file nodes in filesystem
+ * @f_ffree: free file nodes in filesystem
+ * @f_fsid: filesystem ID
+ * @f_namelen: maximum length of filenames
+ * @f_frsize: fragment size
+ * @f_flags: mount flags
+ * @f_spare: spare for later
+ */
+struct kstatfs {
+	long f_type;
+	long f_bsize;
+	u64 f_blocks;
+	u64 f_bfree;
+	u64 f_bavail;
+	u64 f_files;
+	u64 f_ffree;
+	__kernel_fsid_t f_fsid;
+	long f_namelen;
+	long f_frsize;
+	long f_flags;
+	long f_spare[4];
+};
+
+#endif /* _LINUX_STATFS_H */