[Concept,02/23] linux: path: Add path_put and d_path stubs

Message ID 20260119061529.3383191-3-sjg@u-boot.org
State New
Headers
Series Reduce ext4_uboot.h by moving definitions to linux headers |

Commit Message

Simon Glass Jan. 19, 2026, 6:15 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Add path_put() macro and d_path() stub function to linux/path.h for
filesystem code that uses path operations.

Update linux/fs.h to include linux/path.h instead of duplicating
the struct path definition.

Update ext4_uboot.h to use linux/path.h instead of duplicating
these definitions.

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

 fs/ext4l/ext4_uboot.h | 12 +++---------
 include/linux/fs.h    |  7 ++-----
 include/linux/path.h  | 31 +++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 14 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 4fb8f9111b0..7ad24732cf4 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -928,13 +928,8 @@  void mapping_clear_folio_cache(struct address_space *mapping);
 #define sb_start_pagefault(sb)			do { (void)(sb); } while (0)
 #define sb_end_pagefault(sb)			do { (void)(sb); } while (0)
 
-/* d_path - get pathname - stub returns empty path */
-static inline char *d_path(const struct path *path, char *buf, int buflen)
-{
-	if (buflen > 0)
-		buf[0] = '\0';
-	return buf;
-}
+/* d_path, path_put - use linux/path.h */
+#include <linux/path.h>
 
 /* fscrypt_file_open is in ext4_fscrypt.h */
 #define fsverity_file_open(i, f)		({ (void)(i); (void)(f); 0; })
@@ -1379,8 +1374,7 @@  int inode_generic_drop(struct inode *inode);
 
 /* NFS export helpers are now in linux/exportfs.h */
 
-/* Path operations */
-#define path_put(p)			do { } while (0)
+/* Path operations - path_put, d_path are in linux/path.h */
 
 /* I/O priority - declaration for stub.c */
 int IOPRIO_PRIO_VALUE(int class, int data);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7393fd0d316..28b57b59484 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -51,11 +51,8 @@  struct vfsmount {
 	struct dentry *mnt_root;
 };
 
-/* path - pathname components */
-struct path {
-	struct vfsmount *mnt;
-	struct dentry *dentry;
-};
+/* path - use linux/path.h */
+#include <linux/path.h>
 
 /* Buffer operations are in buffer_head.h */
 
diff --git a/include/linux/path.h b/include/linux/path.h
index 27cc071026a..3ebcb16e3c7 100644
--- a/include/linux/path.h
+++ b/include/linux/path.h
@@ -1,4 +1,9 @@ 
 /* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Path definitions for U-Boot
+ *
+ * Based on Linux path.h - filesystem path operations.
+ */
 #ifndef _LINUX_PATH_H
 #define _LINUX_PATH_H
 
@@ -10,4 +15,30 @@  struct path {
 	struct dentry *dentry;
 };
 
+/**
+ * path_put() - release a path reference
+ * @path: path to release
+ *
+ * U-Boot stub - no reference counting.
+ */
+#define path_put(path)		do { (void)(path); } while (0)
+
+/**
+ * d_path() - get pathname from path structure
+ * @path: path to convert
+ * @buf: buffer for pathname
+ * @buflen: size of buffer
+ *
+ * U-Boot stub - returns empty string.
+ *
+ * Return: pointer to pathname in buffer
+ */
+static inline char *d_path(const struct path *path, char *buf, int buflen)
+{
+	(void)path;
+	if (buflen > 0)
+		buf[0] = '\0';
+	return buf;
+}
+
 #endif /* _LINUX_PATH_H */