Mail Archives: cygwin/2006/02/27/12:41:39
On Mon, Feb 27, 2006 at 05:22:57PM +0000, Eric Blake wrote:
>It looks like d_ino is not being correctly populated within //.
>Running the program below on snapshot 20060220 produced:
A (somewhat) simple test case (patent pending) is nice but it really
should be accompanied with an explanation of the problem. How about
describing *in words* what you think is broken?
cgf
>$ ./foo
>Searching for //eblake, inode 10556217422951964268
>entry 553: name match only (inode 14394969718775064264)
>2098 entries processed
>$ cat foo.c
>#include <stdio.h>
>#include <dirent.h>
>#include <sys/stat.h>
>#include <errno.h>
>#include <unistd.h>
>#include <string.h>
>
>#define DEFAULT_SHARE "eblake"
>
>int main(int argc, char**argv)
>{
> ino_t ino;
> struct stat sb;
> DIR *dirp;
> int i = 0;
>
> switch (argc)
> {
> case 1:
> argv[1] = DEFAULT_SHARE;
> break;
> case 2:
> break;
> default:
> printf("Usage: foo [sharename]\n"
> " Search // for sharename\n");
> return 1;
> }
>
> if (chdir("//") < 0)
> {
> printf("chdir failed: %d %s\n", errno, strerror(errno));
> return 1;
> }
> if (lstat(argv[1], &sb) < 0)
> {
> printf("lstat failed: %d %s\n", errno, strerror(errno));
> return 1;
> }
> ino = sb.st_ino;
> printf("Searching for //%s, inode %llu\n", argv[1], ino);
> if ((dirp = opendir ("..")) == NULL)
> {
> printf("opendir failed: %d %s\n", errno, strerror(errno));
> return 1;
> }
> while (1)
> {
> struct dirent *dp;
>
> errno = 0;
> i++;
> if ((dp = readdir (dirp)) == NULL)
> {
> if (errno)
> {
> printf("opendir failed: %d %s\n", errno, strerror(errno));
> return 2;
> }
> else
> break;
> }
> if (ino == dp->d_ino)
> {
> if (strcasecmp(argv[1], dp->d_name) == 0)
> {
> printf("match found at entry %d\n", i);
> }
> else
> {
> printf("entry %d: inode match only (name %s)\n", i, dp->d_name);
> }
> }
> else if (strcasecmp(argv[1], dp->d_name) == 0)
> {
> printf("entry %d: name match only (inode %llu)\n", i, dp->d_ino);
> }
> }
> printf("%d entries processed\n", i);
> if (closedir (dirp) < 0)
> {
> printf("closedir failed: %d %s\n", errno, strerror(errno));
> return 1;
> }
> return 0;
>}
--
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/
- Raw text -