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?
Answer: To find a file by its inode number, you can use the argument -inum with the find command.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With