4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-01 03:50:28 +08:00

* 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.
This commit is contained in:
Corinna Vinschen 2002-03-15 10:12:31 +00:00
parent 4af6d4a9ab
commit 2f26318784
3 changed files with 68 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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. */