Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to open file by known inode

Tags:

python

I get an inode for some logging file like '/tmp/logging'
and I want to open it via inode, NOT path.
How to do it?

like image 851
kerwin Avatar asked Mar 25 '12 06:03

kerwin


People also ask

Is it possible to find a file by knowing only its inode number?

Answer: To find a file by its inode number, you can use the argument -inum with the find command.

How do I access inode in Linux?

You can also use the ls command, together with the -i option, to get a file's inode number. This command lists files and directories within the filesystem.

What information does inode hold?

Inodes store information about files and directories (folders), such as file ownership, access mode (read, write, execute permissions), and file type. On many older file system implementations, the maximum number of inodes is fixed at file system creation, limiting the maximum number of files the file system can hold.


2 Answers

In general you cannot do this from user-space because the system routines accept a path as an argument.

Take a look at this post.

like image 80
kch Avatar answered Sep 26 '22 22:09

kch


Short of a brute-force search of the filesystem for the inode (ex, find / -inum $X), you can't.

See the discussion here: http://coding.derkeiler.com/Archive/Perl/comp.lang.perl.misc/2006-05/msg02223.html

like image 28
David Wolever Avatar answered Sep 24 '22 22:09

David Wolever