This is the mail archive of the mailing list for the Cygwin project.

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

Possible insight into find/du problems

I have been looking into the problem with the "find" command returning error
messages like "No such file or directory".

(I'll admit to being a newbie to cygwin upfront, so apologies for any
obvious mistakes in what follows. This problem was biting me as I got
started with cygwin so I took it as a challenge to get my feet wet.)

I did some tracing through find and determined that what is happening
relates to chdir() and mounted directories. Here is my mount output (after a
default net setup):

Device              Directory           Type         Flags
C:\bin              /usr/bin            user         binmode
C:\lib              /usr/lib            user         binmode
c:                  /                   user         binmode

(Also,   569k 2000/05/15 C:\bin\cygwin1.dll)

Assume autoexec.bat exists in c:\ (this is in Win98).

The following program illustrates the problem:

#include <stdio.h>
#include <sys/stat.h>
#include <sys/unistd.h>

int main(int argc, char * argv[])
  struct stat  statBuf;
  int  i;
  char  dir[1024] = {'\0'};

  getcwd(dir, sizeof(dir));
  printf("cwd: %s\n", dir);

  for (i = 1; i < argc; i++) {
    if (lstat(argv[i], &statBuf) != 0) {
      fprintf(stderr, "stat failed on %s\n", argv[i]);
    if (S_ISDIR(statBuf.st_mode)) {
      printf("%s is a directory\n", argv[i]);
      getcwd(dir, sizeof(dir));
      printf("cwd: %s\n", dir);

  return (0);

The following results when run:

/% ~/stat bin autoexec.bat
cwd: /
bin is a directory
cwd: /usr
stat failed on autoexec.bat
/% ~/stat windows autoexec.bat
cwd: /
windows is a directory
cwd: /

Note that bin is mounted as /usr/bin while windows has no mount point. The
relative chdir(..) gets confused and makes cwd /usr instead of c:\
(/). Obviously, autoexec.bat does not exist in /usr so the lstat()
fails. This is what essentially happens in find, as well.

Note that on the same system, the following works correctly:

/% cd bin
/bin% cd ..
/% cygpath -w /bin
/% cygpath -w /usr/bin

I looked through, but w/o being able to trace through the code in
gdb, I do not grok what is happening in path_conv::check(). (I have not
figured out how to build and debug cygwin1.dll yet. Any hints?)

Hopefully someone more up on the intricacies of and mounts can
sort this one out.


Want to unsubscribe from this list?
Send a message to

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