summaryrefslogtreecommitdiffstats
path: root/fsset.py
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2007-12-03 12:59:39 -0500
committerJeremy Katz <katzj@redhat.com>2007-12-03 15:47:51 -0500
commitd6b03ab77abcf68c9dbb9f0c674c7dbf3548b786 (patch)
treef8d4b6f19989bc235780789eba6c3368e828a1c4 /fsset.py
parentacd7e206ae041101203d1bb0011a37f735bdbf04 (diff)
downloadanaconda-d6b03ab77abcf68c9dbb9f0c674c7dbf3548b786.tar.gz
anaconda-d6b03ab77abcf68c9dbb9f0c674c7dbf3548b786.tar.xz
anaconda-d6b03ab77abcf68c9dbb9f0c674c7dbf3548b786.zip
Use libblkid instead of custom filesystem probing
This patch gets rid of all of our custom filesystem type and label probing and switches it all over to using a simple binding to libblkid instead.
Diffstat (limited to 'fsset.py')
-rw-r--r--fsset.py127
1 files changed, 2 insertions, 125 deletions
diff --git a/fsset.py b/fsset.py
index 5dee46f32..518aa344d 100644
--- a/fsset.py
+++ b/fsset.py
@@ -1164,7 +1164,8 @@ class AutoFileSystem(PsudoFileSystem):
ret = isys.resetFileContext(mountpoint, instroot)
log.info("set SELinux context for mountpoint %s to %s" %(mountpoint, ret))
- for fs in getFStoTry (device):
+ fs = isys.readFSType(device)
+ if fs is not None:
try:
isys.mount (device, mountpoint, fstype = fs, readOnly =
readOnly, bindMount = bindMount)
@@ -1172,7 +1173,6 @@ class AutoFileSystem(PsudoFileSystem):
except SystemError, (num, msg):
errNum = num
errMsg = msg
- continue
raise SystemError (errNum, errMsg)
@@ -2756,129 +2756,6 @@ def readFstab (anaconda):
fsset.add(entry)
return fsset
-def getDevFD(device):
- try:
- fd = os.open(device, os.O_RDONLY)
- except:
- try:
- file = isys.makeDevInode(device)
- fd = os.open(file, os.O_RDONLY)
- except:
- return -1
- return fd
-
-def isValidExt2(device):
- fd = getDevFD(device)
- if fd == -1:
- return 0
-
- buf = os.read(fd, 2048)
- os.close(fd)
-
- if len(buf) != 2048:
- return 0
-
- if struct.unpack("<H", buf[1080:1082]) == (0xef53,):
- return 1
-
- return 0
-
-def isValidXFS(device):
- fd = getDevFD(device)
- if fd == -1:
- return 0
-
- buf = os.read(fd, 4)
- os.close(fd)
-
- if len(buf) != 4:
- return 0
-
- if buf == "XFSB":
- return 1
-
- return 0
-
-def isValidReiserFS(device):
- fd = getDevFD(device)
- if fd == -1:
- return 0
-
- '''
- ** reiserfs 3.5.x super block begins at offset 8K
- ** reiserfs 3.6.x super block begins at offset 64K
- All versions have a magic value of "ReIsEr" at
- offset 0x34 from start of super block
- '''
- reiserMagicVal = "ReIsEr"
- reiserMagicOffset = 0x34
- reiserSBStart = [64*1024, 8*1024]
- bufSize = 0x40 # just large enough to include the magic value
- for SBOffset in reiserSBStart:
- try:
- os.lseek(fd, SBOffset, 0)
- buf = os.read(fd, bufSize)
- except:
- buf = ""
-
- if len(buf) < bufSize:
- continue
-
- if (buf[reiserMagicOffset:reiserMagicOffset+len(reiserMagicVal)] ==
- reiserMagicVal):
- os.close(fd)
- return 1
-
- 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
-def getFStoTry(device):
- rc = []
-
- if isValidXFS(device):
- rc.append("xfs")
-
- if isValidReiserFS(device):
- rc.append("reiserfs")
-
- if isValidJFS(device):
- rc.append("jfs")
-
- if isValidExt2(device):
- if os.access(device, os.O_RDONLY):
- create = 0
- else:
- create = 1
- if isys.ext2HasJournal(device, makeDevNode = create):
- rc.append("ext3")
- rc.append("ext2")
-
- # FIXME: need to check for swap
-
- return rc
-
def allocateLoopback(file):
found = 1
for i in range(8):