xref: /freebsd/lib/libc/gen/ftok.3 (revision 8fbf3d50e331929dfa82912749a2a5ce240d475b)
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$
27e64e7115SEdward Tomasz Napierala.Dd July 9, 2009
2874804d58SMike Pritchard.Dt FTOK 3
29aa12cea2SUlrich Spörlein.Os
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
3632eef9aeSRuslan Ermilov.In sys/types.h
3732eef9aeSRuslan Ermilov.In sys/ipc.h
3885c30cfaSJoerg Wunsch.Ft key_t
391d235314SBruce Evans.Fn ftok "const char *path" "int id"
4085c30cfaSJoerg Wunsch.Sh DESCRIPTION
4185c30cfaSJoerg WunschThe
4285c30cfaSJoerg Wunsch.Fn ftok
4385c30cfaSJoerg Wunschfunction attempts to create a unique key suitable for use with the
44e64e7115SEdward Tomasz Napierala.Xr msgget 2 ,
4585c30cfaSJoerg Wunsch.Xr semget 2
4685c30cfaSJoerg Wunschand
4785c30cfaSJoerg Wunsch.Xr shmget 2
4885c30cfaSJoerg Wunschfunctions given the
4985c30cfaSJoerg Wunsch.Fa path
5085c30cfaSJoerg Wunschof an existing file and a user-selectable
5185c30cfaSJoerg Wunsch.Fa id .
5285c30cfaSJoerg Wunsch.Pp
5385c30cfaSJoerg WunschThe specified
5485c30cfaSJoerg Wunsch.Fa path
5585c30cfaSJoerg Wunschmust specify an existing file that is accessible to the calling process
561a0a9345SRuslan Ermilovor the call will fail.
571a0a9345SRuslan ErmilovAlso, 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 ,
69e64e7115SEdward Tomasz Napierala.Xr msgget 2
7085c30cfaSJoerg Wunsch.Sh HISTORY
7185c30cfaSJoerg WunschThe
7285c30cfaSJoerg Wunsch.Fn ftok
73d6c9f122SJoerg Wunschfunction originates with System V and is typically used by programs
7485c30cfaSJoerg Wunschthat use the System V IPC routines.
75a5941fc2SPhilippe Charnier.Sh AUTHORS
76*8fbf3d50SBaptiste Daroussin.An Thorsten Lockert Aq Mt tholo@sigmasoft.com
7785c30cfaSJoerg Wunsch.Sh BUGS
78d6c9f122SJoerg WunschThe returned key is computed based on the device minor number and inode of the
7985c30cfaSJoerg Wunschspecified
8085c30cfaSJoerg Wunsch.Fa path
81d6c9f122SJoerg Wunschin combination with the lower 8 bits of the given
8285c30cfaSJoerg Wunsch.Fa id .
83e83201b4SWolfram SchneiderThus it is quite possible for the routine to return duplicate keys.
84