libc/ipc: add ftok(3) support

https://man.openbsd.org/ftok.3

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an
2022-05-16 11:25:37 +08:00
committed by Petro Karashchenko
parent 795884dbf1
commit 644283c8ff
4 changed files with 94 additions and 3 deletions
+23 -1
View File
@@ -88,7 +88,29 @@ struct ipc_perm
* Public Function Prototypes
****************************************************************************/
key_t ftok(FAR const char *path, int id);
/****************************************************************************
* Name: ftok
*
* Description:
* Convert a pathname and a project identifier to a System V IPC key.
* The ftok() function uses the identity of the file named by the given
* pathname (which must refer to an existing, accessible file) and the
* least significant 8 bits of proj_id (which must be nonzero) to
* generate a key_t type System V IPC key, suitable for use with
* msgget(2), semget(2), or shmget(2).
*
* Input Parameters:
* pathname - identity of the file name
* proj_id - The value that uniquely project identifies.
*
* Returned Value:
* On success, the generated key_t value is returned.
* On failure -1 is returned, with errno indicating the error as for the
* stat(2) system call.
*
****************************************************************************/
key_t ftok(FAR const char *pathname, int proj_id);
#undef EXTERN
#if defined(__cplusplus)
+1 -1
View File
@@ -158,7 +158,7 @@ typedef int id_t;
* semaphores. A key is simply an integer of type key_t
*/
typedef int16_t key_t;
typedef int32_t key_t;
/* Signed integral type of the result of subtracting two pointers */