summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/lib/opendir.c
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-05-14 14:19:32 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-05-14 14:19:32 +0000
commit167217bec15c9c7aa70ba2a3dc9c689b3cd91872 (patch)
tree7c0c62debf8f9f145643102fb52b81afce743594 /mdk-stage1/dietlibc/lib/opendir.c
parent9097327dc1c667fc51b8e05cc7c0626fac96665d (diff)
downloaddrakx-backup-do-not-use-167217bec15c9c7aa70ba2a3dc9c689b3cd91872.tar
drakx-backup-do-not-use-167217bec15c9c7aa70ba2a3dc9c689b3cd91872.tar.gz
drakx-backup-do-not-use-167217bec15c9c7aa70ba2a3dc9c689b3cd91872.tar.bz2
drakx-backup-do-not-use-167217bec15c9c7aa70ba2a3dc9c689b3cd91872.tar.xz
drakx-backup-do-not-use-167217bec15c9c7aa70ba2a3dc9c689b3cd91872.zip
import new version of dietlibc
Diffstat (limited to 'mdk-stage1/dietlibc/lib/opendir.c')
-rw-r--r--mdk-stage1/dietlibc/lib/opendir.c71
1 files changed, 13 insertions, 58 deletions
diff --git a/mdk-stage1/dietlibc/lib/opendir.c b/mdk-stage1/dietlibc/lib/opendir.c
index 05c0b9bc8..5c0c4a305 100644
--- a/mdk-stage1/dietlibc/lib/opendir.c
+++ b/mdk-stage1/dietlibc/lib/opendir.c
@@ -1,63 +1,18 @@
-#include <sys/stat.h>
+#include "dietdirent.h"
+#include <unistd.h>
+#include <dirent.h>
#include <stdlib.h>
-#include <string.h>
#include <fcntl.h>
-#include <unistd.h>
-#undef _POSIX_PTHREADS
-#include <errno.h>
-
-#include "dirstream.h"
-
-#ifndef O_DIRECTORY
-#define O_DIRECTORY 0200000 /* must be a directory */
-#endif
-
-/*
- * opendir just makes an open() call - it return NULL if it fails
- * (open sets errno), otherwise it returns a DIR * pointer.
- */
-#undef opendir
-DIR *
-opendir(const char * name)
-{
- int fd;
- struct stat statbuf;
- struct dirent *buf;
- DIR *ptr;
-
- /*
- if (stat(name,&statbuf)) return NULL;
- if (!S_ISDIR(statbuf.st_mode)) {
- errno = ENOTDIR;
- return NULL;
- }
- */
- if ((fd = open(name,O_RDONLY|O_DIRECTORY)) < 0)
- return NULL;
- /* According to POSIX, directory streams should be closed when
- * exec. From "Anna Pluzhnikov" <besp@midway.uchicago.edu>.
- */
- if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
- return NULL;
- if (!(ptr=malloc(sizeof(*ptr)))) {
- close(fd);
- errno = ENOMEM;
- return NULL;
- }
-
- ptr->dd_max = statbuf.st_blksize;
- if (ptr->dd_max < 512)
- ptr->dd_max = 512;
- if (!(buf=malloc(ptr->dd_max))) {
- close(fd);
- free(ptr);
- errno = ENOMEM;
- return NULL;
+DIR *opendir (const char *name) {
+ DIR *t=(DIR*)malloc(sizeof(DIR));
+ if (t) {
+ if ((t->fd=open(name,O_RDONLY|O_DIRECTORY))>=0) {
+ t->num=t->cur=0;
+ } else {
+ free(t);
+ t=0;
+ }
}
- ptr->dd_fd = fd;
- ptr->dd_nextoff = ptr->dd_nextloc = ptr->dd_size = 0;
- ptr->dd_buf = buf;
- ptr->dd_getdents = unknown;
- return ptr;
+ return t;
}