]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/ftok.3
Hyphenation fixes
[thirdparty/man-pages.git] / man3 / ftok.3
1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
2 .\"
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.
6 .\"
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.
11 .\"
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
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Modified 2001-11-28, by Michael Kerrisk, <mtk.manpages@gmail.com>
24 .\" Changed data type of proj_id; minor fixes
25 .\" aeb: further fixes; added notes.
26 .\"
27 .TH FTOK 3 2001-11-28 "GNU" "Linux Programmer's Manual"
28 .SH NAME
29 ftok \- convert a pathname and a project identifier to a System V IPC key
30 .SH SYNOPSIS
31 .nf
32 .B
33 #include <sys/types.h>
34 .B
35 #include <sys/ipc.h>
36 .fi
37 .sp
38 .BI "key_t ftok(const char *" pathname ", int " proj_id );
39 .SH DESCRIPTION
40 The
41 .BR ftok ()
42 function uses the identity of the file named by the given
43 .I pathname
44 (which must refer to an existing, accessible file)
45 and the least significant 8 bits of
46 .I proj_id
47 (which must be nonzero) to generate a
48 .I key_t
49 type System V IPC key, suitable for use with
50 .BR msgget (2),
51 .BR semget (2),
52 or
53 .BR shmget (2).
54 .LP
55 The resulting value is the same for all pathnames that
56 name the same file, when the same value of
57 .I proj_id
58 is used.
59 The value returned should be different when the
60 (simultaneously existing) files or the project IDs differ.
61 .SH "RETURN VALUE"
62 On success the generated
63 .I key_t
64 value is returned.
65 On failure \-1 is returned, with
66 .I errno
67 indicating the error as for the
68 .BR stat (2)
69 system call.
70 .SH "CONFORMING TO"
71 POSIX.1-2001.
72 .SH NOTES
73 Under libc4 and libc5 (and under SunOS 4.x) the prototype was:
74 .sp
75 .RS
76 .BI "key_t ftok(char *" pathname ", char " proj_id );
77 .RE
78 .PP
79 Today
80 .I proj_id
81 is an
82 .IR int ,
83 but still only 8 bits are used.
84 Typical usage has an ASCII character
85 .IR proj_id ,
86 that is why the behavior is said to be undefined when
87 .I proj_id
88 is zero.
89 .LP
90 Of course no guarantee can be given that the resulting
91 .I key_t
92 is unique.
93 Typically, a best effort attempt combines the given
94 .I proj_id
95 byte, the lower 16 bits of the i-node number, and the
96 lower 8 bits of the device number into a 32-bit result.
97 Collisions may easily happen, for example between files on
98 .I /dev/hda1
99 and files on
100 .IR /dev/sda1 .
101 .SH "SEE ALSO"
102 .BR msgget (2),
103 .BR semget (2),
104 .BR shmget (2),
105 .BR stat (2),
106 .BR svipc (7)