Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com Message-ID: <00F8D6E8AB0DD3118F1A006008186C965368@server1.axonet.com.au> From: Andrew Dalgleish To: cygwin-developers AT sourceware DOT cygnus DOT com Subject: patch for bug in mount_info::del_item() Date: Sat, 24 Jul 1999 02:09:17 +1000 X-Priority: 3 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1458.49) Content-Type: text/plain 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 * 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