Why not linux use a larger 'dev_id' ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
miaowei
Member
Member
Posts: 84
Joined: Wed Dec 18, 2013 9:10 am

Why not linux use a larger 'dev_id' ?

Post 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.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post by iansjack »

dev_t is a 32-bit value, not 16.
User avatar
Sik
Member
Member
Posts: 251
Joined: Wed Aug 17, 2016 4:55 am

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

Post 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.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post by iansjack »

That was over 13 years ago, so the OP is looking at prehistoric source code.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

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

Post 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).
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
miaowei
Member
Member
Posts: 84
Joined: Wed Dec 18, 2013 9:10 am

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

Post by miaowei »

@iansjack @Sik @Schol-R-LEA
Thank you all !
I got it.
I am reading source code of linux 0.11.
miaowei
Member
Member
Posts: 84
Joined: Wed Dec 18, 2013 9:10 am

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

Post 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 ?
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post by iansjack »

'OP' is short for 'original poster'; it refers to the person that started the thread.
miaowei
Member
Member
Posts: 84
Joined: Wed Dec 18, 2013 9:10 am

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

Post 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 "楼主".
Post Reply