Re: [PATCH] print_dev_t for 2.6.0-test1-mm

From: H. Peter Anvin (
Date: Wed Jul 16 2003 - 22:00:57 EST

Followup to: <>
By author: Andries Brouwer <>
In newsgroup:
> > >
> > > 16-bit only: 8:8, otherwise 32-bit only: 16:16, otherwise 32:32.
> > Why do we need the 16:16 option?
> It is not very important, but major 0 is reserved, so if userspace
> (or a filesystem) hands us a 32-bit device number, we have to
> split that in some way, not 0+32. Life is easiest with 16+16.
> (Now the major is nonzero, otherwise we had 8+8.)
> Other choices lead to slightly more complicated code.

I would still recommend the arrangement for 64-bit dev_t that I posted
a while ago:

dev_t<63:40> := major<31:8>
dev_t<39:16> := minor<31:8>
dev_t<15:8> := major<7:0>
dev_t<7:0> := minor<7:0>

No aliasing, no forbidden bit patterns, no conditional code, no need
for magic numbers, and it's fully compatible with the current
LSB-adjusted user space dev_t format. I also posted i386 code for the
various operations to show that they really can be done with very
little code.

If you want, you can even make it 32-bit-friendly, although it makes
it more complex; for example, this version would implement 32-bit with
a 12:20 split:

dev_t<63:44> := major<31:12>
dev_t<43:32> := minor<31:20>
dev_t<31:28> := major<11:8>
dev_t<27:16> := minor<19:8>
dev_t<15:8> := major<7:0>
dev_t<7:0> := minor<7:0>


<> at work, <> in private!
If you send me mail in HTML format I will assume it's spam.
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Wed Jul 23 2003 - 22:00:28 EST