1*60f2a097Sguenther.\" $OpenBSD: ftok.3,v 1.17 2014/11/15 22:22:09 guenther 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.\" 28*60f2a097Sguenther.Dd $Mdocdate: November 15 2014 $ 2907dc8595Saaron.Dt FTOK 3 307f3168a2Saaron.Os 31df930be7Sderaadt.Sh NAME 32df930be7Sderaadt.Nm ftok 33f7de5c7bSalex.Nd create IPC identifier from a pathname 34df930be7Sderaadt.Sh SYNOPSIS 3564d4e987Stedu.In sys/ipc.h 36df930be7Sderaadt.Ft key_t 378adfbbe0Sjmc.Fn ftok "const char *path" "int id" 38df930be7Sderaadt.Sh DESCRIPTION 39df930be7SderaadtThe 40df930be7Sderaadt.Fn ftok 41df930be7Sderaadtfunction attempts to create a unique key suitable for use with the 42df930be7Sderaadt.Xr msgget 2 , 43df930be7Sderaadt.Xr semget 2 44df930be7Sderaadtand 45df930be7Sderaadt.Xr shmget 2 46df930be7Sderaadtfunctions given the 47df930be7Sderaadt.Fa path 48df930be7Sderaadtof an existing file and a user-selectable 49df930be7Sderaadt.Fa id . 50df930be7Sderaadt.Pp 51df930be7SderaadtThe specified 52df930be7Sderaadt.Fa path 5311627327Saaronmust refer to an existing file that is accessible to the calling process 5410cc2884Saaronor the call will fail. 5510cc2884SaaronAlso, note that links to files will return the same key, given the same 56df930be7Sderaadt.Fa id . 57c41c6c2fSderaadtOnly the 8 least significant bits of 58c41c6c2fSderaadt.Fa id 59c41c6c2fSderaadtare used in the key generation; the rest of the bits are ignored. 60df930be7Sderaadt.Sh RETURN VALUES 61df930be7SderaadtThe 62df930be7Sderaadt.Fn ftok 632b0e239dSaaronfunction will return (key_t)\-1 if 64df930be7Sderaadt.Fa path 65df930be7Sderaadtdoes not exist or if it cannot be accessed by the calling process. 66df930be7Sderaadt.Sh SEE ALSO 67df930be7Sderaadt.Xr msgget 2 , 68df930be7Sderaadt.Xr semget 2 , 69df930be7Sderaadt.Xr shmget 2 70df930be7Sderaadt.Sh HISTORY 71df930be7SderaadtThe 72df930be7Sderaadt.Fn ftok 73f6cb5b19Smichaelsfunction originated with System V and is typically used by programs 74df930be7Sderaadtthat use the System V IPC routines. 75ea2542f8Smpech.Sh AUTHORS 767d353dc4Sschwarze.An Thorsten Lockert Aq Mt tholo@sigmasoft.com 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 . 83f6cb5b19SmichaelsThus it is quite possible for the routine to return duplicate keys 84df930be7Sderaadtgiven that those fields are not 8- and 16-bit quantities like they 85f6cb5b19Smichaelswere on System V based systems where this library routine's ancestors 86df930be7Sderaadtwere originally created. 87