xref: /freebsd/lib/libc/gen/ftok.3 (revision 25bb73e063c17cd9048cf60100dbc0ac5177e94a)
185c30cfaSJoerg Wunsch.\" Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
285c30cfaSJoerg Wunsch.\" All rights reserved.
385c30cfaSJoerg Wunsch.\"
485c30cfaSJoerg Wunsch.\" Redistribution and use in source and binary forms, with or without
585c30cfaSJoerg Wunsch.\" modification, are permitted provided that the following conditions
685c30cfaSJoerg Wunsch.\" are met:
785c30cfaSJoerg Wunsch.\" 1. Redistributions of source code must retain the above copyright
885c30cfaSJoerg Wunsch.\"    notice, this list of conditions and the following disclaimer.
985c30cfaSJoerg Wunsch.\" 2. Redistributions in binary form must reproduce the above copyright
1085c30cfaSJoerg Wunsch.\"    notice, this list of conditions and the following disclaimer in the
1185c30cfaSJoerg Wunsch.\"    documentation and/or other materials provided with the distribution.
1285c30cfaSJoerg Wunsch.\" 3. The name of the author may not be used to endorse or promote products
1385c30cfaSJoerg Wunsch.\"    derived from this software without specific prior written permission.
1485c30cfaSJoerg Wunsch.\"
1585c30cfaSJoerg Wunsch.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1685c30cfaSJoerg Wunsch.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1785c30cfaSJoerg Wunsch.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1885c30cfaSJoerg Wunsch.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1985c30cfaSJoerg Wunsch.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2085c30cfaSJoerg Wunsch.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2185c30cfaSJoerg Wunsch.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2285c30cfaSJoerg Wunsch.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2385c30cfaSJoerg Wunsch.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2485c30cfaSJoerg Wunsch.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2585c30cfaSJoerg Wunsch.\"
267f3dea24SPeter Wemm.\" $FreeBSD$
2785c30cfaSJoerg Wunsch.Dd June 24, 1994
2885c30cfaSJoerg Wunsch.Os
2974804d58SMike Pritchard.Dt FTOK 3
3085c30cfaSJoerg Wunsch.Sh NAME
3185c30cfaSJoerg Wunsch.Nm ftok
32e2cc67efSMike Pritchard.Nd create IPC identifier from path name
3325bb73e0SAlexey Zelkin.Sh LIBRARY
3425bb73e0SAlexey Zelkin.Lb libc
3585c30cfaSJoerg Wunsch.Sh SYNOPSIS
3685c30cfaSJoerg Wunsch.Fd #include <sys/types.h>
3785c30cfaSJoerg Wunsch.Fd #include <sys/ipc.h>
3885c30cfaSJoerg Wunsch.Ft key_t
391d235314SBruce Evans.Fn ftok "const char *path" "int id"
4085c30cfaSJoerg Wunsch.Sh DESCRIPTION
4185c30cfaSJoerg Wunsch.Bf -symbolic
4285c30cfaSJoerg WunschThis function is available from the compatibility library, libcompat.
4385c30cfaSJoerg Wunsch.Ef
4485c30cfaSJoerg WunschThe
4585c30cfaSJoerg Wunsch.Fn ftok
4685c30cfaSJoerg Wunschfunction attempts to create a unique key suitable for use with the
475f6bedf2SMike Pritchard.Xr msgget 3 ,
4885c30cfaSJoerg Wunsch.Xr semget 2
4985c30cfaSJoerg Wunschand
5085c30cfaSJoerg Wunsch.Xr shmget 2
5185c30cfaSJoerg Wunschfunctions given the
5285c30cfaSJoerg Wunsch.Fa path
5385c30cfaSJoerg Wunschof an existing file and a user-selectable
5485c30cfaSJoerg Wunsch.Fa id .
5585c30cfaSJoerg Wunsch.Pp
5685c30cfaSJoerg WunschThe specified
5785c30cfaSJoerg Wunsch.Fa path
5885c30cfaSJoerg Wunschmust specify an existing file that is accessible to the calling process
5985c30cfaSJoerg Wunschor the call will fail.  Also, note that links to files will return the
6085c30cfaSJoerg Wunschsame key, given the same
6185c30cfaSJoerg Wunsch.Fa id .
6285c30cfaSJoerg Wunsch.Sh RETURN VALUES
6385c30cfaSJoerg WunschThe
6485c30cfaSJoerg Wunsch.Fn ftok
6585c30cfaSJoerg Wunschfunction will return -1 if
6685c30cfaSJoerg Wunsch.Fa path
6785c30cfaSJoerg Wunschdoes not exist or if it cannot be accessed by the calling process.
6885c30cfaSJoerg Wunsch.Sh SEE ALSO
6985c30cfaSJoerg Wunsch.Xr semget 2 ,
705f6bedf2SMike Pritchard.Xr shmget 2 ,
715f6bedf2SMike Pritchard.Xr msgget 3
7285c30cfaSJoerg Wunsch.Sh HISTORY
7385c30cfaSJoerg WunschThe
7485c30cfaSJoerg Wunsch.Fn ftok
75d6c9f122SJoerg Wunschfunction originates with System V and is typically used by programs
7685c30cfaSJoerg Wunschthat use the System V IPC routines.
77a5941fc2SPhilippe Charnier.Sh AUTHORS
78a5941fc2SPhilippe Charnier.An Thorsten Lockert Aq tholo@sigmasoft.com
7985c30cfaSJoerg Wunsch.Sh BUGS
80d6c9f122SJoerg WunschThe returned key is computed based on the device minor number and inode of the
8185c30cfaSJoerg Wunschspecified
8285c30cfaSJoerg Wunsch.Fa path
83d6c9f122SJoerg Wunschin combination with the lower 8 bits of the given
8485c30cfaSJoerg Wunsch.Fa id .
85e83201b4SWolfram SchneiderThus it is quite possible for the routine to return duplicate keys.
86