1*7f3168a2Saaron.\" $OpenBSD: ftok.3,v 1.7 1999/07/07 10:50:04 aaron 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.Dt ftok 3 30*7f3168a2Saaron.Os 31df930be7Sderaadt.Sh NAME 32df930be7Sderaadt.Nm ftok 3311627327Saaron.Nd create IPC indentifier from a pathname 34df930be7Sderaadt.Sh SYNOPSIS 35df930be7Sderaadt.Fd #include <sys/types.h> 36df930be7Sderaadt.Fd #include <sys/ipc.h> 37df930be7Sderaadt.Ft key_t 38c41c6c2fSderaadt.Fn ftok "const char *path" "int 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 5411627327Saaronmust refer to 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 . 58c41c6c2fSderaadtOnly the 8 least significant bits of 59c41c6c2fSderaadt.Fa id 60c41c6c2fSderaadtare used in the key generation; the rest of the bits are ignored. 61df930be7Sderaadt.Sh RETURN VALUES 62df930be7SderaadtThe 63df930be7Sderaadt.Fn ftok 642b0e239dSaaronfunction will return (key_t)\-1 if 65df930be7Sderaadt.Fa path 66df930be7Sderaadtdoes not exist or if it cannot be accessed by the calling process. 67df930be7Sderaadt.Sh SEE ALSO 68df930be7Sderaadt.Xr msgget 2 , 69df930be7Sderaadt.Xr semget 2 , 70df930be7Sderaadt.Xr shmget 2 71df930be7Sderaadt.Sh HISTORY 72df930be7SderaadtThe 73df930be7Sderaadt.Fn ftok 74f6cb5b19Smichaelsfunction originated with System V and is typically used by programs 75df930be7Sderaadtthat use the System V IPC routines. 76df930be7Sderaadt.Sh AUTHOR 77df930be7SderaadtThorsten Lockert <tholo@sigmasoft.com> 78df930be7Sderaadt.Sh BUGS 79df930be7SderaadtThe returned key is computed based on the device and inode of the 80df930be7Sderaadtspecified 81df930be7Sderaadt.Fa path 82df930be7Sderaadtin combination with the given 83df930be7Sderaadt.Fa id . 84f6cb5b19SmichaelsThus it is quite possible for the routine to return duplicate keys 85df930be7Sderaadtgiven that those fields are not 8- and 16-bit quantities like they 86f6cb5b19Smichaelswere on System V based systems where this library routine's ancestors 87df930be7Sderaadtwere originally created. 88