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

[PATCH 09/15] Adjust to new udev world. Use actual device names, not /tmp/<whatever>.



---
 loader2/driverdisk.c |   34 +++++++++++-------------
 loader2/hdinstall.c  |   10 +++----
 loader2/loader.c     |    5 +--
 loader2/method.c     |   69 +++++++++++++++++++++-----------------------------
 loader2/nfsinstall.c |    4 +-
 loader2/urlinstall.c |   12 ++++----
 6 files changed, 58 insertions(+), 76 deletions(-)

diff --git a/loader2/driverdisk.c b/loader2/driverdisk.c
index 6cbf801..dc4b967 100644
--- a/loader2/driverdisk.c
+++ b/loader2/driverdisk.c
@@ -340,10 +340,9 @@ int loadDriverFromMedia(int class, struct loaderData_s *loaderData,
             }
 
             logMessage(INFO, "trying to mount %s as partition", part);
-            devMakeInode(part + 5, "/tmp/ddpart");
-            if (doPwMount("/tmp/ddpart", "/tmp/dpart", "vfat", IMOUNT_RDONLY, NULL)) {
-                if (doPwMount("/tmp/ddpart", "/tmp/dpart", "ext2", IMOUNT_RDONLY, NULL)) {
-                    if (doPwMount("/tmp/ddpart", "/tmp/dpart", "iso9660", IMOUNT_RDONLY, NULL)) {
+            if (doPwMount(part, "/tmp/dpart", "vfat", IMOUNT_RDONLY, NULL)) {
+                if (doPwMount(part, "/tmp/dpart", "ext2", IMOUNT_RDONLY, NULL)) {
+                    if (doPwMount(part, "/tmp/dpart", "iso9660", IMOUNT_RDONLY, NULL)) {
                         newtWinMessage(_("Error"), _("OK"),
                                        _("Failed to mount partition."));
                         stage = DEV_PART;
@@ -375,13 +374,13 @@ int loadDriverFromMedia(int class, struct loaderData_s *loaderData,
                 break;
             }
             if (dir == -1) {
-                umountLoopback("/tmp/drivers", "loop6");
+                umountLoopback("/tmp/drivers", "/dev/loop6");
                 unlink("/tmp/drivers");
                 ddfile = NULL;
                 stage = DEV_CHOOSEFILE;
                 break;
             }
-            if (mountLoopback(ddfile, "/tmp/drivers", "loop6")) {
+            if (mountLoopback(ddfile, "/tmp/drivers", "/dev/loop6")) {
                 newtWinMessage(_("Error"), _("OK"),
                                _("Failed to load driver disk from file."));
                 stage = DEV_CHOOSEFILE;
@@ -406,11 +405,10 @@ int loadDriverFromMedia(int class, struct loaderData_s *loaderData,
             }
             dir = 1;
 
-            devMakeInode(device, "/tmp/dddev");
             logMessage(INFO, "trying to mount %s", device);
-            if (doPwMount("/tmp/dddev", "/tmp/drivers", "vfat", IMOUNT_RDONLY, NULL)) {
-              if (doPwMount("/tmp/dddev", "/tmp/drivers", "ext2", IMOUNT_RDONLY, NULL)) {
-                if (doPwMount("/tmp/dddev", "/tmp/drivers", "iso9660", IMOUNT_RDONLY, NULL)) {
+            if (doPwMount(device, "/tmp/drivers", "vfat", IMOUNT_RDONLY, NULL)) {
+              if (doPwMount(device, "/tmp/drivers", "ext2", IMOUNT_RDONLY, NULL)) {
+                if (doPwMount(device, "/tmp/drivers", "iso9660", IMOUNT_RDONLY, NULL)) {
                     newtWinMessage(_("Error"), _("OK"),
                                    _("Failed to mount driver disk."));
                     stage = DEV_INSERT;
@@ -456,7 +454,7 @@ int loadDriverFromMedia(int class, struct loaderData_s *loaderData,
             stage = DEV_PROBE;
 
             if (ddfile != NULL) {
-                umountLoopback("/tmp/drivers", "loop6");
+                umountLoopback("/tmp/drivers", "/dev/loop6");
                 unlink("/tmp/drivers");
                 umount("/tmp/dpart");
             }
@@ -587,9 +585,9 @@ void getDDFromSource(struct loaderData_s * loaderData, char * src) {
         return;
     }
 
-    if (!mountLoopback(path, "/tmp/drivers", "loop6")) {
+    if (!mountLoopback(path, "/tmp/drivers", "/dev/loop6")) {
         loadFromLocation(loaderData, "/tmp/drivers");
-        umountLoopback("/tmp/drivers", "loop6");
+        umountLoopback("/tmp/drivers", "/dev/loop6");
         unlink("/tmp/drivers");
         if (unlinkf) unlink(path);
     }
@@ -660,16 +658,15 @@ void useKickstartDD(struct loaderData_s * loaderData,
 
 static void getDDFromDev(struct loaderData_s * loaderData, char * dev, 
                         char * fstype) {
-    devMakeInode(dev, "/tmp/dddev");
     if (fstype) {
-        if (doPwMount("/tmp/dddev", "/tmp/drivers", fstype, 
+        if (doPwMount(dev, "/tmp/drivers", fstype, 
                       IMOUNT_RDONLY, NULL)) {
             logMessage(ERROR, "unable to mount %s as %s", dev, fstype);
             return;
         }
-    } else if (doPwMount("/tmp/dddev", "/tmp/drivers", "vfat", IMOUNT_RDONLY, NULL)) {
-        if (doPwMount("/tmp/dddev", "/tmp/drivers", "ext2", IMOUNT_RDONLY, NULL)) {
-            if (doPwMount("/tmp/dddev", "/tmp/drivers", "iso9660", IMOUNT_RDONLY, NULL)) {
+    } else if (doPwMount(dev, "/tmp/drivers", "vfat", IMOUNT_RDONLY, NULL)) {
+        if (doPwMount(dev, "/tmp/drivers", "ext2", IMOUNT_RDONLY, NULL)) {
+            if (doPwMount(dev, "/tmp/drivers", "iso9660", IMOUNT_RDONLY, NULL)) {
                 logMessage(ERROR, "unable to mount driver disk %s", dev);
                 return;
             }
@@ -679,5 +676,4 @@ static void getDDFromDev(struct loaderData_s * loaderData, char * dev,
     loadFromLocation(loaderData, "/tmp/drivers");
     umount("/tmp/drivers");
     unlink("/tmp/drivers");
-    unlink("/tmp/dddev");
 }
diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c
index 71276c0..874a5f1 100644
--- a/loader2/hdinstall.c
+++ b/loader2/hdinstall.c
@@ -145,12 +145,10 @@ static char * setupIsoImages(char * device, char * dirName, char * location,
     logMessage(INFO, "mounting device %s for hard drive install", device);
 
     if (!FL_TESTING(flags)) {
-        if (devMakeInode(device, "/tmp/hddev"))
-            logMessage(WARNING, "devMakeInode failed!");
 
         /* XXX try to mount as ext2 and then vfat */
         for (type=typetry; *type; type++) {
-            if (!doPwMount("/tmp/hddev", "/tmp/hdimage", *type, 
+            if (!doPwMount(device, "/tmp/hdimage", *type, 
                 IMOUNT_RDONLY, NULL))
                 break;
         }
@@ -169,11 +167,11 @@ static char * setupIsoImages(char * device, char * dirName, char * location,
             logMessage(INFO, "Looking for updates for HD in %s", updpath);
             copyUpdatesImg(updpath);
 
-            rc = mountLoopback(path, "/tmp/loopimage", "loop0");
+            rc = mountLoopback(path, "/tmp/loopimage", "/dev/loop0");
             if (!rc) {
                 /* This code is for copying small stage2 into ram */
                 /* and mounting                                   */
-                rc = loadHDImages("/tmp/loopimage", "/", "loop1",
+                rc = loadHDImages("/tmp/loopimage", "/", "/dev/loop1",
                                   "/mnt/runtime", location, modInfo, modLoaded, modDepsPtr);
                 if (rc) {
                     newtWinMessage(_("Error"), _("OK"),
@@ -186,7 +184,7 @@ static char * setupIsoImages(char * device, char * dirName, char * location,
             }
 
             /* we copied stage2 into RAM so we can now umount image */
-            umountLoopback("/tmp/loopimage", "loop0");
+            umountLoopback("/tmp/loopimage", "/dev/loop0");
 
         } else {
             rc = 1;
diff --git a/loader2/loader.c b/loader2/loader.c
index 8810fc9..fc6073b 100644
--- a/loader2/loader.c
+++ b/loader2/loader.c
@@ -444,10 +444,9 @@ void loadUpdates(struct loaderData_s *loaderData) {
 
             logMessage(INFO, "UPDATES device is %s", part);
 
-            devMakeInode(part+5, "/tmp/upd.disk");
-            if (doPwMount("/tmp/upd.disk", "/tmp/update-disk", "ext2",
+            if (doPwMount(part, "/tmp/update-disk", "ext2",
                           IMOUNT_RDONLY, NULL) &&
-                doPwMount("/tmp/upd.disk", "/tmp/update-disk", "iso9660",
+                doPwMount(part, "/tmp/update-disk", "iso9660",
                           IMOUNT_RDONLY, NULL)) {
                 newtWinMessage(_("Error"), _("OK"),
                                _("Failed to mount updates disk"));
diff --git a/loader2/method.c b/loader2/method.c
index 13fd9f1..92f4cab 100644
--- a/loader2/method.c
+++ b/loader2/method.c
@@ -59,8 +59,7 @@ int umountLoopback(char * mntpoint, char * device) {
 
     logMessage(INFO, "umounting loopback %s %s", mntpoint, device);
 
-    devMakeInode(device, "/tmp/loop");
-    loopfd = open("/tmp/loop", O_RDONLY);
+    loopfd = open(device, O_RDONLY);
 
     if (ioctl(loopfd, LOOP_CLR_FD, 0) == -1)
         logMessage(ERROR, "LOOP_CLR_FD failed for %s %s (%s)", mntpoint,
@@ -75,11 +74,8 @@ int umountLoopback(char * mntpoint, char * device) {
 int mountLoopback(char * fsystem, char * mntpoint, char * device) {
     struct loop_info loopInfo;
     int targfd, loopfd;
-    char *filename;
 
     mkdirChain(mntpoint);
-    filename = alloca(15 + strlen(device));
-    sprintf(filename, "/tmp/%s", device);
 
 #ifdef O_DIRECT
     targfd = open(fsystem, O_RDONLY | O_DIRECT);
@@ -94,10 +90,9 @@ int mountLoopback(char * fsystem, char * mntpoint, char * device) {
     }
 #endif
 
-    devMakeInode(device, filename);
-    loopfd = open(filename, O_RDONLY);
+    loopfd = open(device, O_RDONLY);
     if (loopfd == -1) {
-	logMessage(ERROR, "unable to open loop device %s", filename);
+	logMessage(ERROR, "unable to open loop device %s", device);
 	return LOADER_ERROR;
     }
     logMessage(INFO, "mntloop %s on %s as %s fd is %d", 
@@ -126,13 +121,13 @@ int mountLoopback(char * fsystem, char * mntpoint, char * device) {
 
     /* FIXME: really, mountLoopback() should take a list of "valid" 
      * filesystems for the specific type of image being mounted */
-    if (doPwMount(filename, mntpoint, "iso9660", IMOUNT_RDONLY, NULL)) {
-        if (doPwMount(filename, mntpoint, "ext2", IMOUNT_RDONLY, NULL)) {
-          if (doPwMount(filename, mntpoint, "squashfs", IMOUNT_RDONLY, NULL)) {
-            if (doPwMount(filename, mntpoint, "cramfs", IMOUNT_RDONLY, NULL)) {
-              if (doPwMount(filename, mntpoint, "vfat", IMOUNT_RDONLY, NULL)) {
+    if (doPwMount(device, mntpoint, "iso9660", IMOUNT_RDONLY, NULL)) {
+        if (doPwMount(device, mntpoint, "ext2", IMOUNT_RDONLY, NULL)) {
+          if (doPwMount(device, mntpoint, "squashfs", IMOUNT_RDONLY, NULL)) {
+            if (doPwMount(device, mntpoint, "cramfs", IMOUNT_RDONLY, NULL)) {
+              if (doPwMount(device, mntpoint, "vfat", IMOUNT_RDONLY, NULL)) {
                 logMessage(ERROR, "failed to mount loop: %s", strerror(errno));
-                loopfd = open(filename, O_RDONLY);
+                loopfd = open(device, O_RDONLY);
                 ioctl(loopfd, LOOP_CLR_FD, 0);
                 close(loopfd);
                 return LOADER_ERROR;
@@ -168,26 +163,26 @@ char * validIsoImages(char * dirName, int *foundinvalid) {
             continue;
         }
         
-        if (mountLoopback(isoImage, "/tmp/loopimage", "loop7")) {
+        if (mountLoopback(isoImage, "/tmp/loopimage", "/dev/loop7")) {
             logMessage(WARNING, "failed to mount %s", isoImage);
             errno = 0;
             continue;
         }
         
-	if (mountLoopback("/tmp/loopimage/images/stage2.img", "/mnt/runtime", "loop0")) {
-	    umountLoopback("/mnt/runtime", "loop0");
+	if (mountLoopback("/tmp/loopimage/images/stage2.img", "/mnt/runtime", "/dev/loop0")) {
+	    umountLoopback("/mnt/runtime", "/dev/loop0");
 	} else {
 	    if (verifyStamp("/mnt/runtime")) {
-		umountLoopback("/mnt/runtime", "loop0");
-		umountLoopback("/tmp/loopimage", "loop7");
+		umountLoopback("/mnt/runtime", "/dev/loop0");
+		umountLoopback("/tmp/loopimage", "/dev/loop7");
 		break;
 	    }
 	    logMessage(ERROR, "disc %s is not the right image", isoImage);
-	    umountLoopback("/mnt/runtime", "loop0");
+	    umountLoopback("/mnt/runtime", "/dev/loop0");
 	    if (foundinvalid) *foundinvalid = 1;
 	}
         
-        umountLoopback("/tmp/loopimage", "loop7");
+        umountLoopback("/tmp/loopimage", "/dev/loop7");
         
         errno = 0;
     }
@@ -222,7 +217,7 @@ int readStampFileFromIso(char *file, char **timestamp, char **releasedescr) {
 	}
     } else if (S_ISREG(sb.st_mode)) {
 	filetype = 2;
-	if (mountLoopback(file, "/tmp/testmnt", "loop6")) {
+	if (mountLoopback(file, "/tmp/testmnt", "/dev/loop6")) {
 	    logMessage(ERROR, "Failed to mount iso %s to get description",
                        file);
 	    return -1;
@@ -236,7 +231,7 @@ int readStampFileFromIso(char *file, char **timestamp, char **releasedescr) {
     if (!(dir = opendir("/tmp/testmnt"))) {
 	umount("/tmp/testmnt");
 	if (filetype == 2)
-	    umountLoopback("/tmp/testmnt", "loop6");
+	    umountLoopback("/tmp/testmnt", "/dev/loop6");
 	return -1;
     }
 
@@ -312,7 +307,7 @@ int readStampFileFromIso(char *file, char **timestamp, char **releasedescr) {
 
     umount("/tmp/testmnt");
     if (filetype == 2)
-	umountLoopback("/tmp/testmnt", "loop6");
+	umountLoopback("/tmp/testmnt", "/dev/loop6");
 
     if (descr != NULL && tstamp != NULL) {
 	descr[strlen(descr)-1] = '\0';
@@ -483,10 +478,10 @@ int unpackCpioBall(char * ballPath, char * rootDir) {
 
 void copyUpdatesImg(char * path) {
     if (!access(path, R_OK)) {
-        if (!mountLoopback(path, "/tmp/update-disk", "loop7")) {
+        if (!mountLoopback(path, "/tmp/update-disk", "/dev/loop7")) {
             copyDirectory("/tmp/update-disk", "/tmp/updates", copyWarnFn,
                           copyErrorFn);
-            umountLoopback("/tmp/update-disk", "loop7");
+            umountLoopback("/tmp/update-disk", "/dev/loop7");
             unlink("/tmp/update-disk");
         } else {
             unpackCpioBall(path, "/tmp/updates");
@@ -496,10 +491,10 @@ void copyUpdatesImg(char * path) {
 
 void copyProductImg(char * path) {
     if (!access(path, R_OK)) {
-        if (!mountLoopback(path, "/tmp/product-disk", "loop7")) {
+        if (!mountLoopback(path, "/tmp/product-disk", "/dev/loop7")) {
             copyDirectory("/tmp/product-disk", "/tmp/product", copyWarnFn,
                           copyErrorFn);
-            umountLoopback("/tmp/product-disk", "loop7");
+            umountLoopback("/tmp/product-disk", "/dev/loop7");
             unlink("/tmp/product-disk");
         }
     }
@@ -554,7 +549,7 @@ int verifyStamp(char * path) {
    so we can eject CDs.                                                   */
 void umountStage2(void) {
     umount("/mnt/runtime");
-    umountLoopback("/mnt/runtime", "loop0");
+    umountLoopback("/mnt/runtime", "/dev/loop0");
 }
 
 
@@ -565,12 +560,12 @@ int mountStage2(char * path) {
         return 1;
     }
 
-    if (mountLoopback(path, "/mnt/runtime", "loop0")) {
+    if (mountLoopback(path, "/mnt/runtime", "/dev/loop0")) {
         return 1;
     }
 
     if (!verifyStamp("/mnt/runtime")) {
-        umountLoopback("/mnt/runtime", "loop0");
+        umountLoopback("/mnt/runtime", "/dev/loop0");
         return -1;
     }
 
@@ -624,14 +619,9 @@ int getFileFromBlockDevice(char *device, char *path, char * dest) {
 
     logMessage(INFO, "getFileFromBlockDevice(%s, %s)", device, path);
 
-    if (devMakeInode(device, "/tmp/srcdev")) {
-        logMessage(ERROR, "failed to make device node for /dev/%s", device);
-        return 1;
-    }
-
-    if (doPwMount("/tmp/srcdev", "/tmp/mnt", "vfat", IMOUNT_RDONLY, NULL) &&
-        doPwMount("/tmp/srcdev", "/tmp/mnt", "ext2", IMOUNT_RDONLY, NULL) && 
-        doPwMount("/tmp/srcdev", "/tmp/mnt", "iso9660", IMOUNT_RDONLY, NULL)) {
+    if (doPwMount(device, "/tmp/mnt", "vfat", IMOUNT_RDONLY, NULL) &&
+        doPwMount(device, "/tmp/mnt", "ext2", IMOUNT_RDONLY, NULL) && 
+        doPwMount(device, "/tmp/mnt", "iso9660", IMOUNT_RDONLY, NULL)) {
         logMessage(ERROR, "failed to mount /dev/%s: %s", device,
                    strerror(errno));
         return 2;
@@ -650,7 +640,6 @@ int getFileFromBlockDevice(char *device, char *path, char * dest) {
 
     umount("/tmp/mnt");
     unlink("/tmp/mnt");
-    unlink("/tmp/srcdev");
     return rc;
 }
 
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c
index a3cce72..b46898c 100644
--- a/loader2/nfsinstall.c
+++ b/loader2/nfsinstall.c
@@ -184,7 +184,7 @@ char * mountNfsImage(struct installMethod * method,
 		    logMessage(INFO, "Path to valid iso is %s", path);
                     copyUpdatesImg("/mnt/source/updates.img");
 
-                    if (mountLoopback(path, "/mnt/source2", "loop1")) 
+                    if (mountLoopback(path, "/mnt/source2", "/dev/loop1")) 
                         logMessage(WARNING, "failed to mount iso %s loopback", path);
                     else {
                         /* try to see if we're booted off of a CD with stage2 */
@@ -200,7 +200,7 @@ char * mountNfsImage(struct installMethod * method,
                             rc = mountStage2("/mnt/source2/images/stage2.img");
                         }
                         if (rc) {
-                            umountLoopback("/mnt/source2", "loop1");
+                            umountLoopback("/mnt/source2", "/dev/loop1");
                             if (rc == -1)
 				foundinvalid = 1;
                         } else {
diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c
index f8bd3cc..34e2fc0 100644
--- a/loader2/urlinstall.c
+++ b/loader2/urlinstall.c
@@ -108,10 +108,10 @@ static int loadUrlImages(struct iurlinfo * ui) {
      * ramdisk usage */
     if (!loadSingleUrlImage(ui, "images/updates.img",
                             "/tmp/ramfs/updates-disk.img", "/tmp/update-disk",
-                            "loop7", 1)) {
+                            "/dev/loop7", 1)) {
         copyDirectory("/tmp/update-disk", "/tmp/updates", copyWarnFn,
                       copyErrorFn);
-        umountLoopback("/tmp/update-disk", "loop7");
+        umountLoopback("/tmp/update-disk", "/dev/loop7");
         unlink("/tmp/ramfs/updates-disk.img");
         unlink("/tmp/update-disk");
     }
@@ -120,10 +120,10 @@ static int loadUrlImages(struct iurlinfo * ui) {
      * ramdisk usage */
     if (!loadSingleUrlImage(ui, "images/product.img",
                             "/tmp/ramfs/product-disk.img", "/tmp/product-disk",
-                            "loop7", 1)) {
+                            "/dev/loop7", 1)) {
         copyDirectory("/tmp/product-disk", "/tmp/product", copyWarnFn,
                       copyErrorFn);
-        umountLoopback("/tmp/product-disk", "loop7");
+        umountLoopback("/tmp/product-disk", "/dev/loop7");
         unlink("/tmp/ramfs/product-disk.img");
         unlink("/tmp/product-disk");
     }
@@ -142,7 +142,7 @@ static int loadUrlImages(struct iurlinfo * ui) {
     snprintf(tmpstr2, sizeof(tmpstr2), "/tmp/ramfs/%s", stage2img);
 
     rc = loadSingleUrlImage(ui, tmpstr1, tmpstr2,
-                            "/mnt/runtime", "loop0", 0);
+                            "/mnt/runtime", "/dev/loop0", 0);
     if (rc) {
         if (rc != 2) 
             newtWinMessage(_("Error"), _("OK"),
@@ -160,7 +160,7 @@ static int loadUrlImages(struct iurlinfo * ui) {
 
 	newtWinMessage(_("Error"), _("OK"), buf);
 
-	umountLoopback("/mnt/runtime", "loop0");
+	umountLoopback("/mnt/runtime", "/dev/loop0");
 	return 1;
     }
 
-- 
1.5.3.4


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