fs.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:treadmill 作者: Morgan-Stanley 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号