osd.py 文件源码

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

项目:python-ceph-cfg 作者: oms4suse 项目源码 文件源码
def is_partition(self, dev):
        """
        Check whether a given device path is a partition or a full disk.
        """
        if not os.path.exists(dev):
            raise Error('device not found', dev)

        dev = os.path.realpath(dev)
        if not stat.S_ISBLK(os.lstat(dev).st_mode):
            raise Error('not a block device', dev)

        name = self._get_dev_name(dev)
        if os.path.exists(os.path.join('/sys/block', name)):
            return False

        # make sure it is a partition of something else
        for basename in os.listdir('/sys/block'):
            if os.path.exists(os.path.join('/sys/block', basename, name)):
                return True
        raise Error('not a disk or partition', dev)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号