473,473 Members | 2,207 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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

~ $ll /dev/xda7 /dev/xda8
brw-rw---- 1 root disk 13, 7 Nov 30 2000 /dev/xda7
brw-rw---- 1 root disk 13, 8 Nov 30 2000 /dev/xda8

~ $python
Python 2.2.2 (#4, Oct 15 2002, 04:21:28)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import os
os.stat("/dev/xda7") (25008, 17383L, 5643L, 1, 0, 6, 0L, 1007270448, 975597764, 1007270448) os.stat("/dev/xda8") (25008, 17384L, 5643L, 1, 0, 6, 0L, 1007270448, 975597764, 1007270448) 17384 / 256 , 17384 % 256

(67, 232)
I expected major*256+minor, I've tried a lot of combinations at random
and couldn't manage to get 17383 from (13,7)

Any idea ?

Thanks
Alain

Jul 18 '05 #1
1 3827
Alain Tesio wrote:
I expected major*256+minor, I've tried a lot of combinations at random
and couldn't manage to get 17383 from (13,7)


For the answer to this, you should really be looking at man stat. The
values here are implementation defined; Python's just mimicking whatever
the underlying OS is doing. What you want is st_rdev:
import os
os.system('ls -l /dev/ttyS0') crw-rw---- 1 root uucp 4, 64 Jul 17 1994 /dev/ttyS0
0 s = os.stat('/dev/ttyS0')
tuple(s) (8624, 9064L, 769L, 1, 0, 14, 0L, 1058628788, 774488935, 1058628789) s.st_rdev 1088 divmod(1088, 256)

(4, 64)

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Get married, but never to a man who is home all day.
\__/ George Bernard Shaw
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: EKL | last post by:
What do I have to do to guarantee that the objects that my code creates are reclaimed by only minor garbage collection runs? In other words, what do I have to do to only generate garbage for minor...
3
by: Steven T. Hatton | last post by:
I found the following two statements in the file linked below: struct stat st; stat(fileName.c_str(), &st); http://websvn.kde.org/branches/work/kdevelop4-parser/main.cpp?rev=420247&view=markup...
27
by: Aurangzeb M. Agha | last post by:
I'm running Postgres 7.1.3, and just started having a problem where my dynamic site is going down (read-only DB, with no writes happening to the DB) regularly (every other day). I have no idea...
188
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection -...
3
by: Harold A. Mackey | last post by:
I have a situation where a user must enter three int results into three textboxes, save that entry and enter another set. All sets have to be displayed in another box or grid, and when the collection...
6
by: W1ld0ne [MCSD] | last post by:
In vb 6 objects you could build a .Version method that returned the version of your object using the App.Major & "." & app.Minor & "." & App.Revision method. How do you do this in .Net? ...
6
by: Frank V. | last post by:
Hello, I'm new to VB.net, moving from VB6 to VB.net. My question is "In VB.net what is the equivalent of the App.major (and others) VB6 property. I, like a lot of people I imaging, display the...
1
by: theWizard1 | last post by:
Using Asp.NET 2.0. I published my web application to the server using the publish to website feature of asp.net 2.0. In VS.Net 2005 IDE, on solution explorer, at top level just below solution, I...
2
by: Birky | last post by:
Can someone point me in the right direction on how to use Version Numbers within Access? I have a database were its primary goal is to track the versions of several projects. Since the version...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.