using os.major

John Doe atterdan at
Wed Aug 11 21:57:43 CEST 2004

Does anyone understand what a 'raw device number' is with respect
os.major() and os.minor()

Found in os-file-dir.html, section 6.1.4, os.major() description is:

    Extracts a device major number from a raw device number. New in
    version 2.3.

The problem is, after searching I can only find two references to 'raw
device number'. Naturally they are in os.major() and os.minor().

There seems to be something related to fileno, but that never returns the
value I know is true. In particular, Linux /dev/fd0 is (2/0).

>>> fd = open('/dev/fd0')
>>> from os import major,minor
>>> fd.fileno()
>>> major(fd.fileno())
>>> minor(fd.fileno())
>>> from os import popen3
[instd,outstd,errstd] = popen3( 'file /dev/fd0' )
'/dev/fd0: block special (2/0)\n'

As you can see, Major is 2, minor is 0. Which is also what ls -l /dev/fd0

I've written a function to parse up the 'file /dev/fd0' results, but I'd
rather us the correct built in, or included modules, before writing my

atterdan at

More information about the Python-list mailing list