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