Discussion:
Getting filename from inode # in 'C'
(too old to reply)
Murray Hooper
2005-03-23 21:23:33 UTC
Permalink
I am working on a project on OpenServer 5 that I need to get a filename
(text) back when given an inode #?
any advice on what functions to investigate?
thank you
murray
Tony Lawrence
2005-03-23 21:26:53 UTC
Permalink
Post by Murray Hooper
I am working on a project on OpenServer 5 that I need to get a filename
(text) back when given an inode #?
any advice on what functions to investigate?
thank you
murray
find / -inum 1234

but you need to restrict that to the filesystem that has the one you are
looking for..
--
Unix/Linux/Mac OS X resources: http://aplawrence.com
Murray Hooper
2005-03-23 21:49:00 UTC
Permalink
Post by Tony Lawrence
Post by Murray Hooper
I am working on a project on OpenServer 5 that I need to get a filename
(text) back when given an inode #?
any advice on what functions to investigate?
thank you
murray
find / -inum 1234
but you need to restrict that to the filesystem that has the one you are
looking for..
--
Unix/Linux/Mac OS X resources: http://aplawrence.com
Thanks Tony.

I am trying to do it within a 'C' program if possible?
Tony Lawrence
2005-03-23 23:13:06 UTC
Permalink
Post by Murray Hooper
Post by Tony Lawrence
Post by Murray Hooper
I am working on a project on OpenServer 5 that I need to get a filename
(text) back when given an inode #?
any advice on what functions to investigate?
thank you
murray
find / -inum 1234
but you need to restrict that to the filesystem that has the one you are
looking for..
--
Unix/Linux/Mac OS X resources: http://aplawrence.com
Thanks Tony.
I am trying to do it within a 'C' program if possible?
Well of course it's possible, but you need to re-invent "find" - well ,
not all of it, but you need to walk every directory, read the inode, and
if it matches, print the filename.

You do understand that the ONLY relationship between filenames and
inodes is in directories and that there can be multiple filenames
pointing to the same inode ?
--
Tony Lawrence
Unix/Linux/Mac OS X resources: http://aplawrence.com
Bill Vermillion
2005-03-24 03:35:01 UTC
Permalink
Post by Tony Lawrence
Post by Murray Hooper
Post by Tony Lawrence
Post by Murray Hooper
I am working on a project on OpenServer 5 that I need to get a filename
(text) back when given an inode #?
any advice on what functions to investigate?
thank you
murray
find / -inum 1234
but you need to restrict that to the filesystem that has the one you are
looking for..
--
Unix/Linux/Mac OS X resources: http://aplawrence.com
Thanks Tony.
I am trying to do it within a 'C' program if possible?
Well of course it's possible, but you need to re-invent "find" -
well , not all of it, but you need to walk every directory, read
the inode, and if it matches, print the filename.
You do understand that the ONLY relationship between filenames and
inodes is in directories and that there can be multiple filenames
pointing to the same inode ?
Which applies to hard links.

For symlinks you will have two separate inodes numbers, one for
the symlink and one for the file to which it points.

Bill
--
Bill Vermillion - bv @ wjv . com
Loading...