473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

using os.major

Does anyone understand what a 'raw device number' is with respect
os.major() and os.minor()

Found in os-file-dir.html, section 6.1.4, os.major() description is:

major(device)
Extracts a device major number from a raw device number. New in
version 2.3.

The problem is, after searching I can only find two references to 'raw
device number'. Naturally they are in 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).

Example:
--------------------------------
fd = open('/dev/fd0')
from os import major,minor
fd.fileno() 3 major(fd.fileno()) 0 minor(fd.fileno()) 3 from os import popen3 [instd,outstd,errstd] = popen3( 'file /dev/fd0' ) outstd.read()

'/dev/fd0: block special (2/0)\n'

As you can see, Major is 2, minor is 0. Which is also what ls -l /dev/fd0
reports.
--------------------------------

I've written a function to parse up the 'file /dev/fd0' results, but I'd
rather us the correct built in, or included modules, before writing my
own.

at******@yahoo.com
Jul 18 '05 #1
1 2491
John Doe <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.
Jul 18 '05 #2

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

Similar topics

3
by: Sandros | last post by:
Background: I'm collecting usability statistics for a group of applications. Each count has the following attributes: date, application, major heading, minor heading, count. My intent is to pull...
0
by: Oliver Elphick | last post by:
The attached proposal is written primarily for Debian. Its motivation is that the current package upgrade process is pretty flaky and also that the current packaging does not really provide for...
10
by: ibic | last post by:
Just curious: is it possible to recursively list all the directorys/files inside a given directory using standard c i/o library routines only, which can be re-compiled and run on any os supportes c...
6
by: archilleswaterland | last post by:
structures typedef struct{ char name; int age; float balance; }account; account xyx; accout *ptr;
2
by: Jef Driesen | last post by:
I'm working on a project where i need to exchange multidimensional data between C/C++ (row-major) and matlab (column-major). I understand the difference between those two mappings to linear memory....
133
by: Alan Silver | last post by:
Hello, Just wondered what range of browsers, versions and OSs people are using to test pages. Also, since I don't have access to a Mac, will I have problems not being able to test on any Mac...
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...
0
by: per9000 | last post by:
Hi all, we use CVS to manage versions of our code. Since the CVS keeps track of everything we need I want to synchronize the assembly info with CVS. The problem is that if I update the assembly...
3
by: Lax | last post by:
Isn't it "technically" meaningless to call C a "row major language," since there are no such things as multidimensional arrays in C. In C you can define arrays of arrays, and the way that the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.