From 2ae2199ff3e982afe1d24c3c78a09af20ec20e43 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 3 Feb 2004 18:42:42 -0800 Subject: [PATCH] [PATCH] Make naming of parititions in sysfs match /proc/partitions. From: Neil Brown 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 anomoly so that names in sysfs can be parsed more reliably. This has been extensively discussed. It will probably break the external `iostat' tool. But only for disks whose name ends in a digit, which appears to be only DAC960. --- fs/partitions/check.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/partitions/check.c b/fs/partitions/check.c index f34189c455b24..81727e4cb021a 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -315,7 +315,10 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len) 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); -- 2.53.0