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

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


Hi Martin!

First, some self-corrections.. :-)

> > It seems like we really need some way to decode r_dev. One possible
> > solutions are to implement major(), minor(), and makedev() somewhere.

"solution is"

> > Another solution, if r_dev's raw value has no obvious use, would be to

This should be st_rdev.

> > turn it into a two elements tuple like (major, minor).

> I'd add a field r_dev_pair which splits this into major and minor. I
> would not remove r_dev, since existing code may break.

Isn't st_rdev being made available only in 2.3, trough stat attributes?

> Notice that major, minor, and makedev is already available through
> TYPES on many platforms, although this has the known limitations, and
> is probably wrong for Linux at the moment.

Indeed. Here's what's defined here:

def major(dev): return ((int)(((dev) >> 8) & 0xff))
def minor(dev): return ((int)((dev) & 0xff))
def major(dev): return (((dev).__val[1] >> 8) & 0xff)
def minor(dev): return ((dev).__val[1] & 0xff)
def major(dev): return (((dev).__val[0] >> 8) & 0xff)
def minor(dev): return ((dev).__val[0] & 0xff)

-- 
Gustavo Niemeyer

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