X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FComponents%2FHarddisk.py;fp=lib%2Fpython%2FComponents%2FHarddisk.py;h=9b3a684c4f60f0c8c2ed2444add581ff04954f13;hp=0e73dee7d3d9f94324cbbb59f7ac602ed3066541;hb=1d557af556c71a9c658deea9cec783a66903c136;hpb=07aa6cf57eae72224a32f6ef3f83b299f49977cf diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 0e73dee..9b3a684 100755 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -58,6 +58,56 @@ def enableUdevEvent(enable = True): print "CMD : ", cmd system(cmd) +def findMountPoint(path): + 'Example: findMountPoint("/media/hdd/some/file") returns "/media/hdd"' + path = os.path.abspath(path) + while not os.path.ismount(path): + path = os.path.dirname(path) + return path + +def getDeviceFile(dev_path): + for parts in getProcMounts(): + if os.path.realpath(parts[1]).startswith(dev_path): + return parts[0] + +def getMountPath(mountPath): + mountPath = os.path.realpath(mountPath) + while not os.path.ismount(mountPath): + mountPath = os.path.dirname(mountPath) + + return mountPath + +def getDeviceInterface(mountPath): + mountPath = getMountPath(mountPath) + + if mountPath == '/': + return None + + from Components.Harddisk import getDeviceFile + dev = getDeviceFile(mountPath) + + if dev and dev.startswith("/dev/sd"): + dev = os.path.basename(dev) + phyPath = os.path.realpath('/sys/block/' + dev[:3]) + + # check usb + for x in glob.glob("/sys/bus/usb/devices/usb*"): + if phyPath.find(os.path.realpath(x)) != -1: + from Tools.HardwareInfo import HardwareInfo + if (HardwareInfo().get_vu_device_name() == "zero4k") and (phyPath.find("f0b00500.ehci_v2/usb2/2-1") != -1): + return "ata" + else: + return "usb" + + # check ata + if phyPath.find("/ata") != -1: + return "ata" + + return None + +def isUsbStorage(dirname): + return getDeviceInterface(dirname) in (None, "usb") + DEVTYPE_UDEV = 0 DEVTYPE_DEVFS = 1