From 2f2631878427c98ed306ec34f1c9f657faa70c5c Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 15 Mar 2002 10:12:31 +0000 Subject: * glob.c (stat32_to_STAT): New function. (g_lstat): Call user space functions always with 32 bit struct stat as a workaround. (g_stat): Ditto. * include/glob.h (struct glob): Don't prototype function pointers when compiling Cygwin. --- winsup/cygwin/ChangeLog | 9 +++++++ winsup/cygwin/glob.c | 58 +++++++++++++++++++++++++++++++++++++++++--- winsup/cygwin/include/glob.h | 5 ++++ 3 files changed, 68 insertions(+), 4 deletions(-) (limited to 'winsup') diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 659649cf0..16ea9ce71 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2002-03-15 Corinna Vinschen + + * glob.c (stat32_to_STAT): New function. + (g_lstat): Call user space functions always with 32 bit struct stat + as a workaround. + (g_stat): Ditto. + * include/glob.h (struct glob): Don't prototype function pointers + when compiling Cygwin. + 2002-03-14 Christopher Faylor * pinfo.cc (pinfo::init): Properly handle execed process stub when diff --git a/winsup/cygwin/glob.c b/winsup/cygwin/glob.c index cdb30a855..f1fec9055 100644 --- a/winsup/cygwin/glob.c +++ b/winsup/cygwin/glob.c @@ -807,17 +807,51 @@ g_opendir(str, pglob) return(opendir(buf)); } +static void +stat32_to_STAT (struct __stat32 *src, struct STAT *dst) +{ + dst->st_dev = src->st_dev; + dst->st_ino = src->st_ino; + dst->st_mode = src->st_mode; + dst->st_nlink = src->st_nlink; + dst->st_uid = src->st_uid; + dst->st_gid = src->st_gid; + dst->st_rdev = src->st_rdev; + dst->st_size = src->st_size; + dst->st_atime = src->st_atime; + dst->st_mtime = src->st_mtime; + dst->st_ctime = src->st_ctime; + dst->st_blksize = src->st_blksize; + dst->st_blocks = src->st_blocks; +} + static int g_lstat(fn, sb, pglob) register Char *fn; struct STAT *sb; glob_t *pglob; { + /* FIXME: This only works as long as the application uses the old + struct stat with 32 bit off_t types!!! + + As soon as we switch over to 64 bit, we have to decide by + the applications API minor version number, whether to use + a pointer to a __stat64 or a _stat32 struct to the + pglob->gl_lstat function. */ +#ifdef __CYGWIN_USE_BIG_TYPES__ +#error FIXME check apps API minor and use correct struct stat +#endif char buf[MAXPATHLEN]; g_Ctoc(fn, buf); - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return((*pglob->gl_lstat)(buf, sb)); + if (pglob->gl_flags & GLOB_ALTDIRFUNC) { + struct __stat32 lsb; + int ret; + + if (!(ret = (*pglob->gl_lstat)(buf, &lsb))) + stat32_to_STAT (&lsb, sb); + return ret; + } #ifdef __INSIDE_CYGWIN__ return(lstat64(buf, sb)); #else @@ -831,11 +865,27 @@ g_stat(fn, sb, pglob) struct STAT *sb; glob_t *pglob; { + /* FIXME: This only works as long as the application uses the old + struct stat with 32 bit off_t types!!! + + As soon as we switch over to 64 bit, we have to decide by + the applications API minor version number, whether to use + a pointer to a __stat64 or a _stat32 struct to the + pglob->gl_stat function. */ +#ifdef __CYGWIN_USE_BIG_TYPES__ +#error FIXME check apps API minor and use correct struct stat +#endif char buf[MAXPATHLEN]; g_Ctoc(fn, buf); - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return((*pglob->gl_stat)(buf, sb)); + if (pglob->gl_flags & GLOB_ALTDIRFUNC) { + struct __stat32 lsb; + int ret; + + if (!(ret = (*pglob->gl_stat)(buf, &lsb))) + stat32_to_STAT (&lsb, sb); + return ret; + } #ifdef __INSIDE_CYGWIN__ return(stat64(buf, sb)); #else diff --git a/winsup/cygwin/include/glob.h b/winsup/cygwin/include/glob.h index e6e648f11..6a393f004 100644 --- a/winsup/cygwin/include/glob.h +++ b/winsup/cygwin/include/glob.h @@ -65,10 +65,15 @@ typedef struct { #ifdef __LIBC12_SOURCE__ int (*gl_lstat) __P((const char *, struct stat12 *)); int (*gl_stat) __P((const char *, struct stat12 *)); +#else +#if defined (__INSIDE_CYGWIN__) + int (*gl_lstat) (); + int (*gl_stat) (); #else int (*gl_lstat) __P((const char *, struct stat *)); int (*gl_stat) __P((const char *, struct stat *)); #endif +#endif } glob_t; #define GLOB_APPEND 0x0001 /* Append to output from previous call. */ -- cgit v1.2.3