I have an AFS problem and would like to find out if it is a bug or if I
am trying to do something that is unsupported.  I am running AFS on a
hp9000/s700 running HP-UX 9.0.

The problem is with creating a scratch file by doing an open on it and
then unlinking it.  This works fine for local HP-UX files and for NFS
mounted files but it doesn't work for AFS files.  When I do a ftruncate
on an unlinked file in AFS the ftruncate fails.

Steve Ellcey
[EMAIL PROTECTED]


Below is the program I am using, if the unlink is removed (or moved to
the end of the program) then everything works fine.  I do an unlink
after creating the file so that the file will disappear after the
program dies even if it core-dumps and has no chance to unlink the
file before stopping.


    extern int errno;
    #include <fcntl.h>
    #include <unistd.h>
    main ()
    {
        int fd,j;
        char name[80];
        strcpy(name,tempnam(NULL,NULL));
        fd = open(name,O_RDWR | O_CREAT, 438);
        printf("open of %s returns %d\n",name,fd);
        j = unlink(name);
        printf("unlink returns %d\n",j);
        j = write(fd,"hello world",10);
        printf("write of 10 bytes returns %d\n",j);
        j = ftruncate(fd,(size_t) 5);
        printf("truncate to 5 bytes returns %d\n",j);
        if (j != 0) printf("errno is %d\n",errno);
        exit(0);
    }


If I run with TMPDIR as a local directory:

        [hpsje - sje.10] $ TMPDIR=/tmp ./x
        open of /tmp/AAAa04055 returns 3
        unlink returns 0
        write of 10 bytes returns 10
        truncate to 5 bytes returns 0

If I run with TMPDIR as a NFS directory:

        [hpsje - sje.10] $ TMPDIR=/nfs/campy/tmp ./x
        open of /usr/tmp/AAAa04056 returns 3
        unlink returns 0
        write of 10 bytes returns 10
        truncate to 5 bytes returns 0

If I run with TMPDIR as a AFS directory:

        [hpsje - sje.10] $ TMPDIR=/afs/ch/public/sje ./x
        open of /afs/ch/public/sje/AAAa04057 returns 3
        unlink returns 0
        write of 10 bytes returns 10
        truncate to 5 bytes returns -1
        errno is 102




Reply via email to