From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/3] fs: implement new resolve_fsdevice_path helper
Date: Thu, 11 Dec 2025 16:18:16 +0100 [thread overview]
Message-ID: <20251211151820.3726093-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20251211151820.3726093-1-a.fatoum@pengutronix.de>
For use by the EFI loader, we will want to split off the file path
within a device from the device path.
As we have no function that generates a path relative to a mountpoint's
root, add a function that does this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/fs.c | 25 +++++++++++++++++++++++++
include/fs.h | 1 +
2 files changed, 26 insertions(+)
diff --git a/fs/fs.c b/fs/fs.c
index 28378989f91b..77f22d69ea49 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -2454,6 +2454,31 @@ struct fs_device *get_fsdevice_by_path(int dirfd, const char *pathname)
return fsdev;
}
+struct fs_device *resolve_fsdevice_path(int dirfd, const char *pathname, char **filepath)
+{
+ struct fs_device *fsdev;
+ char *res = NULL;
+ struct path path;
+ int ret;
+
+ fsdev = get_fsdevice_by_path(dirfd, pathname);
+ if (!fsdev)
+ return NULL;
+
+ ret = filename_lookup(dirfd, getname(pathname), LOOKUP_FOLLOW, &path);
+ if (ret)
+ goto out;
+
+ res = dpath(path.dentry, fsdev->vfsmount.mnt_root);
+ if (res)
+ *filepath = res;
+
+ path_put(&path);
+out:
+ errno_set(ret);
+ return res ? fsdev : NULL;
+}
+
static int vfs_rmdir(struct inode *dir, struct dentry *dentry)
{
int error;
diff --git a/include/fs.h b/include/fs.h
index b9bd14da81a7..9c3c8d95123a 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -141,6 +141,7 @@ void cdev_print(const struct cdev *cdev);
char *canonicalize_path(int dirfd, const char *pathname);
struct fs_device *get_fsdevice_by_path(int dirfd, const char *path);
+struct fs_device *resolve_fsdevice_path(int dirfd, const char *pathname, char **filepath);
const char *get_mounted_path(const char *path);
--
2.47.3
next prev parent reply other threads:[~2025-12-11 15:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 15:18 [PATCH 1/3] bbu: detect devices when devicefile has no /dev/ prefix as well Ahmad Fatoum
2025-12-11 15:18 ` [PATCH 2/3] treewide: replace open-coded variants of devpath_to_name Ahmad Fatoum
2025-12-11 15:18 ` Ahmad Fatoum [this message]
2025-12-15 10:18 ` [PATCH 1/3] bbu: detect devices when devicefile has no /dev/ prefix as well 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=20251211151820.3726093-3-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--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