vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / posix / sys / ftok.c
blob1c25f6381113b565de5de8658a8d608ea53e679a
1 /*
2 * Copyright 2008, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Salvatore Benedetto <salvatore.benedetto@gmail.com>
7 */
9 #include <sys/ipc.h>
10 #include <sys/stat.h>
13 key_t
14 ftok(const char *path, int id)
16 struct stat st;
18 if (stat(path, &st) < 0)
19 return (key_t)-1;
21 return (key_t)(id << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xffff));