using os.major
Dima Dorfman
d+pylist at nospamplease.trit.org
Thu Aug 12 01:03:07 EDT 2004
John Doe <atterdan at yahoo.com> wrote:
> Does anyone understand what a 'raw device number' is with respect
> 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).
The raw device number isn't the file descriptor number; it's the
device ID, such as those returned by stat in the st_dev and st_rdev
fields:
>>> st = os.stat('/dev/fd/0')
>>> os.major(st.st_rdev)
22
>>> os.minor(st.st_rdev)
0
The documentation for os.stat mentions st_rdev, but it doesn't call it
the "raw" device number. The FreeBSD documentation is about evenly
split on calling it the "raw device number" or the "device ID", but
Posix uses the latter, and I think that makes more sense. There's
nothing raw about this value; I think it's only "raw" compared to
internal kernel structures, where a device could be a pointer to
struct instead of an integer (it's certainly not more raw than st_dev,
which has the same type).
Dima.
More information about the Python-list
mailing list