#include #include #include #include #include #include void find_6l(char *dir, char **p1, ino_t *number) { DIR *d; struct dirent *de; struct stat buf; char *pn; int length; length = strlen(dir); pn = (char *) malloc(sizeof(char) * (length + 258)); strcpy(pn, dir); d = opendir(dir); if (d == NULL) { perror(dir); exit(1); } for (de = readdir(d); de != NULL; de = readdir(d)) { sprintf(pn+length, "/%s", de->d_name); if (stat(pn, &buf) != 0) { perror(pn); exit(1); } printf("pn: %s\n", pn); if (buf.st_mode & S_IFDIR) { if (strcmp(de->d_name, ".") != 0 && strcmp(de->d_name, "..") != 0) { find_6l(pn, p1, number); } } else { if (buf.st_nlink >= 6) { if (*p1 == NULL) { *p1 = strdup(pn); *number = buf.st_ino; } else if (buf.st_ino == *number) { printf("%s\n%s\n", *p1, pn); exit(0); } } } } closedir(d); free(pn); } int main() { ino_t num; char *firstpn; firstpn = NULL; find_6l(".", &firstpn, &num); return 0; }