1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified 2001-11-28, by Michael Kerrisk, <mtk-manpages@gmx.net>
24 .\" Changed data type of proj_id; minor fixes
25 .\" aeb: further fixes; added notes.
27 .TH FTOK 3 2001-11-28 "Linux 2.4" "Linux Programmer's Manual"
29 ftok \- convert a pathname and a project identifier to a System V IPC key
33 # include <sys/types.h>
38 .BI "key_t ftok(const char *" pathname ", int " proj_id );
42 function uses the identity of the file named by the given
44 (which must refer to an existing, accessible file)
45 and the least significant 8 bits of
47 (which must be non-zero) to generate a
49 type System V IPC key, suitable for use with
55 The resulting value is the same for all pathnames that
56 name the same file, when the same value of
58 is used. The value returned should be different when the
59 (simultaneously existing) files or the project IDs differ.
61 On success the generated
63 value is returned. On failure \-1 is returned, with
65 indicating the error as for the
71 Under libc4 and libc5 (and under SunOS 4.x) the prototype was
73 .BI "key_t ftok(char *" pathname ", char " proj_id );
79 but still only 8 bits are used. Typical usage has an ASCII character
81 that is why the behaviour is said to be undefined when
85 Of course no guarantee can be given that the resulting
87 is unique. Typically, a best effort attempt combines the given
89 byte, the lower 16 bits of the i\-node number, and the
90 lower 8 bits of the device number into a 32\-bit result.
91 Collisions may easily happen, for example between files on