Subject: Bug in stat()?
From: Eric Blake <[email-masked]>
To: [email-masked]
Date: Tue, 30 Apr 2002 14:30:51 -0600

I am running into weird behavior with stat().  I am getting the same
st_ino number for two distinct directories.  When using the jikes
compiler on the GNU Classpath project (the upstream source of libjava in
gcc), jikes is keying off of the inode number to determine where to
write .class files.  Because the inode number is a duplicate, jikes is
making the wrong choice, and then failing to compile.

I've simplified the demonstration of the problem as follows:
$ cd /tmp
$ cat blah.cpp
#include <sys/stat.h>
#include <stdio.h>
int main(int argc, char** argv)
{
    struct stat status;
    int result;
    result = stat("./java/net", &status);
    printf("net (%d): %d, %d\n", result, status.st_dev, status.st_ino);
    result = stat("./java/nio", &status);
    printf("nio (%d): %d, %d\n", result, status.st_dev, status.st_ino);
    return 0;
}
$ g++ blah.cpp -o blah
$ cd ~/cp/lib
$ rm -Rf java
$ mkdir java java/net
$ /tmp/blah
net (0): 4096, 547532427
nio (-1): 0, 0
$ mkdir java/nio
$ /tmp/blah
net (0): 4096, 547532427
nio (0): 4096, 547532427
$ cd /tmp
$ rm -Rf java
$ mkdir java java/net java/nio
$ /tmp/blah
net (0): 4096, 314387057
nio (0): 4096, 311437853

Notice that in the /tmp directory, stat() correctly gave different
st_ino values for the two newly created directories.  However, in
~/cp/lib, BOTH directories are given the inode of 547532427, even though
they are distinct objects.

Is there a bug in the implementation of <sys/stat.h>?  I am running the
latest version of cygwin (1.3.10-1) and gcc (2.95.3-5) unmodified, with
the root directory located at d:\cygwin on a Win98 box.

-- 
This signature intentionally left boring.

Eric Blake             [email-masked]
  BYU student, free software programmer

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/