|
Lines 1-9
Link Here
|
| 1 |
/** |
1 |
/** |
| 2 |
* This file is copyright ©2009 Corvus Corax |
2 |
* This file is copyright ©2009 Corvus Corax |
| 3 |
* Distributed under the terms of the GPL version 2 or higher |
3 |
* Distributed under the terms of the GPL version 2 or higher |
| 4 |
*/ |
4 |
*/ |
|
|
5 |
#define _FILE_OFFSET_BITS 64 |
| 5 |
#include <config.h> |
6 |
#include <config.h> |
| 6 |
|
7 |
|
| 7 |
#ifdef USE_GNU_SOURCE |
8 |
#ifdef USE_GNU_SOURCE |
| 8 |
#define _GNU_SOURCE |
9 |
#define _GNU_SOURCE |
| 9 |
#endif |
10 |
#endif |
|
Lines 33-46
Link Here
|
| 33 |
|
34 |
|
| 34 |
static int mydesc=-1; |
35 |
static int mydesc=-1; |
| 35 |
static off_t current=0; |
36 |
static off_t current=0; |
| 36 |
|
37 |
|
| 37 |
void _init(void); |
38 |
void _init(void); |
|
|
39 |
int open(const char*,int,...); |
| 38 |
int open64(const char*,int,...); |
40 |
int open64(const char*,int,...); |
|
|
41 |
off_t lseek(int,off_t,int); |
| 39 |
off64_t lseek64(int,off64_t,int); |
42 |
off64_t lseek64(int,off64_t,int); |
| 40 |
ssize_t read(int,void*,size_t); |
43 |
ssize_t read(int,void*,size_t); |
| 41 |
int close64(int); |
44 |
int close(int); |
| 42 |
|
45 |
|
| 43 |
ssize_t write(int, const void *, size_t); |
46 |
ssize_t write(int, const void *, size_t); |
| 44 |
|
47 |
|
| 45 |
|
48 |
|
| 46 |
static int softerror[MAXSOFTERRORS]={0}; |
49 |
static int softerror[MAXSOFTERRORS]={0}; |
|
Lines 155-164
Link Here
|
| 155 |
realread=dlsym(RTLD_NEXT,"read"); |
158 |
realread=dlsym(RTLD_NEXT,"read"); |
| 156 |
myprint("debugfile initialising - reading config "CONFIGFILE"\n"); |
159 |
myprint("debugfile initialising - reading config "CONFIGFILE"\n"); |
| 157 |
readoptions(); |
160 |
readoptions(); |
| 158 |
} |
161 |
} |
| 159 |
|
162 |
|
|
|
163 |
int open(const char *pathname, int flags, ...) { |
| 164 |
int mode=0; |
| 165 |
if (flags & O_CREAT) { |
| 166 |
va_list ap; |
| 167 |
va_start (ap,flags); |
| 168 |
mode=va_arg(ap,int); |
| 169 |
va_end(ap); |
| 170 |
} |
| 171 |
return open64(pathname,flags,mode); |
| 172 |
} |
| 173 |
|
| 160 |
int open64(const char *pathname,int flags,...) { |
174 |
int open64(const char *pathname,int flags,...) { |
| 161 |
//va_list ap; |
175 |
//va_list ap; |
| 162 |
int fd; |
176 |
int fd; |
| 163 |
int mode=0; |
177 |
int mode=0; |
| 164 |
if (flags & O_CREAT) { |
178 |
if (flags & O_CREAT) { |
|
Lines 192-201
Link Here
|
| 192 |
mydesc=-1; |
206 |
mydesc=-1; |
| 193 |
} |
207 |
} |
| 194 |
return realclose(fd); |
208 |
return realclose(fd); |
| 195 |
} |
209 |
} |
| 196 |
|
210 |
|
|
|
211 |
off_t lseek(int filedes, off_t offset, int whence) { |
| 212 |
return lseek64(filedes,offset,whence); |
| 213 |
} |
| 214 |
|
| 197 |
off64_t lseek64(int filedes, off64_t offset, int whence) { |
215 |
off64_t lseek64(int filedes, off64_t offset, int whence) { |
| 198 |
off64_t newcurrent=0; |
216 |
off64_t newcurrent=0; |
| 199 |
if ( filedes==mydesc && mydesc!=-1) { |
217 |
if ( filedes==mydesc && mydesc!=-1) { |
| 200 |
if (whence==SEEK_SET) { |
218 |
if (whence==SEEK_SET) { |
| 201 |
myprint("seeking in debug: SEEK_SET to "); |
219 |
myprint("seeking in debug: SEEK_SET to "); |