嗨,我到达了inode 2,根目录。我知道它的直接块号,也就是265。如何在C中列出根目录的内容?
发布于 2011-05-24 19:28:20
这应该能行。我建议查找opendir()和readdir()的手册页。这不是基于节点。您是否需要能够查找基于inode的目录?
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
int main() {
DIR *dir = opendir("/");
if(dir==NULL) {
perror("Couldn't open dir");
exit(1);
}
printf("opened\n");
struct dirent * entry;
while((entry = readdir(dir))) {
printf("%s\n", entry->d_name);
}
return 0;
}https://stackoverflow.com/questions/6115181
复制相似问题