mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/5] fs: devfs-core: have device_find_partition search symlinks
Date: Mon, 14 Oct 2019 08:39:18 +0200	[thread overview]
Message-ID: <20191014063922.17233-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20191014063922.17233-1-a.fatoum@pengutronix.de>

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>
---
 fs/devfs-core.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 2b93a951f269..258bb2dbaaee 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);
-- 
2.23.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2019-10-14  6:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14  6:39 [PATCH 0/4] ARM: stm32mp: dk2: support barebox_update and env Ahmad Fatoum
2019-10-14  6:39 ` Ahmad Fatoum [this message]
2019-10-14  6:39 ` [PATCH 2/5] ARM: dts: stm32mp: add barebox-enviroment on DK boards Ahmad Fatoum
2019-10-14  6:39 ` [PATCH 3/5] ARM: stm32mp: dk2: rename function according to init level Ahmad Fatoum
2019-10-14  6:39 ` [PATCH 4/5] ARM: stm32mp: dk2: add barebox SD-Card update handler Ahmad Fatoum
2019-10-14 12:51   ` Sascha Hauer
2019-10-15  6:58     ` Ahmad Fatoum
2019-10-15  7:59       ` Sascha Hauer
2019-10-15  8:21         ` Ahmad Fatoum
2019-10-14  6:39 ` [PATCH 5/5] Documentation: boards: stm32mp: document environment partition Ahmad Fatoum

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=20191014063922.17233-2-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