def readFSType(device): if not os.path.exists(device): device = "/dev/%s" % device fstype = _isys.getblkid(device, "TYPE") if fstype is None: # FIXME: libblkid doesn't show physical volumes as having a filesystem # so let's sniff for that.(#409321) try: fd = os.open(device, os.O_RDONLY) buf = os.read(fd, 2048) except: return fstype finally: try: os.close(fd) except: pass if buf.startswith("HM"): return "physical volume (LVM)" for sec in range(0, 4): off = (sec * 512) + 24 if len(buf) < off: continue if buf[off:].startswith("LVM2"): return "physical volume (LVM)" elif fstype == "lvm2pv": return "physical volume (LVM)" return fstype
def readFSLabel(device): if not os.path.exists(device): device = "/dev/%s" % device label = _isys.getblkid(device, "LABEL") return label
def readFSUuid(device): if not os.path.exists(device): device = "/dev/%s" % device label = _isys.getblkid(device, "UUID") return label