function uses the identity of the file named by the given
(which must refer to an existing, accessible file)
and the least significant 8 bits of
(which must be nonzero) to generate a
type System V IPC key, suitable for use with
The resulting value is the same for all pathnames that
name the same file, when the same value of
The value returned should be different when the
(simultaneously existing) files or the project IDs differ.
On success the generated
value is returned.
On failure -1 is returned, with
indicating the error as for the
Under libc4 and libc5 (and under SunOS 4.x) the prototype was:
key_t ftok(char *pathname, char proj_id);
but still only 8 bits are used.
Typical usage has an ASCII character
that is why the behavior is said to be undefined when
Of course no guarantee can be given that the resulting
Typically, a best effort attempt combines the given
byte, the lower 16 bits of the inode number, and the
lower 8 bits of the device number into a 32-bit result.
Collisions may easily happen, for example between files on
and files on