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)
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))
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())
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())