From: Doug Kaufman Newsgroups: comp.os.msdos.djgpp Subject: Re: stat and character devices Date: Thu, 26 Jun 2003 00:43:05 +0000 (UTC) Organization: a2i network Lines: 52 Message-ID: References: <2950-Wed25Jun2003124946+0300-eliz AT elta DOT co DOT il> NNTP-Posting-Host: violet.rahul.net X-Trace: blue.rahul.net 1056588185 21495 66.237.72.28 (26 Jun 2003 00:43:05 GMT) X-Complaints-To: support AT rahul DOT net NNTP-Posting-Date: Thu, 26 Jun 2003 00:43:05 +0000 (UTC) User-Agent: nn/6.6.4 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Ben Peddell writes: (I wrote) > >>>I noticed that stat treats some character devices differently, depending > >>>on whether it is run in a DOS box under Win98 or in plain DOS. The COM > >>>series (com1, com2, etc.) shows as a character device when run under > >>>plain DOS, but not in the DOS box under Win98. >I tested it. It doesn't like long file names in the path. > > >DJGPP CWD=c:/ >Windows CWD=C:\ >crw-r--r-- 1 dosuser dos 0, 0 Jun 26 01:51 $mmxxxx0 >crw-r--r-- 1 dosuser dos 0, 0 Jun 26 01:51 aux >crw-r--r-- 1 dosuser dos 0, 0 Jun 26 01:51 clock$ >crw-r--r-- 1 dosuser dos 0, 0 Jun 26 01:51 com1 >crw-r--r-- 1 dosuser dos 0, 0 Jun 26 01:51 com2 >crw-r--r-- 1 dosuser dos 0, 0 Jun 26 01:51 com3 >crw-r--r-- 1 dosuser dos 0, 0 Jun 26 01:51 com4 >... > >DJGPP CWD=c:/Program Files >Windows CWD=C:\Program Files >ls: com1: No such file or directory (ENOENT) >ls: com2: No such file or directory (ENOENT) >ls: com3: No such file or directory (ENOENT) >ls: com4: No such file or directory (ENOENT) >crw-r--r-- 1 dosuser dos 0, 0 Jun 26 01:51 $mmxxxx0 >crw-r--r-- 1 dosuser dos 0, 0 Jun 26 01:51 aux >crw-r--r-- 1 dosuser dos 0, 0 Jun 26 01:51 clock$ I can confirm this behavior. When not run under bash it seems stranger. Under command.com in Win98 (2nd edition), if you cd to "Program Files" and run the program you get the "No such file" behavior. If you cd to "progra~1", you get the exact same Windows prompt of "Program Files", but it shows the character device. So even though Windows converts the DOS form to a long filename form for the prompt, the behavior of the program depends on the name used on the command line by which you change to that directory. This has some practical effects, since the S_ISCHR testing is used in renaming files that might not be writable on a DOS or Windows machine in programs such as djtarx, tar, and the DJGPP port I did of wget. It isn't very common to need the conversions, but this means that the programs trying to write these COMx files from a unix machine to a DOS/Windows machine may fail to write them, depending on the name of the directory from which the program is run. Doug -- Doug Kaufman Internet: dkaufman AT rahul DOT net