xref: /haiku/src/system/libroot/posix/sys/ftok.c (revision 47ca7595ca54e08dac7482950a35b045e6ad8801)
1 /*
2  * Copyright 2008, Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Salvatore Benedetto <salvatore.benedetto@gmail.com>
7  */
8 
9 #include <sys/ipc.h>
10 #include <sys/stat.h>
11 
12 
13 key_t
ftok(const char * path,int id)14 ftok(const char *path, int id)
15 {
16 	struct stat st;
17 
18 	if (stat(path, &st) < 0)
19 		return (key_t)-1;
20 
21 	return (key_t)(id << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xffff));
22 }
23