示例#1
0
文件: block.py 项目: sukidoke/drgn
def disk_devt(disk):
    """
    .. c:function:: dev_t disk_devt(struct gendisk *disk)

    Get a disk's device number.
    """
    return MKDEV(disk.major, disk.first_minor)
示例#2
0
文件: block.py 项目: osandov/drgn
def disk_devt(disk: Object) -> Object:
    """
    Get a disk's device number.

    :param disk: ``struct gendisk *``
    :return: ``dev_t``
    """
    return Object(disk.prog_, "dev_t", MKDEV(disk.major, disk.first_minor))
示例#3
0
 def test_loop_part(self):
     if not self.loop:
         self.skipTest("could not create loop device")
     rdev = os.stat(self.loop.fileno()).st_rdev
     devt = MKDEV(os.major(rdev), os.minor(rdev))
     for part in for_each_partition(self.prog):
         if part_devt(part) == devt:
             break
     else:
         self.fail("loop partition not found")
     self.assertEqual(part_name(part), os.path.basename(self.loop.name).encode())
示例#4
0
 def test_loop_disk(self):
     if not self.loop:
         self.skipTest("could not create loop device")
     rdev = os.stat(self.loop.fileno()).st_rdev
     devt = MKDEV(os.major(rdev), os.minor(rdev))
     for disk in for_each_disk(self.prog):
         if disk_devt(disk) == devt:
             break
     else:
         self.fail("loop disk not found")
     self.assertEqual(disk_name(disk), os.path.basename(self.loop.name).encode())