Merge with git+ssh://master.kernel.org/pub/scm/libs/klibc/klibc.git
diff --git a/usr/include/sys/mman.h b/usr/include/sys/mman.h
index c146ec8..56f0b65 100644
--- a/usr/include/sys/mman.h
+++ b/usr/include/sys/mman.h
@@ -14,6 +14,8 @@
 __extern void *mmap(void *, size_t, int, int, int, off_t);
 __extern int munmap(void *, size_t);
 __extern void *mremap(void *, size_t, size_t, unsigned long);
+__extern int shm_open(const char *, int, mode_t);
+__extern int shm_unlink(const char *);
 __extern int msync(const void *, size_t, int);
 __extern int mprotect(const void *, size_t, int);
 __extern int mlockall(int);
diff --git a/usr/include/unistd.h b/usr/include/unistd.h
index dadb63d..4df42d6 100644
--- a/usr/include/unistd.h
+++ b/usr/include/unistd.h
@@ -86,6 +86,7 @@
 __extern int open(const char *, int, ...);
 __extern int openat(int, const char *, int, ...);
 #endif
+__extern int open_cloexec(const char *, int, mode_t);
 __extern int close(int);
 __extern off_t lseek(int, off_t, int);
 /* off_t is 64 bits now even on 32-bit platforms; see llseek.c */
diff --git a/usr/kinit/Kbuild b/usr/kinit/Kbuild
index 8b4620e..f0c9541 100644
--- a/usr/kinit/Kbuild
+++ b/usr/kinit/Kbuild
@@ -8,7 +8,7 @@
 use-libs := $(before-descend)
 static-y := kinit
 kinit-y  := kinit.o do_mounts.o ramdisk_load.o initrd.o
-kinit-y  += getintfile.o open.o readfile.o xpio.o
+kinit-y  += getintfile.o readfile.o xpio.o
 kinit-y  += do_mounts_md.o do_mounts_mtd.o nfsroot.o
 
 kinit-y  += ipconfig/
diff --git a/usr/kinit/kinit.h b/usr/kinit/kinit.h
index 03cc358..895f920 100644
--- a/usr/kinit/kinit.h
+++ b/usr/kinit/kinit.h
@@ -25,8 +25,6 @@
 char *get_arg(int argc, char *argv[], const char *name);
 int get_flag(int argc, char *argv[], const char *name);
 
-int open_cloexec(const char *path, int flags, mode_t mode);
-
 int getintfile(const char *path, long *val);
 
 ssize_t readfile(const char *path, char **pptr);
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index c2bfd2f..65ca2e4 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -18,7 +18,8 @@
 	  setpgrp.o getpgrp.o daemon.o \
 	  printf.o vprintf.o fprintf.o vfprintf.o perror.o \
 	  statfs.o fstatfs.o umount.o \
-	  open.o openat.o fopen.o fread.o fread2.o fgetc.o fgets.o \
+	  open.o openat.o open_cloexec.o \
+	  fopen.o fread.o fread2.o fgetc.o fgets.o \
 	  fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \
 	  sleep.o usleep.o strtotimespec.o strtotimeval.o \
 	  raise.o abort.o assert.o alarm.o pause.o \
@@ -26,7 +27,8 @@
 	  siglongjmp.o \
 	  sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
 	  pselect.o ppoll.o \
-	  brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \
+	  brk.o sbrk.o malloc.o realloc.o calloc.o \
+	  mmap.o shm_open.o shm_unlink.o \
 	  memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
 	  memmove.o memchr.o memrchr.o \
 	  strcasecmp.o strncasecmp.o strndup.o strerror.o strsignal.o \
diff --git a/usr/kinit/open.c b/usr/klibc/open_cloexec.c
similarity index 92%
rename from usr/kinit/open.c
rename to usr/klibc/open_cloexec.c
index f53e2f1..e30b09d 100644
--- a/usr/kinit/open.c
+++ b/usr/klibc/open_cloexec.c
@@ -1,5 +1,5 @@
 /*
- * open.c
+ * open_cloexec.c
  *
  * A quick hack to do an open() and set the cloexec flag
  */
diff --git a/usr/klibc/shm_open.c b/usr/klibc/shm_open.c
new file mode 100644
index 0000000..8fe93aa
--- /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_cloexec(path, oflag, mode);
+}
diff --git a/usr/klibc/shm_unlink.c b/usr/klibc/shm_unlink.c
new file mode 100644
index 0000000..94a98a0
--- /dev/null
+++ b/usr/klibc/shm_unlink.c
@@ -0,0 +1,23 @@
+/*
+ * shm_unlink.c
+ *
+ * POSIX shared memory support
+ */
+
+#include <stdlib.h>
+#include <alloca.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+
+int shm_unlink(const char *path)
+{
+	int len = strlen(path);
+	char *pathbuf = alloca(len+10);
+
+	memcpy(pathbuf, "/dev/shm/", 9);
+	memcpy(pathbuf+9, path, len+1);
+
+	return unlink(path);
+}