Mail Archives: djgpp-workers/1998/08/25/02:43:00
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 -