Changeset 1482
- Timestamp:
- 12/15/06 14:20:01 (6 years ago)
- File:
-
- 1 edited
-
zzuf/trunk/src/preload.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/preload.c
r1479 r1482 34 34 #include <stdlib.h> 35 35 #include <fcntl.h> 36 #include <errno.h>37 36 #include <regex.h> 38 37 … … 56 55 static int (*open64_orig) (const char *file, int oflag, ...); 57 56 static ssize_t (*read_orig) (int fd, void *buf, size_t count); 57 static off_t (*lseek_orig) (int fd, off_t offset, int whence); 58 58 static off64_t (*lseek64_orig) (int fd, off64_t offset, int whence); 59 59 static int (*close_orig) (int fd); … … 80 80 LOADSYM(open64); 81 81 LOADSYM(read); 82 LOADSYM(lseek); 82 83 LOADSYM(lseek64); 83 84 LOADSYM(close); … … 89 90 90 91 /* Our function wrappers */ 91 #define FOPEN(fn , path, mode) \92 #define FOPEN(fn) \ 92 93 do \ 93 94 { \ … … 117 118 FILE *fopen(const char *path, const char *mode) 118 119 { 119 FILE *ret; FOPEN(fopen , path, mode); return ret;120 FILE *ret; FOPEN(fopen); return ret; 120 121 } 121 122 122 123 FILE *fopen64(const char *path, const char *mode) 123 124 { 124 FILE *ret; FOPEN(fopen64 , path, mode); return ret;125 FILE *ret; FOPEN(fopen64); return ret; 125 126 } 126 127 … … 197 198 } 198 199 199 #define OPEN(fn , file, oflag) \200 #define OPEN(fn) \ 200 201 do \ 201 202 { \ … … 241 242 int open(const char *file, int oflag, ...) 242 243 { 243 int ret; OPEN(open , file, oflag); return ret;244 int ret; OPEN(open); return ret; 244 245 } 245 246 246 247 int open64(const char *file, int oflag, ...) 247 248 { 248 int ret; OPEN(open64 , file, oflag); return ret;249 int ret; OPEN(open64); return ret; 249 250 } 250 251 … … 268 269 files[fd].pos += ret; 269 270 } 271 272 /* Sanity check */ 273 if((uint64_t)lseek64_orig(fd, 0, SEEK_CUR) != files[fd].pos) 274 fprintf(stderr, "ZZUF ERROR: OFFSET INCONSISTENCY\n"); 275 276 return ret; 277 } 278 279 #define LSEEK(fn, off_t) \ 280 do { \ 281 if(!_zzuf_ready) \ 282 LOADSYM(fn); \ 283 ret = ORIG(fn)(fd, offset, whence); \ 284 if(!_zzuf_ready) \ 285 return ret; \ 286 if(!files[fd].managed) \ 287 return ret; \ 288 debug(STR(fn)"(%i, %lli, %i) = %lli", \ 289 fd, (long long int)offset, whence, (long long int)ret); \ 290 if(ret != (off_t)-1) \ 291 files[fd].pos = (int64_t)ret; \ 292 } while(0) 293 294 off_t lseek(int fd, off_t offset, int whence) 295 { 296 off_t ret; 297 LSEEK(lseek, off_t); 270 298 return ret; 271 299 } … … 273 301 off64_t lseek64(int fd, off64_t offset, int whence) 274 302 { 275 int ret; 276 277 if(!_zzuf_ready) 278 LOADSYM(lseek64); 279 ret = lseek64_orig(fd, offset, whence); 280 if(!_zzuf_ready) 281 return ret; 282 283 if(!files[fd].managed) 284 return ret; 285 286 debug("lseek64(%i, %lli, %i) = %i", fd, (long long int)offset, whence, ret); 287 if(ret != (off64_t)-1) 288 files[fd].pos = (int64_t)ret; 289 303 off64_t ret; 304 LSEEK(lseek64, off64_t); 290 305 return ret; 291 306 }
Note: See TracChangeset
for help on using the changeset viewer.
