diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2002-03-15 10:12:31 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2002-03-15 10:12:31 +0000 |
commit | 2f2631878427c98ed306ec34f1c9f657faa70c5c (patch) | |
tree | 818e64586fe9f8823074b5bc0da6e1e1279c5b47 | |
parent | 4af6d4a9ab85eb27ac4fb41225e5b6edea2d427c (diff) | |
download | newlib-2f2631878427c98ed306ec34f1c9f657faa70c5c.zip newlib-2f2631878427c98ed306ec34f1c9f657faa70c5c.tar.gz newlib-2f2631878427c98ed306ec34f1c9f657faa70c5c.tar.bz2 |
* 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.
-rw-r--r-- | winsup/cygwin/ChangeLog | 9 | ||||
-rw-r--r-- | winsup/cygwin/glob.c | 58 | ||||
-rw-r--r-- | winsup/cygwin/include/glob.h | 5 |
3 files changed, 68 insertions, 4 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 659649c..16ea9ce 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2002-03-15 Corinna Vinschen <corina@vinschen.de> + + * 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 <cgf@redhat.com> * pinfo.cc (pinfo::init): Properly handle execed process stub when diff --git a/winsup/cygwin/glob.c b/winsup/cygwin/glob.c index cdb30a8..f1fec90 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 e6e648f..6a393f0 100644 --- a/winsup/cygwin/include/glob.h +++ b/winsup/cygwin/include/glob.h @@ -66,9 +66,14 @@ typedef struct { 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. */ |