summaryrefslogtreecommitdiff
path: root/src/dirent/opendir.c
blob: e2507e548cae90c755a36c79a15b8b073ec48c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#if 0

#include <dirent.h>
#include <errno.h>
#include <sys/types.h>
#include <stdlib.h>
#include <fcntl.h>
#include "_dirent.h"

DIR * opendir(const char * dirname)
{
	DIR *dir = malloc(sizeof(*dir));
	if (dir == NULL) {
		errno = ENOMEM;
		return NULL;
	}

	dir->fd = open(dirname, O_DIRECTORY | O_SEARCH);
	if (dir->fd == -1) {
		free(dir);
		return NULL;
	}
	fcntl(dir->fd, F_SETFD, FD_CLOEXEC);

	return dir;
}

/*
POSIX(1)
*/


#endif