From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/6] fs: Add device parameter for Linux root= option
Date: Thu, 18 Jun 2015 09:43:41 +0200 [thread overview]
Message-ID: <1434613424-19989-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1434613424-19989-1-git-send-email-s.hauer@pengutronix.de>
When registering a filesystem device add a device parameter suitable
for the Linux root= option to boot from exactly this filesystem. Currently
the fs layer sets this parameter to the root=PARTUUID= mechanism if a
partuuid is available. Other filesystems like NFS and UBIFS which do
not have a PARTUUID can overwrite this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/fs.c | 37 +++++++++++++++++++++++++++++++++++++
include/fs.h | 4 ++++
2 files changed, 41 insertions(+)
diff --git a/fs/fs.c b/fs/fs.c
index c249f84..67c78cd 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1298,6 +1298,12 @@ int mount(const char *device, const char *fsname, const char *_path,
goto err_no_driver;
}
+ if (!fsdev->linux_rootarg && fsdev->cdev && fsdev->cdev->partuuid[0] != 0) {
+ char *str = asprintf("root=PARTUUID=%s", fsdev->cdev->partuuid);
+
+ fsdev_set_linux_rootarg(fsdev, str);
+ }
+
return 0;
err_no_driver:
@@ -1708,3 +1714,34 @@ void mount_all(void)
cdev_mount_default(cdev, NULL);
}
}
+
+void fsdev_set_linux_rootarg(struct fs_device_d *fsdev, const char *str)
+{
+ fsdev->linux_rootarg = xstrdup(str);
+
+ dev_add_param_fixed(&fsdev->dev, "linux.bootargs", fsdev->linux_rootarg);
+}
+
+/**
+ * path_get_linux_rootarg() - Given a path return a suitable root= option for
+ * Linux
+ * @path: The path
+ *
+ * Return: A string containing the root= option or an ERR_PTR. the returned
+ * string must be freed by the caller.
+ */
+char *path_get_linux_rootarg(const char *path)
+{
+ struct fs_device_d *fsdev;
+ const char *str;
+
+ fsdev = get_fsdevice_by_path(path);
+ if (!fsdev)
+ return ERR_PTR(-EINVAL);
+
+ str = dev_get_param(&fsdev->dev, "linux.bootargs");
+ if (!str)
+ return ERR_PTR(-ENOSYS);
+
+ return xstrdup(str);
+}
diff --git a/include/fs.h b/include/fs.h
index f95464d..ee7e48b 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -100,6 +100,7 @@ struct fs_device_d {
struct device_d *parent_device;
struct list_head list;
char *options;
+ char *linux_rootarg;
};
#define drv_to_fs_driver(d) container_of(d, struct fs_driver_d, drv)
@@ -189,4 +190,7 @@ const char *cdev_get_mount_path(struct cdev *cdev);
const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions);
void mount_all(void);
+void fsdev_set_linux_rootarg(struct fs_device_d *fsdev, const char *str);
+char *path_get_linux_rootarg(const char *path);
+
#endif /* __FS_H */
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-06-18 7:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-18 7:43 Bootspec: Allow to automatically append " Sascha Hauer
2015-06-18 7:43 ` [PATCH 1/6] Add globalvar_add_simple_string function Sascha Hauer
2015-06-18 7:43 ` [PATCH 2/6] cdev: Add partuuid string to struct cdev Sascha Hauer
2015-06-18 7:43 ` Sascha Hauer [this message]
2015-06-18 7:43 ` [PATCH 4/6] fs: ubifs: Implement Linux rootarg Sascha Hauer
2015-06-18 7:43 ` [PATCH 5/6] fs: nfs: " Sascha Hauer
2015-06-18 7:43 ` [PATCH 6/6] blspec: Automatically append rootarg Sascha Hauer
2015-06-30 7:26 ` Marc Kleine-Budde
2015-07-01 6:58 ` Sascha Hauer
2015-07-01 7:22 ` Marc Kleine-Budde
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=1434613424-19989-4-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@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