www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/08/14:14:00

Date: Tue, 6 Oct 1998 15:30:44 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Olivier Perron <perron AT art DOT alcatel DOT fr>
cc: M DOT A DOT Bukin AT ino DOT nsk DOT ru, nate AT cartsys DOT com, djgpp AT delorie DOT com
Subject: Re: /dev/null problems with bash when rebuild from sources
In-Reply-To: <Pine.GSO.4.05.9810061334420.5502-100000@rtbsci146s>
Message-ID: <Pine.SUN.3.91.981006152624.17517B-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

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 -


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