Mail Archives: djgpp/1998/10/08/14:14:00
On Tue, 6 Oct 1998, Olivier Perron wrote:
> Here are some results: because of the value of SYSROOT being "C:",
> dosutil_expand_path expands /dev/null to c:/dev/null.
> Then a call to 'open' is performed with "c:/dev/null" as first argument.
> It is this call which fails.
>
> A little test program easily shows that 'stat' and 'open' effectively fail
> with "c:/dev/null" but not with "/dev/null".
Seems like the problem is in `putpath', then. But I thought that the
version of `putpath' in the patched libc is already corrected. Nate?
I append below the corrected version of putpath.c. Compile it, put
putpath.o into libc.a, relink, and Bash should work with /dev/null.
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
#include <libc/dosio.h>
#include <libc/farptrgs.h>
#include <go32.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
void
_put_path(const char *path)
{
_put_path2(path, 0);
}
void
_put_path2(const char *path, int offset)
{
int o, space = _go32_info_block.size_of_transfer_buffer - offset;
const char *p = path;
if (path == 0)
{
errno = EFAULT;
abort();
}
if (p[0] && p[1] == ':')
p += 2;
if (strcmp(p, "/dev/null") == 0)
path = "nul";
else if (strcmp(p, "/dev/tty") == 0)
path = "con";
else if (strncmp(p, "/dev/", 5) == 0 && p[5] != 0)
path = p + 5;
_farsetsel(_dos_ds);
/* collapse multiple slashes to a single slash */
for (o=__tb+offset; *path; path++)
{
if (path[0] != '/' || path[1] != '/')
{
_farnspokeb(o, *path);
o++;
if (--space < 2) /* safety check */
break;
}
}
/* remove trailing slash if it doesn't
represent the root directory */
if (o-2 >= __tb+offset
&& _farnspeekb(o-1) == '/'
&& _farnspeekb(o-2) != ':')
o--;
/* null terminate it */
_farnspokeb(o, 0);
}
- Raw text -