[PATCH 2/2] fs: add filepath helper
Ahmad Fatoum
a.fatoum at barebox.org
Wed Oct 15 01:16:46 PDT 2025
This helper can be useful for debugging code, so export it in a header
and make first use of it.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
fs/legacy.c | 8 ++++----
include/fs.h | 5 +++++
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/fs/legacy.c b/fs/legacy.c
index c2170f52a40b..dce14706ca20 100644
--- a/fs/legacy.c
+++ b/fs/legacy.c
@@ -16,8 +16,7 @@ static struct inode *legacy_get_inode(struct super_block *sb, const struct inode
static int legacy_iterate(struct file *file, struct dir_context *ctx)
{
- struct dentry *dentry = file->f_path.dentry;
- struct inode *dir = d_inode(dentry);
+ struct inode *dir = d_inode(file->f_path.dentry);
struct super_block *sb = dir->i_sb;
struct fs_device *fsdev = container_of(sb, struct fs_device, sb);
const struct fs_legacy_ops *legacy_ops = fsdev->driver->legacy_ops;
@@ -27,7 +26,7 @@ static int legacy_iterate(struct file *file, struct dir_context *ctx)
dir_emit_dots(file, ctx);
- pathname = dpath(dentry, fsdev->vfsmount.mnt_root);
+ pathname = filepath(file);
d = legacy_ops->opendir(&fsdev->dev, pathname);
if (!d)
@@ -87,7 +86,8 @@ static int legacy_open(struct inode *inode, struct file *file)
if (!legacy_ops->open)
return 0;
- pathname = dpath(file->f_path.dentry, fsdev->vfsmount.mnt_root);
+ pathname = filepath(file);
+
error = legacy_ops->open(&file->fsdev->dev, file, pathname);
free(pathname);
diff --git a/include/fs.h b/include/fs.h
index 86442eacddf9..98c482bbf2a9 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -172,4 +172,9 @@ static inline const char *devpath_to_name(const char *devpath)
const char *fs_detect(const char *filename, const char *fsoptions);
+static inline char *filepath(struct file *f)
+{
+ return dpath(f->f_path.dentry, f->fsdev->vfsmount.mnt_root);
+}
+
#endif /* __FS_H */
--
2.47.3
More information about the barebox
mailing list