os.major()
in Python is used to extract the major device number from the specified raw device number (usually the value of the st_dev attribute or st_rdev of the object & # 39; os.stat_result & # 39; returned by os.stat () ). ,
In Linux everything is file-based, some are regular files and some — special files. Special files can be found in the / dev directory. These special files are called device files. Character and block devices are the most common type of device file. These device files are represented by the Linux kernel as a pair of numbers (major device number and minor device number).
The major device number indicates which driver is used to access the hardware. Each driver on the system has a unique major number, and all device files with the same major device number are controlled by the same driver.
Whereas the sub device number is used by the driver to distinguish between the different hardware it controls. The minor device number tells the kernel the special characteristics of the device being accessed.
Syntax: os.major (device)
Parameter:
device : An integer value representing the raw device numberReturn Type: This method returns an integer value which represents the device major number.
Code: using the os method .major () to extract the major device number from the raw device number.
|
Output:
Raw device number: 2056 Device major number: 8