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]

How do you fstat an open directory?


I've been trying to get chgrp -R from coreutils working and I ran up against this problem. I can't properly stat a directory whose file descriptor I get from the dirfd function/macro.

mark@althor ~
$ cat > testcase.c
#include <stdlib.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>


int main() { DIR *dirp; int fd; struct stat sb; dirp = opendir("d"); fd = dirfd(dirp); fstat(fd, &sb); printf("inode of d:%llu\n", sb.st_ino); }

mark@althor ~
$ gcc testcase.c -o testcase

mark@althor ~
$ mkdir d

mark@althor ~
$ ./testcase.exe
inode of d:17489383932880356520

mark@althor ~
$ ls -id d
3659174697343209 d/

mark@althor ~
$

Notice that the inodes don't match from ls -id and from my test program. Am I doing something wrong?

Mark Blackburn

--
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]