summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/lib/telldir.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/dietlibc/lib/telldir.c')
-rw-r--r--mdk-stage1/dietlibc/lib/telldir.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/mdk-stage1/dietlibc/lib/telldir.c b/mdk-stage1/dietlibc/lib/telldir.c
index eca175381..58be5d034 100644
--- a/mdk-stage1/dietlibc/lib/telldir.c
+++ b/mdk-stage1/dietlibc/lib/telldir.c
@@ -1,38 +1,7 @@
+#include "dietdirent.h"
#include <unistd.h>
-#include <errno.h>
+#include <dirent.h>
-#include "dirstream.h"
-
-#undef telldir
-off_t
-telldir(DIR * dir)
-{
- off_t offset;
-
- if (!dir) {
- errno = EBADF;
- return -1;
- }
-
- switch (dir->dd_getdents)
- {
- case no_getdents:
- /* We are running the old kernel. This is the starting offset
- of the next readdir(). */
- offset = lseek(dir->dd_fd, 0, SEEK_CUR);
- break;
-
- case unknown:
- /* readdir () is not called yet. but seekdir () may be called. */
- case have_getdents:
- /* The next entry. */
- offset = dir->dd_nextoff;
- break;
-
- default:
- errno = EBADF;
- offset = -1;
- }
-
- return offset;
+off_t telldir(DIR *d) {
+ return lseek(d->fd,0,SEEK_CUR)-d->num+d->cur;
}