]>
Commit | Line | Data |
---|---|---|
e9ce8d39 A |
1 | .\" $OpenBSD: ftok.3,v 1.8 1999/07/07 10:55:36 aaron Exp $ |
2 | .\" | |
3 | .\" Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com> | |
4 | .\" All rights reserved. | |
5 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" 3. The name of the author may not be used to endorse or promote products | |
15 | .\" derived from this software without specific prior written permission. | |
16 | .\" | |
17 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
18 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
19 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
20 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
22 | .\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
23 | .\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
24 | .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
25 | .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
26 | .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 | .\" | |
28 | .Dd June 24, 1994 | |
29 | .Dt FTOK 3 | |
30 | .Os | |
31 | .Sh NAME | |
32 | .Nm ftok | |
33 | .Nd create IPC indentifier from a pathname | |
34 | .Sh SYNOPSIS | |
35 | .Fd #include <sys/types.h> | |
36 | .Fd #include <sys/ipc.h> | |
37 | .Ft key_t | |
38 | .Fn ftok "const char *path" "int id" ; | |
39 | .Sh DESCRIPTION | |
40 | The | |
41 | .Fn ftok | |
42 | function attempts to create a unique key suitable for use with the | |
43 | .Xr msgget 2 , | |
44 | .Xr semget 2 | |
45 | and | |
46 | .Xr shmget 2 | |
47 | functions given the | |
48 | .Fa path | |
49 | of an existing file and a user-selectable | |
50 | .Fa id . | |
51 | .Pp | |
52 | The specified | |
53 | .Fa path | |
54 | must refer to an existing file that is accessible to the calling process | |
55 | or the call will fail. Also, note that links to files will return the | |
56 | same key, given the same | |
57 | .Fa id . | |
58 | Only the 8 least significant bits of | |
59 | .Fa id | |
60 | are used in the key generation; the rest of the bits are ignored. | |
61 | .Sh RETURN VALUES | |
62 | The | |
63 | .Fn ftok | |
64 | function will return (key_t)\-1 if | |
65 | .Fa path | |
66 | does not exist or if it cannot be accessed by the calling process. | |
67 | .Sh SEE ALSO | |
68 | .Xr msgget 2 , | |
69 | .Xr semget 2 , | |
70 | .Xr shmget 2 | |
71 | .Sh HISTORY | |
72 | The | |
73 | .Fn ftok | |
74 | function originated with System V and is typically used by programs | |
75 | that use the System V IPC routines. | |
76 | .Sh AUTHOR | |
77 | Thorsten Lockert <tholo@sigmasoft.com> | |
78 | .Sh BUGS | |
79 | The returned key is computed based on the device and inode of the | |
80 | specified | |
81 | .Fa path | |
82 | in combination with the given | |
83 | .Fa id . | |
84 | Thus it is quite possible for the routine to return duplicate keys | |
85 | given that those fields are not 8- and 16-bit quantities like they | |
86 | were on System V based systems where this library routine's ancestors | |
87 | were originally created. |