diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2002-03-15 13:12:31 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2002-03-15 13:12:31 +0300 |
commit | 2f2631878427c98ed306ec34f1c9f657faa70c5c (patch) | |
tree | 818e64586fe9f8823074b5bc0da6e1e1279c5b47 /winsup/cygwin/glob.c | |
parent | 4af6d4a9ab85eb27ac4fb41225e5b6edea2d427c (diff) |
* 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.
Diffstat (limited to 'winsup/cygwin/glob.c')
-rw-r--r-- | winsup/cygwin/glob.c | 58 |
1 files changed, 54 insertions, 4 deletions
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 |