From: Doug Kaufman Newsgroups: comp.os.msdos.djgpp Subject: stat and character devices Date: Wed, 25 Jun 2003 05:56:30 +0000 (UTC) Organization: a2i network Lines: 33 Message-ID: NNTP-Posting-Host: violet.rahul.net X-Trace: blue.rahul.net 1056520590 19143 66.237.72.28 (25 Jun 2003 05:56:30 GMT) X-Complaints-To: support AT rahul DOT net NNTP-Posting-Date: Wed, 25 Jun 2003 05:56:30 +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 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 couldn't find a reference to this in searching the archives. This problem doesn't apply to PRN or the LPT series. A test program that demonstrates this follows. The results of running the program depend on whether or not it is run on plain DOS. I am using DJGPP 2.03 libc.a from December 24, 2001. Doug #include #include int main() { char *base; struct stat s; base="com1"; stat(base, &s); printf("The value of base is %s\r\n", base); printf("The value of st_dev is %d.\r\n", s.st_dev); printf("The value of st_mode is %d.\r\n", s.st_mode); if(S_ISCHR(s.st_mode)) { printf("The file is a character device.\r\n"); }else { printf("The file is not a character device.\r\n"); } return 1; } -- Doug Kaufman Internet: dkaufman AT rahul DOT net