This is the mail archive of the
cygwin
mailing list for the Cygwin project.
How do you fstat an open directory?
- From: Mark Blackburn <marklist at fangorn dot ca>
- To: cygwin at cygwin dot com
- Date: Mon, 22 Mar 2004 21:30:36 -0500
- Subject: How do you fstat an open directory?
- Reply-to: cygwin at cygwin dot com
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/