You are here : python_2ososmakedev

os.makedev() - os


The method makedev() composes a raw device number from the major and minor device numbers.

  • major -- This is Major device number.

  • minor -- This is Minor device number.


os.makedev(major, minor)



import os, sys

path = "/var/www/html/foo.txt"

# Now get  the touple
info = os.lstat(path)

# Get major and minor device number
major_dnum = os.major(info.st_dev)
minor_dnum = os.minor(info.st_dev)

print "Major Device Number :", major_dnum
print "Minor Device Number :", minor_dnum

# Make a device number
dev_num = os.makedev(major_dnum, minor_dnum)
print "Device Number :", dev_num

Output / Return Value

When we run above program, it produces following result:

Major Device Number : 0 Minor Device Number : 103 Device Number : 103


Alternatives / See Also