diff options
author | Jeremy Katz <katzj@redhat.com> | 2003-11-09 00:09:23 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2003-11-09 00:09:23 +0000 |
commit | 051af548f6989519fb4eb2a363805dd931feb836 (patch) | |
tree | 7c30b08ff35c407fd1306fe07fc0d34218473d5c | |
parent | 8c7d35b6a2f28e049de3d6a88f23f66526b7ae7b (diff) | |
download | anaconda-051af548f6989519fb4eb2a363805dd931feb836.tar.gz anaconda-051af548f6989519fb4eb2a363805dd931feb836.tar.xz anaconda-051af548f6989519fb4eb2a363805dd931feb836.zip |
some more xfs/jfs bits based off of patch from
Ajay Ramaswamy <xfs@ramaswamy.net>. this adds support for xfs labels
and for sniffing jfs in a couple of places
-rw-r--r-- | fsset.py | 27 | ||||
-rw-r--r-- | isys/isys.py | 30 | ||||
-rw-r--r-- | partedUtils.py | 13 |
3 files changed, 62 insertions, 8 deletions
@@ -1346,7 +1346,7 @@ class FileSystemSet: if not entry.mountpoint or entry.mountpoint == "swap": continue try: - label = isys.readExt2Label(dev) + label = isys.readFSLabel(dev) except: continue if label: @@ -1655,7 +1655,7 @@ class Device: def getLabel(self): try: - return isys.readExt2Label(self.setupDevice(), makeDevNode = 0) + return isys.readFSLabel(self.setupDevice(), makeDevNode = 0) except: return "" @@ -2224,6 +2224,25 @@ def isValidReiserFS(device): os.close(fd) return 0 +def isValidJFS(device): + fd = getDevFD(device) + if fd == -1: + return 0 + + try: + os.lseek(fd, 32768, 0) + buf = os.read(fd, 128) + except: + buf = "" + + os.close(fd) + if len(buf) < 4: + return 0 + + if (buf[0:4] == "JFS1"): + return 1 + + return 0 # this will return a list of types of filesystems which device # looks like it could be to try mounting as @@ -2236,6 +2255,9 @@ def getFStoTry(device): if isValidReiserFS(device): rc.append("reiserfs") + if isValidJFS(device): + rc.append("jfs") + if isValidExt2(device): if os.access(device, os.O_RDONLY): create = 0 @@ -2247,7 +2269,6 @@ def getFStoTry(device): # FIXME: need to check for swap - # XXX check for, jfs signature, and others ? return rc def allocateLoopback(file): diff --git a/isys/isys.py b/isys/isys.py index e1adf8246..b10c5f7c7 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -473,6 +473,30 @@ def pumpNetDevice(device): # otherwise return _isys.pumpnetdevice(device) +def readXFSLabel_int(device): + try: + fd = os.open(device, os.O_RDONLY) + except: + return None + + buf = os.read(fd, 128) + os.close(fd) + + xfslabel = None + if len(buf) == 128 and buf[0:4] == "XFSB": + xfslabel = string.rstrip(buf[108:120],"\0x00") + + return xfslabel + +def readXFSLabel(device, makeDevNode = 1): + if makeDevNode: + makeDevInode(device, "/tmp/disk") + label = readXFSLabel_int("/tmp/disk") + os.unlink("/tmp/disk") + else: + label = readXFSLabel_int(device) + return label + def readExt2Label(device, makeDevNode = 1): if makeDevNode: makeDevInode(device, "/tmp/disk") @@ -482,6 +506,12 @@ def readExt2Label(device, makeDevNode = 1): label = _isys.e2fslabel(device) return label +def readFSLabel(device, makeDevNode = 1): + label = readExt2Label(device, makeDevNode) + if label is None: + label = readXFSLabel(device, makeDevNode) + return label + def ext2IsDirty(device): makeDevInode(device, "/tmp/disk") label = _isys.e2dirty("/tmp/disk"); diff --git a/partedUtils.py b/partedUtils.py index 8fc03b173..5fdb300a5 100644 --- a/partedUtils.py +++ b/partedUtils.py @@ -421,7 +421,10 @@ def sniffFilesystemType(device): if fsset.isValidReiserFS(dev): return "reiserfs" - # FIXME: we don't look for jfs, or vfat + if fsset.isValidJFS(dev): + return "jfs" + + # FIXME: we don't look for vfat return None @@ -529,17 +532,17 @@ class DiskSet: not (part.get_flag(parted.PARTITION_RAID) or part.get_flag(parted.PARTITION_LVM)) and part.fs_type - and (part.fs_type.name == "ext2" - or part.fs_type.name == "ext3")) + and (part.fs_type.name in ("ext2", + "ext3", "xfs"))) parts = filter_partitions(disk, func) for part in parts: node = get_partition_name(part) - label = isys.readExt2Label(node) + label = isys.readFSLabel(node) if label: labels[node] = label for dev, devices, level, numActive in DiskSet.mdList: - label = isys.readExt2Label(dev) + label = isys.readFSLabel(dev) if label: labels[dev] = label |