www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/08/25/02:43:00

Date: Tue, 25 Aug 1998 09:42:05 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Nate Eldredge <nate AT cartsys DOT com>, "John M. Aldrich" <fighteer AT cs DOT net>,
Michel de Ruiter <mdruiter AT cs DOT vu DOT nl>, djgpp-workers AT delorie DOT com
cc: Martin Str|mberg <ams AT ludd DOT luth DOT se>
Subject: Re: stat c:/con
In-Reply-To: <Pine.SUN.3.91.980823170827.1451V-100000@is>
Message-ID: <Pine.SUN.3.91.980825093508.6686A-100000@is>
MIME-Version: 1.0

On Sun, 23 Aug 1998, I wrote:

> The problem is, DOS 7 seems to have broken the feature whereby 
> `_truename' returns "x:/foo" (yes, with a forward slash) for any device 
> `foo'.  And `stat' relies on that to detect devices.  Damn you, Bill from 
> Redmond!

Sorry, I was in a hurry when I wrote this, and didn't check everything I 
should have.  This problem is common to all versions of DOS I have 
access  to (Windows 95 does solve it).  Since I knew this problem doesn't 
happen on my main development machine (DOS 5.0), I assumed incorrectly 
that DOS 7 has introduced a new misfeature.

As it turns out, I have found and solved this buglet several months ago, 
but the patch (below) somehow didn't make it into the alpha release 
(probably, my fault).

Michel, I believe that if you use the version of stat.c from the latest 
alpha after applying this patch, your problems will be gone.

Nate, could you please check if this patch is included in the patched 
libc, and if not, update the patched libraries?

*** src/libc/posix/sys/stat/stat.c~4	Wed May 28 08:49:56 1997
--- src/libc/posix/sys/stat/stat.c	Tue Jan  6 21:44:04 1998
*************** stat_assist(const char *path, struct sta
*** 472,477 ****
--- 472,478 ----
           invented inode and one which belongs to a real file.  This is
           also compatible with what our fstat() does.
        */
+     char_dev:
        if (canon_path[2] == '/')
          {
            char dev_name[9];     /* devices are at most 8 characters long */
*************** stat_assist(const char *path, struct sta
*** 594,599 ****
--- 595,621 ----
        statbuf->st_mode |= READ_ACCESS;
        if ( !(ff_blk.ff_attrib & 0x07) )  /* no R, H or S bits set */
          statbuf->st_mode |= WRITE_ACCESS;
+ 
+       /* Sometimes `_truename' doesn't return X:/FOO for character
+ 	 devices.  However, FindFirst returns attribute 40h for them.  */
+       if (ff_blk.ff_attrib == 0x40)
+ 	{
+ 	  size_t cplen = strlen (canon_path);
+ 	  char *pslash = canon_path + cplen - 1;
+ 
+ 	  while (pslash > canon_path + 2 && *pslash != '\\')
+ 	    pslash--;
+ 
+ 	  /* Force it into X:/FOO form.  */
+ 	  if (canon_path[1] == ':')
+ 	    {
+ 	      if (pslash > canon_path + 2)
+ 		memmove (canon_path + 2, pslash,
+ 			 cplen - (pslash - canon_path) + 1);
+ 	      canon_path[2] = '/';
+ 	      goto char_dev;
+ 	    }
+ 	}
  
        /* Directories should have Execute bits set. */
        if (ff_blk.ff_attrib & 0x10)


- Raw text -


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