bootstrap-vz/common/fs/__init__.py
Anders Ingemann ff7c04c120 Support for partitions
MAJOR refactor. The volume is now abstracted into a model along with a partitionmap and partitions.
Volumes and partitions are now controlled via an FSM to ensure that commands are called in the proper sequence.
GRUB can now be installed properly onto loop devices by using dmsetup to fake a proper harddisk.
2013-10-27 18:11:12 +01:00

11 lines
382 B
Python

def get_major_minor_dev_num(device_name):
import re
regexp = re.compile('^ *(?P<major>\d+) *(?P<minor>\d+) *(?P<num_blks>\d+) {device_name}$'
.format(device_name=device_name))
with open('/proc/partitions') as partitions:
for line in partitions:
match = regexp.match(line)
if match is not None:
return match.group('major'), match.group('minor')