def maj_min_to_blk(major, minor):
"""Returns the block device name to the major:minor numbers in the param.
:param major:
The major number of the device
:param minor:
The minor number of the device
:returns:
Block device name.
:rtype:
``str``
"""
maj_min = '{}:{}'.format(major, minor)
block_dev = None
for sys_path in glob.glob(os.path.join(os.sep, 'sys', 'class', 'block',
'*', 'dev')):
with io.open(sys_path) as f:
if f.read().strip() == maj_min:
block_dev = '/dev/{}'.format(sys_path.split(os.sep)[-2])
break
return block_dev
评论列表
文章目录