diff options
author | Artem Bityutskiy <artem.bityutskiy@intel.com> | 2013-04-11 15:01:07 +0300 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@intel.com> | 2013-04-19 16:27:40 +0300 |
commit | 6b2bcd1959cc2de86a559a9815b32364b814f27c (patch) | |
tree | 5e4781291858cc6dfb67743e941c987c410f7db2 | |
parent | e90442d06c2103d97a3abde909e762125075301c (diff) | |
download | mic-6b2bcd1959cc2de86a559a9815b32364b814f27c.tar.gz mic-6b2bcd1959cc2de86a559a9815b32364b814f27c.tar.bz2 mic-6b2bcd1959cc2de86a559a9815b32364b814f27c.zip |
partitinedfs.py: implement the --part-type option
Implement the --part-type option for GPT partitions. In case of MBR partitions
- just error out and say that the option is not implemented, but if someone
needs it for the MBR case in the future - it may be implemented.
Change-Id: I7f45db71df85bd36850d1379a38a84fe73532de6
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
-rw-r--r-- | mic/imager/raw.py | 3 | ||||
-rw-r--r-- | mic/utils/partitionedfs.py | 25 |
2 files changed, 23 insertions, 5 deletions
diff --git a/mic/imager/raw.py b/mic/imager/raw.py index 474a76f..19efe0d 100644 --- a/mic/imager/raw.py +++ b/mic/imager/raw.py @@ -193,7 +193,8 @@ class RawImageCreator(BaseImageCreator): p.label, fsopts = p.fsopts, boot = p.active, - align = p.align) + align = p.align, + part_type = p.part_type) self.__instloop.layout_partitions(self._ptable_format) diff --git a/mic/utils/partitionedfs.py b/mic/utils/partitionedfs.py index 03999c5..226e4d9 100644 --- a/mic/utils/partitionedfs.py +++ b/mic/utils/partitionedfs.py @@ -94,7 +94,8 @@ class PartitionedMount(Mount): self.__add_disk(part['disk_name']) def add_partition(self, size, disk_name, mountpoint, fstype = None, - label=None, fsopts = None, boot = False, align = None): + label=None, fsopts = None, boot = False, align = None, + part_type = None): """ Add the next partition. Prtitions have to be added in the first-to-last order. """ @@ -146,6 +147,7 @@ class PartitionedMount(Mount): 'num': None, # Partition number 'boot': boot, # Bootable flag 'align': align, # Partition alignment + 'part_type' : part_type, # Partition type 'partuuid': None } # Partition UUID (GPT-only) self.__add_partition(part) @@ -174,6 +176,13 @@ class PartitionedMount(Mount): raise MountError("No disk %s for partition %s" \ % (p['disk_name'], p['mountpoint'])) + if p['part_type'] and ptable_format != 'gpt': + # The --part-type can also be implemented for MBR partitions, + # in which case it would map to the 1-byte "partition type" + # filed at offset 3 of the partition entry. + raise MountError("setting custom partition type is only " \ + "imlemented for GPT partitions") + # Get the disk where the partition is located d = self.disks[p['disk_name']] d['numpart'] += 1 @@ -339,7 +348,8 @@ class PartitionedMount(Mount): "%d" % p['num'], flag_name, "on"]) # If the partition table format is "gpt", find out PARTUUIDs for all - # the partitions + # the partitions. And if users specified custom parition type UUIDs, + # set them. for disk_name, disk in self.disks.items(): if disk['ptable_format'] != 'gpt': continue @@ -353,11 +363,18 @@ class PartitionedMount(Mount): for n in d['partitions']: p = self.partitions[n] if p['num'] == pnum: - # Found, assign PARTUUID + # Found, fetch PARTUUID (partition's unique ID) p['partuuid'] = entry['part_uuid'] - msger.debug("PARTUUID for partition %d of disk '%s' " \ + msger.debug("PARTUUID for partition %d on disk '%s' " \ "(mount point '%s') is '%s'" % (pnum, \ disk_name, p['mountpoint'], p['partuuid'])) + if p['part_type']: + entry['type_uuid'] = p['part_type'] + msger.debug("Change type of partition %d on disk " \ + "'%s' (mount point '%s') to '%s'" % \ + (pnum, disk_name, p['mountpoint'], + p['part_type'])) + gpt_parser.change_partition(entry) del gpt_parser |