C
cartercc
This is a listing named testinode.c:
1 #include <stdio.h>
2 #include <sys/stat.h>
3 int main()
4 {
5 char filename[256] = "test.txt";
6 struct stat filestat;
7 stat(filename, &filestat);
8 printf("st_ino is %d\n", filestat.st_ino);
9 return 0;
10 }
When I run it, it prints out the inode of the file, like this:
$ ./testinode.exe => st_ino is 102832
I can reverse this to go the other way, like this:
$ find -inum 102832 => ./test.txt
QUESTION: Is there any built in function, library function, or system call that allows me to use the inode directly? That is, change line 7 above to something like this:
stat(inode, &filestat);
where 'inode' is a number like 102832?
Thanks much, CC.
1 #include <stdio.h>
2 #include <sys/stat.h>
3 int main()
4 {
5 char filename[256] = "test.txt";
6 struct stat filestat;
7 stat(filename, &filestat);
8 printf("st_ino is %d\n", filestat.st_ino);
9 return 0;
10 }
When I run it, it prints out the inode of the file, like this:
$ ./testinode.exe => st_ino is 102832
I can reverse this to go the other way, like this:
$ find -inum 102832 => ./test.txt
QUESTION: Is there any built in function, library function, or system call that allows me to use the inode directly? That is, change line 7 above to something like this:
stat(inode, &filestat);
where 'inode' is a number like 102832?
Thanks much, CC.