mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 2/2] fs: add filepath helper
Date: Wed, 15 Oct 2025 10:16:46 +0200	[thread overview]
Message-ID: <20251015081648.4078283-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20251015081648.4078283-1-a.fatoum@barebox.org>

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@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




  reply	other threads:[~2025-10-15  8:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15  8:16 [PATCH 1/2] fs: make dpath always panic on OOM Ahmad Fatoum
2025-10-15  8:16 ` Ahmad Fatoum [this message]
2025-10-20 11:14 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251015081648.4078283-2-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox