diff options
Diffstat (limited to 'usr/klibc/shm_open.c')
-rw-r--r-- | usr/klibc/shm_open.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/usr/klibc/shm_open.c b/usr/klibc/shm_open.c new file mode 100644 index 0000000..a54e246 --- /dev/null +++ b/usr/klibc/shm_open.c @@ -0,0 +1,23 @@ +/* + * shm_open.c + * + * POSIX shared memory support + */ + +#include <stdlib.h> +#include <alloca.h> +#include <string.h> +#include <unistd.h> +#include <sys/mman.h> + + +int shm_open(const char *path, int oflag, mode_t mode) +{ + int len = strlen(path); + char *pathbuf = alloca(len+10); + + memcpy(pathbuf, "/dev/shm/", 9); + memcpy(pathbuf+9, path, len+1); + + return open(path, oflag, mode|O_CLOEXEC); +} |