mirror of https://git.musl-libc.org/git/musl
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
430 B
26 lines
430 B
|
15 years ago
|
#define _GNU_SOURCE
|
||
|
|
#include <dirent.h>
|
||
|
|
#include <fcntl.h>
|
||
|
|
#include <sys/stat.h>
|
||
|
|
#include <errno.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
#include <unistd.h>
|
||
|
|
#include <limits.h>
|
||
|
|
#include "__dirent.h"
|
||
|
|
|
||
|
|
DIR *opendir(const char *name)
|
||
|
|
{
|
||
|
|
int fd;
|
||
|
|
DIR *dir;
|
||
|
|
|
||
|
|
if ((fd = open(name, O_RDONLY|O_DIRECTORY)) < 0)
|
||
|
|
return 0;
|
||
|
|
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||
|
|
if (!(dir = calloc(1, sizeof *dir))) {
|
||
|
|
close(fd);
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
dir->fd = fd;
|
||
|
|
return dir;
|
||
|
|
}
|