summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-10-14 08:39:18 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-10-15 09:57:24 +0200
commit8e9548839b13e5d0683e6a6c3ccfeb26e54f2bf9 (patch)
tree0c4b7eb323666723053db4e0a0d01833b5f23c98 /fs
parentb93cbf9ccd08f1049249688048cf633faed5b69f (diff)
downloadbarebox-8e9548839b13e5d0683e6a6c3ccfeb26e54f2bf9.tar.gz
fs: devfs-core: have device_find_partition search symlinks
The barebox,environment binding documentation notes following for the device-path property's second string: > <partname> can be the label for MTD partitions, the number for DOS > partitions (beginning with 0) or the name for GPT partitions. This doesn't work currently because the named partitions are realized as symlinks and those aren't searched by device_find_partition. Fix this by having symlinks feature an appropriate partname if the cdev they link at has one and then have device_find_partition search those as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/devfs-core.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 2b93a95..258bb2d 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -122,10 +122,17 @@ struct cdev *device_find_partition(struct device_d *dev, const char *name)
struct device_d *child;
list_for_each_entry(cdev, &dev->cdevs, devices_list) {
+ struct cdev *cdevl;
+
if (!cdev->partname)
continue;
if (!strcmp(cdev->partname, name))
return cdev;
+
+ list_for_each_entry(cdevl, &cdev->links, link_entry) {
+ if (!strcmp(cdevl->partname, name))
+ return cdev_readlink(cdevl);
+ }
}
device_for_each_child(dev, child) {
@@ -252,6 +259,20 @@ int devfs_create_link(struct cdev *cdev, const char *name)
new = xzalloc(sizeof(*new));
new->name = xstrdup(name);
new->link = cdev;
+
+ if (cdev->partname) {
+ size_t partnameoff = 0;
+
+ if (cdev->master) {
+ size_t masterlen = strlen(cdev->master->name);
+
+ if (!strncmp(name, cdev->master->name, masterlen))
+ partnameoff += masterlen + 1;
+ }
+
+ new->partname = xstrdup(name + partnameoff);
+ }
+
INIT_LIST_HEAD(&new->links);
list_add_tail(&new->list, &cdev_list);
list_add_tail(&new->link_entry, &cdev->links);