all Python 3Linux · macOSosfunction
os.minor
os — device numbers
Extract the minor device number from a raw device id.
Syntax
os.minor(...)
The minor number tells apart devices of one driver: for SCSI disks on Linux it encodes the disk and partition. Use it with major, and rebuild the number with makedev. Manual bit operations give wrong results on another system.
Examples
import os
info = os.stat('/dev/null')
print(os.minor(info.st_rdev)) # → ? только Unix: младший номер устройства /dev/null, обычно 3
print(os.major(info.st_rdev)) # → ? только Unix: старший номер того же устройства, обычно 1
print(os.minor(os.makedev(8, 1))) # → 1 — makedev собирает номер из (major, minor), minor разбирает обратно
print(os.minor(os.stat('/tmp').st_rdev)) # → 0 — у обычного файла или каталога st_rdev нулевой, minor осмыслен лишь для файлов устройств
See also
Open in the full glossarydocs.python.orgReport an inaccuracy