delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/06/26/10:15:38

From: Ben Peddell <killer DOT lightspeed AT bigpond DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.1) Gecko/20020826
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: stat and character devices
References: <bdbdie$im7$1 AT blue DOT rahul DOT net> <2950-Wed25Jun2003124946+0300-eliz AT elta DOT co DOT il> <ga7jfv0tk254jg05c21ran3ligd9lrc96l AT 4ax DOT com> <XDjKa.1201$p8 DOT 45122 AT newsfeeds DOT bigpond DOT com> <1438-Wed25Jun2003224117+0300-eliz AT elta DOT co DOT il>
Lines: 185
Message-ID: <20DKa.1681$p8.68983@newsfeeds.bigpond.com>
Date: Thu, 26 Jun 2003 19:39:27 +1000
NNTP-Posting-Host: 144.139.175.171
X-Trace: newsfeeds.bigpond.com 1056636030 144.139.175.171 (Fri, 27 Jun 2003 00:00:30 EST)
NNTP-Posting-Date: Fri, 27 Jun 2003 00:00:30 EST
Organization: Telstra BigPond Internet Services (http://www.bigpond.com)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote:
>>From: Ben Peddell <killer DOT lightspeed AT bigpond DOT com>
>>Newsgroups: comp.os.msdos.djgpp
>>Date: Thu, 26 Jun 2003 02:08:01 +1000
>>
>>I tested it. It doesn't like long file names in the path.
> 
> 
> Thanks!
> 
> Hmm... I wonder why does that only affect COMx, not the other devices.
> It doesn't sound like a DJGPP problem, since we treat all devices the
> same, I think.
> 
> Also note that AUX, which is an alias for one of the COMx, is
> supported no matter what's the value of CWD.

First, AUX and COM1 are different devices in MS-DOS.
 From MSD:

Device        Filename  Units    Header      Attributes
------------  --------  -----  ---------  ----------------
...
AUX                            0070:0028  1...............
PRN                            0070:003A  1.1.....11......
CLOCK$                         0070:004C  1...........1...
Block Device              3    0070:005E  ....1...11....1.
COM1                           0070:006A  1...............
LPT1                           0070:007C  1.1.....11......
LPT2                           0070:008E  1.1.....11......
LPT3                           0070:00A0  1.1.....11......
...

The "Block Device" here is "A:-C:" in mem.

Also, I got the names of the devices from "mem /d /p". I could have 
included nul, but it isn't listed by mem. Also, I couldn't include 
"DblBuff$" since it has lower-case letters in its name, and will never 
match the uppercase search.

I tried "echo >com1" in COMMAND.COM. When I was in a directory that did 
not need the LFN API, it basically said "Access Denied writing device 
com1, Abort, Retry, Ignore, Fail?" (it was a longer error string than 
that). When I tried it in a directory that needed the LFN API, it said 
"File Creation Error".
I checked in bash, and the same thing resulted in a fail for a short 
name and "ENOENT" for a long name.
I wrote a short program to check it with DJGPP:

===== [Start of file "testopen.c"] =====
#include <stdio.h>
#include <errno.h>

void testopen (char *name){
     FILE *f = NULL;
     int tb;
     printf ("%s: open ", name);
     fflush (stdout);
     errno = 0;
     if ((f = fopen (name,"wb")) != NULL){
         printf ("succeeded");
         fflush (stdout);
         fclose (f);
     } else {
         printf ("failed");
         fflush (stdout);
     }
     if (errno != 0){
         perror ("");
     } else {
         printf ("\n");
     }
}




int main (int argc, char **argv){
     int n;
     for (n=1; n<argc; n++){
         testopen (argv[n]);
     }
     return 0;
}
===== [End of file "testopen.c"] =====

and used it with the previously posted script (minus the last two 
sections, and with "ls -l" replaced with "/testopen". It showed that 
lpt[1-3], com[1-4] and prn did not like the LFN API.
However, COMMAND.COM fares fine when you say "\dev\com1" instead of just 
"com1".

Here's the output from "/testdev.sh >testdev.txt 2>&1" in bash:

===== [Start of file "testdev.txt"] =====
Devices are:

$mmxxxx0
aux
clock$
com1
com2
com3
com4
con
config$
dblsysh$
ifs$hlp$
lpt1
lpt2
lpt3
mscd001
prn
setverxx
xmsxxxx0


DJGPP CWD=c:/
Windows CWD=C:\
$mmxxxx0: open succeeded
aux: open succeeded
clock$: open succeeded
com1: open succeeded
com2: open succeeded
com3: open succeeded
com4: open succeeded
con: open succeeded
config$: open succeeded
dblsysh$: open succeeded
ifs$hlp$: open succeeded
lpt1: open succeeded
lpt2: open succeeded
lpt3: open succeeded
mscd001: open succeeded
prn: open succeeded
setverxx: open succeeded
xmsxxxx0: open succeeded


DJGPP CWD=c:/Program Files
Windows CWD=C:\Program Files
$mmxxxx0: open succeeded
aux: open succeeded
clock$: open succeeded
com1: open failed: No such file or directory (ENOENT)
com2: open failed: No such file or directory (ENOENT)
com3: open failed: No such file or directory (ENOENT)
com4: open failed: No such file or directory (ENOENT)
con: open succeeded
config$: open succeeded
dblsysh$: open succeeded
ifs$hlp$: open succeeded
lpt1: open failed: No such file or directory (ENOENT)
lpt2: open failed: No such file or directory (ENOENT)
lpt3: open failed: No such file or directory (ENOENT)
mscd001: open succeeded
prn: open failed: No such file or directory (ENOENT)
setverxx: open succeeded
xmsxxxx0: open succeeded


DJGPP CWD=c:/progra~1
Windows CWD=C:\Program Files
$mmxxxx0: open succeeded
aux: open succeeded
clock$: open succeeded
com1: open succeeded
com2: open succeeded
com3: open succeeded
com4: open succeeded
con: open succeeded
config$: open succeeded
dblsysh$: open succeeded
ifs$hlp$: open succeeded
lpt1: open succeeded
lpt2: open succeeded
lpt3: open succeeded
mscd001: open succeeded
prn: open succeeded
setverxx: open succeeded
xmsxxxx0: open succeeded


===== [End of file "testdev.txt"] =====

- Raw text -


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