[PATCH 4/9] cdev: introduce partition names
Sascha Hauer
s.hauer at pengutronix.de
Wed Jul 10 06:52:03 EDT 2013
currently most partition cdevs have the name <devname>.<partname>
This makes it hard to find a partition by <partname>. This introduces
a partname field in struct cdev so that.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
fs/devfs-core.c | 3 +++
include/driver.h | 5 ++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index a16866e..a2bea93 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -244,6 +244,8 @@ struct cdev *devfs_add_partition(const char *devname, loff_t offset, loff_t size
new = xzalloc(sizeof (*new));
new->name = strdup(name);
+ if (!strncmp(devname, name, strlen(devname)))
+ new->partname = xstrdup(name + strlen(devname) + 1);
new->ops = cdev->ops;
new->priv = cdev->priv;
new->size = size;
@@ -291,6 +293,7 @@ int devfs_del_partition(const char *name)
return ret;
free(cdev->name);
+ free(cdev->partname);
free(cdev);
return 0;
diff --git a/include/driver.h b/include/driver.h
index 9f114ff..353af3a 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -444,7 +444,10 @@ struct cdev {
struct device_d *dev;
struct list_head list;
struct list_head devices_list;
- char *name;
+ char *name; /* filename under /dev/ */
+ char *partname; /* the partition name, usually the above without the
+ * device part, i.e. name = "nand0.barebox" -> partname = "barebox"
+ */
loff_t offset;
loff_t size;
unsigned int flags;
--
1.8.3.2
More information about the barebox
mailing list