From bec70b3aaa1a750d32ac8c5299fb434454a87f07 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 10 Jul 2013 08:27:41 +0200 Subject: [PATCH] cdev: introduce partition names currently most partition cdevs have the name . This makes it hard to find a partition by . This introduces a partname field in struct cdev so that. Signed-off-by: Sascha Hauer --- 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 a16866eab..a2bea93ed 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 9f114fff5..353af3a0c 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;