Mail Archives: djgpp-workers/2000/04/25/07:13:49
I forgot to remove write-protection on a floppy I wanted to empty, and
was rather surprised to see that "rm a:/*" listed all the files with
ENOENT.  It turns out that this is a bug in DOS, so I propose the
following workaround:
----------------
*** src/libc/ansi/stdio/remove~.c	Sun Jun 28 19:13:20 1998
--- src/libc/ansi/stdio/remove.c	Mon Apr 24 19:12:12 2000
***************
*** 43,49 ****
       in addition to the Read-Only bit, or else 214301 will fail.  */
    _chmod(fn, 1, attr & 0xffe0);
  
!   /* Now delete it.  Note, _chmod leaves dir name in tranfer buffer. */
    if (directory_p)
      r.h.ah = 0x3a;		/* DOS Remove Directory function */
    else
--- 43,49 ----
       in addition to the Read-Only bit, or else 214301 will fail.  */
    _chmod(fn, 1, attr & 0xffe0);
  
!   /* Now delete it.  Note, _chmod leaves dir name in transfer buffer. */
    if (directory_p)
      r.h.ah = 0x3a;		/* DOS Remove Directory function */
    else
***************
*** 60,65 ****
--- 60,71 ----
    {
      /* We failed.  Leave the things as we've found them.  */
      int e = __doserr_to_errno(r.x.ax);
+ 
+     /* We know the file exists, so ENOENT at this point means a bug.
+        Since write-protected floppies are the most probable cause,
+        return EACCES instead.  */
+     if(e == ENOENT)
+       e = EACCES;
   
      _chmod(fn, 1, attr & 0xffe7);
      errno = e;
----------------
-- 
Esa Peuha
student of mathematics at the University of Helsinki
http://www.helsinki.fi/~peuha/
- Raw text -