This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: FORTRAN rewind on NFS filesystems


[ I'm re-cc'ing this to the GCC bugs list ]

Mathias Puetz wrote:

> I just compiled with gcc/g77-2.95.2 and the problem persists.
> Unfortunately I can't test with another implementation
> of NFS, we only have Linux boxes around here.

To refresh memories, this is the problematic code.  It works on a local
file system (as it should):

      PROGRAM rew
      OPEN(FILE='testfile',UNIT=10,STATUS='new')
      WRITE(10,*) 'Totally Wrong!'
      REWIND(10)
      WRITE(10,*) 'Right!'
      CLOSE(10)
      END

The error message when the file "testfile" resides on a NFS2 file system
is:

endfile: truncation failed in endfile
apparent state: unit 10 named testfile
last format: list io
lately writing direct formatted external IO
Aborted (core dumped)

The error is probably caused by the following chain of events resulting
from the REWIND statement above (file egcs/libf2c/libI77/endfile.c):

        loc=ftell(bf = b->ufd);
        fseek(bf,0L,SEEK_END);
        len=ftell(bf);
        if (loc >= len || b->useek == 0 || b->ufnm == NULL)
                return(0);
        fclose(b->ufd);
        if (!loc) {
                if (!(bf = fopen(b->ufnm, f__w_mode[b->ufmt])))
                        rc = 1;
                if (b->uwrt)
                        b->uwrt = 1;
                goto done;
	....
done:
        f__cf = b->ufd = bf;
        if (rc)
                err(a->aerr,111,"endfile");
        return 0;
        }

After REWIND, `loc' should be zero, so in fact only the close and the
reopen happen.  So I suspect that for some reason the fopen(b->ufnm,
f__w_mode[b->ufmt]) is failing.

Someone with access to g77 and NFS2 willing to test this (e.g. by
printing b->ufnm, f__w_mode[b->ufmt] and perror("blah") shortly after
the fopen) ?

Thanks in advance,

-- 
Toon Moene (toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
GNU Fortran: http://gcc.gnu.org/onlinedocs/g77_news.html

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]