<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
From: Neil Brown &lt;neilb@cse.unsw.edu.au&gt;

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.



---

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

diff -puN fs/partitions/check.c~partition-naming-fix fs/partitions/check.c
--- 25/fs/partitions/check.c~partition-naming-fix	2004-01-21 20:06:26.000000000 -0800
+++ 25-akpm/fs/partitions/check.c	2004-01-21 20:06:26.000000000 -0800
@@ -315,7 +315,10 @@ void add_partition(struct gendisk *disk,
 			S_IFBLK|S_IRUSR|S_IWUSR,
 			"%s/part%d", disk-&gt;devfs_name, part);
 
-	snprintf(p-&gt;kobj.name,KOBJ_NAME_LEN,"%s%d",disk-&gt;kobj.name,part);
+	if (isdigit(disk-&gt;kobj.name[strlen(disk-&gt;kobj.name)-1]))
+		snprintf(p-&gt;kobj.name,KOBJ_NAME_LEN,"%sp%d",disk-&gt;kobj.name,part);
+	else
+		snprintf(p-&gt;kobj.name,KOBJ_NAME_LEN,"%s%d",disk-&gt;kobj.name,part);
 	p-&gt;kobj.parent = &amp;disk-&gt;kobj;
 	p-&gt;kobj.ktype = &amp;ktype_part;
 	kobject_register(&amp;p-&gt;kobj);

_
</pre></body></html>