[Python-Dev] os.stat(filename).r_dev

Gustavo Niemeyer niemeyer@conectiva.com
Sun, 9 Jun 2002 16:19:18 -0300


While talking to Lars about tarfile.py, he has noted an interesting
detail in the current implementation of os.stat(filename).r_dev:

-------------
With the current os.stat(), it is impossible to implement addition of
those devices. That's because the result for st_rdev is just a plain
integer, which still must be divided into the major and minor part.
This division (resp. the C type dev_t) differs between several
operating systems:

OS        format    major          minor

Linux     32-bit    upper 16bits   lower 16bits
SVR4      32-bit    upper 14bits   lower 18bits
BSD       16-bit    upper 8bits    lower 8bits
-------------

It seems like we really need some way to decode r_dev. One possible
solutions are to implement major(), minor(), and makedev() somewhere.
Another solution, if r_dev's raw value has no obvious use, would be to
turn it into a two elements tuple like (major, minor).

Any suggestions?

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]