summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-09-30 17:40:17 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-10-04 11:01:24 +0200
commit9719692439b21f828eb63d6e8d703ec34fbfebe2 (patch)
tree9388031911fcfa701ef5e3c1eed1184ae5263c57 /fs
parent13c7a12af0ab73adb5577adfd3d28731cd1b6190 (diff)
downloadbarebox-9719692439b21f828eb63d6e8d703ec34fbfebe2.tar.gz
fs: implement cdev_mount()
EFI loaders provide both block device and file system access to software running under it. For file system access, we will just want to get a mount if available and mount at a default location if not. Provide a helper that does just that. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220930154017.750867-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/fs.c b/fs/fs.c
index 78878e7112..a314a49b2d 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1000,6 +1000,25 @@ const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions)
}
/*
+ * cdev_mount - return existing mount or mount a cdev to the default path
+ *
+ * If a cdev is already mounted anywhere return the path
+ * it's mounted on.
+ * Otherwise mount it to /mnt/<cdevname> and return the path. Returns an
+ * error pointer on failure.
+ */
+const char *cdev_mount(struct cdev *cdev)
+{
+ const char *path;
+
+ path = cdev_get_mount_path(cdev);
+ if (path)
+ return path;
+
+ return cdev_mount_default(cdev, NULL);
+}
+
+/*
* mount_all - iterate over block devices and mount all devices we are able to
*/
void mount_all(void)