Changeset 2299


Ignore:
Timestamp:
26/09/2008 21:24:11 (3 years ago)
Author:
chris
Message:

Fix compilation of open64() intercept.

Location:
box/trunk/lib/intercept
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/intercept/intercept.cpp

    r2183 r2299  
    2323 
    2424#include <errno.h> 
     25#include <stdarg.h> 
    2526 
    2627#ifdef HAVE_DLFCN_H 
     
    233234 
    234235extern "C" int 
    235 open(const char *path, int flags, mode_t mode) 
     236#ifdef DEFINE_ONLY_OPEN64 
     237        open64(const char *path, int flags, ...) 
     238#else 
     239        open(const char *path, int flags, ...) 
     240#endif // DEFINE_ONLY_OPEN64 
    236241{ 
    237242        if(intercept_count > 0) 
     
    246251        } 
    247252 
     253        mode_t mode = 0; 
     254        if (flags & O_CREAT) 
     255        { 
     256                va_list ap; 
     257                va_start(ap, flags); 
     258                mode = va_arg(ap, mode_t); 
     259                va_end(ap); 
     260        } 
     261 
    248262#ifdef PLATFORM_NO_SYSCALL 
    249263        int r = TEST_open(path, flags, mode); 
     
    267281} 
    268282 
     283#ifndef DEFINE_ONLY_OPEN64 
    269284extern "C" int 
    270 open64(const char *path, int flags, mode_t mode) 
    271 { 
     285// open64(const char *path, int flags, mode_t mode) 
     286// open64(const char *path, int flags, ...) 
     287open64 (__const char *path, int flags, ...) 
     288{ 
     289        mode_t mode = 0; 
     290        if (flags & O_CREAT) 
     291        { 
     292                va_list ap; 
     293                va_start(ap, flags); 
     294                mode = va_arg(ap, mode_t); 
     295                va_end(ap); 
     296        } 
     297 
    272298        // With _FILE_OFFSET_BITS set to 64 this should really use (flags | 
    273299        // O_LARGEFILE) here, but not actually necessary for the tests and not 
     
    275301        return open(path, flags, mode); 
    276302} 
     303#endif // !DEFINE_ONLY_OPEN64 
    277304 
    278305extern "C" int 
  • box/trunk/lib/intercept/intercept.h

    r2183 r2299  
    2424        typedef int            (closedir_t)(DIR *dir); 
    2525#if defined __GNUC__ && __GNUC__ >= 2 
    26 #define LINUX_WEIRD_LSTAT 
    27 #define STAT_STRUCT struct stat /* should be stat64 */ 
    28         typedef int            (lstat_t)   (int ver, const char *file_name,  
    29                                             STAT_STRUCT *buf); 
     26        #if _FILE_OFFSET_BITS == 64 
     27                #define DEFINE_ONLY_OPEN64 
     28        #endif 
     29        #define LINUX_WEIRD_LSTAT 
     30        #define STAT_STRUCT struct stat /* should be stat64 */ 
     31                typedef int    (lstat_t)   (int ver, const char *file_name,  
     32                                            STAT_STRUCT *buf); 
    3033#else 
    31 #define STAT_STRUCT struct stat 
    32         typedef int            (lstat_t)   (const char *file_name,  
    33                                             STAT_STRUCT *buf); 
     34        #define STAT_STRUCT struct stat 
     35                typedef int    (lstat_t)   (const char *file_name,  
     36                                            STAT_STRUCT *buf); 
    3437#endif 
    3538} 
Note: See TracChangeset for help on using the changeset viewer.