Align seekdir and telldir API to POSIX definition.

* Makefile.in (NEW_FUNCTIONS): Remove seekdir and telldir mappings.
	* dir.cc (telldir): Move functionality from telldir64 here.  Use
	long, rather than _off_t.
	(telldir64): Just call telldir.  Only keep for backward compatibility.
	(seekdir): Move functionality from seekdir64 here.  Use long, rather
	than _off_t.
	(seekdir64): Just call seekdir.  Only keep for backward compatibility.
	* fhandler.h: Throughout, change prototypes of seekdir and telldir
	methods to use long, rather than _off64_t.
	* fhandler_disk_file.cc: Change aforementioned methods accordingly.
	* fhandler_netdrive.cc: Ditto.
	* fhandler_registry.cc: Ditto.
	* fhandler_virtual.cc: Ditto.
	* include/sys/dirent.h (struct __DIR): Change __d_position from
	_off_t to long to reflect API change.
	(telldir): Change prototype to use long, rather than off_t.
	(seekdir): Ditto.
This commit is contained in:
Corinna Vinschen 2010-07-05 16:59:56 +00:00
parent c8fe6dc446
commit c492992f13
10 changed files with 59 additions and 33 deletions

View File

@ -1,3 +1,24 @@
2010-07-05 Corinna Vinschen <corinna@vinschen.de>
Align seekdir and telldir API to POSIX definition.
* Makefile.in (NEW_FUNCTIONS): Remove seekdir and telldir mappings.
* dir.cc (telldir): Move functionality from telldir64 here. Use
long, rather than _off_t.
(telldir64): Just call telldir. Only keep for backward compatibility.
(seekdir): Move functionality from seekdir64 here. Use long, rather
than _off_t.
(seekdir64): Just call seekdir. Only keep for backward compatibility.
* fhandler.h: Throughout, change prototypes of seekdir and telldir
methods to use long, rather than _off64_t.
* fhandler_disk_file.cc: Change aforementioned methods accordingly.
* fhandler_netdrive.cc: Ditto.
* fhandler_registry.cc: Ditto.
* fhandler_virtual.cc: Ditto.
* include/sys/dirent.h (struct __DIR): Change __d_position from
_off_t to long to reflect API change.
(telldir): Change prototype to use long, rather than off_t.
(seekdir): Ditto.
2010-07-04 Christopher Faylor <me+cygwin@cgf.cx> 2010-07-04 Christopher Faylor <me+cygwin@cgf.cx>
* path.cc (path_conv::check): Move fs-specific settings to a point * path.cc (path_conv::check): Move fs-specific settings to a point

View File

@ -210,7 +210,6 @@ NEW_FUNCTIONS:=$(addprefix --replace=,\
mknod=_mknod32 \ mknod=_mknod32 \
mmap=_mmap64 \ mmap=_mmap64 \
open=_open64 \ open=_open64 \
seekdir=_seekdir64 \
setegid=_setegid32 \ setegid=_setegid32 \
seteuid=_seteuid32 \ seteuid=_seteuid32 \
setgid=_setgid32 \ setgid=_setgid32 \
@ -219,7 +218,6 @@ NEW_FUNCTIONS:=$(addprefix --replace=,\
setreuid=_setreuid32 \ setreuid=_setreuid32 \
setuid=_setuid32 \ setuid=_setuid32 \
stat=_stat64 \ stat=_stat64 \
telldir=_telldir64 \
timezone= \ timezone= \
tmpfile=_tmpfile64 \ tmpfile=_tmpfile64 \
truncate=_truncate64 \ truncate=_truncate64 \

View File

@ -187,8 +187,9 @@ readdir_r (DIR *dir, dirent *de, dirent **ode)
return res; return res;
} }
extern "C" _off64_t /* telldir */
telldir64 (DIR *dir) extern "C" long
telldir (DIR *dir)
{ {
myfault efault; myfault efault;
if (efault.faulted (EFAULT)) if (efault.faulted (EFAULT))
@ -199,15 +200,18 @@ telldir64 (DIR *dir)
return ((fhandler_base *) dir->__fh)->telldir (dir); return ((fhandler_base *) dir->__fh)->telldir (dir);
} }
/* telldir */ /* telldir was never defined using off_t in POSIX, only in early versions
extern "C" _off_t of glibc. We have to keep the function in as entry point for backward
telldir (DIR *dir) compatibility. */
extern "C" _off64_t
telldir64 (DIR *dir)
{ {
return telldir64 (dir); return (_off64_t) telldir (dir);
} }
/* seekdir */
extern "C" void extern "C" void
seekdir64 (DIR *dir, _off64_t loc) seekdir (DIR *dir, long loc)
{ {
myfault efault; myfault efault;
if (efault.faulted (EFAULT)) if (efault.faulted (EFAULT))
@ -219,11 +223,13 @@ seekdir64 (DIR *dir, _off64_t loc)
return ((fhandler_base *) dir->__fh)->seekdir (dir, loc); return ((fhandler_base *) dir->__fh)->seekdir (dir, loc);
} }
/* seekdir */ /* seekdir was never defined using off_t in POSIX, only in early versions
of glibc. We have to keep the function in as entry point for backward
compatibility. */
extern "C" void extern "C" void
seekdir (DIR *dir, _off_t loc) seekdir64 (DIR *dir, _off64_t loc)
{ {
seekdir64 (dir, (_off64_t)loc); seekdir (dir, (long) loc);
} }
/* rewinddir: POSIX 5.1.2.1 */ /* rewinddir: POSIX 5.1.2.1 */

View File

@ -1441,7 +1441,7 @@ fhandler_base::readdir (DIR *, dirent *)
return ENOTDIR; return ENOTDIR;
} }
_off64_t long
fhandler_base::telldir (DIR *) fhandler_base::telldir (DIR *)
{ {
set_errno (ENOTDIR); set_errno (ENOTDIR);
@ -1449,7 +1449,7 @@ fhandler_base::telldir (DIR *)
} }
void void
fhandler_base::seekdir (DIR *, _off64_t) fhandler_base::seekdir (DIR *, long)
{ {
set_errno (ENOTDIR); set_errno (ENOTDIR);
} }

View File

@ -378,8 +378,8 @@ class fhandler_base
virtual int rmdir (); virtual int rmdir ();
virtual DIR *opendir (int fd) __attribute__ ((regparm (2))); virtual DIR *opendir (int fd) __attribute__ ((regparm (2)));
virtual int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); virtual int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
virtual _off64_t telldir (DIR *); virtual long telldir (DIR *);
virtual void seekdir (DIR *, _off64_t); virtual void seekdir (DIR *, long);
virtual void rewinddir (DIR *); virtual void rewinddir (DIR *);
virtual int closedir (DIR *); virtual int closedir (DIR *);
virtual bool is_slow () {return false;} virtual bool is_slow () {return false;}
@ -774,8 +774,8 @@ class fhandler_disk_file: public fhandler_base
int rmdir (); int rmdir ();
DIR *opendir (int fd) __attribute__ ((regparm (2))); DIR *opendir (int fd) __attribute__ ((regparm (2)));
int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
_off64_t telldir (DIR *); long telldir (DIR *);
void seekdir (DIR *, _off64_t); void seekdir (DIR *, long);
void rewinddir (DIR *); void rewinddir (DIR *);
int closedir (DIR *); int closedir (DIR *);
@ -1333,8 +1333,8 @@ class fhandler_virtual : public fhandler_base
virtual int exists(); virtual int exists();
DIR *opendir (int fd) __attribute__ ((regparm (2))); DIR *opendir (int fd) __attribute__ ((regparm (2)));
_off64_t telldir (DIR *); long telldir (DIR *);
void seekdir (DIR *, _off64_t); void seekdir (DIR *, long);
void rewinddir (DIR *); void rewinddir (DIR *);
int closedir (DIR *); int closedir (DIR *);
ssize_t __stdcall write (const void *ptr, size_t len); ssize_t __stdcall write (const void *ptr, size_t len);
@ -1372,7 +1372,7 @@ class fhandler_netdrive: public fhandler_virtual
fhandler_netdrive (); fhandler_netdrive ();
int exists(); int exists();
int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
void seekdir (DIR *, _off64_t); void seekdir (DIR *, long);
void rewinddir (DIR *); void rewinddir (DIR *);
int closedir (DIR *); int closedir (DIR *);
int open (int flags, mode_t mode = 0); int open (int flags, mode_t mode = 0);
@ -1390,8 +1390,8 @@ class fhandler_registry: public fhandler_proc
void set_name (path_conv &pc); void set_name (path_conv &pc);
int exists(); int exists();
int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
_off64_t telldir (DIR *); long telldir (DIR *);
void seekdir (DIR *, _off64_t); void seekdir (DIR *, long);
void rewinddir (DIR *); void rewinddir (DIR *);
int closedir (DIR *); int closedir (DIR *);

View File

@ -2128,14 +2128,14 @@ go_ahead:
return res; return res;
} }
_off64_t long
fhandler_disk_file::telldir (DIR *dir) fhandler_disk_file::telldir (DIR *dir)
{ {
return dir->__d_position; return dir->__d_position;
} }
void void
fhandler_disk_file::seekdir (DIR *dir, _off64_t loc) fhandler_disk_file::seekdir (DIR *dir, long loc)
{ {
rewinddir (dir); rewinddir (dir);
while (loc > dir->__d_position) while (loc > dir->__d_position)

View File

@ -259,7 +259,7 @@ out:
} }
void void
fhandler_netdrive::seekdir (DIR *dir, _off64_t pos) fhandler_netdrive::seekdir (DIR *dir, long pos)
{ {
rewinddir (dir); rewinddir (dir);
if (pos < 0) if (pos < 0)

View File

@ -643,14 +643,14 @@ out:
return res; return res;
} }
_off64_t long
fhandler_registry::telldir (DIR * dir) fhandler_registry::telldir (DIR * dir)
{ {
return dir->__d_position & REG_POSITION_MASK; return dir->__d_position & REG_POSITION_MASK;
} }
void void
fhandler_registry::seekdir (DIR * dir, _off64_t loc) fhandler_registry::seekdir (DIR * dir, long loc)
{ {
/* Unfortunately cannot simply set __d_position due to transition from sub-keys to /* Unfortunately cannot simply set __d_position due to transition from sub-keys to
* values. * values.

View File

@ -97,13 +97,14 @@ fhandler_virtual::opendir (int fd)
return res; return res;
} }
_off64_t fhandler_virtual::telldir (DIR * dir) long
fhandler_virtual::telldir (DIR * dir)
{ {
return dir->__d_position; return dir->__d_position;
} }
void void
fhandler_virtual::seekdir (DIR * dir, _off64_t loc) fhandler_virtual::seekdir (DIR * dir, long loc)
{ {
dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot; dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot;
dir->__d_position = loc; dir->__d_position = loc;

View File

@ -38,7 +38,7 @@ typedef struct __DIR
unsigned long __d_cookie; unsigned long __d_cookie;
struct dirent *__d_dirent; struct dirent *__d_dirent;
char *__d_dirname; /* directory name with trailing '*' */ char *__d_dirname; /* directory name with trailing '*' */
_off_t __d_position; /* used by telldir/seekdir */ long __d_position; /* used by telldir/seekdir */
int __d_fd; int __d_fd;
unsigned __d_internal; unsigned __d_internal;
void *__handle; void *__handle;
@ -58,8 +58,8 @@ int dirfd (DIR *);
#ifndef _POSIX_SOURCE #ifndef _POSIX_SOURCE
#ifndef __INSIDE_CYGWIN__ #ifndef __INSIDE_CYGWIN__
off_t telldir (DIR *); long telldir (DIR *);
void seekdir (DIR *, off_t loc); void seekdir (DIR *, long loc);
#endif #endif
int scandir (const char *__dir, int scandir (const char *__dir,