Date: Sun, 4 Oct 1998 12:34:05 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: bowman cc: djgpp-workers AT delorie DOT com Subject: Re: proposed change to mntent.c In-Reply-To: <361273F0.3CB2784@montana.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 30 Sep 1998, bowman wrote: > + /* See whether drive A: is mapped to B: and if it is, change > + DRIVE_NUMBER on the fly and raise the flag to skip drive > + number 2 next time we are called (meaning there is only > + one floppy drive). */ > + if (drive_number == 1 && (drive_a_mapping = assigned_to(1)) > 0) > + { > + skip_drive_b = 1; > + drive_number = drive_a_mapping; > + } > /* Work around a possible bug in QDPMI: _truename() would > sometimes > crash the calling program when there is no disk in a (floppy) > drive. To avoid this, we have to check if the drive is empty > *************** > *** 560,582 **** > operation after disk change, each time resetting the > drive, until something other than 6 is returned or we > run out of our patience. */ > ! while (++count < 10 && (bios_status = > biosdisk(2, drive_number - 1, 0, 0, 1, 1, buf)) == 6) > biosdisk(0, drive_number - 1, 0, 0, 0, 0, NULL); I think this patch is not quite right. The problem is that it changes drive_number *before* the second call to `biosdisk', which causes it to be called on a second floppy drive (which might be absent) in certain cases. Here's one way to see the problem. On a system which has only one floppy drive, do these steps: insert a floppy into the drive dir b: [press Enter when DOS asks for a floppy] mntent (I assume that mntent.c was compiled with -DTEST into mntent.exe.) You will see that, although there is a disk in the drive, the program will behave as if the disk were not there. Here's a patch that I suggest instead. Can you please see if it works for you on Compaq? Btw, is there any reason that you decreased the number of attempts from 10 to 2? This is only done after a disk was changed, so it should be unrelated to your problem. *** src/libc/compat/mntent/mntent.c~0 Sun Jun 28 22:16:02 1998 --- src/libc/compat/mntent/mntent.c Fri Oct 2 11:33:12 1998 *************** getmntent(FILE *filep) *** 583,588 **** --- 583,594 ---- if (drive_number == 2 && skip_drive_b) continue; + /* See whether drive A: is mapped to B: and if it is, raise the + flag to skip drive number 2 next time we are called (meaning + there is only one floppy drive). */ + if (drive_number == 1 && (drive_a_mapping = assigned_to(1)) > 0) + skip_drive_b = 1; + /* Work around a possible bug in QDPMI: _truename() would sometimes crash the calling program when there is no disk in a (floppy) drive. To avoid this, we have to check if the drive is empty *************** getmntent(FILE *filep) *** 604,619 **** /* If the loop ends with nonzero status, fail. */ if (bios_status != 0) continue; - } ! /* See whether drive A: is mapped to B: and if it is, change ! DRIVE_NUMBER on the fly and raise the flag to skip drive ! number 2 next time we are called (meaning there is only ! one floppy drive). */ ! if (drive_number == 1 && (drive_a_mapping = assigned_to(1)) > 0) ! { ! skip_drive_b = 1; ! drive_number = drive_a_mapping; } drvstr_len = sprintf(drive_string, "%c:\\", '@' + drive_number); --- 610,620 ---- /* If the loop ends with nonzero status, fail. */ if (bios_status != 0) continue; ! /* If there's only one floppy drive, change DRIVE_NUMBER on ! the fly to whatever logical drive it is currently mapped. */ ! if (skip_drive_b) ! drive_number = drive_a_mapping; } drvstr_len = sprintf(drive_string, "%c:\\", '@' + drive_number);