[PATCH - 2.6.2-pre] Make naming of parititions in sysfs match /proc/partitions.

From: Neil Brown
Date: Wed Jan 21 2004 - 21:23:06 EST




In fs/partitions/check.c there are two pieces of code that add a
partition number to a block-device name:

- the 'disk_name' function
- a snprintf in add_partitions.

'disk_name' inserts a 'p' before the partition number if the device
name ends with a digit. The snprintf in add_partitions doesn't.

This patch rectifies this anomily so that names in sysfs can be
parsed more reliably.


----------- Diffstat output ------------
./fs/partitions/check.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletion(-)

diff ./fs/partitions/check.c~current~ ./fs/partitions/check.c
--- ./fs/partitions/check.c~current~ 2004-01-22 08:57:32.000000000 +1100
+++ ./fs/partitions/check.c 2004-01-22 08:58:37.000000000 +1100
@@ -315,7 +315,10 @@ void add_partition(struct gendisk *disk,
S_IFBLK|S_IRUSR|S_IWUSR,
"%s/part%d", disk->devfs_name, part);

- snprintf(p->kobj.name,KOBJ_NAME_LEN,"%s%d",disk->kobj.name,part);
+ if (isdigit(disk->kobj.name[strlen(disk->kobj.name)-1]))
+ snprintf(p->kobj.name,KOBJ_NAME_LEN,"%sp%d",disk->kobj.name,part);
+ else
+ snprintf(p->kobj.name,KOBJ_NAME_LEN,"%s%d",disk->kobj.name,part);
p->kobj.parent = &disk->kobj;
p->kobj.ktype = &ktype_part;
kobject_register(&p->kobj);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/