Is there any way that I can search for a file or a filename using a given inode number?

后端 未结 1 1621
情歌与酒
情歌与酒 2021-01-14 18:06

I am taking in an inode number from a user and I have to search the file system for that file. How do I search through inode numbers. I have to do this using C and unix.

1条回答
  •  悲&欢浪女
    2021-01-14 18:36

    Traverse your filesystem's directories recursively, doing stat (or probably lstat) on each file, comparing st_ino member of struct stat to the inode number you're searching.

    If you didn't have to do it in C, I would recommend find /fs/root -inum N instead.

    0 讨论(0)
提交回复
热议问题