How to get the minor and major device numbers with os.stat ?

A

Alain Tesio

Hi, I can't manage to get the major or minor device numbers
with os.stat :

~ $ll /dev/xda7 /dev/xda8
brw-rw---- 1 root disk 13, 7 Nov 30 2000 /dev/xda7
brw-rw---- 1 root disk 13, 8 Nov 30 2000 /dev/xda8

~ $python
Python 2.2.2 (#4, Oct 15 2002, 04:21:28)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.(67, 232)


I expected major*256+minor, I've tried a lot of combinations at random
and couldn't manage to get 17383 from (13,7)

Any idea ?

Thanks
Alain
 
E

Erik Max Francis

Alain said:
I expected major*256+minor, I've tried a lot of combinations at random
and couldn't manage to get 17383 from (13,7)

For the answer to this, you should really be looking at man stat. The
values here are implementation defined; Python's just mimicking whatever
the underlying OS is doing. What you want is st_rdev:
crw-rw---- 1 root uucp 4, 64 Jul 17 1994 /dev/ttyS0
0(4, 64)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top