Revision 94d0a699

b/snf-image-helper/disklabel.py
448 448
    def get_last_partition_id(self):
449 449
        raise NotImplementedError
450 450

  
451
    def lba2chs(self, lba, hpc=None, spt=None):
452
        """Return the CHS address for a given LBA address"""
453

  
454
        # NetBSD uses LBA-Assisted translation. The sectors per track (spt)
455
        # value is always 63 and the heads per cylinder (hpc) value depends on
456
        # the size of the disk
457

  
458
        disk_size = self.field['secperunit']
459

  
460
        # Maximum disk size that can be addressed is 1024 * HPC* SPT
461
        spt = 63
462
        for hpc in 16, 32, 64, 128, 255:
463
            if disk_size <= 1024 * hpc * spt:
464
                break
465

  
466
        chs = super(BSDDisklabel, self).lba2chs(lba, hpc, spt)
467

  
468
        if chs[0] > 1023:  # Cylinders overflowed
469
            assert hpc == 255  # Cylinders may overflow only for large disks
470
            return (1023, chs[1], chs[2])
471

  
472
        return chs
473

  
451 474
    def __str__(self):
452 475
        """Print the Disklabel"""
453 476

  

Also available in: Unified diff