Date: Sun, 4 Oct 1998 13:27:16 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: DJ Delorie cc: djgpp-workers AT delorie DOT com Subject: getmntent and bogus disk labels Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Did you notice that `getmntent' on plain DOS returns a bogus filesystem name for floppies that were written with LFN support? Well, the following patch should correct that: *** src/libc/compat/mntent/mntent.c~1 Fri Oct 2 11:33:12 1998 --- src/libc/compat/mntent/mntent.c Fri Oct 2 19:50:48 1998 *************** getmntent(FILE *filep) *** 750,760 **** { /* Look for the volume label. */ int e = errno; strcat(drive_string, "*.*"); errno = 0; ! if (!findfirst(drive_string, &mnt_ff, FA_LABEL)) { errno = e; --- 750,773 ---- { /* Look for the volume label. */ int e = errno; + int volume_found = 0; strcat(drive_string, "*.*"); errno = 0; + volume_found = findfirst(drive_string, &mnt_ff, FA_LABEL) == 0; + /* Floppies and other disks written by Windows 9X include + entries that have volume label bit set, but they are + actually parts of some LFN entry. We only accept volume + labels which have all their RHS bits reset; otherwise + we pretend we never saw that label. */ + if (volume_found && + (mnt_ff.ff_attrib & (FA_RDONLY|FA_HIDDEN|FA_SYSTEM)) != 0) + { + volume_found = 0; + errno = ENMFILE; + } ! if (volume_found) { errno = e; *** src/docs/kb/wc202.t~2 Fri Oct 2 12:59:26 1998 --- src/docs/kb/wc202.txi Fri Oct 2 19:53:42 1998 *************** *** 292,298 **** @code{getmntent} better supports Windows NT and doesn't cause DOS to return stale data when the disk is changed. Removable media such as JAZ ! drives are no longer reported when the drive is empty. @findex getmntent File names which begin with @file{/dev/} or @file{x:/dev/} (where --- 292,300 ---- @code{getmntent} better supports Windows NT and doesn't cause DOS to return stale data when the disk is changed. Removable media such as JAZ ! drives are no longer reported when the drive is empty. Disks written by ! Windows 9X are no longer reported with bogus names taken from LFN ! directory entries (which have their volume label attribute bit set). @findex getmntent File names which begin with @file{/dev/} or @file{x:/dev/} (where