Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2002-03-15 13:12:31 +0300
committerCorinna Vinschen <corinna@vinschen.de>2002-03-15 13:12:31 +0300
commit2f2631878427c98ed306ec34f1c9f657faa70c5c (patch)
tree818e64586fe9f8823074b5bc0da6e1e1279c5b47 /winsup
parent4af6d4a9ab85eb27ac4fb41225e5b6edea2d427c (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')
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/glob.c58
-rw-r--r--winsup/cygwin/include/glob.h5
3 files changed, 68 insertions, 4 deletions
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 <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 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
@@ -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. */