It seems to me that tmpfs is not re-using inode numbers, but instead creates a new inode number via a +1 sequence everytime it needs a free inode.
Do you know how this is implemented / can you pin-point me to some source code where i could check the algorithm that is used in tmpfs ?
I need to understand this in order to bypass a limitation in a caching system that uses the inode number as its cache key (hence leading to rare, but occuring collisions when inodes are re-used too often). tmpfs could save my day if I can prove that it keeps creating unique inode numbers.
Thank you for your help,
Jerome Wagner
inum or I-node number is an integer associated with a file. Whenever a new file is created, a unique integer number is generated in sequence and associated with the file. This number is nothing but the pointer to the inode structure which contains the meta data of the file.
To get the number of inodes of files in a directory, for example, the root directory, open a terminal window and run the following ls command, where the -l option means long listing format, -a means all files and -i mean to print the index number of each file.
As mentioned earlier, when you create a file system in UNIX, about 1 percent of the total disk space is allocated to the inode table. Every time you create a file in the file system, an inode is allocated to the file.
badblocks is actually present in the root directory as a regular file owned by root and mode 0. root can open it but reading or writing it is undefined. There is some ancient tradition that inodes start from 1, #1 is . badblocks , and #2 is the root directory.
I won't directly answer your question, so I apologize in advance for that.
The tmpfs idea is good, but I wouldn't have my program depend on a more or less obscure implementation detail for generating keys. Why don't you try another method, such as combining the inode number with some other information? Maybe modification date: it's impossible two files get the same inode number AND modification date at the time of key-generation, unless system date changes.
Cheers!
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