On 03/10/05, John E. Malmberg <[EMAIL PROTECTED]> wrote:
> Sebb wrote:
> > On 03/10/05, John E. Malmberg <[EMAIL PROTECTED]> wrote:
> >
> >>Sebb wrote:
> >>
> >>>On 03/10/05, John E. Malmberg <[EMAIL PROTECTED]> wrote:
> >>>
> >>>
> >>>>New files opened for write are created in the first directory of a
> >>>>search list.  New files opened for append are created in the last
> >>>>directory of a search list.
> >>>
> >>>Are you sure appended files use the last directory?
> >>>
> >>>This doesn't happen with Perl 5.5-3A3.
> >>
> >>I am going by the behavior of the file system.
> >
>
> > When using C on VMS 7.3-2 on an ODS-2 volume the following code:
> >
> > #include stdio
> > main(){
> >    FILE *out=fopen("chain:c.tmp","a");
> >    if (out == NULL) perror("fopen");
> >    fprintf(out,"test\n");
> >    fclose(out);
> > }
> >
> > creates the output file in the first link in the chain, not the last.
> > But if c.tmp already exists elsewhere in the chain, it is appended to 
> > correctly.
>
> And that is going through the CRTL.  Until your example, I was not aware
> that it was behaving differently than what the file system does when you
> make the same request with one call instead of several.
>
> The implication here is that the CRTL looked for the file in one
> operation and when it did not find it, did a create as as separate
> operation.
>
> If you try the same experiment from DCL you will get a different result.

How are you doing it using DCL?

I can't reproduce the behaviour you are reporting.

> And it is quite possible that if you use the RMS extensions to the
> UNIXIO, Standard IO open/creat calls to convert an open for write to do
> a "create if non-existent", it may behave differently than fopen().
>

This behaves the same as fopen():

#include stdio
#include fcntl
#include unistd

main(){
   int fd = open("chain:c.tmp",O_APPEND|O_CREAT);
   if (fd==-1) perror("open");
   close(fd);
}

Omitting the O_CREAT causes a failure if the file does not exist (as expected).

> Personally I think that having append go to the end of the search list
> to create a new file is an undesired and unexpected feature, but that is
> the way it works.

I agree it's undesired and unexpected.

I just don't see that it is working that way ...

> It appears that possibly when fopen() was implemented, that either
> someone deliberately decided to make sure the file was always created at
> the beginning of a search list, or it could have been an artifact of how
> it was implemented.  That was so long ago, it might take a while to find
> out for sure.  In any case it appears that the the CRTL documentation
> needs an update.

It's not only the CRTL.

APPEND 1,2 chain:3 /NEW
and
COPY 1,2 chain:4

also create the file at the start of the chain, and they don't use the CRTL

> Like Perl, the CRTL is in many ways trying to be more compatible with
> UNIX behavior than it is with expected VMS behavior.  Unfortunately

But Unix does not have chained logicals, so there's no behaviour to be
compatible with.

S.

Reply via email to