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

[PATCH 10/15] Handle the new udev world; don't try and make devices. Adjust calls as necessary.



---
 anaconda          |   12 ------
 dmraid.py         |    6 +--
 fsset.py          |   32 +++--------------
 image.py          |    2 -
 installmethod.py  |    2 +-
 isys/dasd.c       |    1 -
 isys/eddsupport.c |    7 +---
 isys/isys.py      |  100 ++++++++++++-----------------------------------------
 partedUtils.py    |   27 ++++++--------
 partitions.py     |    7 +---
 raid.py           |    3 +-
 11 files changed, 46 insertions(+), 153 deletions(-)

diff --git a/anaconda b/anaconda
index 79a619a..4bbdfc5 100755
--- a/anaconda
+++ b/anaconda
@@ -667,9 +667,6 @@ if __name__ == "__main__":
 
         import rescue, instdata
 
-        iutil.makeDriveDeviceNodes()
-        iutil.makeCharDeviceNodes()
-
         anaconda.id = instdata.InstallData(anaconda, [], anaconda.methodstr, opts.display_mode)
         rescue.runRescue(anaconda, instClass)
 
@@ -730,11 +727,6 @@ if __name__ == "__main__":
 
     checkMemory(opts)
 
-    # create character device nodes if we're not running in test mode - have
-    # to do this early sine it's used for Synaptics, etc.
-    if not flags.test:
-        iutil.makeCharDeviceNodes()
-
     # this lets install classes force text mode instlls
     if instClass.forceTextMode:
         stdoutLog.info(_("Install class forcing text mode installation"))
@@ -841,10 +833,6 @@ if __name__ == "__main__":
         else:
             anaconda.intf.messageWindow("Unknown monitor", msg)
 
-    # create device nodes for detected devices if we're not running in test mode
-    if not flags.test and flags.setupFilesystems:
-        iutil.makeDriveDeviceNodes()
-
     # imports after setting up the path
     if anaconda.methodstr:
         anaconda.setMethod(instClass)
diff --git a/dmraid.py b/dmraid.py
index 82f5f8e..95cc6b2 100644
--- a/dmraid.py
+++ b/dmraid.py
@@ -122,8 +122,7 @@ def scanForRaid(drives, degradedOk=False):
 
     probeDrives = []
     for d in drives:
-        dp = isys.makeDevInode(d)
-        probeDrives.append(dp)
+        probeDrives.append(d)
     
     dmsets = []
     def nonDegraded(rs):
@@ -237,8 +236,7 @@ def scanForMPath(drives):
 
     probeDrives = []
     for d in drives:
-        dp = isys.makeDevInode(d)
-        probeDrives.append(dp)
+        probeDrives.append(d)
 
     import block as _block
     oldPath = _block.getBdevidPath()
diff --git a/fsset.py b/fsset.py
index 5dee46f..ec03c97 100644
--- a/fsset.py
+++ b/fsset.py
@@ -552,8 +552,6 @@ class extFileSystem(FileSystemType):
     def getMinimumSize(self, device):
         """Return the minimum filesystem size in megabytes"""
         devicePath = "/dev/%s" % (device,)
-        if not os.path.exists(devicePath):
-            isys.makeDevInode(device, devicePath)
 
         # FIXME: it'd be nice if we didn't have to parse this out ourselves
         buf = iutil.execWithCapture("dumpe2fs",
@@ -634,7 +632,7 @@ class extFileSystem(FileSystemType):
         devicePath = entry.device.setupDevice(chroot)
 
         # if no journal, don't turn off the fsck
-        if not isys.ext2HasJournal(devicePath, makeDevNode = 0):
+        if not isys.ext2HasJournal(devicePath):
             return
 
         rc = iutil.execWithRedirect("tune2fs",
@@ -661,7 +659,7 @@ class ext2FileSystem(extFileSystem):
                                  "than ext3")
 
         # if journal already exists skip
-        if isys.ext2HasJournal(devicePath, makeDevNode = 0):
+        if isys.ext2HasJournal(devicePath):
             log.info("Skipping migration of %s, has a journal already.\n" % devicePath)
             return
 
@@ -676,7 +674,7 @@ class ext2FileSystem(extFileSystem):
         # XXX this should never happen, but appears to have done
         # so several times based on reports in bugzilla.
         # At least we can avoid leaving them with a system which won't boot
-        if not isys.ext2HasJournal(devicePath, makeDevNode = 0):
+        if not isys.ext2HasJournal(devicePath):
             log.warning("Migration of %s attempted but no journal exists after "
                         "running tune2fs.\n" % (devicePath))
             if message:
@@ -965,8 +963,6 @@ class NTFSFileSystem(FileSystemType):
     def getMinimumSize(self, device):
         """Return the minimum filesystem size in megabytes"""
         devicePath = "/dev/%s" % (device,)
-        if not os.path.exists(devicePath):
-            isys.makeDevInode(device, devicePath)
 
         buf = iutil.execWithCapture("ntfsresize", ["--info", devicePath],
                                     stderr = "/dev/tty5")
@@ -1420,8 +1416,6 @@ MAILADDR root
     def mkDevRoot(self, instPath):
         root = self.getEntryByMountPoint("/")
         dev = "%s/dev/%s" % (instPath, root.device.getDevice())
-        if not os.path.exists(dev):
-            isys.makeDevInode(root.device.getDevice(), dev)        
         rdev = os.stat(dev).st_rdev
 
         if not os.path.exists("%s/dev/root" %(instPath,)):
@@ -2202,7 +2196,7 @@ class Device:
 
     def getLabel(self):
         try:
-            return isys.readFSLabel(self.setupDevice(), makeDevNode = 0)
+            return isys.readFSLabel(self.setupDevice())
         except:
             return ""
 
@@ -2232,7 +2226,6 @@ class DevDevice(Device):
     def setupDevice(self, chroot='/', devPrefix='/dev'):
         #We use precreated device but we have to make sure that the device exists
         path = '/dev/%s' % (self.getDevice(),)
-        isys.makeDevInode(self.getDevice(), path)
         return path
 
 class RAIDDevice(Device):
@@ -2353,9 +2346,6 @@ class RAIDDevice(Device):
         def devify(x):
             return "/dev/%s" %(x,)
 
-        node = "%s/%s" % (devPrefix, self.device)
-        isys.makeDevInode(self.device, node)
-
         if not self.isSetup:
             for device in self.members:
                 pd = PartitionDevice(device)
@@ -2500,7 +2490,6 @@ class PartitionDevice(Device):
 
     def setupDevice(self, chroot="/", devPrefix='/dev'):
         path = '%s/%s' % (devPrefix, self.device)
-        isys.makeDevInode(self.device, path)
         if self.crypto:
             self.crypto.formatDevice()
             self.crypto.openDevice()
@@ -2584,7 +2573,6 @@ class LoopbackDevice(Device):
             path = '%s/%s' % (devPrefix, self.getDevice())
         else:
             path = '%s/%s' % (devPrefix, self.getDevice())
-            isys.makeDevInode(self.getDevice(), path)
         path = os.path.normpath(path)
         return path
 
@@ -2760,11 +2748,7 @@ 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 -1
     return fd
 
 def isValidExt2(device):
@@ -2867,11 +2851,7 @@ def getFStoTry(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):
+        if isys.ext2HasJournal(device):
             rc.append("ext3")
         rc.append("ext2")
 
diff --git a/image.py b/image.py
index 5cfaa54..4089ba1 100644
--- a/image.py
+++ b/image.py
@@ -269,8 +269,6 @@ class CdromInstallMethod(ImageInstallMethod):
                         needed in discNum):
                         done = 1
                         self.currentMedia = discNum
-                        # make /tmp/cdrom again so cd gets ejected
-                        isys.makeDevInode(self.device, "/tmp/cdrom")
 
                 if not done:
                     self.messageWindow(_("Wrong Disc"),
diff --git a/installmethod.py b/installmethod.py
index 368b018..914fdc9 100644
--- a/installmethod.py
+++ b/installmethod.py
@@ -86,7 +86,7 @@ def doMethodComplete(anaconda):
     anaconda.method.filesDone()
 
     if not anaconda.isKickstart:
-        isys.ejectCdrom(anaconda.method.device, makeDevice=1)
+        isys.ejectCdrom(anaconda.method.device)
 
     mtab = "/dev/root / ext3 ro 0 0\n"
     for ent in anaconda.id.fsset.entries:
diff --git a/isys/dasd.c b/isys/dasd.c
index a32d031..74a679e 100644
--- a/isys/dasd.c
+++ b/isys/dasd.c
@@ -58,7 +58,6 @@ int isUsableDasd(char *device) {
     memset(&dasd_info, 0, sizeof(dasd_info));
     strcpy(devname, "/dev/");
     strcat(devname, device);
-    devMakeInode(device, devname);
 
     if ((f = open(devname, O_RDONLY)) == -1)
         return 0;
diff --git a/isys/eddsupport.c b/isys/eddsupport.c
index 230bf06..7d3698b 100644
--- a/isys/eddsupport.c
+++ b/isys/eddsupport.c
@@ -103,11 +103,7 @@ static struct device ** createDiskList(){
 static int readDiskSig(char *device, uint32_t *disksig) {
     int fd, rc;
 
-    if (devMakeInode(device, "/tmp/biosdev")){
-        return -1;
-    }
-
-    fd = open("/tmp/biosdev", O_RDONLY);
+    fd = open(device, O_RDONLY);
     if (fd < 0) {
 #ifdef STANDALONE 
         fprintf(stderr, "Error opening device %s: %s\n ", device, 
@@ -138,7 +134,6 @@ static int readDiskSig(char *device, uint32_t *disksig) {
     }
 
     close(fd);
-    unlink("/tmp/biosdev");
     return 0;
 }
 
diff --git a/isys/isys.py b/isys/isys.py
index c36febf..663bc1b 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -150,7 +150,6 @@ def raidstop(mdDevice):
 
     devInode = "/dev/%s" % mdDevice
 
-    makeDevInode(mdDevice, devInode)
     try:
         _stopRaid(devInode)
     except:
@@ -177,9 +176,6 @@ def raidstart(mdDevice, aMember):
     mdInode = "/dev/%s" % mdDevice
     mbrInode = "/dev/%s" % aMember
 
-    makeDevInode(mdDevice, mdInode)
-    makeDevInode(aMember, mbrInode)
-
     minor = os.minor(os.stat(mdInode).st_rdev)
     try:
         info = _getRaidInfo(mbrInode)
@@ -209,7 +205,6 @@ def wipeRaidSB(device):
 #        need to exist to begin with.
 # @return A RAID superblock in its raw on-disk format.
 def raidsb(mdDevice):
-    makeDevInode(mdDevice, "/dev/%s" % mdDevice)
     return raidsbFromDevice("/dev/%s" % mdDevice)
 
 ## Get the superblock from a RAID device.
@@ -311,14 +306,6 @@ def mount(device, location, fstype = "ext2", readOnly = 0, bindMount = 0, remoun
     # mount without making a device node.  If that still fails, the caller
     # will have to deal with the exception.
     # We note whether or not we created a node so we can clean up later.
-    createdNode = 0
-    if device and device != "none" and device[0] != "/":
-	
-	try:
-	    makeDevInode (device)
-	    createdNode = 1
-	except SystemError:
-	    pass
 
     if mountCount.has_key(location) and mountCount[location] > 0:
 	mountCount[location] = mountCount[location] + 1
@@ -330,10 +317,6 @@ def mount(device, location, fstype = "ext2", readOnly = 0, bindMount = 0, remoun
     if not rc:
 	mountCount[location] = 1
 
-    # did we create a node, if so remove
-    if createdNode:
-	os.unlink(device)
-
     return rc
 
 ## Unmount a filesystem, similar to the umount system call.
@@ -768,13 +751,8 @@ def _readXFSLabel_int(device):
 
     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)
+def readXFSLabel(device):
+    label = _readXFSLabel_int(device)
     return label
 
 def _readJFSLabel_int(device):
@@ -801,13 +779,8 @@ def _readJFSLabel_int(device):
 
     return jfslabel
 
-def readJFSLabel(device, makeDevNode = 1):
-    if makeDevNode:
-        makeDevInode(device, "/tmp/disk")
-	label = _readJFSLabel_int("/tmp/disk")
-	os.unlink("/tmp/disk")
-    else:
-        label = _readJFSLabel_int(device)
+def readJFSLabel(device):
+    label = _readJFSLabel_int(device)
     return label
 
 def _readSwapLabel_int(device):
@@ -833,22 +806,12 @@ def _readSwapLabel_int(device):
         label = string.rstrip(buf[1052:1068], "\0x00")
     return label
 
-def readSwapLabel(device, makeDevNode = 1):
-    if makeDevNode:
-        makeDevInode(device, "/tmp/disk")
-        label = _readSwapLabel_int("/tmp/disk")
-        os.unlink("/tmp/disk")
-    else:
-        label = _readSwapLabel_int(device)
+def readSwapLabel(device):
+    label = _readSwapLabel_int(device)
     return label
 
-def readExt2Label(device, makeDevNode = 1):
-    if makeDevNode:
-        makeDevInode(device, "/tmp/disk")
-        label = _isys.e2fslabel("/tmp/disk");
-        os.unlink("/tmp/disk")
-    else:
-        label = _isys.e2fslabel(device)
+def readExt2Label(device):
+    label = _isys.e2fslabel(device)
     return label
 
 def _readReiserFSLabel_int(device):
@@ -895,51 +858,35 @@ def _readReiserFSLabel_int(device):
     os.close(fd)
     return label
 
-def readReiserFSLabel(device, makeDevNode = 1):
-    if makeDevNode:
-        makeDevInode(device, "/tmp/disk")
-	label = _readReiserFSLabel_int("/tmp/disk")
-        os.unlink("/tmp/disk")
-    else:
-        label = _readReiserFSLabel_int(device)
+def readReiserFSLabel(device):
+    label = _readReiserFSLabel_int(device)
     return label
 
-def readFSLabel(device, makeDevNode = 1):
-    label = readExt2Label(device, makeDevNode)
+def readFSLabel(device):
+    label = readExt2Label(device)
     if label is None:
-        label = readSwapLabel(device, makeDevNode)
+        label = readSwapLabel(device)
     if label is None:
-        label = readXFSLabel(device, makeDevNode)
+        label = readXFSLabel(device)
     if label is None:
-        label = readJFSLabel(device, makeDevNode)
+        label = readJFSLabel(device)
     if label is None:
-        label = readReiserFSLabel(device, makeDevNode)
+        label = readReiserFSLabel(device)
     return label
 
-def ext2Clobber(device, makeDevNode = 1):
+def ext2Clobber(device):
     _isys.e2fsclobber(device)
 
 def ext2IsDirty(device):
-    makeDevInode(device, "/tmp/disk")
-    label = _isys.e2dirty("/tmp/disk");
-    os.unlink("/tmp/disk")
+    label = _isys.e2dirty(device);
     return label
 
-def ext2HasJournal(device, makeDevNode = 1):
-    if makeDevNode:
-        makeDevInode(device, "/tmp/disk")
-        hasjournal = _isys.e2hasjournal("/tmp/disk");
-        os.unlink("/tmp/disk")
-    else:
-        hasjournal = _isys.e2hasjournal(device);
+def ext2HasJournal(device):
+    hasjournal = _isys.e2hasjournal(device);
     return hasjournal
 
-def ejectCdrom(device, makeDevice = 1):
-    if makeDevice:
-        makeDevInode(device, "/tmp/cdrom")
-        fd = os.open("/tmp/cdrom", os.O_RDONLY|os.O_NONBLOCK)
-    else:
-        fd = os.open(device, os.O_RDONLY|os.O_NONBLOCK)
+def ejectCdrom(device):
+    fd = os.open(device, os.O_RDONLY|os.O_NONBLOCK)
 
     # this is a best effort
     try:
@@ -950,9 +897,6 @@ def ejectCdrom(device, makeDevice = 1):
 
     os.close(fd)
 
-    if makeDevice:
-        os.unlink("/tmp/cdrom")
-
 def driveUsesModule(device, modules):
     """Returns true if a drive is using a prticular module.  Only works
        for SCSI devices right now."""
diff --git a/partedUtils.py b/partedUtils.py
index 4adc0b9..9e47788 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -457,13 +457,13 @@ def isLinuxNativeByNumtype(numtype):
 def sniffFilesystemType(device):
     """Sniff to determine the type of fs on device.  
 
-    device - name of device to sniff.  we try to create it if it doesn't exist.
+    device - name of device to sniff.
     """
 
     if os.access(device, os.O_RDONLY):
         dev = device
     else:
-        dev = isys.makeDevInode(device)
+        dev = "/dev/%s" %(device,)
 
     pagesize = resource.getpagesize()
     if pagesize > 2048:
@@ -509,7 +509,7 @@ def sniffFilesystemType(device):
 
     # ext2 check
     if struct.unpack("<H", buf[1080:1082]) == (0xef53,):
-        if isys.ext2HasJournal(dev, makeDevNode = 0):
+        if isys.ext2HasJournal(dev):
             return "ext3"
         else:
             return "ext2"
@@ -773,7 +773,7 @@ class DiskSet:
             if lvorigin:
                 continue
             node = "%s/%s" % (vg, lv)
-            label = isys.readFSLabel("/dev/" + node, makeDevNode=0)
+            label = isys.readFSLabel("/dev/" + node)
             if label:
                 labels[node] = label
 
@@ -811,7 +811,7 @@ class DiskSet:
                     if ((upgradeany == 1) or
                         (productMatches(relstr, productName))):
                         try:
-                            label = isys.readFSLabel(dev, makeDevNode=0)
+                            label = isys.readFSLabel(dev)
                         except:
                             label = None
             
@@ -842,7 +842,7 @@ class DiskSet:
                     if ((upgradeany == 1) or
                         (productMatches(relstr, productName))):
                         try:
-                            label = isys.readFSLabel(dev, makeDevNode=0)
+                            label = isys.readFSLabel(dev)
                         except:
                             label = None
             
@@ -890,7 +890,7 @@ class DiskSet:
                         if ((upgradeany == 1) or
                             (productMatches(relstr, productName))):
                             try:
-                                label = isys.readFSLabel("/dev/%s" % node, makeDevNode=0)
+                                label = isys.readFSLabel("/dev/%s" % node)
                             except:
                                 label = None
 
@@ -983,10 +983,6 @@ class DiskSet:
         w = self.anaconda.intf.progressWindow (_("Initializing"),
                              _("Please wait while formatting drive %s...\n"
                                ) % (drive,), 100)
-        try:
-            dev = isys.makeDevInode(drive)
-        except:
-            pass
 
         argList = [ "/sbin/dasdfmt",
                     "-y",
@@ -995,7 +991,7 @@ class DiskSet:
                     "-F",
                     "-P",
                     "-f",
-                    dev]
+                    "/dev/%s" % (dev,)]
 
         fd = os.open("/dev/null", os.O_RDWR | os.O_CREAT | os.O_APPEND)
         p = os.pipe()
@@ -1107,7 +1103,7 @@ class DiskSet:
     def _labelDevice(self, drive):
         log.info("Reinitializing label for drive %s" % (drive,))
 
-        deviceFile = isys.makeDevInode(drive, "/dev/" + drive)
+        deviceFile = "/dev/" + drive
 
         try:
             try:
@@ -1158,7 +1154,6 @@ class DiskSet:
                     drive not in DiskSet.exclusiveDisks:
                 continue
 
-            deviceFile = isys.makeDevInode(drive, "/dev/" + drive)
             if not isys.mediaPresent(drive):
                 DiskSet.skippedDisks.append(drive)
                 continue
@@ -1169,7 +1164,7 @@ class DiskSet:
             if self.initializedDisks.has_key(drive):
                 if not self.disks.has_key(drive):
                     try:
-                        dev = parted.PedDevice.get(deviceFile)
+                        dev = parted.PedDevice.get("/dev/%s" % (drive,))
                         disk = parted.PedDisk.new(dev)
                         self._addDisk(drive, disk)
                     except parted.error, msg:
@@ -1208,7 +1203,7 @@ class DiskSet:
 
             try:
                 if not dev:
-                    dev = parted.PedDevice.get(deviceFile)
+                    dev = parted.PedDevice.get("/dev/%s" % (drive,))
                     disk = None
             except parted.error, msg:
                 log.debug("parted error: %s" % (msg,))
diff --git a/partitions.py b/partitions.py
index 3c6f5fe..1df3f46 100644
--- a/partitions.py
+++ b/partitions.py
@@ -69,9 +69,6 @@ def partitionObjectsInitialize(anaconda):
     anaconda.id.partitions.setFromDisk(anaconda.id.diskset)
     anaconda.id.partitions.setProtected(anaconda.dispatch)
 
-    # make sure we have all the device nodes we'll want
-    iutil.makeDriveDeviceNodes()
-
 # dispatch.py helper function
 def partitioningComplete(anaconda):
     if anaconda.dir == DISPATCH_BACK and anaconda.id.fsset.isActive():
@@ -266,7 +263,7 @@ class Partitions:
             else:
                 fsystem = fsset.fileSystemTypeGet(fs)
                 try:
-                    fslabel = isys.readFSLabel(theDev, makeDevNode=0)
+                    fslabel = isys.readFSLabel(theDev)
                 except:
                     fslabel = None
 
@@ -336,7 +333,7 @@ class Partitions:
                 else:
                     fsystem = fsset.fileSystemTypeGet(fs)
                     try:
-                        fslabel = isys.readFSLabel(theDev, makeDevNode=0)
+                        fslabel = isys.readFSLabel(theDev)
                     except:
                         fslabel = None
 
diff --git a/raid.py b/raid.py
index 73842da..990aeee 100644
--- a/raid.py
+++ b/raid.py
@@ -65,9 +65,8 @@ def scanForRaid(drives):
 
     for d in drives:
         parts = []
-	dp = isys.makeDevInode(d)
         try:
-            dev = parted.PedDevice.get(dp)
+            dev = parted.PedDevice.get(d)
             disk = parted.PedDisk.new(dev)
 
             raidParts = partedUtils.get_raid_partitions(disk)
-- 
1.5.3.4


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