Date: Wed, 18 Aug 93 16:50:22 +0200 From: kuku AT acds DOT physik DOT rwth-aachen DOT de (Christoph Kukulies) To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Novell problem solved Finally I solved the problems I had with go32 under NOVELL. The example below should return 0 from both fstat calls if the file exists and is located on a network drive. Under BC 3.0 and TC it returns a -1 from the second fstat. #include #include main(argc,argv) int argc; char **argv; { int i,j; struct stat buf; if(argc!=2) printf(" pass filename\n"),exit(1); j=open(argv[1],O_RDONLY,0666); printf("fstat returns: %d\n",fstat(j,&buf)); i=creat(argv[1],0666); close(i); printf("fstat returns: i=%d %d\n",i,fstat(j,&buf)); } This also affects gcc compiled programs since open/creat etc. are implemented via go32 (exphdlr.c) turboassist() function. As GO32 is married with TC there can only be a workaround if it can be done with means of TC. The above code doesn't seem to make any sense but it is the boiled down sequence of calls that occurs when f2c decides to open a file and goes through the logic of various open's, creat's and fopens before it finally uses the file. Further investigations lead to the conclusion that when fstat calls filelength() - a TC internal function which does an int21h with 4200, 4201 and 4202 - the in21h 4202h returns an 'invalid file handle' error. This is because Borland C uses a creat rather than an open with truncate in it's creat implementation. I solved the problem by replacing the creat in exphdlr.c by an open with O_CREAT|O_TRUNC,S_IREAD|S_IWRITE flags. Sorry for not supplying a diff but I have so many 1.09, 1.10 playgrounds on my disk that I was not able to pull a fresh .zip file and run the diff. It's only one line, anyway in exphdlr.c, routine turboassist around line 819: case 1: retrieve_string(p1+ARENA, buf, 0); /* r = creat(buf, S_IREAD | S_IWRITE); */ r = open(buf, _fmode | O_CREAT | O_TRUNC | O_WRONLY , S_IREAD | S_IWRITE); I replaced the creat by an open. From all I tested by now - some complex f2c compiled programs using a lot of different files/filetypes I can say it works. If anyone else finds any objecting behaviour, let me know. --Chris Christoph P. U. Kukulies kuku AT acds DOT physik DOT rwth-aachen DOT de *** Error code 1 Stop.