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
Asked
Active
Viewed 1,912 times
3
-
Is the inode the inode of a directory you want the name of, or is it the inode of a file in some containing directory which you want to know the name of? – Null Set Jan 05 '11 at 15:48
-
2You do realize that a given file can be in several different directories, don't you? – David Thornley Jan 05 '11 at 18:03
-
Could you give an example of how you might use this feature (and how it is useful)? – nategoose Jan 05 '11 at 22:41
2 Answers
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
-