add missing xattr functions
[musl] / src / mman / shm_open.c
1 #include <sys/mman.h>
2 #include <errno.h>
3 #include <fcntl.h>
4 #include <unistd.h>
5 #include <string.h>
6
7 int shm_open(const char *name, int flag, mode_t mode)
8 {
9         int fd, dir;
10
11         while (*name == '/') name++;
12         if (strchr(name, '/')) {
13                 errno = EINVAL;
14                 return -1;
15         }
16
17         if ((dir = open("/dev/shm", O_DIRECTORY|O_RDONLY)) < 0) return -1;
18         fd = openat(dir, name, flag|O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK, mode);
19         close(dir);
20         return fd;
21 }