summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-07-10 08:27:41 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-07-15 11:16:04 +0200
commitbec70b3aaa1a750d32ac8c5299fb434454a87f07 (patch)
tree11a10dc8713f56d156ececc3bf5dc25992e37dc7
parentabf95154f5d139f2e54559955e80e1752989cc88 (diff)
downloadbarebox-bec70b3aaa1a750d32ac8c5299fb434454a87f07.tar.gz
barebox-bec70b3aaa1a750d32ac8c5299fb434454a87f07.tar.xz
cdev: introduce partition names
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@pengutronix.de>
-rw-r--r--fs/devfs-core.c3
-rw-r--r--include/driver.h5
2 files changed, 7 insertions, 1 deletions
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index a16866eab9..a2bea93ed6 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 9f114fff58..353af3a0cb 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;