How do you fstat an open directory?
Mark Blackburn
marklist@fangorn.ca
Tue Mar 23 08:06:00 GMT 2004
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/
More information about the Cygwin
mailing list