This will fail for __DARWIN_ONLY_64_BIT_INO_T configurations.

I suggest that you don't set _DARWIN_NO_64_BIT_INODE in CPPFLAGS in the 
Makefile and instead do this first (not tested, but you should be able to get 
the point):

#include <sys/cdefs.h>
#if defined(_DARWIN_FEATURE_64_BIT_INODE) && 
!defined(_DARWIN_FEATURE_ONLY_64_BIT_INODE)
// The architecture we're building for has multiple versions of stat.
// We need to undo sys/cdefs.h changes for _DARWIN_FEATURE_64_BIT_INODE
#define __DARWIN_64_BIT_INO_T 0
#define __DARWIN_SUF_64_BIT_INO_T ""
#undef _DARWIN_FEATURE_64_BIT_INODE
#endif

then put all the stat64 and lstat64 bits inside:

#ifndef _DARWIN_FEATURE_ONLY_64_BIT_INODE
...
#endif

--Jeremy


On Dec 12, 2010, at 01:30, [email protected] wrote:

> Revision: 74318
>          http://trac.macports.org/changeset/74318
> Author:   [email protected]
> Date:     2010-12-12 01:30:21 -0800 (Sun, 12 Dec 2010)
> Log Message:
> -----------
> wrap stat64 and lstat64 in darwintracelib (fixes #21582)
> 
> Modified Paths:
> --------------
>    trunk/base/src/darwintracelib1.0/Makefile
>    trunk/base/src/darwintracelib1.0/darwintrace.c
> 
> Modified: trunk/base/src/darwintracelib1.0/Makefile
> ===================================================================
> --- trunk/base/src/darwintracelib1.0/Makefile 2010-12-12 05:16:24 UTC (rev 
> 74317)
> +++ trunk/base/src/darwintracelib1.0/Makefile 2010-12-12 09:30:21 UTC (rev 
> 74318)
> @@ -7,6 +7,8 @@
> include ../../Mk/macports.autoconf.mk
> 
> CFLAGS+= -fPIC
> +# will need to update this to cope with 64-bit inodes someday
> +CPPFLAGS+= -D_DARWIN_NO_64_BIT_INODE
> 
> all:: ${SHLIB_NAME}
> 
> 
> Modified: trunk/base/src/darwintracelib1.0/darwintrace.c
> ===================================================================
> --- trunk/base/src/darwintracelib1.0/darwintrace.c    2010-12-12 05:16:24 UTC 
> (rev 74317)
> +++ trunk/base/src/darwintracelib1.0/darwintrace.c    2010-12-12 09:30:21 UTC 
> (rev 74318)
> @@ -465,6 +465,8 @@
>  */
> static int is_directory(const char * path)
> {
> +/* will need to update this to cope with 64-bit inodes someday - for now, we
> + build with -D_DARWIN_NO_64_BIT_INODE */
> #define stat(path, sb) syscall(SYS_stat, path, sb)
>       struct stat s;
>       if(stat(path, &s)==-1)
> @@ -920,9 +922,37 @@
> #undef stat
> }
> 
> +int stat64(const char * path, struct stat64 * sb)
> +{
> +#define stat64(path, sb) syscall(SYS_stat64, path, sb)
> +     int result=0;
> +     char newpath[260];
> +             
> +     *newpath=0;
> +     if(!is_directory(path)&&__darwintrace_is_in_sandbox(path, newpath)==0)
> +     {
> +             errno=ENOENT;
> +             result=-1;
> +     }else
> +     {
> +             if(*newpath)
> +                     path=newpath;
> +                     
> +             result=stat64(path, sb);
> +     }
> +     
> +     return result;
> +#undef stat64
> +}
> +
> +int stat$INODE64(const char * path, struct stat64 * sb)
> +{
> +    return stat64(path, sb);
> +}
> +
> int lstat(const char * path, struct stat * sb)
> {
> -#define stat(path, sb) syscall(SYS_lstat, path, sb)
> +#define lstat(path, sb) syscall(SYS_lstat, path, sb)
>       int result=0;
>       char newpath[260];
>       
> @@ -936,9 +966,37 @@
>               if(*newpath)
>                       path=newpath;
>                       
> -             result=stat(path, sb);
> +             result=lstat(path, sb);
>       }
>       
>       return result;
> -#undef stat
> +#undef lstat
> }
> +
> +int lstat64(const char * path, struct stat64 * sb)
> +{
> +#define lstat64(path, sb) syscall(SYS_lstat64, path, sb)
> +     int result=0;
> +     char newpath[260];
> +     
> +     *newpath=0;
> +     if(!is_directory(path)&&__darwintrace_is_in_sandbox(path, newpath)==0)
> +     {
> +             errno=ENOENT;
> +             result=-1;
> +     }else
> +     {
> +             if(*newpath)
> +                     path=newpath;
> +                     
> +             result=lstat64(path, sb);
> +     }
> +     
> +     return result;
> +#undef lstat64
> +}
> +
> +int lstat$INODE64(const char * path, struct stat64 * sb)
> +{
> +    return lstat64(path, sb);
> +}
> _______________________________________________
> macports-changes mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macports-changes

_______________________________________________
macports-dev mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev

Reply via email to