* dir.cc (readdir_workdir): Only fill out d_ino when linked into older app.

* include/cygwin/version.h: Bump api minor number to 147, reflecting
obsolescence of d_ino.
(CYGWIN_VERSION_USER_API_VERSION_COMBINED): New convenience macro.
(CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO): New convenience macro.
This commit is contained in:
Christopher Faylor 2005-12-05 21:02:53 +00:00
parent 4535b5961f
commit c34aee9b23
4 changed files with 69 additions and 56 deletions

View File

@ -1,3 +1,12 @@
2005-12-05 Christopher Faylor <cgf@timesys.com>
* dir.cc (readdir_workdir): Only fill out d_ino when linked into older
app.
* include/cygwin/version.h: Bump api minor number to 147, reflecting
obsolescence of d_ino.
(CYGWIN_VERSION_USER_API_VERSION_COMBINED): New convenience macro.
(CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO): New convenience macro.
2005-12-05 Christopher Faylor <cgf@timesys.com>
Remove unneeded whitespace.

View File

@ -24,6 +24,8 @@ details. */
#include "dtable.h"
#include "cygheap.h"
#include "cygtls.h"
#include "perprocess.h"
#include "cygwin/version.h"
extern "C" int
dirfd (DIR *dir)
@ -99,43 +101,49 @@ readdir_worker (DIR *dir, dirent *de)
}
if (!res)
{
/* Compute d_ino by combining filename hash with the directory hash
(which was stored in dir->__d_dirhash when opendir was called). */
if (de->d_name[0] == '.')
{
if (de->d_name[1] == '\0')
{
de->d_ino = dir->__d_dirhash;
dir->__flags |= dirent_saw_dot;
}
else if (de->d_name[1] != '.' || de->d_name[2] != '\0')
goto hashit;
else
{
dir->__flags |= dirent_saw_dot_dot;
char *p, up[strlen (dir->__d_dirname) + 1];
strcpy (up, dir->__d_dirname);
if (!(p = strrchr (up, '\\')))
goto hashit;
*p = '\0';
if (!(p = strrchr (up, '\\')))
de->d_ino = hash_path_name (0, ".");
else
{
*p = '\0';
de->d_ino = hash_path_name (0, up);
}
}
}
else
{
hashit:
__ino64_t dino = hash_path_name (dir->__d_dirhash, "\\");
de->d_ino = hash_path_name (dino, de->d_name);
}
de->__ino32 = de->d_ino; // for legacy applications
}
if (!CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO)
{
de->__deprecated_d_ino = 0;
de->__ino32 = 0;
}
else
{
/* Compute __deprecated_d_ino by combining filename hash with the directory hash
(which was stored in dir->__d_dirhash when opendir was called). */
if (de->d_name[0] == '.')
{
if (de->d_name[1] == '\0')
{
de->__deprecated_d_ino = dir->__d_dirhash;
dir->__flags |= dirent_saw_dot;
}
else if (de->d_name[1] != '.' || de->d_name[2] != '\0')
goto hashit;
else
{
dir->__flags |= dirent_saw_dot_dot;
char *p, up[strlen (dir->__d_dirname) + 1];
strcpy (up, dir->__d_dirname);
if (!(p = strrchr (up, '\\')))
goto hashit;
*p = '\0';
if (!(p = strrchr (up, '\\')))
de->__deprecated_d_ino = hash_path_name (0, ".");
else
{
*p = '\0';
de->__deprecated_d_ino = hash_path_name (0, up);
}
}
}
else
{
hashit:
__ino64_t dino = hash_path_name (dir->__d_dirhash, "\\");
de->__deprecated_d_ino = hash_path_name (dino, de->d_name);
}
de->__ino32 = de->__deprecated_d_ino; // for legacy applications
}
return res;
}

View File

@ -63,43 +63,38 @@ details. */
#define CYGWIN_VERSION_DLL_BAD_SIGNAL_MASK 19005
#define CYGWIN_VERSION_USER_API_VERSION_COMBINED \
CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor)
/* API versions <= this had a termios structure whose members were
too small to accomodate modern settings. */
#define CYGWIN_VERSION_DLL_OLD_TERMIOS 5
#define CYGWIN_VERSION_DLL_IS_OLD_TERMIOS \
(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) <= \
CYGWIN_VERSION_DLL_OLD_TERMIOS)
(CYGWIN_VERSION_USER_API_VERSION_COMBINED <= CYGWIN_VERSION_DLL_OLD_TERMIOS)
#define CYGWIN_VERSION_DLL_MALLOC_ENV 28
/* Old APIs had getc/putc macros that conflict with new CR/LF
handling in the stdio buffers */
#define CYGWIN_VERSION_OLD_STDIO_CRLF_HANDLING \
(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) <= \
20)
(CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 20)
#define CYGWIN_VERSION_CHECK_FOR_S_IEXEC \
(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) >= \
36)
(CYGWIN_VERSION_USER_API_VERSION_COMBINED >= 36)
#define CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK \
(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) <= \
28)
(CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 28)
#define CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES \
(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) >= \
79)
(CYGWIN_VERSION_USER_API_VERSION_COMBINED >= 79)
#define CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR \
(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) <= \
138)
(CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 138)
#define CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES \
(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) <= \
138)
(CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 138)
/* We used to use the DLL major/minor to track
non-backward-compatible interface changes to the API. Now we
use an API major/minor number for this purpose. */
#define CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO \
(CYGWIN_VERSION_USER_API_VERSION_COMBINED < 147)
/* API_MAJOR 0.0: Initial version. API_MINOR changes:
1: Export cygwin32_ calls as cygwin_ as well.
@ -285,12 +280,13 @@ details. */
145: Add MAP_NORESERVE flag to mmap.
146: Change SI_USER definition. FIXME: Need to develop compatibility macro
for this?
147: Eliminate problematic d_ino from dirent structure.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
#define CYGWIN_VERSION_API_MINOR 146
#define CYGWIN_VERSION_API_MINOR 147
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible

View File

@ -20,7 +20,7 @@
struct dirent
{
long d_version; /* Used since Cygwin 1.3.3. */
__ino64_t d_ino; /* still junk but with more bits */
__ino64_t __deprecated_d_ino; /* still junk but with more bits */
long d_fd; /* File descriptor of open directory.
Used since Cygwin 1.3.3. */
unsigned __ino32;