This is the mail archive of the cygwin-developers@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

patch for bug in mount_info::del_item()


mount_info::del_item() leaves holes in the mount_info::mount[] table.

This causes "umount --remove-all-mounts" to go into an endless loop.

You can also get other strange symptoms if you call umount followed by
mount.
This depends on your mount table, and what directories you umount and
mount.

To reproduce the bug, create a mount table like this:
(note that the posix root is not the last line)
Device              Directory           Type         Flags
c:\foobar           /                   user         textmode
c:\foo              /foo                user         textmode
then type "umount --remove-all-mounts".


The mount_info::posix_sorted[] and mount_info::native_sorted[] tables
correctly ignore the holes, 
but there are many accesses to mount_info::mount[] which do not use the
XXX_sorted[] tables
and do not check for the holes.


This patch is relative to winsup-src-19990718.tar.gz.

Sat Jul 24 01:35:38 1999  Andrew Dalgleish <andrewd@axonet.com.au>
	* path.cc (mount_info::del_item): Don't leave holes in the mount
table.

--- winsup/path.cc.orig Thu Jul 15 12:49:24 1999
+++ winsup/path.cc      Sat Jul 24 01:35:38 1999
@@ -1673,12 +1674,16 @@
            || strcmp (mount[i].native_path, pathtmp) == 0)) &&
          ((mount[i].flags & MOUNT_SYSTEM) == (flags & MOUNT_SYSTEM)))
        {
-         /* Delete by emptying mount point in question, then sorting
-            the mount table, which will put the empty one to the end.
-            Inefficient but simple.  */
-         mount[i].init ("", "", 0);
-         sort ();
+        /* Move all the remaining mounts down one in the table. */
+        for (; i < nmounts - 1; i++)
+          mount[i] = mount[i+1];
+
+        /* Remember we have one less entry */
          nmounts--;
+
+        /* Sort the remaining entries. */
+         sort ();
+
          return 0;
        }
     }



Regards,
Andrew Dalgleish


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]