Page 1 of 1

Why not linux use a larger 'dev_id' ?

Posted: Sat Oct 15, 2016 7:50 am
by miaowei
Hi, friends.
I want to know, why does linux use a 16-bit value to indicate device id ?
8-bit for major and 8-bit for minor seems not enough nowadays.
For example, device major id 8 indicate the 1th to 16th SCSI disks, and we have to indicate another 17th - 32th disks using major id 65.

This seems ugly? isn't it ?

If we use a 32-bit device value, namely, 16-bit for major, 16-bit for minor, we can adopt all device instance with one device major.

I am writing a kernel somewhat like linux kernel, and I am considering using a 32-bit device value.

Re: Why not linux use a larger 'dev_id' ?

Posted: Sat Oct 15, 2016 8:29 am
by iansjack
dev_t is a 32-bit value, not 16.

Re: Why not linux use a larger 'dev_id' ?

Posted: Sat Oct 15, 2016 10:52 am
by Sik
After looking around I think I know what's going on: it originally used to hold 16-bit values (8-bit major and 8-bit minor) but they started running out of space so eventually it got extended to 32-bit values (12-bit major and 20-bit minor). The old 16-bit values are still supported for backwards compatibility.

Re: Why not linux use a larger 'dev_id' ?

Posted: Sat Oct 15, 2016 11:35 am
by iansjack
That was over 13 years ago, so the OP is looking at prehistoric source code.

Re: Why not linux use a larger 'dev_id' ?

Posted: Sun Oct 16, 2016 9:59 am
by Schol-R-LEA
iansjack wrote:That was over 13 years ago, so the OP is looking at prehistoric source code.
On a guess was it either Linus' original 0.1 forum post code :P , or maybe the code from the 1999 edition of Linux Core Kernel Commentary (great book, laid out very much in the manner of the 1996 facsimile version of Lions' Commentary on Unix 6th Edition - which is also highly recommended despite being decades old - but dated even at the time of publication; I had the 2001 update until recently, and while it was very helpful, it could also be misleading because of its age).

Re: Why not linux use a larger 'dev_id' ?

Posted: Mon Oct 17, 2016 3:50 am
by miaowei
@iansjack @Sik @Schol-R-LEA
Thank you all !
I got it.
I am reading source code of linux 0.11.

Re: Why not linux use a larger 'dev_id' ?

Posted: Mon Oct 17, 2016 3:53 am
by miaowei
iansjack wrote:That was over 13 years ago, so the OP is looking at prehistoric source code.
Excuse me, what does 'OP' mean ?

Re: Why not linux use a larger 'dev_id' ?

Posted: Mon Oct 17, 2016 4:04 am
by iansjack
'OP' is short for 'original poster'; it refers to the person that started the thread.

Re: Why not linux use a larger 'dev_id' ?

Posted: Mon Oct 17, 2016 4:37 am
by miaowei
iansjack wrote:'OP' is short for 'original poster'; it refers to the person that started the thread.
Thanks!
In china, this is called "lz', or 'louzhu', or "楼主".