Revision 83fe59dd

b/image_creator/bundle_volume.py
219 219
            image_disk.setPartitionGeometry(
220 220
                image_disk.getPartitionBySector(last.start),
221 221
                parted.Constraint(device=image_disk.device),
222
                start=last.start, end=last.end)
222
                start=last.start, end=part_end)
223 223
            image_disk.commit()
224 224

  
225 225
            # Parted may have changed this for better alignment
......
228 228
            partitions[-1] = last
229 229

  
230 230
            # Leave 2048 blocks at the end.
231
            new_end = new_size + 2048
231
            new_end = part_end + 2048
232 232

  
233 233
            if last.type == parted.PARTITION_LOGICAL:
234 234
                # Fix the extended partition
......
239 239
                    ext.geometry.start, end=last.end)
240 240
                image_disk.commit()
241 241

  
242
        image_dev.destroy()
242 243
        return new_end
243 244

  
244 245
    def _map_partition(self, dev, num, start, end):
......
417 418

  
418 419
        self._create_filesystems(image)
419 420

  
421
        # Truncate image to the new size. I counldn't find a better way to do
422
        # this. It seems that python's high level functions work in a different
423
        # way.
424
        fd = os.open(image, os.O_RDWR)
425
        try:
426
            os.ftruncate(fd, size)
427
        finally:
428
            os.close(fd)
429

  
420 430
        return image
421 431

  
422 432
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :

Also available in: Unified diff