Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 91761 | Differences between
and this patch

Collapse All | Expand All

(-)GLIStorageDevice.py (-21 / +6 lines)
Lines 1-4 Link Here
1
import commands, string, os, parted
1
import commands, string, os, parted
2
from GLIException import *
2
3
3
MEGABYTE = 1024 * 1024
4
MEGABYTE = 1024 * 1024
4
5
Lines 387-399 Link Here
387
		print self._total_bytes, self._geometry
388
		print self._total_bytes, self._geometry
388
389
389
	##
390
	##
390
	# Utility function for raising an exception
391
	# @param message Error message
392
	def _error(self, message):
393
		"Raises an exception"
394
		raise GLIException("DeviceObjectError", 'fatal', 'Device', message)
395
		
396
	##
397
	# Utility function for running a command and returning it's output as a list
391
	# Utility function for running a command and returning it's output as a list
398
	# @param cmd Command to run
392
	# @param cmd Command to run
399
	def _run(self, cmd):
393
	def _run(self, cmd):
Lines 698-709 Link Here
698
			self._device._partitions[free_minor]._mb = mb - self._mb
692
			self._device._partitions[free_minor]._mb = mb - self._mb
699
			self._mb = mb
693
			self._mb = mb
700
694
701
	##
702
	# Utility function to raise an exception
703
	# @param message Error message
704
	def _error(self, message):
705
		raise GLIException("PartitionObjectError", 'fatal', 'Partition', message)
706
707
##
695
##
708
# Returns a list of detected partitionable devices
696
# Returns a list of detected partitionable devices
709
def detect_devices():
697
def detect_devices():
Lines 711-726 Link Here
711
	
699
	
712
	# Make sure sysfs exists
700
	# Make sure sysfs exists
713
	if not os.path.exists("/sys/bus"):
701
	if not os.path.exists("/sys/bus"):
714
		raise Exception, "no sysfs found (you MUST use a kernel >2.6)"
702
		raise GLIException("GLIStorageDeviceError", 'fatal', 'detect_devices', "no sysfs found (you MUST use a kernel >2.6)")
715
	# Make sure /proc/partitions exists
703
	# Make sure /proc/partitions exists
716
	if not os.path.exists("/proc/partitions"):
704
	if not os.path.exists("/proc/partitions"):
717
		raise Exception, "/proc/partitions does not exist!"
705
		raise GLIException("GLIStorageDeviceError", 'fatal', 'detect_devices', "/proc/partitions does not exist! Please make sure procfs is in your kernel and mounted!")
718
	
706
	
719
	# Load /proc/partitions into the variable 'partitions'
707
	# Load /proc/partitions into the variable 'partitions'
720
	partitions = []
708
	partitions = []
721
	for line in open("/proc/partitions"):
709
	for line in open("/proc/partitions"):
722
		if len(line.split()) < 4 or not line.split()[0].isdigit() or \
710
		if len(line.split()) < 4 or not line.split()[0].isdigit() or not line.split()[1].isdigit():
723
						not line.split()[1].isdigit():
724
			continue
711
			continue
725
		
712
		
726
		# Get the major, minor and device name
713
		# Get the major, minor and device name
Lines 763-770 Link Here
763
			
750
			
764
			# For each device in the devices on that bus
751
			# For each device in the devices on that bus
765
			for sysfs_device in sysfs_devices:
752
			for sysfs_device in sysfs_devices:
766
				dev_file = "/sys/bus/" + dev_type + "/devices/"\
753
				dev_file = "/sys/bus/" + dev_type + "/devices/" + sysfs_device + "/block/dev"
767
						+ sysfs_device + "/block/dev"
768
						
754
						
769
				# If the file is not a block device, loop
755
				# If the file is not a block device, loop
770
				if not os.path.exists(dev_file):
756
				if not os.path.exists(dev_file):
Lines 776-783 Link Here
776
					major = int(major)
762
					major = int(major)
777
					minor = int(minor)
763
					minor = int(minor)
778
				except:
764
				except:
779
					raise Exception, "invalid major minor in "\
765
					raise GLIException("GLIStorageDeviceError", 'fatal', 'detect_devices', "invalid major minor in " + dev_file)
780
								+ dev_file
781
			
766
			
782
				# Find a device listed in /proc/partitions
767
				# Find a device listed in /proc/partitions
783
				# that has the same minor and major as our
768
				# that has the same minor and major as our

Return to bug 91761