[7.3] patch: instPath,fsset,diskset cleanup (PART 1)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I sent this message on Friday, but at ~57k, it exceeded the 40k limit for
posts to this list.  The moderators haven't contacted me in the meantime,
so I'm just sending it again - in two parts. 

This message (PART 1) will contain the summary and the first part of the patch
(up to ~30k), and the next message (PART2) will contain the second part of
the patch.  The two patches should be taken as a single patch, as they are
codependent (as they are, in fact, the same patch)

Here we go...


Greetings anaconda hackers.

My apologies in advance for a lengthy post.

I'm currently maintaining the installer for Mitel SMEServer (formally the
e-smith server and gateway), for which we use a customized version of anaconda.

Up until just recently, our installer was forked from the Red Hat 7.0
version of anaconda.  I've almost completed forward-porting all our
changes,  which by and large required complete rewrites (not necessarily a
bad thing).

Through this effort I've made a number of changes to anaconda that I hope
will be useful to the rest of you.  I think/hope they are appropriate to roll
into the core anaconda sources.

Included at the bottom of this message is a fairly large patch containing
various fixes, and I apologize for not splitting it up into smaller
patches.  I will however give a written summary of the patch for those who
are interested.

First, a short disclaimer :)

*** DISCLAIMER ***
- I have only used/tested these changes on an i386 platform, in text-only
  mode, using a CustomKickstart install method.  
- Where applicable, I updated the gui/iw files as well, but they have not
  been tested.  
- I just finished these changes this afternoon, so obviously, they have
  only undergone very limited testing (basic install/upgrade)
******************

So, here's a summary of the changes in this patch, and my motivations behind
making them:

1. Cleanup of (instPath/instRoot/chroot/rootPath/prefix) parameters.
    After plowing through the code for awhile, I quickly found that
    the instPath string (ie: '/mnt/sysimage') was passed around nearly
    everywhere.  I refactored the code (for my own sanity) so that it only
    really needs to be in three places:
    - passed into the InstData() constructor from anaconda, and stored as an
      attribute (id.instPath)
    - passed into the FileSystemSet() constructor from the InstClass
      constructor, and stored as an attribute (fsset.chroot)
    - passed into the FileSystemSetEntry() constructor from: 
      FileSystemSet.reset(), readFstab(), PartitionSpec.toEntry(),
      and stored as an attribute (entry.chroot)
    The fallout from this was that it cleaned up the code quite a bit,
    improving readability and object cohesion.  
    This change, of course, touched quite a few files.  There's more cleanup
    that could be done, but I'd had enough by this point :)

2. Move to a single instantiation of FileSystemSet and DiskSet.
    The id.fsset and id.diskset objects are passed around and used
    throughout the program, but there were several different places where
    they were instantiated.  I found this confusing, and so I refactored a
    little bit to allow for the initial instantiations to be reused
    throughout the program. This involved:
    - InstData.reset() passes instantiated fsset to DiskSet() constructor,
      where it is stored as an attribute (diskset.fsset)
    - moved fsset.readFstab() global function to FileSystemSet.readFstab()
      method
    - changed a few parameter lists in dispatch.installSteps

3. Fix for inaccurate FileSystemSet.isActive() method.
    The fsset object was keeping track of it's own mountcount, but
    each of the FileSystemSetEntry objects in fsset.entries were keeping
    track of there own mountcount.  Well, the fsset object never actually
    decremented it's mountcount.  Anyway, it turned out that the only thing
    that uses the fsset.mountcount attribute was the fsset.isActive()
    method, so I changed it to count from the entry objects instead.
    
    NOTE:  the swapFileSystem class raises a RuntimeError if you try to
    unmount it, since apparently: 
    	# unfortunately, turning off swap is bad
    I'll take your word for it. However, I just wanted to point out that
    this should do the right thing now, since the mountcount will not get
    decremented for the swap entry, and thus the fsset.isActive() method
    will return 1 if a swap partition has been mounted.  
    BTW, I needed this to essentially back out of an upgrade and into an
    install - more on that below.

4. Don't turn on swap in upgrade.upgradeMountFilesystems() global function.
    This is related to #3 above.  Essentially, I wanted to mount all the
    partitions except for any swap partitions, so that I could autodetect
    an upgradable system, and cleanup afterwards.
    If the system isn't upgradable, I can now just change id.instClass to an
    install class, and then do: 
        fsset.unmountFilesystems()
	diskset.stopAllRaid()
	diskset.savePartitions()
    Then I go on my merry way with an install.  The swap is turned on
    later during the addswap step anyway. 


Ok, that's a pretty complete summary.  I wish I could say that the changes
went in as cleanly as the summary indicates :)


Without further ado, here's the patch.  Let me know what you think.

cheers, 

Tony Clayton


anaconda-7.3-7.patch.instPath_fsset_diskset_cleanup:
----------------------------------------------------
diff -u anaconda/anaconda:1.1.1.1 anaconda/anaconda:1.1.1.1.2.1
--- anaconda/anaconda:1.1.1.1	Thu Aug 22 17:21:27 2002
+++ anaconda/anaconda	Fri Sep 13 20:29:07 2002
@@ -584,7 +584,8 @@
 
 floppyDevice = floppy.probeFloppyDevice()
 
-id = instClass.installDataClass(extraModules, floppyDevice, configFileData)
+id = instClass.installDataClass(extraModules, floppyDevice, configFileData,
+                                rootPath)
 #id = instClass.installDataClass(extraModules, floppyDevice)
 
 if mousehw:
@@ -601,7 +602,7 @@
     
 instClass.setInstallData(id)
 
-dispatch = dispatch.Dispatcher(intf, id, method, rootPath)
+dispatch = dispatch.Dispatcher(intf, id, method)
 
 if lang:
     dispatch.skipStep("language", permanent = 1)
diff -u anaconda/bootloader.py:1.1.1.1 anaconda/bootloader.py:1.1.1.1.2.1
--- anaconda/bootloader.py:1.1.1.1	Thu Aug 22 17:21:27 2002
+++ anaconda/bootloader.py	Fri Sep 13 20:29:08 2002
@@ -161,9 +161,10 @@
     def setDevice(self, device):
         self.device = device
 
-    def getBootloaderConfig(self, instRoot, fsset, bl, langs, kernelList,
+    def getBootloaderConfig(self, fsset, bl, langs, kernelList,
                             chainList, defaultDev):
 	images = bl.images.getImages()
+	instRoot = fsset.chroot
 
         # on upgrade read in the lilo config file
 	lilo = LiloConfigFile ()
@@ -842,7 +843,8 @@
         bl.above1024 = 1
     
 
-def writeBootloader(intf, instRoot, fsset, bl, langs, comps):
+def writeBootloader(intf, fsset, bl, langs, comps):
+    instRoot = fsset.chroot
     justConfigFile = not flags.setupFilesystems
 
     if bl.defaultDevice == -1:
diff -u anaconda/dispatch.py:1.1.1.1 anaconda/dispatch.py:1.1.1.1.2.1
--- anaconda/dispatch.py:1.1.1.1	Thu Aug 22 17:21:27 2002
+++ anaconda/dispatch.py	Fri Sep 13 20:29:08 2002
@@ -53,8 +53,8 @@
     ("reconfigwelcome", ()),
     ("reconfigkeyboard", ("id.instLanguage", "id.keyboard", "id.xconfig")),
     ("installtype", ("dispatch", "id", "method", "intf")),
-    ("findrootparts", findRootParts, ("intf", "id", "dir", "instPath")),
-    ("findinstall", ("dispatch", "intf", "id", "instPath")),
+    ("findrootparts", findRootParts, ("intf", "id", "dir")),
+    ("findinstall", ("dispatch", "intf", "id")),
     ("partitionmethod", ("id.partitions", "id.instClass")),
     ("partitionobjinit", partitionObjectsInitialize, ("id.diskset",
                                                       "id.partitions",
@@ -67,16 +67,14 @@
                                                "id.instClass", "dispatch")),
     ("fdisk", ("id.diskset", "id.partitions", "intf")),
     ("partition", ("id.fsset", "id.diskset", "id.partitions", "intf")),
-    ("upgrademount", upgradeMountFilesystems, ("intf", "id.upgradeRoot",
-                                               "id.fsset", "instPath")),
+    ("upgrademount", upgradeMountFilesystems, ("intf", "id.diskset", 
+                                               "id.upgradeRoot", "id.fsset")),
     ("upgradecontinue", queryUpgradeContinue, ("intf", "dir")),
-    ("upgradeswapsuggestion", upgradeSwapSuggestion, ("dispatch", "id",
-                                                      "instPath")),
-    ("addswap", ("intf", "id.fsset", "instPath",
-                 "id.upgradeSwapInfo", "dispatch")),
+    ("upgradeswapsuggestion", upgradeSwapSuggestion, ("dispatch", "id")),
+    ("addswap", ("intf", "id.fsset", "id.upgradeSwapInfo", "dispatch")),
     ("partitiondone", partitioningComplete, ("id.bootloader", "id.fsset",
                                              "id.diskset", "id.partitions",
-                                             "intf", "instPath", "dir")),
+                                             "intf", "dir")),
     ("upgrademigfind", upgradeMigrateFind, ("dispatch", "id.fsset")),
     ("upgrademigratefs",  ("id.fsset",)),
     ("upgbootloader", ("dispatch", "id.bootloader")),
@@ -93,42 +91,36 @@
     ("accounts", ("id.rootPassword", "id.accounts")),
     ("authentication", ("id.auth",)),
     ("readcomps", readPackages, ("intf", "method", "id")),
-    ("findpackages", upgradeFindPackages, ("intf", "method", "id",
-                                           "instPath", "dir")),
+    ("findpackages", upgradeFindPackages, ("intf", "method", "id", "dir")),
     ("package-selection", ("id.comps", "dispatch")),
     ("indivpackage", ("id.comps", "id.hdList")),
-    ("handleX11pkgs", handleX11Packages, ("dir", "intf", "dispatch",
-                                          "id", "instPath")),
-    ("checkdeps", checkDependencies, ("dir", "intf", "dispatch",
-                                      "id", "instPath")),
+    ("handleX11pkgs", handleX11Packages, ("dir", "intf", "dispatch", "id")),
+    ("checkdeps", checkDependencies, ("dir", "intf", "dispatch", "id")),
     ("dependencies", ("id.comps", "id.dependencies")),
     ("videocard", ("dispatch", "id.xconfig", "id.videocard", "intf")),
     ("confirminstall", ()),
     ("confirmupgrade", ()),
     ("install", ("dir", "intf", "id")),
     ("enablefilesystems", turnOnFilesystems, ("dir", "id.fsset",
-                                              "id.diskset", "id.upgrade",
-                                              "instPath")),
+                                              "id.diskset", "id.upgrade")),
     ("migratefilesystems", doMigrateFilesystems, ("dir", "id.fsset",
-                                              "id.diskset", "id.upgrade",
-                                              "instPath")),
-    ("preinstallconfig", doPreInstall, ("method", "id", "intf", "instPath",
-                                        "dir")),
-    ("installpackages", doInstall, ("method", "id", "intf", "instPath")),
-    ("postinstallconfig", doPostInstall, ("method", "id", "intf", "instPath")),
-    ("writeconfig", writeConfiguration, ("id", "instPath")),
-    ("instbootloader", writeBootloader, ("intf", "instPath", "id.fsset", 
+                                              "id.diskset", "id.upgrade")),
+    ("preinstallconfig", doPreInstall, ("method", "id", "intf", "dir")),
+    ("installpackages", doInstall, ("method", "id", "intf")),
+    ("postinstallconfig", doPostInstall, ("method", "id", "intf")),
+    ("writeconfig", writeConfiguration, ("id",)),
+    ("instbootloader", writeBootloader, ("intf", "id.fsset", 
                                          "id.bootloader", "id.langSupport",
                                          "id.comps")),
     ("bootdisk", ("dir", "dispatch", "id.fsset")),
     ("makebootdisk", makeBootdisk, ("intf", "id.floppyDevice",
-                                    "id.hdList", "instPath", "id.bootloader")),
+                                    "id.hdList", "id.instPath", "id.bootloader")),
     ("monitor", ("id.xconfig", "id.monitor")),
     ("xcustom", ("id.xconfig", "id.monitor", "id.videocard",
                  "id.desktop", "id.comps")),
-    ("writexconfig", writeXConfiguration, ("id", "instPath")),
-    ("writeksconfig", writeKSConfiguration, ("id", "instPath")),
-    ("dopostaction", doPostAction, ("id", "instPath")),
+    ("writexconfig", writeXConfiguration, ("id",)),
+    ("writeksconfig", writeKSConfiguration, ("id",)),
+    ("dopostaction", doPostAction, ("id",)),
     ("complete", ()),
     ("reconfigcomplete", ())
     ]
@@ -251,7 +243,7 @@
 
 	return (step, args)
 
-    def __init__(self, intf, id, method, instPath):
+    def __init__(self, intf, id, method):
 	self.dir = DISPATCH_FORWARD
 	self.step = None
 	self.skipSteps = {}
@@ -261,5 +253,4 @@
 	self.intf = intf
 	self.method = method
 	self.dispatch = self
-	self.instPath = instPath
 	self.firstStep = 0
diff -u anaconda/fsset.py:1.1.1.1 anaconda/fsset.py:1.1.1.1.4.1
--- anaconda/fsset.py:1.1.1.1	Thu Aug 22 17:21:27 2002
+++ anaconda/fsset.py	Fri Sep 13 20:29:08 2002
@@ -667,16 +667,19 @@
 fileSystemTypeRegister(AutoFileSystem())
 
 class FileSystemSet:
-    def __init__(self):
+    def __init__(self, chroot = '/'):
+	self.chroot = chroot
         self.messageWindow = None
         self.progressWindow = None
         self.waitWindow = None
-        self.mountcount = 0
         self.migratedfs = 0
         self.reset()
 
     def isActive(self):
-        return self.mountcount != 0
+	mountcount = 0
+        for entry in self.entries:
+            mountcount = mountcount + entry.mountcount
+        return mountcount != 0
         
     def registerMessageWindow(self, method):
         self.messageWindow = method
@@ -689,12 +692,16 @@
 
     def reset (self):
         self.entries = []
-        proc = FileSystemSetEntry(Device(), '/proc', fileSystemTypeGet("proc"))
+        proc = FileSystemSetEntry(Device(), '/proc', fileSystemTypeGet("proc"),
+	                          chroot = self.chroot)
         self.add(proc)
         pts = FileSystemSetEntry(Device(), '/dev/pts',
-                                 fileSystemTypeGet("devpts"), "gid=5,mode=620")
+                                 fileSystemTypeGet("devpts"), "gid=5,mode=620",
+				 chroot = self.chroot)
         self.add(pts)
-        shm = FileSystemSetEntry(Device(), '/dev/shm', fileSystemTypeGet("tmpfs"))
+        shm = FileSystemSetEntry(Device(), '/dev/shm', 
+	                         fileSystemTypeGet("tmpfs"), 
+				 chroot = self.chroot)
 
     def verify (self):
         for entry in self.entries:
@@ -732,7 +739,7 @@
         return None
 
     def copy (self):
-        new = FileSystemSet()
+        new = FileSystemSet(chroot=self.chroot)
         for entry in self.entries:
             new.add (entry)
         return new
@@ -780,35 +787,35 @@
 
         return raidtab
 
-    def write (self, prefix):
-        f = open (prefix + "/etc/fstab", "w")
+    def write (self):
+        f = open (self.chroot + "/etc/fstab", "w")
         f.write (self.fstab())
         f.close ()
 
         raidtab = self.raidtab()
 
         if raidtab:
-            f = open (prefix + "/etc/raidtab", "w")
+            f = open (self.chroot + "/etc/raidtab", "w")
             f.write (raidtab)
             f.close ()
 
         # touch mtab
-        open (prefix + "/etc/mtab", "w+")
+        open (self.chroot + "/etc/mtab", "w+")
         f.close ()
 
-    def restoreMigratedFstab(self, prefix):
+    def restoreMigratedFstab(self):
         if not self.migratedfs:
             return
 
-        fname = prefix + "/etc/fstab"
+        fname = self.chroot + "/etc/fstab"
         if os.access(fname + ".rpmsave", os.R_OK):
             os.rename(fname + ".rpmsave", fname)
 
-    def migratewrite(self, prefix):
+    def migratewrite(self):
         if not self.migratedfs:
             return
         
-        fname = prefix + "/etc/fstab"
+        fname = self.chroot + "/etc/fstab"
         f = open (fname, "r")
         lines = f.readlines()
         f.close()
@@ -934,13 +941,13 @@
             if bootPart:
                 del bootPart
 
-    def formatSwap (self, chroot):
+    def formatSwap (self):
         for entry in self.entries:
             if (not entry.fsystem or not entry.fsystem.getName() == "swap"
                 or not entry.getFormat() or entry.isMounted()):
                 continue
             try:
-                self.formatEntry(entry, chroot)
+                self.formatEntry(entry)
             except SystemError:
                 if self.messageWindow:
                     self.messageWindow(_("Error"),
@@ -953,13 +960,12 @@
                 sys.exit(0)
                     
                 
-    def turnOnSwap (self, chroot):
+    def turnOnSwap (self):
         for entry in self.entries:
             if (entry.fsystem and entry.fsystem.getName() == "swap"
                 and not entry.isMounted()):
                 try:
-                    entry.mount(chroot)
-                    self.mountcount = self.mountcount + 1
+                    entry.mount()
                 except SystemError, (num, msg):
                     if self.messageWindow:
                         self.messageWindow(_("Error"), 
@@ -974,14 +980,14 @@
                                            % (entry.device.getDevice(), msg))
                     sys.exit(0)
 
-    def labelEntry(self, entry, chroot):
-        entry.fsystem.labelDevice(entry, chroot)
+    def labelEntry(self, entry):
+        entry.fsystem.labelDevice(entry, self.chroot)
     
-    def formatEntry(self, entry, chroot):
-        entry.fsystem.formatDevice(entry, self.progressWindow, chroot)
+    def formatEntry(self, entry):
+        entry.fsystem.formatDevice(entry, self.progressWindow, self.chroot)
 
-    def badblocksEntry(self, entry, chroot):
-        entry.fsystem.badblocksDevice(entry, self.progressWindow, chroot)
+    def badblocksEntry(self, entry):
+        entry.fsystem.badblocksDevice(entry, self.progressWindow, self.chroot)
         
     def getMigratableEntries(self):
         retval = []
@@ -998,13 +1004,13 @@
                 list.append (entry)
         return list
 
-    def checkBadblocks(self, chroot='/'):
+    def checkBadblocks(self):
         for entry in self.entries:
             if (not entry.fsystem.isFormattable() or not entry.getBadblocks()
                 or entry.isMounted()):
                 continue
             try:
-                self.badblocksEntry(entry, chroot)
+                self.badblocksEntry(entry)
             except SystemError:
                 if self.messageWindow:
                     self.messageWindow(_("Error"),
@@ -1016,7 +1022,7 @@
                                        % (entry.device.getDevice(),))
                 sys.exit(0)
 
-    def makeFilesystems (self, chroot='/'):
+    def makeFilesystems (self):
         formatted = []
         notformatted = []
         for entry in self.entries:
@@ -1025,7 +1031,7 @@
                 notformatted.append(entry)
                 continue
             try:
-                self.formatEntry(entry, chroot)
+                self.formatEntry(entry)
                 formatted.append(entry)
             except SystemError:
                 if self.messageWindow:
@@ -1040,7 +1046,7 @@
 
         for entry in formatted:
             try:
-                self.labelEntry(entry, chroot)
+                self.labelEntry(entry)
             except SystemError:
                 # should be OK, we'll still use the device name to mount.
                 pass
@@ -1056,12 +1062,12 @@
             if label:
                 entry.setLabel(label)
             else:
-                self.labelEntry(entry, chroot)
+                self.labelEntry(entry)
 
     def haveMigratedFilesystems(self):
         return self.migratedfs
 
-    def migrateFilesystems (self, chroot='/'):
+    def migrateFilesystems (self):
         if self.migratedfs:
             return
         
@@ -1073,7 +1079,7 @@
                 continue
             try: 
                 entry.origfsystem.migrateFileSystem(entry, self.messageWindow,
-                                                    chroot)
+                                                    self.chroot)
             except SystemError:
                 if self.messageWindow:
                     self.messageWindow(_("Error"),
@@ -1087,13 +1093,12 @@
 
         self.migratedfs = 1
 
-    def mountFilesystems(self, instPath = '/', raiseErrors = 0, readOnly = 0):
+    def mountFilesystems(self, raiseErrors = 0, readOnly = 0):
 	for entry in self.entries:
             if not entry.fsystem.isMountable():
 		continue
             try:
-                entry.mount(instPath, readOnly = readOnly)
-                self.mountcount = self.mountcount + 1
+                entry.mount(readOnly = readOnly)
             except OSError, (num, msg):
                 if self.messageWindow:
                     if num == errno.EEXIST:
@@ -1130,13 +1135,13 @@
                                           entry.mountpoint, msg))
                 sys.exit(0)
 
-    def filesystemSpace(self, chroot='/'):
+    def filesystemSpace(self):
 	space = []
         # XXX limit to ext[23] etc?
         for entry in self.entries:
             if not entry.isMounted():
                 continue
-            path = "%s/%s" % (chroot, entry.mountpoint)
+            path = "%s/%s" % (self.chroot, entry.mountpoint)
             try:
                 space.append((entry.mountpoint, isys.fsSpaceAvailable(path)))
             except SystemError:
@@ -1175,10 +1180,10 @@
 
 	return 0
 
-    def umountFilesystems(self, instPath, ignoreErrors = 0):
+    def umountFilesystems(self, ignoreErrors = 0):
         # XXX remove special case
         try:
-            isys.umount(instPath + '/proc/bus/usb', removeDir = 0)
+            isys.umount(self.chroot + '/proc/bus/usb', removeDir = 0)
             log("Umount USB OK")
         except:
 #           log("Umount USB Fail")
@@ -1188,16 +1193,119 @@
         reverse.reverse()
 
 	for entry in reverse:
-            entry.umount(instPath)
+            entry.umount()
+
+    # XXX fix RAID
+    def readFstab (self, path, diskset):
+	# first, we look at all the disks on the systems and get any ext2/3
+	# labels off of the filesystem.
+	# temporary, to get the labels
+	diskset.openDevices()
+	labels = diskset.getLabels()
+
+	labelToDevice = {}
+	for device, label in labels.items():
+	    labelToDevice[label] = device
+
+	# mark these labels found on the system as used so the factory
+	# doesn't give them to another device
+	labelFactory.reserveLabels(labels)
+	
+	loopIndex = {}
+
+	f = open (path, "r")
+	lines = f.readlines ()
+	f.close()
+
+	for line in lines:
+	    fields = string.split (line)
+
+	    if not fields: continue
+
+	    # pick up the magic comment in fstab that tells us which
+	    # device is the loop host in a partionless upgrade
+	    if fields[0] == "#" and len(fields) > 4 and fields[1][:4] == "LOOP":
+		device = string.lower(fields[1])
+		if device[len(device) - 1] == ":":
+		    device = device[:len(device) - 1]
+		realDevice = fields[2]
+		if realDevice[:5] == "/dev/":
+		    realDevice = realDevice[5:]
+		loopIndex[device] = (realDevice, fields[3])
+
+	    if line[0] == "#":
+		# skip all comments
+		continue
+
+	    # all valid fstab entries have 6 fields; if the last two are missing
+	    # they are assumed to be zero per fstab(5)
+	    if len(fields) < 4:
+		continue
+	    elif len(fields) == 4:
+		fields.append(0)
+		fields.append(0)
+	    elif len(fields) == 5:
+		fields.append(0)
+	    elif len(fields) > 6:
+		continue
+
+	    # if we don't support mounting the filesystem, continue
+	    if not fileSystemTypes.has_key(fields[2]):
+		continue
+	    if string.find(fields[3], "noauto") != -1: continue
+
+	    fsystem = fileSystemTypeGet(fields[2])
+	    label = None
+
+
+	    if fields[0] == "none":
+		device = Device()
+	    elif len(fields) >= 6 and fields[0][:6] == "LABEL=":
+		label = fields[0][6:]
+		if labelToDevice.has_key(label):
+		    device = makeDevice(labelToDevice[label])
+		else:
+		    log ("Warning: fstab file has LABEL=%s, but this label "
+			 "could not be found on any filesystem", label)
+		    # bad luck, skip this entry.
+		    continue
+	    elif (fields[2] == "swap" and fields[0][:5] != "/dev/"):
+		# swap files
+		file = fields[0]
+
+		if file[:15] == "/initrd/loopfs/":
+		    file = file[14:]
+		    device = PiggybackSwapFileDevice("/mnt/loophost", file)
+		else:
+		    device = SwapFileDevice(file)
+	    elif fields[0][:9] == "/dev/loop":
+		# look up this loop device in the index to find the
+		# partition that houses the filesystem image
+		# XXX currently we assume /dev/loop1
+		if loopIndex.has_key(device):
+		    (dev, fs) = loopIndex[device]
+		    device = LoopbackDevice(dev, fs)
+	    elif fields[0][:5] == "/dev/":
+		device = makeDevice(fields[0][5:])
+	    else:
+		continue
+	    
+	    entry = FileSystemSetEntry(device, fields[1], fsystem, fields[3],
+				       origfsystem=fsystem, chroot=self.chroot)
+	    if label:
+		entry.setLabel(label)
+	    self.add(entry)
+
 
 class FileSystemSetEntry:
     def __init__ (self, device, mountpoint,
                   fsystem=None, options=None,
                   origfsystem=None, migrate=0,
                   order=-1, fsck=-1, format=0,
-                  badblocks = 0):
+                  badblocks = 0, chroot = '/'):
         if not fsystem:
             fsystem = fileSystemTypeGet("ext2")
+	self.chroot = chroot
         self.device = device
         self.mountpoint = mountpoint
         self.fsystem = fsystem
@@ -1229,22 +1337,22 @@
         self.format = format
         self.badblocks = badblocks
 
-    def mount(self, chroot='/', devPrefix='/tmp', readOnly = 0):
-        device = self.device.setupDevice(chroot, devPrefix=devPrefix)
+    def mount(self, devPrefix='/tmp', readOnly = 0):
+        device = self.device.setupDevice(self.chroot, devPrefix=devPrefix)
         # FIXME: we really should migrate before turnOnFilesystems.
         # but it's too late now
         if (self.migrate == 1) and (self.origfsystem is not None):
-            self.origfsystem.mount(device, "%s/%s" % (chroot, self.mountpoint),
+            self.origfsystem.mount(device, "%s/%s" % (self.chroot, self.mountpoint),
                                    readOnly = readOnly)
         else:
-            self.fsystem.mount(device, "%s/%s" % (chroot, self.mountpoint),
+            self.fsystem.mount(device, "%s/%s" % (self.chroot, self.mountpoint),
                                readOnly = readOnly)
         self.mountcount = self.mountcount + 1
 
-    def umount(self, chroot='/'):
+    def umount(self):
         if self.mountcount > 0:
             try:
-                self.fsystem.umount(self.device, "%s/%s" % (chroot,
+                self.fsystem.umount(self.device, "%s/%s" % (self.chroot,
                                                             self.mountpoint))
                 self.mountcount = self.mountcount - 1
             except RuntimeError:
@@ -1522,111 +1630,6 @@
         device = PartitionDevice(dev)
     return device
 
-# XXX fix RAID
-def readFstab (path):
-    fsset = FileSystemSet()
-
-    # first, we look at all the disks on the systems and get any ext2/3
-    # labels off of the filesystem.
-    # temporary, to get the labels
-    diskset = partitioning.DiskSet()
-    diskset.openDevices()
-    labels = diskset.getLabels()
-
-    labelToDevice = {}
-    for device, label in labels.items():
-	labelToDevice[label] = device
-
-    # mark these labels found on the system as used so the factory
-    # doesn't give them to another device
-    labelFactory.reserveLabels(labels)
-    
-    loopIndex = {}
-
-    f = open (path, "r")
-    lines = f.readlines ()
-    f.close()
-
-    for line in lines:
-	fields = string.split (line)
-
-	if not fields: continue
-
-        # pick up the magic comment in fstab that tells us which
-        # device is the loop host in a partionless upgrade
-	if fields[0] == "#" and len(fields) > 4 and fields[1][:4] == "LOOP":
-	    device = string.lower(fields[1])
-	    if device[len(device) - 1] == ":":
-		device = device[:len(device) - 1]
-	    realDevice = fields[2]
-	    if realDevice[:5] == "/dev/":
-		realDevice = realDevice[5:]
-	    loopIndex[device] = (realDevice, fields[3])
-
-	if line[0] == "#":
-	    # skip all comments
-	    continue
-
-	# all valid fstab entries have 6 fields; if the last two are missing
-        # they are assumed to be zero per fstab(5)
-        if len(fields) < 4:
-            continue
-        elif len(fields) == 4:
-            fields.append(0)
-            fields.append(0)
-        elif len(fields) == 5:
-            fields.append(0)
-        elif len(fields) > 6:
-            continue
-
-        # if we don't support mounting the filesystem, continue
-        if not fileSystemTypes.has_key(fields[2]):
-	    continue
-	if string.find(fields[3], "noauto") != -1: continue
-
-        fsystem = fileSystemTypeGet(fields[2])
-        label = None
-
-
-	if fields[0] == "none":
-            device = Device()
-        elif len(fields) >= 6 and fields[0][:6] == "LABEL=":
-            label = fields[0][6:]
-            if labelToDevice.has_key(label):
-                device = makeDevice(labelToDevice[label])
-            else:
-                log ("Warning: fstab file has LABEL=%s, but this label "
-                     "could not be found on any filesystem", label)
-                # bad luck, skip this entry.
-                continue
-	elif (fields[2] == "swap" and fields[0][:5] != "/dev/"):
-	    # swap files
-	    file = fields[0]
-
-	    if file[:15] == "/initrd/loopfs/":
-		file = file[14:]
-                device = PiggybackSwapFileDevice("/mnt/loophost", file)
-            else:
-                device = SwapFileDevice(file)
-        elif fields[0][:9] == "/dev/loop":
-	    # look up this loop device in the index to find the
-            # partition that houses the filesystem image
-            # XXX currently we assume /dev/loop1
-	    if loopIndex.has_key(device):
-		(dev, fs) = loopIndex[device]
-                device = LoopbackDevice(dev, fs)
-	elif fields[0][:5] == "/dev/":
-            device = makeDevice(fields[0][5:])
-	else:
-            continue
-        
-        entry = FileSystemSetEntry(device, fields[1], fsystem, fields[3],
-                                   origfsystem=fsystem)
-        if label:
-            entry.setLabel(label)
-        fsset.add(entry)
-    return fsset
-
 def isValidExt2(device):
     file = '/tmp/' + device
     isys.makeDevInode(device, file)
@@ -1793,7 +1796,9 @@
 if __name__ == "__main__":
     log.open("foo")
     
-    fsset = readFstab("fstab")
+    diskset = partitioning.DiskSet()
+    fsset = FileSystemSet()
+    fsset.readFstab("fstab", diskset)
 
     print fsset.fstab()
     print fsset.rootOnLoop()
diff -u anaconda/harddrive.py:1.1.1.1 anaconda/harddrive.py:1.1.1.1.2.1
--- anaconda/harddrive.py:1.1.1.1	Thu Aug 22 17:21:27 2002
+++ anaconda/harddrive.py	Fri Sep 13 20:29:08 2002
@@ -72,7 +72,7 @@
 	# since we read headers from the disk, we don't need to do this
 	pass
 
-    def systemMounted(self, fsset, chroot, selected):
+    def systemMounted(self, fsset, selected):
 	self.mountMedia()
 	    
     def filesDone(self):
@@ -181,7 +181,7 @@
 	hdlist.mergeFullHeaders(self.tree + "/RedHat/base/hdlist2")
 	self.umountMedia()
 
-    def systemMounted(self, fsset, mntPoint, selected):
+    def systemMounted(self, fsset, selected):
 	self.mountMedia(1)
 	    
     def systemUnmounted(self):
diff -u anaconda/image.py:1.1.1.1 anaconda/image.py:1.1.1.1.2.1
--- anaconda/image.py:1.1.1.1	Thu Aug 22 17:21:27 2002
+++ anaconda/image.py	Fri Sep 13 20:29:08 2002
@@ -41,7 +41,7 @@
 			"%s/RedHat/base/stage2.img" % self.tree)
 	    self.loopbackFile = None
 
-    def systemMounted(self, fsset, chroot, selected):
+    def systemMounted(self, fsset, selected):
 	changeloop=0
 	for p in selected:
 	    if p[1000002] and p[1000002] > 1:
@@ -50,8 +50,8 @@
 	if changeloop == 0:
 	    return
 
-	self.loopbackFile = "%s%s%s" % (chroot,
-                                        fsset.filesystemSpace(chroot)[0][0],
+	self.loopbackFile = "%s%s%s" % (fsset.chroot,
+                                        fsset.filesystemSpace()[0][0],
                                         "/rhinstall-stage2.img")
 
 	try:
diff -u anaconda/installmethod.py:1.1.1.1 anaconda/installmethod.py:1.1.1.1.4.1
--- anaconda/installmethod.py:1.1.1.1	Thu Aug 22 17:21:27 2002
+++ anaconda/installmethod.py	Fri Sep 13 20:29:09 2002
@@ -35,7 +35,7 @@
     def systemUnmounted(self):
 	pass
 
-    def systemMounted(self, fstab, mntPoint, selected):
+    def systemMounted(self, fsset, selected):
 	pass
 
     def filesDone(self):
diff -u anaconda/instdata.py:1.1.1.1 anaconda/instdata.py:1.1.1.1.4.1
--- anaconda/instdata.py:1.1.1.1	Thu Aug 22 17:21:28 2002
+++ anaconda/instdata.py	Fri Sep 13 20:29:09 2002
@@ -63,7 +63,7 @@
 	self.upgrade = Boolean()
         # XXX move fsset and/or diskset into Partitions object?
 	self.fsset.reset()
-        self.diskset = partitioning.DiskSet()
+        self.diskset = partitioning.DiskSet(self.fsset)
         self.partitions = partitioning.Partitions()
         self.bootloader = bootloader.getBootloader()
         self.dependencies = []
@@ -93,16 +93,16 @@
     def setXconfig(self, xconfig):
         self.xconfig = xconfig
 
-    def write(self, instPath):
-        self.langSupport.write (instPath) 
-	self.mouse.write(instPath)
-        self.keyboard.write (instPath)
-        self.network.write (instPath)
-        self.timezone.write (instPath)
-        self.auth.write (instPath)
-	self.firewall.write (instPath)
-        self.rootPassword.write (instPath, self.auth)
-        self.accounts.write (instPath, self.auth)
+    def write(self):
+        self.langSupport.write (self.instPath) 
+	self.mouse.write(self.instPath)
+        self.keyboard.write (self.instPath)
+        self.network.write (self.instPath)
+        self.timezone.write (self.instPath)
+        self.auth.write (self.instPath)
+	self.firewall.write (self.instPath)
+        self.rootPassword.write (self.instPath, self.auth)
+        self.accounts.write (self.instPath, self.auth)
 
     def writeKS(self, filename):
         # make it so only root can read, could have password
@@ -152,7 +152,8 @@
 	f.write("\n%post\n")
 	self.accounts.writeKScommands(f, self.auth)
 
-    def __init__(self, extraModules, floppyDevice, configFileData):
+    def __init__(self, extraModules, floppyDevice, configFileData, instPath):
+	self.instPath = instPath
 	self.instLanguage = language.InstallTimeLanguage()
 	self.keyboard = kbd.Keyboard()
         self.tmpData = configFileData
@@ -164,6 +165,6 @@
         self.xconfig = None
 	self.extraModules = extraModules
 	self.floppyDevice = floppyDevice
-	self.fsset = fsset.FileSystemSet()
+	self.fsset = fsset.FileSystemSet(chroot=self.instPath)
         
 	self.reset()





[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux