projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
use rt_sigprocmask, not legacy sigprocmask, syscall in pthread exit code
[oweals/musl.git]
/
src
/
dirent
/
opendir.c
1
#define _GNU_SOURCE
2
#include <dirent.h>
3
#include <fcntl.h>
4
#include <sys/stat.h>
5
#include <errno.h>
6
#include <stdlib.h>
7
#include <unistd.h>
8
#include <limits.h>
9
#include "__dirent.h"
10
11
DIR *opendir(const char *name)
12
{
13
int fd;
14
DIR *dir;
15
16
if ((fd = open(name, O_RDONLY|O_DIRECTORY)) < 0)
17
return 0;
18
fcntl(fd, F_SETFD, FD_CLOEXEC);
19
if (!(dir = calloc(1, sizeof *dir))) {
20
close(fd);
21
return 0;
22
}
23
dir->fd = fd;
24
return dir;
25
}