1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Modified 2001-11-28, by Michael Kerrisk, <mtk.manpages@gmail.com>
6 .\" Changed data type of proj_id; minor fixes
7 .\" aeb: further fixes; added notes.
9 .TH FTOK 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
11 ftok \- convert a pathname and a project identifier to a System V IPC key
14 .RI ( libc ", " \-lc )
17 .B #include <sys/ipc.h>
20 .BI "key_t ftok(const char *" pathname ", int " proj_id );
24 function uses the identity of the file named by the given
26 (which must refer to an existing, accessible file)
27 and the least significant 8 bits of
29 (which must be nonzero) to generate a
31 type System V IPC key, suitable for use with
37 The resulting value is the same for all pathnames that
38 name the same file, when the same value of
41 The value returned should be different when the
42 (simultaneously existing) files or the project IDs differ.
44 On success, the generated
47 On failure \-1 is returned, with
49 indicating the error as for the
53 For an explanation of the terms used in this section, see
61 Interface Attribute Value
64 T} Thread safety MT-Safe
70 POSIX.1-2001, POSIX.1-2008.
72 On some ancient systems, the prototype was:
76 .BI "key_t ftok(char *" pathname ", char " proj_id );
84 but still only 8 bits are used.
85 Typical usage has an ASCII character
87 that is why the behavior is said to be undefined when
91 Of course, no guarantee can be given that the resulting
94 Typically, a best-effort attempt combines the given
96 byte, the lower 16 bits of the inode number, and the
97 lower 8 bits of the device number into a 32-bit result.
98 Collisions may easily happen, for example between files on