diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4b697be2c..2d9a77c7c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,24 @@ +2010-07-05 Corinna Vinschen + + 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 * path.cc (path_conv::check): Move fs-specific settings to a point diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index 3f4c0044f..e4e5be66a 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -210,7 +210,6 @@ NEW_FUNCTIONS:=$(addprefix --replace=,\ mknod=_mknod32 \ mmap=_mmap64 \ open=_open64 \ - seekdir=_seekdir64 \ setegid=_setegid32 \ seteuid=_seteuid32 \ setgid=_setgid32 \ @@ -219,7 +218,6 @@ NEW_FUNCTIONS:=$(addprefix --replace=,\ setreuid=_setreuid32 \ setuid=_setuid32 \ stat=_stat64 \ - telldir=_telldir64 \ timezone= \ tmpfile=_tmpfile64 \ truncate=_truncate64 \ diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index 641aabe4b..c51cff701 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -187,8 +187,9 @@ readdir_r (DIR *dir, dirent *de, dirent **ode) return res; } -extern "C" _off64_t -telldir64 (DIR *dir) +/* telldir */ +extern "C" long +telldir (DIR *dir) { myfault efault; if (efault.faulted (EFAULT)) @@ -199,15 +200,18 @@ telldir64 (DIR *dir) return ((fhandler_base *) dir->__fh)->telldir (dir); } -/* telldir */ -extern "C" _off_t -telldir (DIR *dir) +/* telldir 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" _off64_t +telldir64 (DIR *dir) { - return telldir64 (dir); + return (_off64_t) telldir (dir); } +/* seekdir */ extern "C" void -seekdir64 (DIR *dir, _off64_t loc) +seekdir (DIR *dir, long loc) { myfault efault; if (efault.faulted (EFAULT)) @@ -219,11 +223,13 @@ seekdir64 (DIR *dir, _off64_t 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 -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 */ diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index bd4422a89..a8264e403 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1441,7 +1441,7 @@ fhandler_base::readdir (DIR *, dirent *) return ENOTDIR; } -_off64_t +long fhandler_base::telldir (DIR *) { set_errno (ENOTDIR); @@ -1449,7 +1449,7 @@ fhandler_base::telldir (DIR *) } void -fhandler_base::seekdir (DIR *, _off64_t) +fhandler_base::seekdir (DIR *, long) { set_errno (ENOTDIR); } diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 561ada18b..54e9d0694 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -378,8 +378,8 @@ class fhandler_base virtual int rmdir (); virtual DIR *opendir (int fd) __attribute__ ((regparm (2))); virtual int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - virtual _off64_t telldir (DIR *); - virtual void seekdir (DIR *, _off64_t); + virtual long telldir (DIR *); + virtual void seekdir (DIR *, long); virtual void rewinddir (DIR *); virtual int closedir (DIR *); virtual bool is_slow () {return false;} @@ -774,8 +774,8 @@ class fhandler_disk_file: public fhandler_base int rmdir (); DIR *opendir (int fd) __attribute__ ((regparm (2))); int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - _off64_t telldir (DIR *); - void seekdir (DIR *, _off64_t); + long telldir (DIR *); + void seekdir (DIR *, long); void rewinddir (DIR *); int closedir (DIR *); @@ -1333,8 +1333,8 @@ class fhandler_virtual : public fhandler_base virtual int exists(); DIR *opendir (int fd) __attribute__ ((regparm (2))); - _off64_t telldir (DIR *); - void seekdir (DIR *, _off64_t); + long telldir (DIR *); + void seekdir (DIR *, long); void rewinddir (DIR *); int closedir (DIR *); ssize_t __stdcall write (const void *ptr, size_t len); @@ -1372,7 +1372,7 @@ class fhandler_netdrive: public fhandler_virtual fhandler_netdrive (); int exists(); int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - void seekdir (DIR *, _off64_t); + void seekdir (DIR *, long); void rewinddir (DIR *); int closedir (DIR *); int open (int flags, mode_t mode = 0); @@ -1390,8 +1390,8 @@ class fhandler_registry: public fhandler_proc void set_name (path_conv &pc); int exists(); int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); - _off64_t telldir (DIR *); - void seekdir (DIR *, _off64_t); + long telldir (DIR *); + void seekdir (DIR *, long); void rewinddir (DIR *); int closedir (DIR *); diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 00d4d4a4e..a284b81f9 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -2128,14 +2128,14 @@ go_ahead: return res; } -_off64_t +long fhandler_disk_file::telldir (DIR *dir) { return dir->__d_position; } void -fhandler_disk_file::seekdir (DIR *dir, _off64_t loc) +fhandler_disk_file::seekdir (DIR *dir, long loc) { rewinddir (dir); while (loc > dir->__d_position) diff --git a/winsup/cygwin/fhandler_netdrive.cc b/winsup/cygwin/fhandler_netdrive.cc index 4cce69753..f3339a653 100644 --- a/winsup/cygwin/fhandler_netdrive.cc +++ b/winsup/cygwin/fhandler_netdrive.cc @@ -259,7 +259,7 @@ out: } void -fhandler_netdrive::seekdir (DIR *dir, _off64_t pos) +fhandler_netdrive::seekdir (DIR *dir, long pos) { rewinddir (dir); if (pos < 0) diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc index 9c68b2cdd..e414efbb3 100644 --- a/winsup/cygwin/fhandler_registry.cc +++ b/winsup/cygwin/fhandler_registry.cc @@ -643,14 +643,14 @@ out: return res; } -_off64_t +long fhandler_registry::telldir (DIR * dir) { return dir->__d_position & REG_POSITION_MASK; } 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 * values. diff --git a/winsup/cygwin/fhandler_virtual.cc b/winsup/cygwin/fhandler_virtual.cc index c47d2ccdd..3becf03e9 100644 --- a/winsup/cygwin/fhandler_virtual.cc +++ b/winsup/cygwin/fhandler_virtual.cc @@ -97,13 +97,14 @@ fhandler_virtual::opendir (int fd) return res; } -_off64_t fhandler_virtual::telldir (DIR * dir) +long +fhandler_virtual::telldir (DIR * dir) { return dir->__d_position; } 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->__d_position = loc; diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys/dirent.h index fa059ec30..3d441a20c 100644 --- a/winsup/cygwin/include/sys/dirent.h +++ b/winsup/cygwin/include/sys/dirent.h @@ -38,7 +38,7 @@ typedef struct __DIR unsigned long __d_cookie; struct dirent *__d_dirent; 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; unsigned __d_internal; void *__handle; @@ -58,8 +58,8 @@ int dirfd (DIR *); #ifndef _POSIX_SOURCE #ifndef __INSIDE_CYGWIN__ -off_t telldir (DIR *); -void seekdir (DIR *, off_t loc); +long telldir (DIR *); +void seekdir (DIR *, long loc); #endif int scandir (const char *__dir,