all Python 3Linux · macOSosfunction
os.makedev
os — device numbers
Compose a raw device id from major and minor numbers.
Syntax
os.makedev(...)
It is the inverse of major and minor: os.major(os.makedev(8, 1)) returns 8. It is needed to create a device file with os.mknod. The resulting number's layout is system-specific — pass it only to functions on the same system.
Examples
import os
dev = os.makedev(8, 1) # 8:1 — первый раздел первого SATA/SCSI-диска
print(dev) # → ? только Unix: упакованный идентификатор устройства; кодировка зависит от ядра (в Linux — 2049)
print(os.major(dev), os.minor(dev)) # → ? 8 1 — makedev и major/minor строго обратны друг другу
st = os.stat('/dev/null')
print(os.makedev(os.major(st.st_rdev), os.minor(st.st_rdev)) == st.st_rdev) # → True — разобрали и собрали настоящий st_rdev без потерь
print(os.makedev(0, 0)) # → 0 — нулевой идентификатор: ровно такой st_rdev у обычных файлов, у которых устройства нет
See also
Open in the full glossarydocs.python.orgReport an inaccuracy