14int main(
int argc,
char* argv[])
20 fprintf(stderr,
"Usage: readdir_inode dir\n");
24 dirp = opendir(argv[1]);
26 perror(
"failed to open directory");
32 while (dent != NULL) {
33 if (strcmp(dent->d_name,
".") != 0 && strcmp(dent->d_name,
"..") != 0) {
34 printf(
"%llu %d %s\n", (
unsigned long long)dent->d_ino,
35 (
int)dent->d_type, dent->d_name);
36 if ((
long long)dent->d_ino < 0)
37 fprintf(stderr,
"%s : bad d_ino %llu\n",
38 dent->d_name, (
unsigned long long)dent->d_ino);
39 if ((dent->d_type < 1) || (dent->d_type > 15))
40 fprintf(stderr,
"%s : bad d_type %d\n",
41 dent->d_name, (
int)dent->d_type);
43 if (dent->d_type != DT_DIR)
44 fprintf(stderr,
"%s : bad d_type %d\n",
45 dent->d_name, (
int)dent->d_type);
50 perror(
"failed to read directory entry");