Skip to contentSkip to conversation

Use hex numbers in fs/block_dev.c

PATCH In review Rolf Eike Beer 3 participants 4 messages Feb 26, 2003 – Feb 27, 2003 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use hex numbers in fs/block_dev.c

We're using hex numbers to identify devices in most places. We should use them in filesystem messages, errors etc. too, this would be much more consistent and avoids things like this where two different naming styles for the same error are used:

     end_request: [...] dev 16:45 (hdd), sector 9175248
     EXT3-fs error (device ide1(22,69)): [...] inode=575269, block=1146906

With this patch the second message would look like this:

     EXT3-fs error (device ide1(16:45)): [...] inode=575269, block=1146906

This code is used in some drivers outside fs/ too, but there only in *print* or DEBUG's.

Eike

fs/block_dev.c renamed from fs/block_dev.c.orig +1 -1
@@ -794,7 +794,7 @@
 	if (!name)
 		name = "unknown-block";
 
-	sprintf(buffer, "%s(%d,%d)", name, MAJOR(dev), MINOR(dev));
+	sprintf(buffer, "%s(%x:%x)", name, MAJOR(dev), MINOR(dev));
 	return buffer;
 }
 
#1 lore raw
Quoted 6 lines · Rolf Eike Beer

We're using hex numbers to identify devices in most places. We should use them in filesystem messages, errors etc. too, this would be much more consistent and avoids things like this where two different naming styles for the same error are used:

Quoted 6 lines
     end_request: [...] dev 16:45 (hdd), sector 9175248
     EXT3-fs error (device ide1(22,69)): [...] inode=575269, block=1146906

With this patch the second message would look like this:

     EXT3-fs error (device ide1(16:45)): [...] inode=575269, block=1146906

Whis is _horrible_. Am I supposed to guess that ide does not use major 16, so it will be 0x16 == 22 instead?

Better use the patch below, if at all.

fs/block_dev.c renamed from fs/block_dev.c.orig +1 -1
@@ -794,7 +794,7 @@
 	if (!name)
 		name = "unknown-block";
 
-	sprintf(buffer, "%s(%d,%d)", name, MAJOR(dev), MINOR(dev));
+	sprintf(buffer, "%s(0x%x:0x%x)", name, MAJOR(dev), MINOR(dev));
 	return buffer;
 }
 

Jörn

Signature · 3 lines
Courage is not the absence of fear, but rather the judgement that
something else is more important than fear.
-- Ambrose Redmoon
#2 lore raw

Am Mittwoch, 26. Februar 2003 17:37 schrieb Jörn Engel:

Quoted 10 lines · Rolf Eike Beer
Quoted 9 lines

We're using hex numbers to identify devices in most places. We should use them in filesystem messages, errors etc. too, this would be much more consistent and avoids things like this where two different naming styles for the same error are used:

     end_request: [...] dev 16:45 (hdd), sector 9175248
     EXT3-fs error (device ide1(22,69)): [...] inode=575269,

block=1146906

Quoted 7 lines
Quoted 4 lines

With this patch the second message would look like this:

     EXT3-fs error (device ide1(16:45)): [...] inode=575269,

block=1146906

Whis is _horrible_. Am I supposed to guess that ide does not use major 16, so it will be 0x16 == 22 instead?

Of course, I know. But then we have to fix the end_request stuff also. And root=831 command line etc. This _is_ ugly. I just tried to make it one kind of ugly at all.

Eike

#3 lore raw
Quoted 16 lines · Rolf Eike Beer

Am Mittwoch, 26. Februar 2003 17:37 schrieb Jörn Engel:

Quoted 15 lines · Rolf Eike Beer
Quoted 13 lines

We're using hex numbers to identify devices in most places. We should use them in filesystem messages, errors etc. too, this would be much more consistent and avoids things like this where two different naming styles for the same error are used:

     end_request: [...] dev 16:45 (hdd), sector 9175248
     EXT3-fs error (device ide1(22,69)): [...] inode=575269,

block=1146906

With this patch the second message would look like this:

     EXT3-fs error (device ide1(16:45)): [...] inode=575269,

block=1146906

Quoted 6 lines
Quoted 2 lines

Whis is _horrible_. Am I supposed to guess that ide does not use major 16, so it will be 0x16 == 22 instead?

Of course, I know. But then we have to fix the end_request stuff also. And root=831 command line etc. This _is_ ugly. I just tried to make it one kind of ugly at all.

If you are going to print it in hex do make it clear but one 0x should be enough: 0x16:45 is OK, 0x16:0x45 is hideous.

Given that the way i would identify device would be to grep for the numbers in an ls of /dev i'd much rather they be in decimal. It all depends on how people will use the values. When would i use the hex representation be useful?

Signature · 5 lines
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		[email protected]

		Remember Cernan and Schmitt