[comp.lang.perl] Perl op.stat failure

kgallagh@digi.lonestar.org (Kevin Gallagher) (11/09/90)

In article <1219@digi.lonestar.org> kgallagh@digi.lonestar.org (Kevin Gallagher) writes:
>In article <3071@nosc.NOSC.MIL> dennis@peanuts.nosc.mil (Dennis Cottel) writes:
>>In mid-August I posted a followup to a person who found a problem
>>installing Perl on their Apollo.  I confirmed that I, too, had a
>>problem with the op.stat regression test failing.  I posted my log
>>entry:
>>
>>     op.stat... FAILED on test 1
>>        This test opens a file and then looks to see if there is one hard
>>        link, but the link field is still 0.  When I added a close before
>>        the stat, this test worked (but, naturally, test 2 failed).
>>[stuff deleted]
>>The failure happened again when I installed patches through 37.  On a
>>hunch I CRPed onto the node whose disk contains the Perl distribution
>>and the problem went away.  It appears to have something to do with
>>cross-node I/O.  It's nice to know I wasn't seeing things, but kind of
>>scary that such differences from normal UNIX behavior still exist.
>
>I doubt it.  Our installation of Perl passes the op.stat tests regardless of
>the node those tests are run on.  

Well, it turns out I was wrong.  I have perl, pl37, installed.  If I run
op.stat on my node in a directory on the disk in my node, the first op.stat
test passes.  If I creep on to another node (or simply log on to another node)
and run the test in the same directory on my disk, the first op.stat test
fails.  The number of links returned by stat is 0, when it fails.

I tried modifying the op.stat perl script by adding the line

    close(foo);

immediately before the invocation of stat.  Now, it did not matter if I ran it
from my node or some other node, stat always returned 0 as the number of
links.

So, I asked myself the question: "Is the perl stat broken or is Apollo's stat
broken?  To check out the Apollo stat, I ran the following program:

/*
** teststat.c
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>

struct stat buf;
char *path;

main()
{
  path = "./Op.stat.tmp";
  stat(path, &buf);
  printf("%s number of links = %d\n", path, buf.st_nlink);
}  

Well, it did not matter where we ran it, local or remote node, it always
reported 1 link for the file.

If I modified the perl op.stat script NOT to open the file before invoking the
stat command, it always returned 0 links, no matter where I was logged in.

It appears that, on the Apollo, perl's stat only works correctly if the file
is opened AND is located on a a disk in the same node where the script is
executed.  But this is a preliminary guess.  I did not check if the two nodes
I used were on the same or different rings.  Maybe it works OK if the nodes
are in the same ring.  But I am puzzled why perl stat always returns 0 links
when the file is not opened.  Anyway, the problem needs further investigation.
I briefly searched the perl source this evening and suspect that the file
doio.c handles the perl stat processing.

Anyone got a clue what is going on here?