3

i am tring to add a new feature to bash and the job need a func to get the directory name from the given inode value so how to got this work? i mean if there's some builtin func in bash's source code if not , any help will be accept

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
jyf1987
  • 135
  • 13

2 Answers2

6

This is impossible without searching through the filesystem for a dir that contains a file with the given inode. Filenames are named references to inodes with no backlinks.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
1

List the directory and get the inode of .. then list that and find the name of the file there that has the inode you are looking for.

Null Set
  • 5,374
  • 24
  • 37
  • How do you list the directory if you only know the inode? (That's significantly different than having a file descriptor.) – ephemient Jan 05 '11 at 16:27
  • @ephemient: Whoops. I guess that just seemed like such a useful thing that I assumed you could do it without being in the kernel. – Null Set Jan 05 '11 at 16:36
  • well its this, i am a chinese, and my linux system was configure to zh_CN.utf-8 lang, but as you know windows's default encoding is not this, and once i have use scp to copy files from windows to my linux server,then hold the original encoding, so it will display mass on my linux server, i think i can use ls -i to display all file or directory's inode value , then use cd -i inode_value to enter a directory that display mass – jyf1987 Jan 07 '11 at 05:51
  • this answer closed to my destination – jyf1987 Feb 23 '12 at 14:55