www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000248

When Created: 08/27/1998 21:38:03
Against DJGPP version: 2.01
By whom: nate@cartsys.com
Abstract: `stat' of devices tries to read them
`stat' of a device can try to read from it to decide if it is executable.  
This is clearly wrong.

Eli actually fixed this bug.

Solution added: 08/27/1998 21:39:18
By whom: nate@cartsys.com
This patch is due to Eli.  It will reside on my patch site shortly.

*** 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)

Fixed in version 2.02 on 10/27/1998 21:00:25
By whom: dj@delorie.com



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