www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/10/04/07:47:11

Date: Sun, 4 Oct 1998 13:27:16 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: DJ Delorie <dj AT delorie DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: getmntent and bogus disk labels
Message-ID: <Pine.SUN.3.91.981004132447.1863v-100000@is>
MIME-Version: 1.0

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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019