Section: Linux Programmer's Manual (3)
Return to Main Contents
ftok - convert a pathname and a project identifier to a System V IPC key
key_t ftok(const char *pathname, int proj_id);
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
This page is part of release 3.54 of the Linux
A description of the project,
and information about reporting bugs,
can be found at
- RETURN VALUE
- CONFORMING TO
- SEE ALSO
This document was created by
using the manual pages.
Time: 14:08:36 GMT, January 18, 2018