如何获取文本文件的 inode 编号列表?在C中
int main(int argc, char *argv[])
{
FILE *pFile;
pFile=fopen("file.txt", "r");
.
.
.
.
fclose(pFile);
system("pause");
return 0;
}
我不知道如何获取inode。
由某人代码添加?
最佳答案
正确吗?
int main (int argc, char *argv[])
{
struct stat fileStat;
int fd=0;
FILE *filename = "infile.txt";
if ( ( fd = open (filename , O_RDONLY) ) == -1){
perror ( "open " );
system("pause");
exit (1) ;
}
if(fstat(fd, &fileStat)<0) return 1;
printf("Information for %s\n",filename);
printf("---------------------------\n");
printf("File Size: \t\t%d bytes\n",fileStat.st_size);
printf("Number of Links: \t%d\n",fileStat.st_nlink);
printf("File inode: \t\t%d\n",fileStat.st_ino);
system("pause");
return 0;
}
关于c - 在C中打印 inode 号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39791426/