"""
path = util.create_sparse_file("disk", TEST_DISK_SIZE)
+ # Connect to a loop device
+ loop_device = self._losetup(path)
+
# Open the file with parted
- device = parted.Device(path)
+ device = parted.Device(loop_device)
# Create a Disk object
disk = Disk(self.bricklayer, device)
self.disks.append(disk)
+ def _losetup(self, path):
+ # Find a free loop device
+ device = self.bricklayer.command(["losetup", "-f"])
+
+ device = device.rstrip()
+
+ # Connect the image to the loop device
+ self.bricklayer.command(["losetup", device, path])
+
+ # Return the name of the loop device
+ return device
+
@property
def supported(self):
"""