using os.major
John Doe
atterdan at yahoo.com
Wed Aug 11 15:57:43 EDT 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:
major(device)
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).
Example:
--------------------------------
>>> fd = open('/dev/fd0')
>>> from os import major,minor
>>> fd.fileno()
3
>>> major(fd.fileno())
0
>>> minor(fd.fileno())
3
>>> from os import popen3
[instd,outstd,errstd] = popen3( 'file /dev/fd0' )
>>> outstd.read()
'/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
reports.
--------------------------------
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
own.
atterdan at yahoo.com
More information about the Python-list
mailing list