This is the mail archive of the cygwin 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]
Other format: [Raw text]

lstat on FAT - Was: Problem with find on FAT drives


Hi!

I just found a strange problem when using find on a FAT drive.
I got: "find: .\tmp changed during execution of find"

OK, I analyzed the problem a bit and found that lstat can give different inode numbers on fat, see the attached testcase.

To test this you have to have a directory called tmp in your
current working directory.

On a FAT drive you get:
$ /tmp/lstat_test.exe
Checking pathname: .\tmp
cur_stat_buf.st_ino: -1375632239
stat_buf.st_ino: 802199907
Error Inode numbers are different!

Bug or feature?

Volker

--
PGP/GPG key  (ID: 0x9F8A785D)  available  from  wwwkeys.de.pgp.net
key-fingerprint 550D F17E B082 A3E9 F913  9E53 3D35 C9BA 9F8A 785D
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>

int
main (int argc, char **argv)
{
  char pathname[]=".\\tmp";
  long a,b;
  struct stat stat_buf, cur_stat_buf;

  /* get &stat_buf  */
  lstat (pathname, &stat_buf);

  if (chdir (pathname) < 0)
	{
	  printf("Errno: %d Path: %s\n", errno, pathname);
	  return;
	}

  /* get &cur_stat_buf. Should be the same as stat_buf. */
  if (lstat (".", &cur_stat_buf) != 0)
	printf("Errno: %d Path: %s\n", errno, pathname);
  /* Use a and b intsead of the variables, otherwise you get strange
     results with printf. */
  a = cur_stat_buf.st_ino;
  b = stat_buf.st_ino;
  printf("Checking pathname: %s\ncur_stat_buf.st_ino: %d\nstat_buf.st_ino: %d\n",pathname, a, b );
  if (cur_stat_buf.st_dev != stat_buf.st_dev ||
	  cur_stat_buf.st_ino != stat_buf.st_ino)
	printf("Error Inode numbers are different!\n");
}

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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