#!/usr/bin/env python
+#
# -*- coding: utf-8 -*-
#
# Copyright (C) 2013 GRNET S.A.
"""Print the Partition table"""
val = ""
for i in range(len(self.part)):
- val = "%s%s\n" % (val, str(self.part[i]))
+ val += "%c: %s\n" % (chr(ord('a') + i), str(self.part[i]))
return val
def pack(self):
self.bbsize,
self.sbsize,
self.ptable.pack() +
- ((364 - self.npartitions*16) * '\x00'))
+ ((364 - self.npartitions * 16) * '\x00'))
def compute_checksum(self):
"""Compute the checksum of the disklabel"""
"Magic Number: 0x%x\n" % self.magic + \
"Drive type: %d\n" % self.dtype + \
"Subtype: %d\n" % self.subtype + \
- "Typename: %s\n" % self.typename + \
- "Pack Identifier: %s\n" % self.packname + \
+ "Typename: %s\n" % self.typename.strip('\x00').strip() + \
+ "Pack Identifier: %s\n" % self.packname.strip('\x00').strip() + \
"Number of bytes per sector: %d\n" % self.secsize + \
"Number of data sectors per track: %d\n" % self.nsectors + \
"Number of tracks per cylinder: %d\n" % self.ntracks + \
parser.add_option("-l", "--list", action="store_true", dest="list",
default=False,
help="list the disklabel on the specified media")
- parser.add_option("--print-last", action="store_true", dest="last_part",
- default=False,
+ parser.add_option("--get-last-partition", action="store_true",
+ dest="last_part", default=False,
help="print the label of the last partition")
- parser.add_option("--print-last-linux", action="store_true",
- dest="last_linux", default=False,
- help="print the linux number for the last partition")
- parser.add_option("--print-duid", action="store_true", dest="duid",
+ parser.add_option("--get-duid", action="store_true", dest="duid",
default=False,
help="print the disklabel unique identifier")
parser.add_option("-d", "--enlarge-disk", type="int", dest="disk_size",
if options.last_part:
print "%c" % chr(ord('a') + disklabel.get_last_partition_id())
- if options.last_linux:
- part_id = disklabel.get_last_partition_id()
- # The linux kernel does not assign a partition for label 'c' that
- # describes the whole disk
- print part_id + (4 if part_id > 2 else 5)
-
if options.disk_size is not None:
disklabel.enlarge_disk(options.disk_size)