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

Alain Tesio alain at onesite.org
Sun Oct 20 22:18:18 EDT 2002


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.
>>> import os
>>> os.stat("/dev/xda7")
(25008, 17383L, 5643L, 1, 0, 6, 0L, 1007270448, 975597764, 1007270448)
>>> os.stat("/dev/xda8")
(25008, 17384L, 5643L, 1, 0, 6, 0L, 1007270448, 975597764, 1007270448)
>>> 17384 / 256 , 17384 % 256
(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




More information about the Python-list mailing list