18198Sjoerg/*
28198Sjoerg * Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
38198Sjoerg * All rights reserved.
48198Sjoerg *
58198Sjoerg * Redistribution and use in source and binary forms, with or without
68198Sjoerg * modification, are permitted provided that the following conditions
78198Sjoerg * are met:
88198Sjoerg * 1. Redistributions of source code must retain the above copyright
98198Sjoerg *    notice, this list of conditions and the following disclaimer.
108198Sjoerg * 2. Redistributions in binary form must reproduce the above copyright
118198Sjoerg *    notice, this list of conditions and the following disclaimer in the
128198Sjoerg *    documentation and/or other materials provided with the distribution.
138198Sjoerg * 3. The name of the author may not be used to endorse or promote products
148198Sjoerg *    derived from this software without specific prior written permission.
158198Sjoerg *
168198Sjoerg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
178198Sjoerg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
188198Sjoerg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
198198Sjoerg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
208198Sjoerg * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
218198Sjoerg * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
228198Sjoerg * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
238198Sjoerg * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
248198Sjoerg * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
258198Sjoerg * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
268198Sjoerg */
278198Sjoerg
2890039Sobrien#include <sys/cdefs.h>
2990039Sobrien__FBSDID("$FreeBSD: releng/10.3/lib/libc/gen/ftok.c 129926 2004-06-01 06:53:07Z tjr $");
308198Sjoerg
318198Sjoerg#include <sys/types.h>
328198Sjoerg#include <sys/stat.h>
338198Sjoerg#include <sys/ipc.h>
348198Sjoerg
358198Sjoergkey_t
368198Sjoergftok(path, id)
378198Sjoerg	const char *path;
38129926Stjr	int id;
398198Sjoerg{
408198Sjoerg	struct stat st;
418198Sjoerg
428198Sjoerg	if (stat(path, &st) < 0)
438198Sjoerg		return (key_t)-1;
448198Sjoerg
458198Sjoerg	return (key_t) (id << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xffff));
468198Sjoerg}
47