www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/04/25/07:13:49

X-Authentication-Warning: sirppi.helsinki.fi: peuha owned process doing -bs
Date: Tue, 25 Apr 2000 15:08:35 +0300 (EET DST)
From: Esa A E Peuha <peuha AT cc DOT helsinki DOT fi>
Sender: peuha AT cc DOT helsinki DOT fi
To: djgpp-workers AT delorie DOT com
Subject: Patch for remove.c
Message-ID: <Pine.OSF.4.20.0004251458020.20774-100000@sirppi.helsinki.fi>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

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 -


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