# Include <sys/types. h>
# Include <sys/IPC. h>
As follows:
Key_t ftok (char * fname, int ID)
Fname is the specified file name (an existing file name). The current directory is generally used, for example:
Key_t key;
Key = ftok (".", 1); in this way, the fname is set to the current directory.
ID is a subserial number.
In general UNIX implementationS index NodeThe return value of key_t is obtained by adding the subnumber.
For example, if the index node number of a specified file is 65538, it is converted into a hexadecimal value of 0x010002, And the id value you specified is 38, it is converted into a hexadecimal value of 0x26, then the final key_t return value is 0x26010002.
To query the node number of a file index, use LS-I.
After deleting the rebuilt file, the index node number isOperating SystemIt is allocated according to the usage of the file system at that time. Therefore, the index node number obtained is different from the original one.