xref: /freebsd/lib/libc/gen/ftok.3 (revision 5f6bedf2ac736c50dc3815e1d8b5d8bcec039709)
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.\"
265f6bedf2SMike Pritchard.\"	$Id: ftok.3,v 1.2 1996/01/30 18:12:32 mpp Exp $
2785c30cfaSJoerg Wunsch.Dd June 24, 1994
2885c30cfaSJoerg Wunsch.Os
2985c30cfaSJoerg Wunsch.Dt ftok 3
3085c30cfaSJoerg Wunsch.Sh NAME
3185c30cfaSJoerg Wunsch.Nm ftok
32e2cc67efSMike Pritchard.Nd create IPC identifier from path name
3385c30cfaSJoerg Wunsch.Sh SYNOPSIS
3485c30cfaSJoerg Wunsch.Fd #include <sys/types.h>
3585c30cfaSJoerg Wunsch.Fd #include <sys/ipc.h>
3685c30cfaSJoerg Wunsch.Ft key_t
3785c30cfaSJoerg Wunsch.Fn ftok "const char *path" "char id" ;
3885c30cfaSJoerg Wunsch.Sh DESCRIPTION
3985c30cfaSJoerg Wunsch.Bf -symbolic
4085c30cfaSJoerg WunschThis function is available from the compatibility library, libcompat.
4185c30cfaSJoerg Wunsch.Ef
4285c30cfaSJoerg WunschThe
4385c30cfaSJoerg Wunsch.Fn ftok
4485c30cfaSJoerg Wunschfunction attempts to create a unique key suitable for use with the
455f6bedf2SMike Pritchard.Xr msgget 3 ,
4685c30cfaSJoerg Wunsch.Xr semget 2
4785c30cfaSJoerg Wunschand
4885c30cfaSJoerg Wunsch.Xr shmget 2
4985c30cfaSJoerg Wunschfunctions given the
5085c30cfaSJoerg Wunsch.Fa path
5185c30cfaSJoerg Wunschof an existing file and a user-selectable
5285c30cfaSJoerg Wunsch.Fa id .
5385c30cfaSJoerg Wunsch.Pp
5485c30cfaSJoerg WunschThe specified
5585c30cfaSJoerg Wunsch.Fa path
5685c30cfaSJoerg Wunschmust specify an existing file that is accessible to the calling process
5785c30cfaSJoerg Wunschor the call will fail.  Also, note that links to files will return the
5885c30cfaSJoerg Wunschsame key, given the same
5985c30cfaSJoerg Wunsch.Fa id .
6085c30cfaSJoerg Wunsch.Sh RETURN VALUES
6185c30cfaSJoerg WunschThe
6285c30cfaSJoerg Wunsch.Fn ftok
6385c30cfaSJoerg Wunschfunction will return -1 if
6485c30cfaSJoerg Wunsch.Fa path
6585c30cfaSJoerg Wunschdoes not exist or if it cannot be accessed by the calling process.
6685c30cfaSJoerg Wunsch.Sh SEE ALSO
6785c30cfaSJoerg Wunsch.Xr semget 2 ,
685f6bedf2SMike Pritchard.Xr shmget 2 ,
695f6bedf2SMike Pritchard.Xr msgget 3
7085c30cfaSJoerg Wunsch.Sh HISTORY
7185c30cfaSJoerg WunschThe
7285c30cfaSJoerg Wunsch.Fn ftok
7385c30cfaSJoerg Wunschfunction originate with System V and is typically used by programs
7485c30cfaSJoerg Wunschthat use the System V IPC routines.
7585c30cfaSJoerg Wunsch.Sh AUTHOR
7685c30cfaSJoerg Wunsch.Bl -tag
7785c30cfaSJoerg WunschThorsten Lockert <tholo@sigmasoft.com>
7885c30cfaSJoerg Wunsch.El
7985c30cfaSJoerg Wunsch.Sh BUGS
8085c30cfaSJoerg WunschThe returned key is computed based on the device and inode of the
8185c30cfaSJoerg Wunschspecified
8285c30cfaSJoerg Wunsch.Fa path
8385c30cfaSJoerg Wunschin combination with the given
8485c30cfaSJoerg Wunsch.Fa id .
8585c30cfaSJoerg WunschThus is is quite possible for the routine to return duplicate keys
8685c30cfaSJoerg Wunschgiven that those fields are not 8- and 16-bit quantities like they
8785c30cfaSJoerg Wunschwere on System V based systems where this library routine's ancestor
8885c30cfaSJoerg Wunschwere originally created.
89