Some bug fixes I forgot to check-in the other day.
authorErik Andersen <andersen@codepoet.org>
Mon, 13 Mar 2000 04:07:02 +0000 (04:07 -0000)
committerErik Andersen <andersen@codepoet.org>
Mon, 13 Mar 2000 04:07:02 +0000 (04:07 -0000)
Mounting loop devices w/o specifying the filesystem
type choked if it didn't guess right the first time.
 -Erik

Changelog
mount.c
umount.c
util-linux/mount.c
util-linux/umount.c

index 5678f60c2eceaeb082b8f5fefeea6b4b0f812bf1..c6493f8a338ba5c4f76dcf8d1dfbeb2b5571a4d5 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -45,6 +45,8 @@
        * Fixed a bug where "sed 's/foo/bar/g'" (i.e. a script w/o a "-e")
        * ps now supports BB_FEATURE_AUTOWIDTH, and can adjust its width
            to match the terminal (defaults to width=79 when this is off).
+       * Fixed mount'ing loop devices when the filesystem type was not 
+           specified.  It used to revert to non-loop after the first try.
 
 
        -Erik Andersen
diff --git a/mount.c b/mount.c
index c29be5106e1eb8a9c37567d82e65b07915e6e7d9..336cff7d2cc8e6091bc72c38bad5863146f861c5 100644 (file)
--- a/mount.c
+++ b/mount.c
@@ -142,7 +142,6 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
                                fprintf(stderr, "WARNING: loop device is read-only\n");
                                flags &= ~MS_RDONLY;
                        }
-                       use_loop = FALSE;
                }
 #endif
                status =
@@ -415,10 +414,10 @@ extern int mount_main(int argc, char **argv)
                                case 'a':
                                        all = TRUE;
                                        break;
-#ifdef BB_MTAB
                                case 'f':
                                        fakeIt = TRUE;
                                        break;
+#ifdef BB_MTAB
                                case 'n':
                                        useMtab = FALSE;
                                        break;
index 0f087e197e8ae0b9cf320a220f27841d07460943..b0f393cca509b0adc95e51aa57186193c4f761df 100644 (file)
--- a/umount.c
+++ b/umount.c
@@ -41,6 +41,9 @@ static const char umount_usage[] =
 #ifdef BB_FEATURE_REMOUNT
        "\t-r:\tTry to remount devices as read-only if mount is busy\n"
 #endif
+#if defined BB_FEATURE_MOUNT_LOOP
+       "\t-f:\tDo not free loop device (if a loop device has been used)\n"
+#endif
 ;
 
 struct _mtab_entry_t {
@@ -53,9 +56,14 @@ static struct _mtab_entry_t *mtab_cache = NULL;
 
 
 
+#if defined BB_FEATURE_MOUNT_LOOP
+static int freeLoop = TRUE;
+#endif
 static int useMtab = TRUE;
 static int umountAll = FALSE;
+#if defined BB_FEATURE_REMOUNT
 static int doRemount = FALSE;
+#endif
 extern const char mtab_file[]; /* Defined in utility.c */
 
 
@@ -167,7 +175,7 @@ static int do_umount(const char *name, int useMtab)
        status = umount(name);
 
 #if defined BB_FEATURE_MOUNT_LOOP
-       if (blockDevice != NULL && !strncmp("/dev/loop", blockDevice, 9))
+       if (freeLoop == TRUE && blockDevice != NULL && !strncmp("/dev/loop", blockDevice, 9))
                /* this was a loop device, delete it */
                del_loop(blockDevice);
 #endif
@@ -236,6 +244,11 @@ extern int umount_main(int argc, char **argv)
                        case 'a':
                                umountAll = TRUE;
                                break;
+#if defined BB_FEATURE_MOUNT_LOOP
+                       case 'f':
+                               freeLoop = FALSE;
+                               break;
+#endif
 #ifdef BB_MTAB
                        case 'n':
                                useMtab = FALSE;
index c29be5106e1eb8a9c37567d82e65b07915e6e7d9..336cff7d2cc8e6091bc72c38bad5863146f861c5 100644 (file)
@@ -142,7 +142,6 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
                                fprintf(stderr, "WARNING: loop device is read-only\n");
                                flags &= ~MS_RDONLY;
                        }
-                       use_loop = FALSE;
                }
 #endif
                status =
@@ -415,10 +414,10 @@ extern int mount_main(int argc, char **argv)
                                case 'a':
                                        all = TRUE;
                                        break;
-#ifdef BB_MTAB
                                case 'f':
                                        fakeIt = TRUE;
                                        break;
+#ifdef BB_MTAB
                                case 'n':
                                        useMtab = FALSE;
                                        break;
index 0f087e197e8ae0b9cf320a220f27841d07460943..b0f393cca509b0adc95e51aa57186193c4f761df 100644 (file)
@@ -41,6 +41,9 @@ static const char umount_usage[] =
 #ifdef BB_FEATURE_REMOUNT
        "\t-r:\tTry to remount devices as read-only if mount is busy\n"
 #endif
+#if defined BB_FEATURE_MOUNT_LOOP
+       "\t-f:\tDo not free loop device (if a loop device has been used)\n"
+#endif
 ;
 
 struct _mtab_entry_t {
@@ -53,9 +56,14 @@ static struct _mtab_entry_t *mtab_cache = NULL;
 
 
 
+#if defined BB_FEATURE_MOUNT_LOOP
+static int freeLoop = TRUE;
+#endif
 static int useMtab = TRUE;
 static int umountAll = FALSE;
+#if defined BB_FEATURE_REMOUNT
 static int doRemount = FALSE;
+#endif
 extern const char mtab_file[]; /* Defined in utility.c */
 
 
@@ -167,7 +175,7 @@ static int do_umount(const char *name, int useMtab)
        status = umount(name);
 
 #if defined BB_FEATURE_MOUNT_LOOP
-       if (blockDevice != NULL && !strncmp("/dev/loop", blockDevice, 9))
+       if (freeLoop == TRUE && blockDevice != NULL && !strncmp("/dev/loop", blockDevice, 9))
                /* this was a loop device, delete it */
                del_loop(blockDevice);
 #endif
@@ -236,6 +244,11 @@ extern int umount_main(int argc, char **argv)
                        case 'a':
                                umountAll = TRUE;
                                break;
+#if defined BB_FEATURE_MOUNT_LOOP
+                       case 'f':
+                               freeLoop = FALSE;
+                               break;
+#endif
 #ifdef BB_MTAB
                        case 'n':
                                useMtab = FALSE;