OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [sysdeps/] [telldir.c] - Blame information for rev 1767

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
#define lseek __normal_lseek
2
#include <unistd.h>
3
#include <syscall.h>
4
#include <errno.h>
5
#undef lseek
6
 
7
#include "dirstream.h"
8
 
9
static inline
10
_syscall3(off_t,lseek,int,fildes,off_t,offset,int,origin)
11
 
12
off_t
13
telldir(DIR * dir)
14
{
15
  off_t offset;
16
 
17
  if (!dir) {
18
    errno = EBADF;
19
    return -1;
20
  }
21
 
22
  switch (dir->dd_getdents)
23
  {
24
  case no_getdents:
25
    /* We are running the old kernel. This is the starting offset
26
       of the next readdir(). */
27
    offset = lseek(dir->dd_fd, 0, SEEK_CUR);
28
    break;
29
 
30
  case unknown:
31
    /* readdir () is not called yet. but seekdir () may be called. */
32
  case have_getdents:
33
    /* The next entry. */
34
    offset = dir->dd_nextoff;
35
    break;
36
 
37
  default:
38
    errno = EBADF;
39
    offset = -1;
40
  }
41
 
42
  return offset;
43
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.