1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified 2001-11-28, by Michael Kerrisk, <mtk.manpages@gmail.com>
26 .\" Changed data type of proj_id; minor fixes
27 .\" aeb: further fixes; added notes.
29 .TH FTOK 3 2021-03-22 "GNU" "Linux Programmer's Manual"
31 ftok \- convert a pathname and a project identifier to a System V IPC key
34 .B #include <sys/ipc.h>
37 .BI "key_t ftok(const char *" pathname ", int " proj_id );
41 function uses the identity of the file named by the given
43 (which must refer to an existing, accessible file)
44 and the least significant 8 bits of
46 (which must be nonzero) to generate a
48 type System V IPC key, suitable for use with
54 The resulting value is the same for all pathnames that
55 name the same file, when the same value of
58 The value returned should be different when the
59 (simultaneously existing) files or the project IDs differ.
61 On success, the generated
64 On failure \-1 is returned, with
66 indicating the error as for the
70 For an explanation of the terms used in this section, see
78 Interface Attribute Value
81 T} Thread safety MT-Safe
87 POSIX.1-2001, POSIX.1-2008.
89 On some ancient systems, the prototype was:
93 .BI "key_t ftok(char *" pathname ", char " proj_id );
101 but still only 8 bits are used.
102 Typical usage has an ASCII character
104 that is why the behavior is said to be undefined when
108 Of course, no guarantee can be given that the resulting
111 Typically, a best-effort attempt combines the given
113 byte, the lower 16 bits of the inode number, and the
114 lower 8 bits of the device number into a 32-bit result.
115 Collisions may easily happen, for example between files on