delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/09/15/06:52:47

Date: Wed, 15 Sep 1999 11:42:15 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Michel de Ruiter <mdruiter AT cs DOT vu DOT nl>, michel AT smr DOT nl
cc: djgpp-workers AT delorie DOT com
Subject: Re: Chmod bug
In-Reply-To: <m11QsTw-0006OPC@galjas.cs.vu.nl>
Message-ID: <Pine.SUN.3.91.990915114048.27871A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 14 Sep 1999, Michel de Ruiter wrote:

> %DJDIR%\bin\echo.exe xmsxxxx0mytext
> 
> This locks up DOS.

As Hans-Bernhard already guessed, XMSXXXX0 is the device name exported
by HIMEM.SYS for the XMS driver.  Similarly, EMMXXX0 is the devive
name exported by EMM386.EXE.

Character devices appear as files that are present in any directory
(because the device drivers that sit on the device chain are given a
chance to service filename-related functions ahead of core DOS file
code).  That's how you have CON and NUL in any directory.

Programs that generate arbitrary file names should run them through
`stat' to make sure they didn't bump into a character device, before
they use these names.

Users who generate arbitrary file names should do the same ;-).

> - One minor one, the fact that arguments are globbed even when they do
>   not contain special characters. This should be easy to fix.

This is not as simple as it sounds, because the standard globbing
function can be replaced by the application.  Can you submit a change
that does this?

> - One concerning the filename xmsxxxx0mytext, where mytext may be
>   whatever you want, but at least 1 character.

This is how devices behave.  You will also see this with XMSXXX0.EXT,
where EXT is any extension.  For example, the same happens with prn.c,
aux.txt, etc.  I added a special function to the DJGPP port of GNU Tar
to make sure some tarball that comes from Unix with files named like
above doesn't wedge the system.  (If you are interested, see the
function `rename_if_dos_device_name' in extract.c from tar112s.zip.)

> The problem is in _chmod:

That's right, `_chmod' doesn't support devices.  This is one of the
several manifestations of the half-hearted support for devices in DOS:
some DOS functions choke/fail on devices.  We added a call to
findfirst in `access', exactly for this reason.  But `__file_exists'
is supposed to be as fast and as lean-and-mean as it can get...

> I do not know of a simple workaround. Anyone?

How about not using such file names?

I'm serious.  A Unix user that uses, say, /dev/rsd0a (one of the names
of a hard disk partition) or /dev/pty0 will probably get some serious
surprises as well, no?

> PS: I think any mail from @delorie.com to @cs.vu.nl is bounced

That's right, your mail server rejects at least my mail.  Please talk
to your sysadmins, or arrange for an appropriate Reply-to header.

- Raw text -


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