How to get the minor and major device numbers with os.stat ?

Grant Edwards grante at visi.com
Mon Oct 21 04:46:13 CEST 2002


In article <pan.2002.10.21.02.18.18.94011 at onesite.org>, Alain Tesio wrote:

> Hi, I can't manage to get the major or minor device numbers
> with os.stat

AFAIK, os.stat() has never returned device number info.
Last time I looked, the posix stat wrapper doesn't do anyting
with the st_rdev field.  [Don't know why -- it sure would be
useful sometimes.]

This question comes up every year or so in the newsgroup, and
the only answer seems to be to run /sbin/stat and parse the
output.  If you google the group for "stat device major minor"
you should find example work-around code that uses /sbin/stat.

-- 
Grant Edwards                   grante             Yow!  Just imagine you're
                                  at               entering a state-of-the-art
                               visi.com            CAR WASH!!



More information about the Python-list mailing list