iotrace.c revision 1.1 1 1.1 christos /* Copyright (C) 2021 Free Software Foundation, Inc.
2 1.1 christos Contributed by Oracle.
3 1.1 christos
4 1.1 christos This file is part of GNU Binutils.
5 1.1 christos
6 1.1 christos This program is free software; you can redistribute it and/or modify
7 1.1 christos it under the terms of the GNU General Public License as published by
8 1.1 christos the Free Software Foundation; either version 3, or (at your option)
9 1.1 christos any later version.
10 1.1 christos
11 1.1 christos This program is distributed in the hope that it will be useful,
12 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
13 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 1.1 christos GNU General Public License for more details.
15 1.1 christos
16 1.1 christos You should have received a copy of the GNU General Public License
17 1.1 christos along with this program; if not, write to the Free Software
18 1.1 christos Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 1.1 christos MA 02110-1301, USA. */
20 1.1 christos
21 1.1 christos /*
22 1.1 christos * IO events
23 1.1 christos */
24 1.1 christos #include "config.h"
25 1.1 christos #include <dlfcn.h>
26 1.1 christos #include <errno.h>
27 1.1 christos #include <stdarg.h>
28 1.1 christos #include <stdlib.h>
29 1.1 christos
30 1.1 christos // create() and others are defined in fcntl.h.
31 1.1 christos // Our 'create' should not have the __nonnull attribute
32 1.1 christos #undef __nonnull
33 1.1 christos #define __nonnull(x)
34 1.1 christos #include <fcntl.h>
35 1.1 christos
36 1.1 christos #include "gp-defs.h"
37 1.1 christos #include "collector_module.h"
38 1.1 christos #include "gp-experiment.h"
39 1.1 christos #include "data_pckts.h"
40 1.1 christos #include "tsd.h"
41 1.1 christos
42 1.1 christos /* TprintfT(<level>,...) definitions. Adjust per module as needed */
43 1.1 christos #define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings
44 1.1 christos #define DBG_LTT 0 // for interposition on GLIBC functions
45 1.1 christos #define DBG_LT1 1 // for configuration details, warnings
46 1.1 christos #define DBG_LT2 2
47 1.1 christos #define DBG_LT3 3
48 1.1 christos
49 1.1 christos /* define the packet that will be written out */
50 1.1 christos typedef struct IOTrace_packet
51 1.1 christos { /* IO tracing packet */
52 1.1 christos Common_packet comm;
53 1.1 christos IOTrace_type iotype; /* IO type */
54 1.1 christos int32_t fd; /* file descriptor */
55 1.1 christos Size_type nbyte; /* number of bytes */
56 1.1 christos hrtime_t requested; /* time of IO requested */
57 1.1 christos int32_t ofd; /* original file descriptor */
58 1.1 christos FileSystem_type fstype; /* file system type */
59 1.1 christos char fname; /* file name */
60 1.1 christos } IOTrace_packet;
61 1.1 christos
62 1.1 christos typedef long long offset_t;
63 1.1 christos
64 1.1 christos static int open_experiment (const char *);
65 1.1 christos static int start_data_collection (void);
66 1.1 christos static int stop_data_collection (void);
67 1.1 christos static int close_experiment (void);
68 1.1 christos static int detach_experiment (void);
69 1.1 christos static int init_io_intf ();
70 1.1 christos
71 1.1 christos static ModuleInterface module_interface ={
72 1.1 christos SP_IOTRACE_FILE, /* description */
73 1.1 christos NULL, /* initInterface */
74 1.1 christos open_experiment, /* openExperiment */
75 1.1 christos start_data_collection, /* startDataCollection */
76 1.1 christos stop_data_collection, /* stopDataCollection */
77 1.1 christos close_experiment, /* closeExperiment */
78 1.1 christos detach_experiment /* detachExperiment (fork child) */
79 1.1 christos };
80 1.1 christos
81 1.1 christos static CollectorInterface *collector_interface = NULL;
82 1.1 christos static struct Heap *io_heap = NULL;
83 1.1 christos static int io_mode = 0;
84 1.1 christos static CollectorModule io_hndl = COLLECTOR_MODULE_ERR;
85 1.1 christos static unsigned io_key = COLLECTOR_TSD_INVALID_KEY;
86 1.1 christos
87 1.1 christos #define CHCK_REENTRANCE(x) (!io_mode || ((x) = collector_interface->getKey( io_key )) == NULL || (*(x) != 0))
88 1.1 christos #define RECHCK_REENTRANCE(x) (!io_mode || ((x) = collector_interface->getKey( io_key )) == NULL || (*(x) == 0))
89 1.1 christos #define PUSH_REENTRANCE(x) ((*(x))++)
90 1.1 christos #define POP_REENTRANCE(x) ((*(x))--)
91 1.1 christos
92 1.1 christos #define CALL_REAL(x) (__real_##x)
93 1.1 christos #define NULL_PTR(x) (__real_##x == NULL)
94 1.1 christos
95 1.1 christos #define gethrtime collector_interface->getHiResTime
96 1.1 christos
97 1.1 christos #ifdef DEBUG
98 1.1 christos #define Tprintf(...) if (collector_interface) collector_interface->writeDebugInfo( 0, __VA_ARGS__ )
99 1.1 christos #define TprintfT(...) if (collector_interface) collector_interface->writeDebugInfo( 1, __VA_ARGS__ )
100 1.1 christos #else
101 1.1 christos #define Tprintf(...)
102 1.1 christos #define TprintfT(...)
103 1.1 christos #endif
104 1.1 christos
105 1.1 christos /* interposition function handles */
106 1.1 christos static int (*__real_open)(const char *path, int oflag, ...) = NULL;
107 1.1 christos static int (*__real_fcntl)(int fildes, int cmd, ...) = NULL;
108 1.1 christos static int (*__real_openat)(int fildes, const char *path, int oflag, ...) = NULL;
109 1.1 christos static int (*__real_close)(int fildes) = NULL;
110 1.1 christos static FILE *(*__real_fopen)(const char *filename, const char *mode) = NULL;
111 1.1 christos static int (*__real_fclose)(FILE *stream) = NULL;
112 1.1 christos static int (*__real_dup)(int fildes) = NULL;
113 1.1 christos static int (*__real_dup2)(int fildes, int fildes2) = NULL;
114 1.1 christos static int (*__real_pipe)(int fildes[2]) = NULL;
115 1.1 christos static int (*__real_socket)(int domain, int type, int protocol) = NULL;
116 1.1 christos static int (*__real_mkstemp)(char *template) = NULL;
117 1.1 christos static int (*__real_mkstemps)(char *template, int slen) = NULL;
118 1.1 christos static int (*__real_creat)(const char *path, mode_t mode) = NULL;
119 1.1 christos static FILE *(*__real_fdopen)(int fildes, const char *mode) = NULL;
120 1.1 christos static ssize_t (*__real_read)(int fildes, void *buf, size_t nbyte) = NULL;
121 1.1 christos static ssize_t (*__real_write)(int fildes, const void *buf, size_t nbyte) = NULL;
122 1.1 christos static ssize_t (*__real_readv)(int fildes, const struct iovec *iov, int iovcnt) = NULL;
123 1.1 christos static ssize_t (*__real_writev)(int fildes, const struct iovec *iov, int iovcnt) = NULL;
124 1.1 christos static size_t (*__real_fread)(void *ptr, size_t size, size_t nitems, FILE *stream) = NULL;
125 1.1 christos static size_t (*__real_fwrite)(const void *ptr, size_t size, size_t nitems, FILE *stream) = NULL;
126 1.1 christos static ssize_t (*__real_pread)(int fildes, void *buf, size_t nbyte, off_t offset) = NULL;
127 1.1 christos static ssize_t (*__real_pwrite)(int fildes, const void *buf, size_t nbyte, off_t offset) = NULL;
128 1.1 christos static ssize_t (*__real_pwrite64)(int fildes, const void *buf, size_t nbyte, off64_t offset) = NULL;
129 1.1 christos static char *(*__real_fgets)(char *s, int n, FILE *stream) = NULL;
130 1.1 christos static int (*__real_fputs)(const char *s, FILE *stream) = NULL;
131 1.1 christos static int (*__real_fputc)(int c, FILE *stream) = NULL;
132 1.1 christos static int (*__real_fprintf)(FILE *stream, const char *format, ...) = NULL;
133 1.1 christos static int (*__real_vfprintf)(FILE *stream, const char *format, va_list ap) = NULL;
134 1.1 christos static off_t (*__real_lseek)(int fildes, off_t offset, int whence) = NULL;
135 1.1 christos static offset_t (*__real_llseek)(int fildes, offset_t offset, int whence) = NULL;
136 1.1 christos static int (*__real_chmod)(const char *path, mode_t mode) = NULL;
137 1.1 christos static int (*__real_access)(const char *path, int amode) = NULL;
138 1.1 christos static int (*__real_rename)(const char *old, const char *new) = NULL;
139 1.1 christos static int (*__real_mkdir)(const char *path, mode_t mode) = NULL;
140 1.1 christos static int (*__real_getdents)(int fildes, struct dirent *buf, size_t nbyte) = NULL;
141 1.1 christos static int (*__real_unlink)(const char *path) = NULL;
142 1.1 christos static int (*__real_fseek)(FILE *stream, long offset, int whence) = NULL;
143 1.1 christos static void (*__real_rewind)(FILE *stream) = NULL;
144 1.1 christos static long (*__real_ftell)(FILE *stream) = NULL;
145 1.1 christos static int (*__real_fgetpos)(FILE *stream, fpos_t *pos) = NULL;
146 1.1 christos static int (*__real_fsetpos)(FILE *stream, const fpos_t *pos) = NULL;
147 1.1 christos static int (*__real_fsync)(int fildes) = NULL;
148 1.1 christos static struct dirent *(*__real_readdir)(DIR *dirp) = NULL;
149 1.1 christos static int (*__real_flock)(int fd, int operation) = NULL;
150 1.1 christos static int (*__real_lockf)(int fildes, int function, off_t size) = NULL;
151 1.1 christos static int (*__real_fflush)(FILE *stream) = NULL;
152 1.1 christos
153 1.1 christos #if WSIZE(32)
154 1.1 christos static int (*__real_open64)(const char *path, int oflag, ...) = NULL;
155 1.1 christos static int (*__real_creat64)(const char *path, mode_t mode) = NULL;
156 1.1 christos static int (*__real_fgetpos64)(FILE *stream, fpos64_t *pos) = NULL;
157 1.1 christos static int (*__real_fsetpos64)(FILE *stream, const fpos64_t *pos) = NULL;
158 1.1 christos
159 1.1 christos #if ARCH(Intel)
160 1.1 christos static FILE *(*__real_fopen_2_1)(const char *filename, const char *mode) = NULL;
161 1.1 christos static int (*__real_fclose_2_1)(FILE *stream) = NULL;
162 1.1 christos static FILE *(*__real_fdopen_2_1)(int fildes, const char *mode) = NULL;
163 1.1 christos static int (*__real_fgetpos_2_2)(FILE *stream, fpos_t *pos) = NULL;
164 1.1 christos static int (*__real_fsetpos_2_2)(FILE *stream, const fpos_t *pos) = NULL;
165 1.1 christos static int (*__real_fgetpos64_2_2)(FILE *stream, fpos64_t *pos) = NULL;
166 1.1 christos static int (*__real_fsetpos64_2_2)(FILE *stream, const fpos64_t *pos) = NULL;
167 1.1 christos static int (*__real_open64_2_2)(const char *path, int oflag, ...) = NULL;
168 1.1 christos static ssize_t (*__real_pread_2_2)(int fildes, void *buf, size_t nbyte, off_t offset) = NULL;
169 1.1 christos static ssize_t (*__real_pwrite_2_2)(int fildes, const void *buf, size_t nbyte, off_t offset) = NULL;
170 1.1 christos static ssize_t (*__real_pwrite64_2_2)(int fildes, const void *buf, size_t nbyte, off64_t offset) = NULL;
171 1.1 christos static FILE *(*__real_fopen_2_0)(const char *filename, const char *mode) = NULL;
172 1.1 christos static int (*__real_fclose_2_0)(FILE *stream) = NULL;
173 1.1 christos static FILE *(*__real_fdopen_2_0)(int fildes, const char *mode) = NULL;
174 1.1 christos static int (*__real_fgetpos_2_0)(FILE *stream, fpos_t *pos) = NULL;
175 1.1 christos static int (*__real_fsetpos_2_0)(FILE *stream, const fpos_t *pos) = NULL;
176 1.1 christos static int (*__real_fgetpos64_2_1)(FILE *stream, fpos64_t *pos) = NULL;
177 1.1 christos static int (*__real_fsetpos64_2_1)(FILE *stream, const fpos64_t *pos) = NULL;
178 1.1 christos static int (*__real_open64_2_1)(const char *path, int oflag, ...) = NULL;
179 1.1 christos static ssize_t (*__real_pread_2_1)(int fildes, void *buf, size_t nbyte, off_t offset) = NULL;
180 1.1 christos static ssize_t (*__real_pwrite_2_1)(int fildes, const void *buf, size_t nbyte, off_t offset) = NULL;
181 1.1 christos static ssize_t (*__real_pwrite64_2_1)(int fildes, const void *buf, size_t nbyte, off64_t offset) = NULL;
182 1.1 christos #endif /* ARCH() */
183 1.1 christos #endif /* WSIZE(32) */
184 1.1 christos
185 1.1 christos static int
186 1.1 christos collector_align_pktsize (int sz)
187 1.1 christos {
188 1.1 christos int pktSize = sz;
189 1.1 christos if (sz <= 0)
190 1.1 christos return sz;
191 1.1 christos if ((sz % 8) != 0)
192 1.1 christos {
193 1.1 christos pktSize = (sz / 8) + 1;
194 1.1 christos pktSize *= 8;
195 1.1 christos }
196 1.1 christos return pktSize;
197 1.1 christos }
198 1.1 christos
199 1.1 christos static void
200 1.1 christos collector_memset (void *s, int c, size_t n)
201 1.1 christos {
202 1.1 christos unsigned char *s1 = s;
203 1.1 christos while (n--)
204 1.1 christos *s1++ = (unsigned char) c;
205 1.1 christos }
206 1.1 christos
207 1.1 christos static size_t
208 1.1 christos collector_strlen (const char *s)
209 1.1 christos {
210 1.1 christos if (s == NULL)
211 1.1 christos return 0;
212 1.1 christos int len = -1;
213 1.1 christos while (s[++len] != '\0')
214 1.1 christos ;
215 1.1 christos return len;
216 1.1 christos }
217 1.1 christos
218 1.1 christos static size_t
219 1.1 christos collector_strncpy (char *dst, const char *src, size_t dstsize)
220 1.1 christos {
221 1.1 christos size_t i;
222 1.1 christos for (i = 0; i < dstsize; i++)
223 1.1 christos {
224 1.1 christos dst[i] = src[i];
225 1.1 christos if (src[i] == '\0')
226 1.1 christos break;
227 1.1 christos }
228 1.1 christos return i;
229 1.1 christos }
230 1.1 christos
231 1.1 christos static char *
232 1.1 christos collector_strchr (const char *s, int c)
233 1.1 christos {
234 1.1 christos do
235 1.1 christos {
236 1.1 christos if (*s == (char) c)
237 1.1 christos return ((char *) s);
238 1.1 christos }
239 1.1 christos while (*s++);
240 1.1 christos return (NULL);
241 1.1 christos }
242 1.1 christos
243 1.1 christos static FileSystem_type
244 1.1 christos collector_fstype (const char *path)
245 1.1 christos {
246 1.1 christos return UNKNOWNFS_TYPE;
247 1.1 christos }
248 1.1 christos
249 1.1 christos void
250 1.1 christos __collector_module_init (CollectorInterface *_collector_interface)
251 1.1 christos {
252 1.1 christos if (_collector_interface == NULL)
253 1.1 christos return;
254 1.1 christos collector_interface = _collector_interface;
255 1.1 christos Tprintf (0, "iotrace: __collector_module_init\n");
256 1.1 christos io_hndl = collector_interface->registerModule (&module_interface);
257 1.1 christos /* Initialize next module */
258 1.1 christos ModuleInitFunc next_init = (ModuleInitFunc) dlsym (RTLD_NEXT, "__collector_module_init");
259 1.1 christos if (next_init != NULL)
260 1.1 christos next_init (_collector_interface);
261 1.1 christos return;
262 1.1 christos }
263 1.1 christos
264 1.1 christos static int
265 1.1 christos open_experiment (const char *exp)
266 1.1 christos {
267 1.1 christos if (collector_interface == NULL)
268 1.1 christos {
269 1.1 christos Tprintf (0, "iotrace: collector_interface is null.\n");
270 1.1 christos return COL_ERROR_IOINIT;
271 1.1 christos }
272 1.1 christos if (io_hndl == COLLECTOR_MODULE_ERR)
273 1.1 christos {
274 1.1 christos Tprintf (0, "iotrace: handle create failed.\n");
275 1.1 christos collector_interface->writeLog ("<event kind=\"%s\" id=\"%d\">data handle not created</event>\n",
276 1.1 christos SP_JCMD_CERROR, COL_ERROR_IOINIT);
277 1.1 christos return COL_ERROR_IOINIT;
278 1.1 christos }
279 1.1 christos TprintfT (0, "iotrace: open_experiment %s\n", exp);
280 1.1 christos if (NULL_PTR (fopen))
281 1.1 christos init_io_intf ();
282 1.1 christos if (io_heap == NULL)
283 1.1 christos {
284 1.1 christos io_heap = collector_interface->newHeap ();
285 1.1 christos if (io_heap == NULL)
286 1.1 christos {
287 1.1 christos Tprintf (0, "iotrace: new heap failed.\n");
288 1.1 christos collector_interface->writeLog ("<event kind=\"%s\" id=\"%d\">new iotrace heap not created</event>\n",
289 1.1 christos SP_JCMD_CERROR, COL_ERROR_IOINIT);
290 1.1 christos return COL_ERROR_IOINIT;
291 1.1 christos }
292 1.1 christos }
293 1.1 christos
294 1.1 christos const char *params = collector_interface->getParams ();
295 1.1 christos while (params)
296 1.1 christos {
297 1.1 christos if ((params[0] == 'i') && (params[1] == ':'))
298 1.1 christos {
299 1.1 christos params += 2;
300 1.1 christos break;
301 1.1 christos }
302 1.1 christos params = collector_strchr (params, ';');
303 1.1 christos if (params)
304 1.1 christos params++;
305 1.1 christos }
306 1.1 christos if (params == NULL) /* IO data collection not specified */
307 1.1 christos return COL_ERROR_IOINIT;
308 1.1 christos
309 1.1 christos io_key = collector_interface->createKey (sizeof ( int), NULL, NULL);
310 1.1 christos if (io_key == (unsigned) - 1)
311 1.1 christos {
312 1.1 christos Tprintf (0, "iotrace: TSD key create failed.\n");
313 1.1 christos collector_interface->writeLog ("<event kind=\"%s\" id=\"%d\">TSD key not created</event>\n",
314 1.1 christos SP_JCMD_CERROR, COL_ERROR_IOINIT);
315 1.1 christos return COL_ERROR_IOINIT;
316 1.1 christos }
317 1.1 christos
318 1.1 christos collector_interface->writeLog ("<profile name=\"%s\">\n", SP_JCMD_IOTRACE);
319 1.1 christos collector_interface->writeLog (" <profdata fname=\"%s\"/>\n",
320 1.1 christos module_interface.description);
321 1.1 christos /* Record IOTrace_packet description */
322 1.1 christos IOTrace_packet *pp = NULL;
323 1.1 christos collector_interface->writeLog (" <profpckt kind=\"%d\" uname=\"IO tracing data\">\n", IOTRACE_PCKT);
324 1.1 christos collector_interface->writeLog (" <field name=\"LWPID\" uname=\"Lightweight process id\" offset=\"%d\" type=\"%s\"/>\n",
325 1.1 christos &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) == 4 ? "INT32" : "INT64");
326 1.1 christos collector_interface->writeLog (" <field name=\"THRID\" uname=\"Thread number\" offset=\"%d\" type=\"%s\"/>\n",
327 1.1 christos &pp->comm.thr_id, sizeof (pp->comm.thr_id) == 4 ? "INT32" : "INT64");
328 1.1 christos collector_interface->writeLog (" <field name=\"CPUID\" uname=\"CPU id\" offset=\"%d\" type=\"%s\"/>\n",
329 1.1 christos &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) == 4 ? "INT32" : "INT64");
330 1.1 christos collector_interface->writeLog (" <field name=\"TSTAMP\" uname=\"High resolution timestamp\" offset=\"%d\" type=\"%s\"/>\n",
331 1.1 christos &pp->comm.tstamp, sizeof (pp->comm.tstamp) == 4 ? "INT32" : "INT64");
332 1.1 christos collector_interface->writeLog (" <field name=\"FRINFO\" offset=\"%d\" type=\"%s\"/>\n",
333 1.1 christos &pp->comm.frinfo, sizeof (pp->comm.frinfo) == 4 ? "INT32" : "INT64");
334 1.1 christos collector_interface->writeLog (" <field name=\"IOTYPE\" uname=\"IO trace function type\" offset=\"%d\" type=\"%s\"/>\n",
335 1.1 christos &pp->iotype, sizeof (pp->iotype) == 4 ? "INT32" : "INT64");
336 1.1 christos collector_interface->writeLog (" <field name=\"IOFD\" uname=\"File descriptor\" offset=\"%d\" type=\"%s\"/>\n",
337 1.1 christos &pp->fd, sizeof (pp->fd) == 4 ? "INT32" : "INT64");
338 1.1 christos collector_interface->writeLog (" <field name=\"IONBYTE\" uname=\"Number of bytes\" offset=\"%d\" type=\"%s\"/>\n",
339 1.1 christos &pp->nbyte, sizeof (pp->nbyte) == 4 ? "INT32" : "INT64");
340 1.1 christos collector_interface->writeLog (" <field name=\"IORQST\" uname=\"Time of IO requested\" offset=\"%d\" type=\"%s\"/>\n",
341 1.1 christos &pp->requested, sizeof (pp->requested) == 4 ? "INT32" : "INT64");
342 1.1 christos collector_interface->writeLog (" <field name=\"IOOFD\" uname=\"Original file descriptor\" offset=\"%d\" type=\"%s\"/>\n",
343 1.1 christos &pp->ofd, sizeof (pp->ofd) == 4 ? "INT32" : "INT64");
344 1.1 christos collector_interface->writeLog (" <field name=\"IOFSTYPE\" uname=\"File system type\" offset=\"%d\" type=\"%s\"/>\n",
345 1.1 christos &pp->fstype, sizeof (pp->fstype) == 4 ? "INT32" : "INT64");
346 1.1 christos collector_interface->writeLog (" <field name=\"IOFNAME\" uname=\"File name\" offset=\"%d\" type=\"%s\"/>\n",
347 1.1 christos &pp->fname, "STRING");
348 1.1 christos collector_interface->writeLog (" </profpckt>\n");
349 1.1 christos collector_interface->writeLog ("</profile>\n");
350 1.1 christos return COL_ERROR_NONE;
351 1.1 christos }
352 1.1 christos
353 1.1 christos static int
354 1.1 christos start_data_collection (void)
355 1.1 christos {
356 1.1 christos io_mode = 1;
357 1.1 christos Tprintf (0, "iotrace: start_data_collection\n");
358 1.1 christos return 0;
359 1.1 christos }
360 1.1 christos
361 1.1 christos static int
362 1.1 christos stop_data_collection (void)
363 1.1 christos {
364 1.1 christos io_mode = 0;
365 1.1 christos Tprintf (0, "iotrace: stop_data_collection\n");
366 1.1 christos return 0;
367 1.1 christos }
368 1.1 christos
369 1.1 christos static int
370 1.1 christos close_experiment (void)
371 1.1 christos {
372 1.1 christos io_mode = 0;
373 1.1 christos io_key = COLLECTOR_TSD_INVALID_KEY;
374 1.1 christos if (io_heap != NULL)
375 1.1 christos {
376 1.1 christos collector_interface->deleteHeap (io_heap);
377 1.1 christos io_heap = NULL;
378 1.1 christos }
379 1.1 christos Tprintf (0, "iotrace: close_experiment\n");
380 1.1 christos return 0;
381 1.1 christos }
382 1.1 christos
383 1.1 christos static int
384 1.1 christos detach_experiment (void)
385 1.1 christos {
386 1.1 christos /* fork child. Clean up state but don't write to experiment */
387 1.1 christos io_mode = 0;
388 1.1 christos io_key = COLLECTOR_TSD_INVALID_KEY;
389 1.1 christos if (io_heap != NULL)
390 1.1 christos {
391 1.1 christos collector_interface->deleteHeap (io_heap);
392 1.1 christos io_heap = NULL;
393 1.1 christos }
394 1.1 christos Tprintf (0, "iotrace: detach_experiment\n");
395 1.1 christos return 0;
396 1.1 christos }
397 1.1 christos
398 1.1 christos static int
399 1.1 christos init_io_intf ()
400 1.1 christos {
401 1.1 christos void *dlflag;
402 1.1 christos int rc = 0;
403 1.1 christos /* if we detect recursion/reentrance, SEGV so we can get a stack */
404 1.1 christos static int init_io_intf_started;
405 1.1 christos static int init_io_intf_finished;
406 1.1 christos init_io_intf_started++;
407 1.1 christos if (!init_io_intf_finished && init_io_intf_started >= 3)
408 1.1 christos {
409 1.1 christos /* pull the plug if recursion occurs... */
410 1.1 christos abort ();
411 1.1 christos }
412 1.1 christos
413 1.1 christos /* lookup fprint to print fatal error message */
414 1.1 christos void *ptr = dlsym (RTLD_NEXT, "fprintf");
415 1.1 christos if (ptr)
416 1.1 christos __real_fprintf = (int (*)(FILE*, const char*, ...)) ptr;
417 1.1 christos else
418 1.1 christos abort ();
419 1.1 christos
420 1.1 christos #if ARCH(Intel)
421 1.1 christos #if WSIZE(32)
422 1.1 christos #define SYS_FOPEN_X_VERSION "GLIBC_2.1"
423 1.1 christos #define SYS_FGETPOS_X_VERSION "GLIBC_2.2"
424 1.1 christos #define SYS_FGETPOS64_X_VERSION "GLIBC_2.2"
425 1.1 christos #define SYS_OPEN64_X_VERSION "GLIBC_2.2"
426 1.1 christos #define SYS_PREAD_X_VERSION "GLIBC_2.2"
427 1.1 christos #define SYS_PWRITE_X_VERSION "GLIBC_2.2"
428 1.1 christos #define SYS_PWRITE64_X_VERSION "GLIBC_2.2"
429 1.1 christos #else /* WSIZE(64) */
430 1.1 christos #define SYS_FOPEN_X_VERSION "GLIBC_2.2.5"
431 1.1 christos #define SYS_FGETPOS_X_VERSION "GLIBC_2.2.5"
432 1.1 christos #endif
433 1.1 christos #elif ARCH(SPARC)
434 1.1 christos #if WSIZE(32)
435 1.1 christos #define SYS_FOPEN_X_VERSION "GLIBC_2.1"
436 1.1 christos #define SYS_FGETPOS_X_VERSION "GLIBC_2.2"
437 1.1 christos #else /* WSIZE(64) */
438 1.1 christos #define SYS_FOPEN_X_VERSION "GLIBC_2.2"
439 1.1 christos #define SYS_FGETPOS_X_VERSION "GLIBC_2.2"
440 1.1 christos #endif
441 1.1 christos #elif ARCH(Aarch64)
442 1.1 christos #define SYS_FOPEN_X_VERSION "GLIBC_2.17"
443 1.1 christos #define SYS_FGETPOS_X_VERSION "GLIBC_2.17"
444 1.1 christos #endif /* ARCH() */
445 1.1 christos
446 1.1 christos #if WSIZE(32)
447 1.1 christos dlflag = RTLD_NEXT;
448 1.1 christos __real_fopen = (FILE * (*)(const char*, const char*))dlvsym (dlflag, "fopen", SYS_FOPEN_X_VERSION);
449 1.1 christos if (__real_fopen == NULL)
450 1.1 christos {
451 1.1 christos /* We are probably dlopened after libc,
452 1.1 christos * try to search in the previously loaded objects
453 1.1 christos */
454 1.1 christos __real_fopen = (FILE * (*)(const char*, const char*))dlvsym (RTLD_DEFAULT, "fopen", SYS_FOPEN_X_VERSION);
455 1.1 christos if (__real_fopen != NULL)
456 1.1 christos {
457 1.1 christos Tprintf (0, "iotrace: WARNING: init_io_intf() using RTLD_DEFAULT for Linux io routines\n");
458 1.1 christos dlflag = RTLD_DEFAULT;
459 1.1 christos }
460 1.1 christos else
461 1.1 christos {
462 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fopen\n");
463 1.1 christos rc = COL_ERROR_IOINIT;
464 1.1 christos }
465 1.1 christos }
466 1.1 christos
467 1.1 christos __real_fclose = (int (*)(FILE*))dlvsym (dlflag, "fclose", SYS_FOPEN_X_VERSION);
468 1.1 christos if (__real_fclose == NULL)
469 1.1 christos {
470 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fclose\n");
471 1.1 christos rc = COL_ERROR_IOINIT;
472 1.1 christos }
473 1.1 christos
474 1.1 christos __real_fdopen = (FILE * (*)(int, const char*))dlvsym (dlflag, "fdopen", SYS_FOPEN_X_VERSION);
475 1.1 christos if (__real_fdopen == NULL)
476 1.1 christos {
477 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fdopen\n");
478 1.1 christos rc = COL_ERROR_IOINIT;
479 1.1 christos }
480 1.1 christos
481 1.1 christos __real_fgetpos = (int (*)(FILE*, fpos_t*))dlvsym (dlflag, "fgetpos", SYS_FGETPOS_X_VERSION);
482 1.1 christos if (__real_fgetpos == NULL)
483 1.1 christos {
484 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos\n");
485 1.1 christos rc = COL_ERROR_IOINIT;
486 1.1 christos }
487 1.1 christos
488 1.1 christos __real_fsetpos = (int (*)(FILE*, const fpos_t*))dlvsym (dlflag, "fsetpos", SYS_FGETPOS_X_VERSION);
489 1.1 christos if (__real_fsetpos == NULL)
490 1.1 christos {
491 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos\n");
492 1.1 christos rc = COL_ERROR_IOINIT;
493 1.1 christos }
494 1.1 christos
495 1.1 christos
496 1.1 christos #if ARCH(Intel)
497 1.1 christos __real_fopen_2_1 = __real_fopen;
498 1.1 christos __real_fclose_2_1 = __real_fclose;
499 1.1 christos __real_fdopen_2_1 = __real_fdopen;
500 1.1 christos __real_fgetpos_2_2 = __real_fgetpos;
501 1.1 christos __real_fsetpos_2_2 = __real_fsetpos;
502 1.1 christos
503 1.1 christos __real_fopen_2_0 = (FILE * (*)(const char*, const char*))dlvsym (dlflag, "fopen", "GLIBC_2.0");
504 1.1 christos if (__real_fopen_2_0 == NULL)
505 1.1 christos {
506 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fopen_2_0\n");
507 1.1 christos rc = COL_ERROR_IOINIT;
508 1.1 christos }
509 1.1 christos
510 1.1 christos __real_fclose_2_0 = (int (*)(FILE*))dlvsym (dlflag, "fclose", "GLIBC_2.0");
511 1.1 christos if (__real_fclose_2_0 == NULL)
512 1.1 christos {
513 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fclose_2_0\n");
514 1.1 christos rc = COL_ERROR_IOINIT;
515 1.1 christos }
516 1.1 christos
517 1.1 christos __real_fdopen_2_0 = (FILE * (*)(int, const char*))dlvsym (dlflag, "fdopen", "GLIBC_2.0");
518 1.1 christos if (__real_fdopen_2_0 == NULL)
519 1.1 christos {
520 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fdopen_2_0\n");
521 1.1 christos rc = COL_ERROR_IOINIT;
522 1.1 christos }
523 1.1 christos
524 1.1 christos __real_fgetpos_2_0 = (int (*)(FILE*, fpos_t*))dlvsym (dlflag, "fgetpos", "GLIBC_2.0");
525 1.1 christos if (__real_fgetpos_2_0 == NULL)
526 1.1 christos {
527 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos_2_0\n");
528 1.1 christos rc = COL_ERROR_IOINIT;
529 1.1 christos }
530 1.1 christos
531 1.1 christos __real_fsetpos_2_0 = (int (*)(FILE*, const fpos_t*))dlvsym (dlflag, "fsetpos", "GLIBC_2.0");
532 1.1 christos if (__real_fsetpos_2_0 == NULL)
533 1.1 christos {
534 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos_2_0\n");
535 1.1 christos rc = COL_ERROR_IOINIT;
536 1.1 christos }
537 1.1 christos
538 1.1 christos __real_fgetpos64_2_1 = (int (*)(FILE*, fpos64_t*))dlvsym (dlflag, "fgetpos64", "GLIBC_2.1");
539 1.1 christos if (__real_fgetpos64_2_1 == NULL)
540 1.1 christos {
541 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos64_2_1\n");
542 1.1 christos rc = COL_ERROR_IOINIT;
543 1.1 christos }
544 1.1 christos
545 1.1 christos __real_fsetpos64_2_1 = (int (*)(FILE*, const fpos64_t*))dlvsym (dlflag, "fsetpos64", "GLIBC_2.1");
546 1.1 christos if (__real_fsetpos64_2_1 == NULL)
547 1.1 christos {
548 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos64_2_1\n");
549 1.1 christos rc = COL_ERROR_IOINIT;
550 1.1 christos }
551 1.1 christos
552 1.1 christos __real_open64_2_1 = (int (*)(const char*, int, ...))dlvsym (dlflag, "open64", "GLIBC_2.1");
553 1.1 christos if (__real_open64_2_1 == NULL)
554 1.1 christos {
555 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT open64_2_1\n");
556 1.1 christos rc = COL_ERROR_IOINIT;
557 1.1 christos }
558 1.1 christos
559 1.1 christos __real_pread_2_1 = (int (*)(int fildes, void *buf, size_t nbyte, off_t offset))dlvsym (dlflag, "pread", "GLIBC_2.1");
560 1.1 christos if (__real_pread_2_1 == NULL)
561 1.1 christos {
562 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pread_2_1\n");
563 1.1 christos rc = COL_ERROR_IOINIT;
564 1.1 christos }
565 1.1 christos
566 1.1 christos __real_pwrite_2_1 = (int (*)(int fildes, const void *buf, size_t nbyte, off_t offset))dlvsym (dlflag, "pwrite", "GLIBC_2.1");
567 1.1 christos if (__real_pwrite_2_1 == NULL)
568 1.1 christos {
569 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite_2_1\n");
570 1.1 christos rc = COL_ERROR_IOINIT;
571 1.1 christos }
572 1.1 christos
573 1.1 christos __real_pwrite64_2_1 = (int (*)(int fildes, const void *buf, size_t nbyte, off64_t offset))dlvsym (dlflag, "pwrite64", "GLIBC_2.1");
574 1.1 christos if (__real_pwrite64_2_1 == NULL)
575 1.1 christos {
576 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite64_2_1\n");
577 1.1 christos rc = COL_ERROR_IOINIT;
578 1.1 christos }
579 1.1 christos
580 1.1 christos __real_fgetpos64_2_2 = (int (*)(FILE*, fpos64_t*))dlvsym (dlflag, "fgetpos64", SYS_FGETPOS64_X_VERSION);
581 1.1 christos if (__real_fgetpos64_2_2 == NULL)
582 1.1 christos {
583 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos64_2_2\n");
584 1.1 christos rc = COL_ERROR_IOINIT;
585 1.1 christos }
586 1.1 christos
587 1.1 christos __real_fsetpos64_2_2 = (int (*)(FILE*, const fpos64_t*))dlvsym (dlflag, "fsetpos64", SYS_FGETPOS64_X_VERSION);
588 1.1 christos if (__real_fsetpos64_2_2 == NULL)
589 1.1 christos {
590 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos64_2_2\n");
591 1.1 christos rc = COL_ERROR_IOINIT;
592 1.1 christos }
593 1.1 christos
594 1.1 christos __real_open64_2_2 = (int (*)(const char*, int, ...))dlvsym (dlflag, "open64", SYS_OPEN64_X_VERSION);
595 1.1 christos if (__real_open64_2_2 == NULL)
596 1.1 christos {
597 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT open64_2_2\n");
598 1.1 christos rc = COL_ERROR_IOINIT;
599 1.1 christos }
600 1.1 christos
601 1.1 christos __real_pread_2_2 = (int (*)(int fildes, void *buf, size_t nbyte, off_t offset))dlvsym (dlflag, "pread", SYS_PREAD_X_VERSION);
602 1.1 christos if (__real_pread_2_2 == NULL)
603 1.1 christos {
604 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pread_2_2\n");
605 1.1 christos rc = COL_ERROR_IOINIT;
606 1.1 christos }
607 1.1 christos
608 1.1 christos __real_pwrite_2_2 = (int (*)(int fildes, const void *buf, size_t nbyte, off_t offset))dlvsym (dlflag, "pwrite", SYS_PWRITE_X_VERSION);
609 1.1 christos if (__real_pwrite_2_2 == NULL)
610 1.1 christos {
611 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite_2_2\n");
612 1.1 christos rc = COL_ERROR_IOINIT;
613 1.1 christos }
614 1.1 christos
615 1.1 christos __real_pwrite64_2_2 = (int (*)(int fildes, const void *buf, size_t nbyte, off64_t offset))dlvsym (dlflag, "pwrite64", SYS_PWRITE64_X_VERSION);
616 1.1 christos if (__real_pwrite64_2_2 == NULL)
617 1.1 christos {
618 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite64_2_2\n");
619 1.1 christos rc = COL_ERROR_IOINIT;
620 1.1 christos }
621 1.1 christos
622 1.1 christos #endif
623 1.1 christos
624 1.1 christos #else /* WSIZE(64) */
625 1.1 christos dlflag = RTLD_NEXT;
626 1.1 christos __real_fopen = (FILE * (*)(const char*, const char*))dlvsym (dlflag, "fopen", SYS_FOPEN_X_VERSION);
627 1.1 christos if (__real_fopen == NULL)
628 1.1 christos {
629 1.1 christos /* We are probably dlopened after libc,
630 1.1 christos * try to search in the previously loaded objects
631 1.1 christos */
632 1.1 christos __real_fopen = (FILE * (*)(const char*, const char*))dlvsym (RTLD_DEFAULT, "fopen", SYS_FOPEN_X_VERSION);
633 1.1 christos if (__real_fopen != NULL)
634 1.1 christos {
635 1.1 christos Tprintf (0, "iotrace: WARNING: init_io_intf() using RTLD_DEFAULT for Linux io routines\n");
636 1.1 christos dlflag = RTLD_DEFAULT;
637 1.1 christos }
638 1.1 christos else
639 1.1 christos {
640 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fopen\n");
641 1.1 christos rc = COL_ERROR_IOINIT;
642 1.1 christos }
643 1.1 christos }
644 1.1 christos
645 1.1 christos __real_fclose = (int (*)(FILE*))dlvsym (dlflag, "fclose", SYS_FOPEN_X_VERSION);
646 1.1 christos if (__real_fclose == NULL)
647 1.1 christos {
648 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fclose\n");
649 1.1 christos rc = COL_ERROR_IOINIT;
650 1.1 christos }
651 1.1 christos
652 1.1 christos __real_fdopen = (FILE * (*)(int, const char*))dlvsym (dlflag, "fdopen", SYS_FOPEN_X_VERSION);
653 1.1 christos if (__real_fdopen == NULL)
654 1.1 christos {
655 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fdopen\n");
656 1.1 christos rc = COL_ERROR_IOINIT;
657 1.1 christos }
658 1.1 christos
659 1.1 christos __real_fgetpos = (int (*)(FILE*, fpos_t*))dlvsym (dlflag, "fgetpos", SYS_FGETPOS_X_VERSION);
660 1.1 christos if (__real_fgetpos == NULL)
661 1.1 christos {
662 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos\n");
663 1.1 christos rc = COL_ERROR_IOINIT;
664 1.1 christos }
665 1.1 christos
666 1.1 christos __real_fsetpos = (int (*)(FILE*, const fpos_t*))dlvsym (dlflag, "fsetpos", SYS_FGETPOS_X_VERSION);
667 1.1 christos if (__real_fsetpos == NULL)
668 1.1 christos {
669 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos\n");
670 1.1 christos rc = COL_ERROR_IOINIT;
671 1.1 christos }
672 1.1 christos #endif /* WSIZE(32) */
673 1.1 christos
674 1.1 christos __real_open = (int (*)(const char*, int, ...))dlsym (dlflag, "open");
675 1.1 christos if (__real_open == NULL)
676 1.1 christos {
677 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT open\n");
678 1.1 christos rc = COL_ERROR_IOINIT;
679 1.1 christos }
680 1.1 christos
681 1.1 christos #if WSIZE(32)
682 1.1 christos __real_open64 = (int (*)(const char*, int, ...))dlsym (dlflag, "open64");
683 1.1 christos if (__real_open64 == NULL)
684 1.1 christos {
685 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT open64\n");
686 1.1 christos rc = COL_ERROR_IOINIT;
687 1.1 christos }
688 1.1 christos #endif
689 1.1 christos
690 1.1 christos __real_fcntl = (int (*)(int, int, ...))dlsym (dlflag, "fcntl");
691 1.1 christos if (__real_fcntl == NULL)
692 1.1 christos {
693 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fcntl\n");
694 1.1 christos rc = COL_ERROR_IOINIT;
695 1.1 christos }
696 1.1 christos
697 1.1 christos __real_openat = (int (*)(int, const char*, int, ...))dlsym (dlflag, "openat");
698 1.1 christos if (__real_openat == NULL)
699 1.1 christos {
700 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT openat\n");
701 1.1 christos rc = COL_ERROR_IOINIT;
702 1.1 christos }
703 1.1 christos
704 1.1 christos __real_close = (int (*)(int))dlsym (dlflag, "close");
705 1.1 christos if (__real_close == NULL)
706 1.1 christos {
707 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT close\n");
708 1.1 christos rc = COL_ERROR_IOINIT;
709 1.1 christos }
710 1.1 christos
711 1.1 christos __real_dup = (int (*)(int))dlsym (dlflag, "dup");
712 1.1 christos if (__real_dup == NULL)
713 1.1 christos {
714 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT dup\n");
715 1.1 christos rc = COL_ERROR_IOINIT;
716 1.1 christos }
717 1.1 christos
718 1.1 christos __real_dup2 = (int (*)(int, int))dlsym (dlflag, "dup2");
719 1.1 christos if (__real_dup2 == NULL)
720 1.1 christos {
721 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT dup2\n");
722 1.1 christos rc = COL_ERROR_IOINIT;
723 1.1 christos }
724 1.1 christos
725 1.1 christos __real_pipe = (int (*)(int[]))dlsym (dlflag, "pipe");
726 1.1 christos if (__real_pipe == NULL)
727 1.1 christos {
728 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pipe\n");
729 1.1 christos rc = COL_ERROR_IOINIT;
730 1.1 christos }
731 1.1 christos
732 1.1 christos __real_socket = (int (*)(int, int, int))dlsym (dlflag, "socket");
733 1.1 christos if (__real_socket == NULL)
734 1.1 christos {
735 1.1 christos __real_socket = (int (*)(int, int, int))dlsym (RTLD_NEXT, "socket");
736 1.1 christos if (__real_socket == NULL)
737 1.1 christos {
738 1.1 christos #if 0
739 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERXXX_IOINIT socket\n");
740 1.1 christos rc = COL_ERROR_IOINIT;
741 1.1 christos #endif
742 1.1 christos }
743 1.1 christos }
744 1.1 christos
745 1.1 christos __real_mkstemp = (int (*)(char*))dlsym (dlflag, "mkstemp");
746 1.1 christos if (__real_mkstemp == NULL)
747 1.1 christos {
748 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT mkstemp\n");
749 1.1 christos rc = COL_ERROR_IOINIT;
750 1.1 christos }
751 1.1 christos
752 1.1 christos __real_mkstemps = (int (*)(char*, int))dlsym (dlflag, "mkstemps");
753 1.1 christos if (__real_mkstemps == NULL)
754 1.1 christos {
755 1.1 christos #if 0
756 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERXXX_IOINIT mkstemps\n");
757 1.1 christos rc = COL_ERROR_IOINIT;
758 1.1 christos #endif
759 1.1 christos }
760 1.1 christos
761 1.1 christos __real_creat = (int (*)(const char*, mode_t))dlsym (dlflag, "creat");
762 1.1 christos if (__real_creat == NULL)
763 1.1 christos {
764 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT creat\n");
765 1.1 christos rc = COL_ERROR_IOINIT;
766 1.1 christos }
767 1.1 christos
768 1.1 christos #if WSIZE(32)
769 1.1 christos __real_creat64 = (int (*)(const char*, mode_t))dlsym (dlflag, "creat64");
770 1.1 christos if (__real_creat64 == NULL)
771 1.1 christos {
772 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT creat64\n");
773 1.1 christos rc = COL_ERROR_IOINIT;
774 1.1 christos }
775 1.1 christos #endif
776 1.1 christos
777 1.1 christos __real_read = (ssize_t (*)(int, void*, size_t))dlsym (dlflag, "read");
778 1.1 christos if (__real_read == NULL)
779 1.1 christos {
780 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT read\n");
781 1.1 christos rc = COL_ERROR_IOINIT;
782 1.1 christos }
783 1.1 christos
784 1.1 christos __real_write = (ssize_t (*)(int, const void*, size_t))dlsym (dlflag, "write");
785 1.1 christos if (__real_write == NULL)
786 1.1 christos {
787 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT write\n");
788 1.1 christos rc = COL_ERROR_IOINIT;
789 1.1 christos }
790 1.1 christos
791 1.1 christos __real_readv = (ssize_t (*)(int, const struct iovec*, int))dlsym (dlflag, "readv");
792 1.1 christos if (__real_readv == NULL)
793 1.1 christos {
794 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT readv\n");
795 1.1 christos rc = COL_ERROR_IOINIT;
796 1.1 christos }
797 1.1 christos
798 1.1 christos __real_writev = (ssize_t (*)(int, const struct iovec*, int))dlsym (dlflag, "writev");
799 1.1 christos if (__real_writev == NULL)
800 1.1 christos {
801 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT writev\n");
802 1.1 christos rc = COL_ERROR_IOINIT;
803 1.1 christos }
804 1.1 christos
805 1.1 christos __real_fread = (size_t (*)(void*, size_t, size_t, FILE*))dlsym (dlflag, "fread");
806 1.1 christos if (__real_fread == NULL)
807 1.1 christos {
808 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fread\n");
809 1.1 christos rc = COL_ERROR_IOINIT;
810 1.1 christos }
811 1.1 christos
812 1.1 christos __real_fwrite = (size_t (*)(const void*, size_t, size_t, FILE*))dlsym (dlflag, "fwrite");
813 1.1 christos if (__real_fwrite == NULL)
814 1.1 christos {
815 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fwrite\n");
816 1.1 christos rc = COL_ERROR_IOINIT;
817 1.1 christos }
818 1.1 christos
819 1.1 christos __real_pread = (ssize_t (*)(int, void*, size_t, off_t))dlsym (dlflag, "pread");
820 1.1 christos if (__real_pread == NULL)
821 1.1 christos {
822 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pread\n");
823 1.1 christos rc = COL_ERROR_IOINIT;
824 1.1 christos }
825 1.1 christos
826 1.1 christos __real_pwrite = (ssize_t (*)(int, const void*, size_t, off_t))dlsym (dlflag, "pwrite");
827 1.1 christos if (__real_pwrite == NULL)
828 1.1 christos {
829 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite\n");
830 1.1 christos rc = COL_ERROR_IOINIT;
831 1.1 christos }
832 1.1 christos
833 1.1 christos __real_pwrite64 = (ssize_t (*)(int, const void*, size_t, off64_t))dlsym (dlflag, "pwrite64");
834 1.1 christos if (__real_pwrite64 == NULL)
835 1.1 christos {
836 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT pwrite64\n");
837 1.1 christos rc = COL_ERROR_IOINIT;
838 1.1 christos }
839 1.1 christos
840 1.1 christos __real_fgets = (char* (*)(char*, int, FILE*))dlsym (dlflag, "fgets");
841 1.1 christos if (__real_fgets == NULL)
842 1.1 christos {
843 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgets\n");
844 1.1 christos rc = COL_ERROR_IOINIT;
845 1.1 christos }
846 1.1 christos
847 1.1 christos __real_fputs = (int (*)(const char*, FILE*))dlsym (dlflag, "fputs");
848 1.1 christos if (__real_fputs == NULL)
849 1.1 christos {
850 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fputs\n");
851 1.1 christos rc = COL_ERROR_IOINIT;
852 1.1 christos }
853 1.1 christos
854 1.1 christos __real_fputc = (int (*)(int, FILE*))dlsym (dlflag, "fputc");
855 1.1 christos if (__real_fputc == NULL)
856 1.1 christos {
857 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fputc\n");
858 1.1 christos rc = COL_ERROR_IOINIT;
859 1.1 christos }
860 1.1 christos
861 1.1 christos __real_vfprintf = (int (*)(FILE*, const char*, va_list))dlsym (dlflag, "vfprintf");
862 1.1 christos if (__real_vfprintf == NULL)
863 1.1 christos {
864 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT vfprintf\n");
865 1.1 christos rc = COL_ERROR_IOINIT;
866 1.1 christos }
867 1.1 christos
868 1.1 christos
869 1.1 christos __real_lseek = (off_t (*)(int, off_t, int))dlsym (dlflag, "lseek");
870 1.1 christos if (__real_lseek == NULL)
871 1.1 christos {
872 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT lseek\n");
873 1.1 christos rc = COL_ERROR_IOINIT;
874 1.1 christos }
875 1.1 christos
876 1.1 christos __real_llseek = (offset_t (*)(int, offset_t, int))dlsym (dlflag, "llseek");
877 1.1 christos if (__real_llseek == NULL)
878 1.1 christos {
879 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT llseek\n");
880 1.1 christos rc = COL_ERROR_IOINIT;
881 1.1 christos }
882 1.1 christos
883 1.1 christos __real_chmod = (int (*)(const char*, mode_t))dlsym (dlflag, "chmod");
884 1.1 christos if (__real_chmod == NULL)
885 1.1 christos {
886 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT chmod\n");
887 1.1 christos rc = COL_ERROR_IOINIT;
888 1.1 christos }
889 1.1 christos
890 1.1 christos __real_access = (int (*)(const char*, int))dlsym (dlflag, "access");
891 1.1 christos if (__real_access == NULL)
892 1.1 christos {
893 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT access\n");
894 1.1 christos rc = COL_ERROR_IOINIT;
895 1.1 christos }
896 1.1 christos
897 1.1 christos __real_rename = (int (*)(const char*, const char*))dlsym (dlflag, "rename");
898 1.1 christos if (__real_rename == NULL)
899 1.1 christos {
900 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT rename\n");
901 1.1 christos rc = COL_ERROR_IOINIT;
902 1.1 christos }
903 1.1 christos
904 1.1 christos __real_mkdir = (int (*)(const char*, mode_t))dlsym (dlflag, "mkdir");
905 1.1 christos if (__real_mkdir == NULL)
906 1.1 christos {
907 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT mkdir\n");
908 1.1 christos rc = COL_ERROR_IOINIT;
909 1.1 christos }
910 1.1 christos
911 1.1 christos __real_getdents = (int (*)(int, struct dirent*, size_t))dlsym (dlflag, "getdents");
912 1.1 christos if (__real_getdents == NULL)
913 1.1 christos {
914 1.1 christos #if 0
915 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERXXX_IOINIT getdents\n");
916 1.1 christos rc = COL_ERROR_IOINIT;
917 1.1 christos #endif
918 1.1 christos }
919 1.1 christos
920 1.1 christos __real_unlink = (int (*)(const char*))dlsym (dlflag, "unlink");
921 1.1 christos if (__real_unlink == NULL)
922 1.1 christos {
923 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT unlink\n");
924 1.1 christos rc = COL_ERROR_IOINIT;
925 1.1 christos }
926 1.1 christos
927 1.1 christos __real_fseek = (int (*)(FILE*, long, int))dlsym (dlflag, "fseek");
928 1.1 christos if (__real_fseek == NULL)
929 1.1 christos {
930 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fseek\n");
931 1.1 christos rc = COL_ERROR_IOINIT;
932 1.1 christos }
933 1.1 christos
934 1.1 christos __real_rewind = (void (*)(FILE*))dlsym (dlflag, "rewind");
935 1.1 christos if (__real_rewind == NULL)
936 1.1 christos {
937 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT rewind\n");
938 1.1 christos rc = COL_ERROR_IOINIT;
939 1.1 christos }
940 1.1 christos
941 1.1 christos __real_ftell = (long (*)(FILE*))dlsym (dlflag, "ftell");
942 1.1 christos if (__real_ftell == NULL)
943 1.1 christos {
944 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT ftell\n");
945 1.1 christos rc = COL_ERROR_IOINIT;
946 1.1 christos }
947 1.1 christos
948 1.1 christos __real_fsync = (int (*)(int))dlsym (dlflag, "fsync");
949 1.1 christos if (__real_fsync == NULL)
950 1.1 christos {
951 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsync\n");
952 1.1 christos rc = COL_ERROR_IOINIT;
953 1.1 christos }
954 1.1 christos
955 1.1 christos __real_readdir = (struct dirent * (*)(DIR*))dlsym (dlflag, "readdir");
956 1.1 christos if (__real_readdir == NULL)
957 1.1 christos {
958 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT readdir\n");
959 1.1 christos rc = COL_ERROR_IOINIT;
960 1.1 christos }
961 1.1 christos
962 1.1 christos __real_flock = (int (*)(int, int))dlsym (dlflag, "flock");
963 1.1 christos if (__real_flock == NULL)
964 1.1 christos {
965 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT flock\n");
966 1.1 christos rc = COL_ERROR_IOINIT;
967 1.1 christos }
968 1.1 christos
969 1.1 christos __real_lockf = (int (*)(int, int, off_t))dlsym (dlflag, "lockf");
970 1.1 christos if (__real_lockf == NULL)
971 1.1 christos {
972 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT lockf\n");
973 1.1 christos rc = COL_ERROR_IOINIT;
974 1.1 christos }
975 1.1 christos
976 1.1 christos __real_fflush = (int (*)(FILE*))dlsym (dlflag, "fflush");
977 1.1 christos if (__real_fflush == NULL)
978 1.1 christos {
979 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fflush\n");
980 1.1 christos rc = COL_ERROR_IOINIT;
981 1.1 christos }
982 1.1 christos
983 1.1 christos #if WSIZE(32)
984 1.1 christos __real_fgetpos64 = (int (*)(FILE*, fpos64_t*))dlsym (dlflag, "fgetpos64");
985 1.1 christos if (__real_fgetpos64 == NULL)
986 1.1 christos {
987 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fgetpos64\n");
988 1.1 christos rc = COL_ERROR_IOINIT;
989 1.1 christos }
990 1.1 christos
991 1.1 christos __real_fsetpos64 = (int (*)(FILE*, const fpos64_t*))dlsym (dlflag, "fsetpos64");
992 1.1 christos if (__real_fsetpos64 == NULL)
993 1.1 christos {
994 1.1 christos CALL_REAL (fprintf)(stderr, "iotrace_init COL_ERROR_IOINIT fsetpos64\n");
995 1.1 christos rc = COL_ERROR_IOINIT;
996 1.1 christos }
997 1.1 christos #endif
998 1.1 christos init_io_intf_finished++;
999 1.1 christos return rc;
1000 1.1 christos }
1001 1.1 christos
1002 1.1 christos /*------------------------------------------------------------- open */
1003 1.1 christos int
1004 1.1 christos open (const char *path, int oflag, ...)
1005 1.1 christos {
1006 1.1 christos int *guard;
1007 1.1 christos int fd;
1008 1.1 christos void *packet;
1009 1.1 christos IOTrace_packet *iopkt;
1010 1.1 christos mode_t mode;
1011 1.1 christos va_list ap;
1012 1.1 christos size_t sz;
1013 1.1 christos unsigned pktSize;
1014 1.1 christos
1015 1.1 christos va_start (ap, oflag);
1016 1.1 christos mode = va_arg (ap, mode_t);
1017 1.1 christos va_end (ap);
1018 1.1 christos
1019 1.1 christos if (NULL_PTR (open))
1020 1.1 christos init_io_intf ();
1021 1.1 christos
1022 1.1 christos if (CHCK_REENTRANCE (guard) || path == NULL)
1023 1.1 christos return CALL_REAL (open)(path, oflag, mode);
1024 1.1 christos PUSH_REENTRANCE (guard);
1025 1.1 christos hrtime_t reqt = gethrtime ();
1026 1.1 christos fd = CALL_REAL (open)(path, oflag, mode);
1027 1.1 christos if (RECHCK_REENTRANCE (guard))
1028 1.1 christos {
1029 1.1 christos POP_REENTRANCE (guard);
1030 1.1 christos return fd;
1031 1.1 christos }
1032 1.1 christos hrtime_t grnt = gethrtime ();
1033 1.1 christos sz = collector_strlen (path);
1034 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
1035 1.1 christos pktSize = collector_align_pktsize (pktSize);
1036 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
1037 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
1038 1.1 christos if (packet != NULL)
1039 1.1 christos {
1040 1.1 christos iopkt = (IOTrace_packet *) packet;
1041 1.1 christos collector_memset (iopkt, 0, pktSize);
1042 1.1 christos iopkt->comm.tsize = pktSize;
1043 1.1 christos iopkt->comm.tstamp = grnt;
1044 1.1 christos iopkt->requested = reqt;
1045 1.1 christos if (fd != -1)
1046 1.1 christos iopkt->iotype = OPEN_TRACE;
1047 1.1 christos else
1048 1.1 christos iopkt->iotype = OPEN_TRACE_ERROR;
1049 1.1 christos iopkt->fd = fd;
1050 1.1 christos iopkt->fstype = collector_fstype (path);
1051 1.1 christos collector_strncpy (&(iopkt->fname), path, sz);
1052 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1053 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
1054 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
1055 1.1 christos }
1056 1.1 christos else
1057 1.1 christos {
1058 1.1 christos Tprintf (0, "iotrace: ERROR: open cannot allocate memory\n");
1059 1.1 christos return -1;
1060 1.1 christos }
1061 1.1 christos POP_REENTRANCE (guard);
1062 1.1 christos return fd;
1063 1.1 christos }
1064 1.1 christos
1065 1.1 christos /*------------------------------------------------------------- open64 */
1066 1.1 christos #if ARCH(Intel) && WSIZE(32)
1067 1.1 christos // map interposed symbol versions
1068 1.1 christos static int
1069 1.1 christos __collector_open64_symver (int(real_open64) (const char *, int, ...),
1070 1.1 christos const char *path, int oflag, mode_t mode);
1071 1.1 christos
1072 1.1 christos SYMVER_ATTRIBUTE (__collector_open64_2_2, open64@@GLIBC_2.2)
1073 1.1 christos int
1074 1.1 christos __collector_open64_2_2 (const char *path, int oflag, ...)
1075 1.1 christos {
1076 1.1 christos mode_t mode;
1077 1.1 christos va_list ap;
1078 1.1 christos va_start (ap, oflag);
1079 1.1 christos mode = va_arg (ap, mode_t);
1080 1.1 christos va_end (ap);
1081 1.1 christos TprintfT (DBG_LTT,
1082 1.1 christos "iotrace: __collector_open64_2_2@%p(path=%s, oflag=0%o, mode=0%o\n",
1083 1.1 christos CALL_REAL (open64_2_2), path ? path : "NULL", oflag, mode);
1084 1.1 christos if (NULL_PTR (open64))
1085 1.1 christos init_io_intf ();
1086 1.1 christos return __collector_open64_symver (CALL_REAL (open64_2_2), path, oflag, mode);
1087 1.1 christos }
1088 1.1 christos
1089 1.1 christos SYMVER_ATTRIBUTE (__collector_open64_2_1, open64@GLIBC_2.1)
1090 1.1 christos int
1091 1.1 christos __collector_open64_2_1 (const char *path, int oflag, ...)
1092 1.1 christos {
1093 1.1 christos mode_t mode;
1094 1.1 christos va_list ap;
1095 1.1 christos va_start (ap, oflag);
1096 1.1 christos mode = va_arg (ap, mode_t);
1097 1.1 christos va_end (ap);
1098 1.1 christos TprintfT (DBG_LTT,
1099 1.1 christos "iotrace: __collector_open64_2_1@%p(path=%s, oflag=0%o, mode=0%o\n",
1100 1.1 christos CALL_REAL (open64_2_1), path ? path : "NULL", oflag, mode);
1101 1.1 christos if (NULL_PTR (open64))
1102 1.1 christos init_io_intf ();
1103 1.1 christos return __collector_open64_symver (CALL_REAL (open64_2_1), path, oflag, mode);
1104 1.1 christos }
1105 1.1 christos
1106 1.1 christos #endif /* ARCH(Intel) && WSIZE(32) */
1107 1.1 christos #if WSIZE(32)
1108 1.1 christos #if ARCH(Intel) && WSIZE(32)
1109 1.1 christos
1110 1.1 christos static int
1111 1.1 christos __collector_open64_symver (int(real_open64) (const char *, int, ...),
1112 1.1 christos const char *path, int oflag, mode_t mode)
1113 1.1 christos {
1114 1.1 christos int *guard;
1115 1.1 christos int fd;
1116 1.1 christos void *packet;
1117 1.1 christos IOTrace_packet *iopkt;
1118 1.1 christos size_t sz;
1119 1.1 christos unsigned pktSize;
1120 1.1 christos if (NULL_PTR (open64))
1121 1.1 christos init_io_intf ();
1122 1.1 christos if (CHCK_REENTRANCE (guard) || path == NULL)
1123 1.1 christos return (real_open64) (path, oflag, mode);
1124 1.1 christos PUSH_REENTRANCE (guard);
1125 1.1 christos hrtime_t reqt = gethrtime ();
1126 1.1 christos fd = real_open64 (path, oflag, mode);
1127 1.1 christos #else /* ^ARCH(Intel) && WSIZE(32) */
1128 1.1 christos
1129 1.1 christos int
1130 1.1 christos open64 (const char *path, int oflag, ...)
1131 1.1 christos {
1132 1.1 christos int *guard;
1133 1.1 christos int fd;
1134 1.1 christos void *packet;
1135 1.1 christos IOTrace_packet *iopkt;
1136 1.1 christos mode_t mode;
1137 1.1 christos va_list ap;
1138 1.1 christos size_t sz;
1139 1.1 christos unsigned pktSize;
1140 1.1 christos
1141 1.1 christos va_start (ap, oflag);
1142 1.1 christos mode = va_arg (ap, mode_t);
1143 1.1 christos va_end (ap);
1144 1.1 christos if (NULL_PTR (open64))
1145 1.1 christos init_io_intf ();
1146 1.1 christos if (CHCK_REENTRANCE (guard) || path == NULL)
1147 1.1 christos return CALL_REAL (open64)(path, oflag, mode);
1148 1.1 christos PUSH_REENTRANCE (guard);
1149 1.1 christos hrtime_t reqt = gethrtime ();
1150 1.1 christos fd = CALL_REAL (open64)(path, oflag, mode);
1151 1.1 christos #endif /* ^ARCH(Intel) && WSIZE(32) */
1152 1.1 christos
1153 1.1 christos if (RECHCK_REENTRANCE (guard) || path == NULL)
1154 1.1 christos {
1155 1.1 christos POP_REENTRANCE (guard);
1156 1.1 christos return fd;
1157 1.1 christos }
1158 1.1 christos hrtime_t grnt = gethrtime ();
1159 1.1 christos sz = collector_strlen (path);
1160 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
1161 1.1 christos pktSize = collector_align_pktsize (pktSize);
1162 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
1163 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
1164 1.1 christos if (packet != NULL)
1165 1.1 christos {
1166 1.1 christos iopkt = (IOTrace_packet *) packet;
1167 1.1 christos collector_memset (iopkt, 0, pktSize);
1168 1.1 christos iopkt->comm.tsize = pktSize;
1169 1.1 christos iopkt->comm.tstamp = grnt;
1170 1.1 christos iopkt->requested = reqt;
1171 1.1 christos if (fd != -1)
1172 1.1 christos iopkt->iotype = OPEN_TRACE;
1173 1.1 christos else
1174 1.1 christos iopkt->iotype = OPEN_TRACE_ERROR;
1175 1.1 christos iopkt->fd = fd;
1176 1.1 christos iopkt->fstype = collector_fstype (path);
1177 1.1 christos collector_strncpy (&(iopkt->fname), path, sz);
1178 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1179 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
1180 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
1181 1.1 christos }
1182 1.1 christos else
1183 1.1 christos {
1184 1.1 christos Tprintf (0, "iotrace: ERROR: open64 cannot allocate memory\n");
1185 1.1 christos return -1;
1186 1.1 christos }
1187 1.1 christos POP_REENTRANCE (guard);
1188 1.1 christos return fd;
1189 1.1 christos }
1190 1.1 christos #endif
1191 1.1 christos
1192 1.1 christos #define F_ERROR_ARG 0
1193 1.1 christos #define F_INT_ARG 1
1194 1.1 christos #define F_LONG_ARG 2
1195 1.1 christos #define F_VOID_ARG 3
1196 1.1 christos
1197 1.1 christos /*
1198 1.1 christos * The following macro is not defined in the
1199 1.1 christos * older versions of Linux.
1200 1.1 christos * #define F_DUPFD_CLOEXEC 1030
1201 1.1 christos *
1202 1.1 christos * Instead use the command that is defined below
1203 1.1 christos * until we start compiling mpmt on the newer
1204 1.1 christos * versions of Linux.
1205 1.1 christos */
1206 1.1 christos #define TMP_F_DUPFD_CLOEXEC 1030
1207 1.1 christos
1208 1.1 christos /*------------------------------------------------------------- fcntl */
1209 1.1 christos int
1210 1.1 christos fcntl (int fildes, int cmd, ...)
1211 1.1 christos {
1212 1.1 christos int *guard;
1213 1.1 christos int fd = 0;
1214 1.1 christos IOTrace_packet iopkt;
1215 1.1 christos long long_arg = 0;
1216 1.1 christos int int_arg = 0;
1217 1.1 christos int which_arg = F_ERROR_ARG;
1218 1.1 christos va_list ap;
1219 1.1 christos switch (cmd)
1220 1.1 christos {
1221 1.1 christos case F_DUPFD:
1222 1.1 christos case TMP_F_DUPFD_CLOEXEC:
1223 1.1 christos case F_SETFD:
1224 1.1 christos case F_SETFL:
1225 1.1 christos case F_SETOWN:
1226 1.1 christos case F_SETSIG:
1227 1.1 christos case F_SETLEASE:
1228 1.1 christos case F_NOTIFY:
1229 1.1 christos case F_SETLK:
1230 1.1 christos case F_SETLKW:
1231 1.1 christos case F_GETLK:
1232 1.1 christos va_start (ap, cmd);
1233 1.1 christos long_arg = va_arg (ap, long);
1234 1.1 christos va_end (ap);
1235 1.1 christos which_arg = F_LONG_ARG;
1236 1.1 christos break;
1237 1.1 christos case F_GETFD:
1238 1.1 christos case F_GETFL:
1239 1.1 christos case F_GETOWN:
1240 1.1 christos case F_GETLEASE:
1241 1.1 christos case F_GETSIG:
1242 1.1 christos which_arg = F_VOID_ARG;
1243 1.1 christos break;
1244 1.1 christos }
1245 1.1 christos if (NULL_PTR (fcntl))
1246 1.1 christos init_io_intf ();
1247 1.1 christos if (CHCK_REENTRANCE (guard))
1248 1.1 christos {
1249 1.1 christos switch (which_arg)
1250 1.1 christos {
1251 1.1 christos case F_INT_ARG:
1252 1.1 christos return CALL_REAL (fcntl)(fildes, cmd, int_arg);
1253 1.1 christos case F_LONG_ARG:
1254 1.1 christos return CALL_REAL (fcntl)(fildes, cmd, long_arg);
1255 1.1 christos case F_VOID_ARG:
1256 1.1 christos return CALL_REAL (fcntl)(fildes, cmd);
1257 1.1 christos case F_ERROR_ARG:
1258 1.1 christos Tprintf (0, "iotrace: ERROR: Unsupported fcntl command\n");
1259 1.1 christos return -1;
1260 1.1 christos }
1261 1.1 christos return -1;
1262 1.1 christos }
1263 1.1 christos if (cmd != F_DUPFD && cmd != TMP_F_DUPFD_CLOEXEC)
1264 1.1 christos {
1265 1.1 christos switch (which_arg)
1266 1.1 christos {
1267 1.1 christos case F_INT_ARG:
1268 1.1 christos return CALL_REAL (fcntl)(fildes, cmd, int_arg);
1269 1.1 christos case F_LONG_ARG:
1270 1.1 christos return CALL_REAL (fcntl)(fildes, cmd, long_arg);
1271 1.1 christos case F_VOID_ARG:
1272 1.1 christos return CALL_REAL (fcntl)(fildes, cmd);
1273 1.1 christos case F_ERROR_ARG:
1274 1.1 christos Tprintf (0, "iotrace: ERROR: Unsupported fcntl command\n");
1275 1.1 christos return -1;
1276 1.1 christos }
1277 1.1 christos return -1;
1278 1.1 christos }
1279 1.1 christos PUSH_REENTRANCE (guard);
1280 1.1 christos hrtime_t reqt = gethrtime ();
1281 1.1 christos switch (cmd)
1282 1.1 christos {
1283 1.1 christos case F_DUPFD:
1284 1.1 christos case TMP_F_DUPFD_CLOEXEC:
1285 1.1 christos fd = CALL_REAL (fcntl)(fildes, cmd, long_arg);
1286 1.1 christos break;
1287 1.1 christos }
1288 1.1 christos if (RECHCK_REENTRANCE (guard))
1289 1.1 christos {
1290 1.1 christos POP_REENTRANCE (guard);
1291 1.1 christos return fd;
1292 1.1 christos }
1293 1.1 christos hrtime_t grnt = gethrtime ();
1294 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
1295 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
1296 1.1 christos iopkt.comm.tstamp = grnt;
1297 1.1 christos iopkt.requested = reqt;
1298 1.1 christos if (fd != -1)
1299 1.1 christos iopkt.iotype = OPEN_TRACE;
1300 1.1 christos else
1301 1.1 christos iopkt.iotype = OPEN_TRACE_ERROR;
1302 1.1 christos iopkt.fd = fd;
1303 1.1 christos iopkt.ofd = fildes;
1304 1.1 christos iopkt.fstype = UNKNOWNFS_TYPE;
1305 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1306 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
1307 1.1 christos POP_REENTRANCE (guard);
1308 1.1 christos return fd;
1309 1.1 christos }
1310 1.1 christos
1311 1.1 christos /*------------------------------------------------------------- openat */
1312 1.1 christos int
1313 1.1 christos openat (int fildes, const char *path, int oflag, ...)
1314 1.1 christos {
1315 1.1 christos int *guard;
1316 1.1 christos int fd;
1317 1.1 christos void *packet;
1318 1.1 christos IOTrace_packet *iopkt;
1319 1.1 christos mode_t mode;
1320 1.1 christos va_list ap;
1321 1.1 christos size_t sz;
1322 1.1 christos unsigned pktSize;
1323 1.1 christos
1324 1.1 christos va_start (ap, oflag);
1325 1.1 christos mode = va_arg (ap, mode_t);
1326 1.1 christos va_end (ap);
1327 1.1 christos if (NULL_PTR (openat))
1328 1.1 christos init_io_intf ();
1329 1.1 christos if (CHCK_REENTRANCE (guard) || path == NULL)
1330 1.1 christos return CALL_REAL (openat)(fildes, path, oflag, mode);
1331 1.1 christos PUSH_REENTRANCE (guard);
1332 1.1 christos hrtime_t reqt = gethrtime ();
1333 1.1 christos fd = CALL_REAL (openat)(fildes, path, oflag, mode);
1334 1.1 christos if (RECHCK_REENTRANCE (guard))
1335 1.1 christos {
1336 1.1 christos POP_REENTRANCE (guard);
1337 1.1 christos return fd;
1338 1.1 christos }
1339 1.1 christos hrtime_t grnt = gethrtime ();
1340 1.1 christos sz = collector_strlen (path);
1341 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
1342 1.1 christos pktSize = collector_align_pktsize (pktSize);
1343 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
1344 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
1345 1.1 christos if (packet != NULL)
1346 1.1 christos {
1347 1.1 christos iopkt = (IOTrace_packet *) packet;
1348 1.1 christos collector_memset (iopkt, 0, pktSize);
1349 1.1 christos iopkt->comm.tsize = pktSize;
1350 1.1 christos iopkt->comm.tstamp = grnt;
1351 1.1 christos iopkt->requested = reqt;
1352 1.1 christos if (fd != -1)
1353 1.1 christos iopkt->iotype = OPEN_TRACE;
1354 1.1 christos else
1355 1.1 christos iopkt->iotype = OPEN_TRACE_ERROR;
1356 1.1 christos iopkt->fd = fd;
1357 1.1 christos iopkt->fstype = collector_fstype (path);
1358 1.1 christos collector_strncpy (&(iopkt->fname), path, sz);
1359 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1360 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
1361 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
1362 1.1 christos }
1363 1.1 christos else
1364 1.1 christos {
1365 1.1 christos Tprintf (0, "iotrace: ERROR: openat cannot allocate memory\n");
1366 1.1 christos return -1;
1367 1.1 christos }
1368 1.1 christos POP_REENTRANCE (guard);
1369 1.1 christos return fd;
1370 1.1 christos }
1371 1.1 christos
1372 1.1 christos /*------------------------------------------------------------- creat */
1373 1.1 christos int
1374 1.1 christos creat (const char *path, mode_t mode)
1375 1.1 christos {
1376 1.1 christos int *guard;
1377 1.1 christos int fd;
1378 1.1 christos void *packet;
1379 1.1 christos IOTrace_packet *iopkt;
1380 1.1 christos size_t sz;
1381 1.1 christos unsigned pktSize;
1382 1.1 christos if (NULL_PTR (creat))
1383 1.1 christos init_io_intf ();
1384 1.1 christos if (CHCK_REENTRANCE (guard) || path == NULL)
1385 1.1 christos return CALL_REAL (creat)(path, mode);
1386 1.1 christos PUSH_REENTRANCE (guard);
1387 1.1 christos hrtime_t reqt = gethrtime ();
1388 1.1 christos fd = CALL_REAL (creat)(path, mode);
1389 1.1 christos if (RECHCK_REENTRANCE (guard))
1390 1.1 christos {
1391 1.1 christos POP_REENTRANCE (guard);
1392 1.1 christos return fd;
1393 1.1 christos }
1394 1.1 christos hrtime_t grnt = gethrtime ();
1395 1.1 christos sz = collector_strlen (path);
1396 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
1397 1.1 christos pktSize = collector_align_pktsize (pktSize);
1398 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
1399 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
1400 1.1 christos if (packet != NULL)
1401 1.1 christos {
1402 1.1 christos iopkt = (IOTrace_packet *) packet;
1403 1.1 christos collector_memset (iopkt, 0, pktSize);
1404 1.1 christos iopkt->comm.tsize = pktSize;
1405 1.1 christos iopkt->comm.tstamp = grnt;
1406 1.1 christos iopkt->requested = reqt;
1407 1.1 christos if (fd != -1)
1408 1.1 christos iopkt->iotype = OPEN_TRACE;
1409 1.1 christos else
1410 1.1 christos iopkt->iotype = OPEN_TRACE_ERROR;
1411 1.1 christos iopkt->fd = fd;
1412 1.1 christos iopkt->fstype = collector_fstype (path);
1413 1.1 christos collector_strncpy (&(iopkt->fname), path, sz);
1414 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1415 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
1416 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
1417 1.1 christos }
1418 1.1 christos else
1419 1.1 christos {
1420 1.1 christos Tprintf (0, "iotrace: ERROR: creat cannot allocate memory\n");
1421 1.1 christos return -1;
1422 1.1 christos }
1423 1.1 christos POP_REENTRANCE (guard);
1424 1.1 christos return fd;
1425 1.1 christos }
1426 1.1 christos
1427 1.1 christos /*------------------------------------------------------------- creat64 */
1428 1.1 christos #if WSIZE(32)
1429 1.1 christos int
1430 1.1 christos creat64 (const char *path, mode_t mode)
1431 1.1 christos {
1432 1.1 christos int *guard;
1433 1.1 christos int fd;
1434 1.1 christos void *packet;
1435 1.1 christos IOTrace_packet *iopkt;
1436 1.1 christos size_t sz;
1437 1.1 christos unsigned pktSize;
1438 1.1 christos
1439 1.1 christos if (NULL_PTR (creat64))
1440 1.1 christos init_io_intf ();
1441 1.1 christos if (CHCK_REENTRANCE (guard) || path == NULL)
1442 1.1 christos return CALL_REAL (creat64)(path, mode);
1443 1.1 christos PUSH_REENTRANCE (guard);
1444 1.1 christos hrtime_t reqt = gethrtime ();
1445 1.1 christos fd = CALL_REAL (creat64)(path, mode);
1446 1.1 christos if (RECHCK_REENTRANCE (guard))
1447 1.1 christos {
1448 1.1 christos POP_REENTRANCE (guard);
1449 1.1 christos return fd;
1450 1.1 christos }
1451 1.1 christos hrtime_t grnt = gethrtime ();
1452 1.1 christos sz = collector_strlen (path);
1453 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
1454 1.1 christos pktSize = collector_align_pktsize (pktSize);
1455 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
1456 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
1457 1.1 christos if (packet != NULL)
1458 1.1 christos {
1459 1.1 christos iopkt = (IOTrace_packet *) packet;
1460 1.1 christos collector_memset (iopkt, 0, pktSize);
1461 1.1 christos iopkt->comm.tsize = pktSize;
1462 1.1 christos iopkt->comm.tstamp = grnt;
1463 1.1 christos iopkt->requested = reqt;
1464 1.1 christos if (fd != -1)
1465 1.1 christos iopkt->iotype = OPEN_TRACE;
1466 1.1 christos else
1467 1.1 christos iopkt->iotype = OPEN_TRACE_ERROR;
1468 1.1 christos iopkt->fd = fd;
1469 1.1 christos iopkt->fstype = collector_fstype (path);
1470 1.1 christos collector_strncpy (&(iopkt->fname), path, sz);
1471 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1472 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
1473 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
1474 1.1 christos }
1475 1.1 christos else
1476 1.1 christos {
1477 1.1 christos Tprintf (0, "iotrace: ERROR: creat64 cannot allocate memory\n");
1478 1.1 christos return -1;
1479 1.1 christos }
1480 1.1 christos POP_REENTRANCE (guard);
1481 1.1 christos return fd;
1482 1.1 christos }
1483 1.1 christos #endif
1484 1.1 christos
1485 1.1 christos /*------------------------------------------------------------- mkstemp */
1486 1.1 christos int
1487 1.1 christos mkstemp (char *template)
1488 1.1 christos {
1489 1.1 christos int *guard;
1490 1.1 christos int fd;
1491 1.1 christos void *packet;
1492 1.1 christos IOTrace_packet *iopkt;
1493 1.1 christos size_t sz;
1494 1.1 christos unsigned pktSize;
1495 1.1 christos if (NULL_PTR (mkstemp))
1496 1.1 christos init_io_intf ();
1497 1.1 christos if (CHCK_REENTRANCE (guard) || template == NULL)
1498 1.1 christos return CALL_REAL (mkstemp)(template);
1499 1.1 christos PUSH_REENTRANCE (guard);
1500 1.1 christos hrtime_t reqt = gethrtime ();
1501 1.1 christos fd = CALL_REAL (mkstemp)(template);
1502 1.1 christos if (RECHCK_REENTRANCE (guard))
1503 1.1 christos {
1504 1.1 christos POP_REENTRANCE (guard);
1505 1.1 christos return fd;
1506 1.1 christos }
1507 1.1 christos hrtime_t grnt = gethrtime ();
1508 1.1 christos sz = collector_strlen (template);
1509 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
1510 1.1 christos pktSize = collector_align_pktsize (pktSize);
1511 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
1512 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
1513 1.1 christos if (packet != NULL)
1514 1.1 christos {
1515 1.1 christos iopkt = (IOTrace_packet *) packet;
1516 1.1 christos collector_memset (iopkt, 0, pktSize);
1517 1.1 christos iopkt->comm.tsize = pktSize;
1518 1.1 christos iopkt->comm.tstamp = grnt;
1519 1.1 christos iopkt->requested = reqt;
1520 1.1 christos if (fd != -1)
1521 1.1 christos iopkt->iotype = OPEN_TRACE;
1522 1.1 christos else
1523 1.1 christos iopkt->iotype = OPEN_TRACE_ERROR;
1524 1.1 christos iopkt->fd = fd;
1525 1.1 christos iopkt->fstype = collector_fstype (template);
1526 1.1 christos collector_strncpy (&(iopkt->fname), template, sz);
1527 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1528 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
1529 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
1530 1.1 christos }
1531 1.1 christos else
1532 1.1 christos {
1533 1.1 christos Tprintf (0, "iotrace: ERROR: mkstemp cannot allocate memory\n");
1534 1.1 christos return -1;
1535 1.1 christos }
1536 1.1 christos POP_REENTRANCE (guard);
1537 1.1 christos return fd;
1538 1.1 christos }
1539 1.1 christos
1540 1.1 christos /*------------------------------------------------------------- mkstemps */
1541 1.1 christos int
1542 1.1 christos mkstemps (char *template, int slen)
1543 1.1 christos {
1544 1.1 christos int *guard;
1545 1.1 christos int fd;
1546 1.1 christos void *packet;
1547 1.1 christos IOTrace_packet *iopkt;
1548 1.1 christos size_t sz;
1549 1.1 christos unsigned pktSize;
1550 1.1 christos if (NULL_PTR (mkstemps))
1551 1.1 christos init_io_intf ();
1552 1.1 christos if (CHCK_REENTRANCE (guard) || template == NULL)
1553 1.1 christos return CALL_REAL (mkstemps)(template, slen);
1554 1.1 christos PUSH_REENTRANCE (guard);
1555 1.1 christos hrtime_t reqt = gethrtime ();
1556 1.1 christos fd = CALL_REAL (mkstemps)(template, slen);
1557 1.1 christos if (RECHCK_REENTRANCE (guard))
1558 1.1 christos {
1559 1.1 christos POP_REENTRANCE (guard);
1560 1.1 christos return fd;
1561 1.1 christos }
1562 1.1 christos hrtime_t grnt = gethrtime ();
1563 1.1 christos sz = collector_strlen (template);
1564 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
1565 1.1 christos pktSize = collector_align_pktsize (pktSize);
1566 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
1567 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
1568 1.1 christos if (packet != NULL)
1569 1.1 christos {
1570 1.1 christos iopkt = (IOTrace_packet *) packet;
1571 1.1 christos collector_memset (iopkt, 0, pktSize);
1572 1.1 christos iopkt->comm.tsize = pktSize;
1573 1.1 christos iopkt->comm.tstamp = grnt;
1574 1.1 christos iopkt->requested = reqt;
1575 1.1 christos if (fd != -1)
1576 1.1 christos iopkt->iotype = OPEN_TRACE;
1577 1.1 christos else
1578 1.1 christos iopkt->iotype = OPEN_TRACE_ERROR;
1579 1.1 christos iopkt->fd = fd;
1580 1.1 christos iopkt->fstype = collector_fstype (template);
1581 1.1 christos collector_strncpy (&(iopkt->fname), template, sz);
1582 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1583 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
1584 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
1585 1.1 christos }
1586 1.1 christos else
1587 1.1 christos {
1588 1.1 christos Tprintf (0, "iotrace: ERROR: mkstemps cannot allocate memory\n");
1589 1.1 christos return -1;
1590 1.1 christos }
1591 1.1 christos POP_REENTRANCE (guard);
1592 1.1 christos return fd;
1593 1.1 christos }
1594 1.1 christos
1595 1.1 christos /*------------------------------------------------------------- close */
1596 1.1 christos int
1597 1.1 christos close (int fildes)
1598 1.1 christos {
1599 1.1 christos int *guard;
1600 1.1 christos int stat;
1601 1.1 christos IOTrace_packet iopkt;
1602 1.1 christos if (NULL_PTR (close))
1603 1.1 christos init_io_intf ();
1604 1.1 christos if (CHCK_REENTRANCE (guard))
1605 1.1 christos return CALL_REAL (close)(fildes);
1606 1.1 christos PUSH_REENTRANCE (guard);
1607 1.1 christos hrtime_t reqt = gethrtime ();
1608 1.1 christos stat = CALL_REAL (close)(fildes);
1609 1.1 christos if (RECHCK_REENTRANCE (guard))
1610 1.1 christos {
1611 1.1 christos POP_REENTRANCE (guard);
1612 1.1 christos return stat;
1613 1.1 christos }
1614 1.1 christos hrtime_t grnt = gethrtime ();
1615 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
1616 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
1617 1.1 christos iopkt.comm.tstamp = grnt;
1618 1.1 christos iopkt.requested = reqt;
1619 1.1 christos if (stat == 0)
1620 1.1 christos iopkt.iotype = CLOSE_TRACE;
1621 1.1 christos else
1622 1.1 christos iopkt.iotype = CLOSE_TRACE_ERROR;
1623 1.1 christos iopkt.fd = fildes;
1624 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1625 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
1626 1.1 christos POP_REENTRANCE (guard);
1627 1.1 christos return stat;
1628 1.1 christos }
1629 1.1 christos
1630 1.1 christos /*------------------------------------------------------------- fopen */
1631 1.1 christos // map interposed symbol versions
1632 1.1 christos #if ARCH(Intel) && WSIZE(32)
1633 1.1 christos
1634 1.1 christos static FILE*
1635 1.1 christos __collector_fopen_symver (FILE*(real_fopen) (), const char *filename, const char *mode);
1636 1.1 christos
1637 1.1 christos SYMVER_ATTRIBUTE (__collector_fopen_2_1, fopen@@GLIBC_2.1)
1638 1.1 christos FILE*
1639 1.1 christos __collector_fopen_2_1 (const char *filename, const char *mode)
1640 1.1 christos {
1641 1.1 christos if (NULL_PTR (fopen))
1642 1.1 christos init_io_intf ();
1643 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fopen_2_1@%p\n", CALL_REAL (fopen_2_1));
1644 1.1 christos return __collector_fopen_symver (CALL_REAL (fopen_2_1), filename, mode);
1645 1.1 christos }
1646 1.1 christos
1647 1.1 christos SYMVER_ATTRIBUTE (__collector_fopen_2_0, fopen@GLIBC_2.0)
1648 1.1 christos FILE*
1649 1.1 christos __collector_fopen_2_0 (const char *filename, const char *mode)
1650 1.1 christos {
1651 1.1 christos if (NULL_PTR (fopen))
1652 1.1 christos init_io_intf ();
1653 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fopen_2_0@%p\n", CALL_REAL (fopen_2_0));
1654 1.1 christos return __collector_fopen_symver (CALL_REAL (fopen_2_0), filename, mode);
1655 1.1 christos }
1656 1.1 christos
1657 1.1 christos #endif
1658 1.1 christos
1659 1.1 christos #if ARCH(Intel) && WSIZE(32)
1660 1.1 christos
1661 1.1 christos static FILE*
1662 1.1 christos __collector_fopen_symver (FILE*(real_fopen) (), const char *filename, const char *mode)
1663 1.1 christos {
1664 1.1 christos #else
1665 1.1 christos
1666 1.1 christos FILE*
1667 1.1 christos fopen (const char *filename, const char *mode)
1668 1.1 christos {
1669 1.1 christos #endif
1670 1.1 christos int *guard;
1671 1.1 christos FILE *fp = NULL;
1672 1.1 christos void *packet;
1673 1.1 christos IOTrace_packet *iopkt;
1674 1.1 christos size_t sz;
1675 1.1 christos unsigned pktSize;
1676 1.1 christos if (NULL_PTR (fopen))
1677 1.1 christos init_io_intf ();
1678 1.1 christos if (CHCK_REENTRANCE (guard) || filename == NULL)
1679 1.1 christos {
1680 1.1 christos #if ARCH(Intel) && WSIZE(32)
1681 1.1 christos return (real_fopen) (filename, mode);
1682 1.1 christos #else
1683 1.1 christos return CALL_REAL (fopen)(filename, mode);
1684 1.1 christos #endif
1685 1.1 christos }
1686 1.1 christos PUSH_REENTRANCE (guard);
1687 1.1 christos hrtime_t reqt = gethrtime ();
1688 1.1 christos
1689 1.1 christos #if ARCH(Intel) && WSIZE(32)
1690 1.1 christos fp = (real_fopen) (filename, mode);
1691 1.1 christos #else
1692 1.1 christos fp = CALL_REAL (fopen)(filename, mode);
1693 1.1 christos #endif
1694 1.1 christos if (RECHCK_REENTRANCE (guard))
1695 1.1 christos {
1696 1.1 christos POP_REENTRANCE (guard);
1697 1.1 christos return fp;
1698 1.1 christos }
1699 1.1 christos hrtime_t grnt = gethrtime ();
1700 1.1 christos sz = collector_strlen (filename);
1701 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
1702 1.1 christos pktSize = collector_align_pktsize (pktSize);
1703 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
1704 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
1705 1.1 christos if (packet != NULL)
1706 1.1 christos {
1707 1.1 christos iopkt = (IOTrace_packet *) packet;
1708 1.1 christos collector_memset (iopkt, 0, pktSize);
1709 1.1 christos iopkt->comm.tsize = pktSize;
1710 1.1 christos iopkt->comm.tstamp = grnt;
1711 1.1 christos iopkt->requested = reqt;
1712 1.1 christos if (fp != NULL)
1713 1.1 christos {
1714 1.1 christos iopkt->iotype = OPEN_TRACE;
1715 1.1 christos iopkt->fd = fileno (fp);
1716 1.1 christos }
1717 1.1 christos else
1718 1.1 christos {
1719 1.1 christos iopkt->iotype = OPEN_TRACE_ERROR;
1720 1.1 christos iopkt->fd = -1;
1721 1.1 christos }
1722 1.1 christos iopkt->fstype = collector_fstype (filename);
1723 1.1 christos collector_strncpy (&(iopkt->fname), filename, sz);
1724 1.1 christos
1725 1.1 christos #if ARCH(Intel) && WSIZE(32)
1726 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
1727 1.1 christos #else
1728 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1729 1.1 christos #endif
1730 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
1731 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
1732 1.1 christos }
1733 1.1 christos else
1734 1.1 christos {
1735 1.1 christos Tprintf (0, "iotrace: ERROR: fopen cannot allocate memory\n");
1736 1.1 christos return NULL;
1737 1.1 christos }
1738 1.1 christos POP_REENTRANCE (guard);
1739 1.1 christos return fp;
1740 1.1 christos }
1741 1.1 christos
1742 1.1 christos /*------------------------------------------------------------- fclose */
1743 1.1 christos // map interposed symbol versions
1744 1.1 christos #if ARCH(Intel) && WSIZE(32)
1745 1.1 christos
1746 1.1 christos static int
1747 1.1 christos __collector_fclose_symver (int(real_fclose) (), FILE *stream);
1748 1.1 christos
1749 1.1 christos SYMVER_ATTRIBUTE (__collector_fclose_2_1, fclose@@GLIBC_2.1)
1750 1.1 christos int
1751 1.1 christos __collector_fclose_2_1 (FILE *stream)
1752 1.1 christos {
1753 1.1 christos if (NULL_PTR (fclose))
1754 1.1 christos init_io_intf ();
1755 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fclose_2_1@%p\n", CALL_REAL (fclose_2_1));
1756 1.1 christos return __collector_fclose_symver (CALL_REAL (fclose_2_1), stream);
1757 1.1 christos }
1758 1.1 christos
1759 1.1 christos SYMVER_ATTRIBUTE (__collector_fclose_2_0, fclose@GLIBC_2.0)
1760 1.1 christos int
1761 1.1 christos __collector_fclose_2_0 (FILE *stream)
1762 1.1 christos {
1763 1.1 christos if (NULL_PTR (fclose))
1764 1.1 christos init_io_intf ();
1765 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fclose_2_0@%p\n", CALL_REAL (fclose_2_0));
1766 1.1 christos return __collector_fclose_symver (CALL_REAL (fclose_2_0), stream);
1767 1.1 christos }
1768 1.1 christos
1769 1.1 christos #endif
1770 1.1 christos
1771 1.1 christos #if ARCH(Intel) && WSIZE(32)
1772 1.1 christos
1773 1.1 christos static int
1774 1.1 christos __collector_fclose_symver (int(real_fclose) (), FILE *stream)
1775 1.1 christos {
1776 1.1 christos #else
1777 1.1 christos
1778 1.1 christos int
1779 1.1 christos fclose (FILE *stream)
1780 1.1 christos {
1781 1.1 christos #endif
1782 1.1 christos int *guard;
1783 1.1 christos int stat;
1784 1.1 christos IOTrace_packet iopkt;
1785 1.1 christos if (NULL_PTR (fclose))
1786 1.1 christos init_io_intf ();
1787 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
1788 1.1 christos {
1789 1.1 christos #if ARCH(Intel) && WSIZE(32)
1790 1.1 christos return (real_fclose) (stream);
1791 1.1 christos #else
1792 1.1 christos return CALL_REAL (fclose)(stream);
1793 1.1 christos #endif
1794 1.1 christos }
1795 1.1 christos PUSH_REENTRANCE (guard);
1796 1.1 christos hrtime_t reqt = gethrtime ();
1797 1.1 christos #if ARCH(Intel) && WSIZE(32)
1798 1.1 christos stat = (real_fclose) (stream);
1799 1.1 christos #else
1800 1.1 christos stat = CALL_REAL (fclose)(stream);
1801 1.1 christos #endif
1802 1.1 christos if (RECHCK_REENTRANCE (guard))
1803 1.1 christos {
1804 1.1 christos POP_REENTRANCE (guard);
1805 1.1 christos return stat;
1806 1.1 christos }
1807 1.1 christos hrtime_t grnt = gethrtime ();
1808 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
1809 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
1810 1.1 christos iopkt.comm.tstamp = grnt;
1811 1.1 christos iopkt.requested = reqt;
1812 1.1 christos if (stat == 0)
1813 1.1 christos iopkt.iotype = CLOSE_TRACE;
1814 1.1 christos else
1815 1.1 christos iopkt.iotype = CLOSE_TRACE_ERROR;
1816 1.1 christos iopkt.fd = fileno (stream);
1817 1.1 christos
1818 1.1 christos #if ARCH(Intel) && WSIZE(32)
1819 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
1820 1.1 christos #else
1821 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1822 1.1 christos #endif
1823 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
1824 1.1 christos POP_REENTRANCE (guard);
1825 1.1 christos return stat;
1826 1.1 christos }
1827 1.1 christos
1828 1.1 christos /*------------------------------------------------------------- fflush */
1829 1.1 christos int
1830 1.1 christos fflush (FILE *stream)
1831 1.1 christos {
1832 1.1 christos int *guard;
1833 1.1 christos int stat;
1834 1.1 christos IOTrace_packet iopkt;
1835 1.1 christos if (NULL_PTR (fflush))
1836 1.1 christos init_io_intf ();
1837 1.1 christos if (CHCK_REENTRANCE (guard))
1838 1.1 christos return CALL_REAL (fflush)(stream);
1839 1.1 christos PUSH_REENTRANCE (guard);
1840 1.1 christos hrtime_t reqt = gethrtime ();
1841 1.1 christos stat = CALL_REAL (fflush)(stream);
1842 1.1 christos if (RECHCK_REENTRANCE (guard))
1843 1.1 christos {
1844 1.1 christos POP_REENTRANCE (guard);
1845 1.1 christos return stat;
1846 1.1 christos }
1847 1.1 christos hrtime_t grnt = gethrtime ();
1848 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
1849 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
1850 1.1 christos iopkt.comm.tstamp = grnt;
1851 1.1 christos iopkt.requested = reqt;
1852 1.1 christos if (stat == 0)
1853 1.1 christos iopkt.iotype = OTHERIO_TRACE;
1854 1.1 christos else
1855 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
1856 1.1 christos if (stream != NULL)
1857 1.1 christos iopkt.fd = fileno (stream);
1858 1.1 christos else
1859 1.1 christos iopkt.fd = -1;
1860 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1861 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
1862 1.1 christos POP_REENTRANCE (guard);
1863 1.1 christos return stat;
1864 1.1 christos }
1865 1.1 christos
1866 1.1 christos /*------------------------------------------------------------- fdopen */
1867 1.1 christos // map interposed symbol versions
1868 1.1 christos #if ARCH(Intel) && WSIZE(32)
1869 1.1 christos
1870 1.1 christos static FILE*
1871 1.1 christos __collector_fdopen_symver (FILE*(real_fdopen) (), int fildes, const char *mode);
1872 1.1 christos
1873 1.1 christos SYMVER_ATTRIBUTE (__collector_fdopen_2_1, fdopen@@GLIBC_2.1)
1874 1.1 christos FILE*
1875 1.1 christos __collector_fdopen_2_1 (int fildes, const char *mode)
1876 1.1 christos {
1877 1.1 christos if (NULL_PTR (fdopen))
1878 1.1 christos init_io_intf ();
1879 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fdopen_2_1@%p\n", CALL_REAL (fdopen_2_1));
1880 1.1 christos return __collector_fdopen_symver (CALL_REAL (fdopen_2_1), fildes, mode);
1881 1.1 christos }
1882 1.1 christos
1883 1.1 christos SYMVER_ATTRIBUTE (__collector_fdopen_2_0, fdopen@GLIBC_2.0)
1884 1.1 christos FILE*
1885 1.1 christos __collector_fdopen_2_0 (int fildes, const char *mode)
1886 1.1 christos {
1887 1.1 christos if (NULL_PTR (fdopen))
1888 1.1 christos init_io_intf ();
1889 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fdopen_2_0@%p\n", CALL_REAL (fdopen_2_0));
1890 1.1 christos return __collector_fdopen_symver (CALL_REAL (fdopen_2_0), fildes, mode);
1891 1.1 christos }
1892 1.1 christos
1893 1.1 christos #endif
1894 1.1 christos
1895 1.1 christos #if ARCH(Intel) && WSIZE(32)
1896 1.1 christos static FILE*
1897 1.1 christos __collector_fdopen_symver (FILE*(real_fdopen) (), int fildes, const char *mode)
1898 1.1 christos {
1899 1.1 christos #else
1900 1.1 christos FILE*
1901 1.1 christos fdopen (int fildes, const char *mode)
1902 1.1 christos {
1903 1.1 christos #endif
1904 1.1 christos int *guard;
1905 1.1 christos FILE *fp = NULL;
1906 1.1 christos IOTrace_packet iopkt;
1907 1.1 christos if (NULL_PTR (fdopen))
1908 1.1 christos init_io_intf ();
1909 1.1 christos if (CHCK_REENTRANCE (guard))
1910 1.1 christos {
1911 1.1 christos #if ARCH(Intel) && WSIZE(32)
1912 1.1 christos return (real_fdopen) (fildes, mode);
1913 1.1 christos #else
1914 1.1 christos return CALL_REAL (fdopen)(fildes, mode);
1915 1.1 christos #endif
1916 1.1 christos }
1917 1.1 christos PUSH_REENTRANCE (guard);
1918 1.1 christos hrtime_t reqt = gethrtime ();
1919 1.1 christos #if ARCH(Intel) && WSIZE(32)
1920 1.1 christos fp = (real_fdopen) (fildes, mode);
1921 1.1 christos #else
1922 1.1 christos fp = CALL_REAL (fdopen)(fildes, mode);
1923 1.1 christos #endif
1924 1.1 christos if (RECHCK_REENTRANCE (guard))
1925 1.1 christos {
1926 1.1 christos POP_REENTRANCE (guard);
1927 1.1 christos return fp;
1928 1.1 christos }
1929 1.1 christos hrtime_t grnt = gethrtime ();
1930 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
1931 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
1932 1.1 christos iopkt.comm.tstamp = grnt;
1933 1.1 christos iopkt.requested = reqt;
1934 1.1 christos if (fp != NULL)
1935 1.1 christos iopkt.iotype = OPEN_TRACE;
1936 1.1 christos else
1937 1.1 christos iopkt.iotype = OPEN_TRACE_ERROR;
1938 1.1 christos iopkt.fd = fildes;
1939 1.1 christos iopkt.fstype = UNKNOWNFS_TYPE;
1940 1.1 christos #if ARCH(Intel) && WSIZE(32)
1941 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
1942 1.1 christos #else
1943 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1944 1.1 christos #endif
1945 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
1946 1.1 christos POP_REENTRANCE (guard);
1947 1.1 christos return fp;
1948 1.1 christos }
1949 1.1 christos
1950 1.1 christos /*------------------------------------------------------------- dup */
1951 1.1 christos int
1952 1.1 christos dup (int fildes)
1953 1.1 christos {
1954 1.1 christos int *guard;
1955 1.1 christos int fd;
1956 1.1 christos IOTrace_packet iopkt;
1957 1.1 christos if (NULL_PTR (dup))
1958 1.1 christos init_io_intf ();
1959 1.1 christos if (CHCK_REENTRANCE (guard))
1960 1.1 christos return CALL_REAL (dup)(fildes);
1961 1.1 christos PUSH_REENTRANCE (guard);
1962 1.1 christos hrtime_t reqt = gethrtime ();
1963 1.1 christos fd = CALL_REAL (dup)(fildes);
1964 1.1 christos if (RECHCK_REENTRANCE (guard))
1965 1.1 christos {
1966 1.1 christos POP_REENTRANCE (guard);
1967 1.1 christos return fd;
1968 1.1 christos }
1969 1.1 christos hrtime_t grnt = gethrtime ();
1970 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
1971 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
1972 1.1 christos iopkt.comm.tstamp = grnt;
1973 1.1 christos iopkt.requested = reqt;
1974 1.1 christos if (fd != -1)
1975 1.1 christos iopkt.iotype = OPEN_TRACE;
1976 1.1 christos else
1977 1.1 christos iopkt.iotype = OPEN_TRACE_ERROR;
1978 1.1 christos
1979 1.1 christos iopkt.fd = fd;
1980 1.1 christos iopkt.ofd = fildes;
1981 1.1 christos iopkt.fstype = UNKNOWNFS_TYPE;
1982 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
1983 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
1984 1.1 christos POP_REENTRANCE (guard);
1985 1.1 christos return fd;
1986 1.1 christos }
1987 1.1 christos
1988 1.1 christos /*------------------------------------------------------------- dup2 */
1989 1.1 christos int
1990 1.1 christos dup2 (int fildes, int fildes2)
1991 1.1 christos {
1992 1.1 christos int *guard;
1993 1.1 christos int fd;
1994 1.1 christos IOTrace_packet iopkt;
1995 1.1 christos if (NULL_PTR (dup2))
1996 1.1 christos init_io_intf ();
1997 1.1 christos if (CHCK_REENTRANCE (guard))
1998 1.1 christos return CALL_REAL (dup2)(fildes, fildes2);
1999 1.1 christos PUSH_REENTRANCE (guard);
2000 1.1 christos hrtime_t reqt = gethrtime ();
2001 1.1 christos fd = CALL_REAL (dup2)(fildes, fildes2);
2002 1.1 christos if (RECHCK_REENTRANCE (guard))
2003 1.1 christos {
2004 1.1 christos POP_REENTRANCE (guard);
2005 1.1 christos return fd;
2006 1.1 christos }
2007 1.1 christos hrtime_t grnt = gethrtime ();
2008 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
2009 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
2010 1.1 christos iopkt.comm.tstamp = grnt;
2011 1.1 christos iopkt.requested = reqt;
2012 1.1 christos if (fd != -1)
2013 1.1 christos iopkt.iotype = OPEN_TRACE;
2014 1.1 christos else
2015 1.1 christos iopkt.iotype = OPEN_TRACE_ERROR;
2016 1.1 christos iopkt.fd = fd;
2017 1.1 christos iopkt.ofd = fildes;
2018 1.1 christos iopkt.fstype = UNKNOWNFS_TYPE;
2019 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2020 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2021 1.1 christos POP_REENTRANCE (guard);
2022 1.1 christos return fd;
2023 1.1 christos }
2024 1.1 christos
2025 1.1 christos /*------------------------------------------------------------- pipe */
2026 1.1 christos int
2027 1.1 christos pipe (int fildes[2])
2028 1.1 christos {
2029 1.1 christos int *guard;
2030 1.1 christos int ret;
2031 1.1 christos IOTrace_packet iopkt;
2032 1.1 christos if (NULL_PTR (pipe))
2033 1.1 christos init_io_intf ();
2034 1.1 christos if (CHCK_REENTRANCE (guard))
2035 1.1 christos return CALL_REAL (pipe)(fildes);
2036 1.1 christos PUSH_REENTRANCE (guard);
2037 1.1 christos hrtime_t reqt = gethrtime ();
2038 1.1 christos ret = CALL_REAL (pipe)(fildes);
2039 1.1 christos if (RECHCK_REENTRANCE (guard))
2040 1.1 christos {
2041 1.1 christos POP_REENTRANCE (guard);
2042 1.1 christos return ret;
2043 1.1 christos }
2044 1.1 christos hrtime_t grnt = gethrtime ();
2045 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
2046 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
2047 1.1 christos iopkt.comm.tstamp = grnt;
2048 1.1 christos iopkt.requested = reqt;
2049 1.1 christos if (ret != -1)
2050 1.1 christos iopkt.iotype = OPEN_TRACE;
2051 1.1 christos else
2052 1.1 christos iopkt.iotype = OPEN_TRACE_ERROR;
2053 1.1 christos iopkt.fd = fildes[0];
2054 1.1 christos iopkt.fstype = UNKNOWNFS_TYPE;
2055 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2056 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2057 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
2058 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
2059 1.1 christos iopkt.comm.tstamp = grnt;
2060 1.1 christos iopkt.requested = reqt;
2061 1.1 christos if (ret != -1)
2062 1.1 christos iopkt.iotype = OPEN_TRACE;
2063 1.1 christos else
2064 1.1 christos iopkt.iotype = OPEN_TRACE_ERROR;
2065 1.1 christos iopkt.fd = fildes[1];
2066 1.1 christos iopkt.fstype = UNKNOWNFS_TYPE;
2067 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2068 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2069 1.1 christos POP_REENTRANCE (guard);
2070 1.1 christos return ret;
2071 1.1 christos }
2072 1.1 christos
2073 1.1 christos /*------------------------------------------------------------- socket */
2074 1.1 christos int
2075 1.1 christos socket (int domain, int type, int protocol)
2076 1.1 christos {
2077 1.1 christos int *guard;
2078 1.1 christos int fd;
2079 1.1 christos IOTrace_packet iopkt;
2080 1.1 christos if (NULL_PTR (socket))
2081 1.1 christos init_io_intf ();
2082 1.1 christos if (CHCK_REENTRANCE (guard))
2083 1.1 christos return CALL_REAL (socket)(domain, type, protocol);
2084 1.1 christos PUSH_REENTRANCE (guard);
2085 1.1 christos hrtime_t reqt = gethrtime ();
2086 1.1 christos fd = CALL_REAL (socket)(domain, type, protocol);
2087 1.1 christos if (RECHCK_REENTRANCE (guard))
2088 1.1 christos {
2089 1.1 christos POP_REENTRANCE (guard);
2090 1.1 christos return fd;
2091 1.1 christos }
2092 1.1 christos hrtime_t grnt = gethrtime ();
2093 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
2094 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
2095 1.1 christos iopkt.comm.tstamp = grnt;
2096 1.1 christos iopkt.requested = reqt;
2097 1.1 christos if (fd != -1)
2098 1.1 christos iopkt.iotype = OPEN_TRACE;
2099 1.1 christos else
2100 1.1 christos iopkt.iotype = OPEN_TRACE_ERROR;
2101 1.1 christos iopkt.fd = fd;
2102 1.1 christos iopkt.fstype = UNKNOWNFS_TYPE;
2103 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2104 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2105 1.1 christos POP_REENTRANCE (guard);
2106 1.1 christos return fd;
2107 1.1 christos }
2108 1.1 christos
2109 1.1 christos /*------------------------------------------------------------- read */
2110 1.1 christos ssize_t
2111 1.1 christos read (int fildes, void *buf, size_t nbyte)
2112 1.1 christos {
2113 1.1 christos int *guard;
2114 1.1 christos ssize_t ret;
2115 1.1 christos IOTrace_packet iopkt;
2116 1.1 christos if (NULL_PTR (read))
2117 1.1 christos init_io_intf ();
2118 1.1 christos if (CHCK_REENTRANCE (guard))
2119 1.1 christos return CALL_REAL (read)(fildes, buf, nbyte);
2120 1.1 christos PUSH_REENTRANCE (guard);
2121 1.1 christos hrtime_t reqt = gethrtime ();
2122 1.1 christos ret = CALL_REAL (read)(fildes, buf, nbyte);
2123 1.1 christos if (RECHCK_REENTRANCE (guard))
2124 1.1 christos {
2125 1.1 christos POP_REENTRANCE (guard);
2126 1.1 christos return ret;
2127 1.1 christos }
2128 1.1 christos hrtime_t grnt = gethrtime ();
2129 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2130 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2131 1.1 christos iopkt.comm.tstamp = grnt;
2132 1.1 christos iopkt.requested = reqt;
2133 1.1 christos if (ret >= 0)
2134 1.1 christos iopkt.iotype = READ_TRACE;
2135 1.1 christos else
2136 1.1 christos iopkt.iotype = READ_TRACE_ERROR;
2137 1.1 christos iopkt.fd = fildes;
2138 1.1 christos iopkt.nbyte = ret;
2139 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2140 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2141 1.1 christos POP_REENTRANCE (guard);
2142 1.1 christos return ret;
2143 1.1 christos }
2144 1.1 christos
2145 1.1 christos /*------------------------------------------------------------- write */
2146 1.1 christos ssize_t
2147 1.1 christos write (int fildes, const void *buf, size_t nbyte)
2148 1.1 christos {
2149 1.1 christos int *guard;
2150 1.1 christos ssize_t ret;
2151 1.1 christos IOTrace_packet iopkt;
2152 1.1 christos if (NULL_PTR (write))
2153 1.1 christos init_io_intf ();
2154 1.1 christos if (CHCK_REENTRANCE (guard))
2155 1.1 christos return CALL_REAL (write)(fildes, buf, nbyte);
2156 1.1 christos PUSH_REENTRANCE (guard);
2157 1.1 christos hrtime_t reqt = gethrtime ();
2158 1.1 christos ret = CALL_REAL (write)(fildes, buf, nbyte);
2159 1.1 christos if (RECHCK_REENTRANCE (guard))
2160 1.1 christos {
2161 1.1 christos POP_REENTRANCE (guard);
2162 1.1 christos return ret;
2163 1.1 christos }
2164 1.1 christos hrtime_t grnt = gethrtime ();
2165 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2166 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2167 1.1 christos iopkt.comm.tstamp = grnt;
2168 1.1 christos iopkt.requested = reqt;
2169 1.1 christos if (ret >= 0)
2170 1.1 christos iopkt.iotype = WRITE_TRACE;
2171 1.1 christos else
2172 1.1 christos iopkt.iotype = WRITE_TRACE_ERROR;
2173 1.1 christos iopkt.fd = fildes;
2174 1.1 christos iopkt.nbyte = ret;
2175 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2176 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2177 1.1 christos POP_REENTRANCE (guard);
2178 1.1 christos return ret;
2179 1.1 christos }
2180 1.1 christos
2181 1.1 christos /*------------------------------------------------------------- readv */
2182 1.1 christos ssize_t
2183 1.1 christos readv (int fildes, const struct iovec *iov, int iovcnt)
2184 1.1 christos {
2185 1.1 christos int *guard;
2186 1.1 christos ssize_t ret;
2187 1.1 christos IOTrace_packet iopkt;
2188 1.1 christos if (NULL_PTR (readv))
2189 1.1 christos init_io_intf ();
2190 1.1 christos if (CHCK_REENTRANCE (guard))
2191 1.1 christos return CALL_REAL (readv)(fildes, iov, iovcnt);
2192 1.1 christos PUSH_REENTRANCE (guard);
2193 1.1 christos hrtime_t reqt = gethrtime ();
2194 1.1 christos ret = CALL_REAL (readv)(fildes, iov, iovcnt);
2195 1.1 christos if (RECHCK_REENTRANCE (guard))
2196 1.1 christos {
2197 1.1 christos POP_REENTRANCE (guard);
2198 1.1 christos return ret;
2199 1.1 christos }
2200 1.1 christos hrtime_t grnt = gethrtime ();
2201 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2202 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2203 1.1 christos iopkt.comm.tstamp = grnt;
2204 1.1 christos iopkt.requested = reqt;
2205 1.1 christos if (ret >= 0)
2206 1.1 christos iopkt.iotype = READ_TRACE;
2207 1.1 christos else
2208 1.1 christos iopkt.iotype = READ_TRACE_ERROR;
2209 1.1 christos iopkt.fd = fildes;
2210 1.1 christos iopkt.nbyte = ret;
2211 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2212 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2213 1.1 christos POP_REENTRANCE (guard);
2214 1.1 christos return ret;
2215 1.1 christos }
2216 1.1 christos
2217 1.1 christos /*------------------------------------------------------------- writev */
2218 1.1 christos ssize_t
2219 1.1 christos writev (int fildes, const struct iovec *iov, int iovcnt)
2220 1.1 christos {
2221 1.1 christos int *guard;
2222 1.1 christos ssize_t ret;
2223 1.1 christos IOTrace_packet iopkt;
2224 1.1 christos if (NULL_PTR (writev))
2225 1.1 christos init_io_intf ();
2226 1.1 christos if (CHCK_REENTRANCE (guard))
2227 1.1 christos return CALL_REAL (writev)(fildes, iov, iovcnt);
2228 1.1 christos PUSH_REENTRANCE (guard);
2229 1.1 christos hrtime_t reqt = gethrtime ();
2230 1.1 christos ret = CALL_REAL (writev)(fildes, iov, iovcnt);
2231 1.1 christos if (RECHCK_REENTRANCE (guard))
2232 1.1 christos {
2233 1.1 christos POP_REENTRANCE (guard);
2234 1.1 christos return ret;
2235 1.1 christos }
2236 1.1 christos hrtime_t grnt = gethrtime ();
2237 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2238 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2239 1.1 christos iopkt.comm.tstamp = grnt;
2240 1.1 christos iopkt.requested = reqt;
2241 1.1 christos if (ret >= 0)
2242 1.1 christos iopkt.iotype = WRITE_TRACE;
2243 1.1 christos else
2244 1.1 christos iopkt.iotype = WRITE_TRACE_ERROR;
2245 1.1 christos iopkt.fd = fildes;
2246 1.1 christos iopkt.nbyte = ret;
2247 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2248 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2249 1.1 christos POP_REENTRANCE (guard);
2250 1.1 christos return ret;
2251 1.1 christos }
2252 1.1 christos
2253 1.1 christos /*------------------------------------------------------------- fread */
2254 1.1 christos size_t
2255 1.1 christos fread (void *ptr, size_t size, size_t nitems, FILE *stream)
2256 1.1 christos {
2257 1.1 christos int *guard;
2258 1.1 christos size_t ret;
2259 1.1 christos IOTrace_packet iopkt;
2260 1.1 christos if (NULL_PTR (fread))
2261 1.1 christos init_io_intf ();
2262 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
2263 1.1 christos return CALL_REAL (fread)(ptr, size, nitems, stream);
2264 1.1 christos PUSH_REENTRANCE (guard);
2265 1.1 christos hrtime_t reqt = gethrtime ();
2266 1.1 christos ret = CALL_REAL (fread)(ptr, size, nitems, stream);
2267 1.1 christos if (RECHCK_REENTRANCE (guard))
2268 1.1 christos {
2269 1.1 christos POP_REENTRANCE (guard);
2270 1.1 christos return ret;
2271 1.1 christos }
2272 1.1 christos hrtime_t grnt = gethrtime ();
2273 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2274 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2275 1.1 christos iopkt.comm.tstamp = grnt;
2276 1.1 christos iopkt.requested = reqt;
2277 1.1 christos if (ferror (stream) == 0)
2278 1.1 christos {
2279 1.1 christos iopkt.iotype = READ_TRACE;
2280 1.1 christos iopkt.nbyte = ret * size;
2281 1.1 christos }
2282 1.1 christos else
2283 1.1 christos {
2284 1.1 christos iopkt.iotype = READ_TRACE_ERROR;
2285 1.1 christos iopkt.nbyte = 0;
2286 1.1 christos }
2287 1.1 christos iopkt.fd = fileno (stream);
2288 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2289 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2290 1.1 christos POP_REENTRANCE (guard);
2291 1.1 christos return ret;
2292 1.1 christos }
2293 1.1 christos
2294 1.1 christos /*------------------------------------------------------------- fwrite */
2295 1.1 christos size_t
2296 1.1 christos fwrite (const void *ptr, size_t size, size_t nitems, FILE *stream)
2297 1.1 christos {
2298 1.1 christos int *guard;
2299 1.1 christos size_t ret;
2300 1.1 christos IOTrace_packet iopkt;
2301 1.1 christos if (NULL_PTR (fwrite))
2302 1.1 christos init_io_intf ();
2303 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
2304 1.1 christos return CALL_REAL (fwrite)(ptr, size, nitems, stream);
2305 1.1 christos PUSH_REENTRANCE (guard);
2306 1.1 christos hrtime_t reqt = gethrtime ();
2307 1.1 christos ret = CALL_REAL (fwrite)(ptr, size, nitems, stream);
2308 1.1 christos if (RECHCK_REENTRANCE (guard))
2309 1.1 christos {
2310 1.1 christos POP_REENTRANCE (guard);
2311 1.1 christos return ret;
2312 1.1 christos }
2313 1.1 christos hrtime_t grnt = gethrtime ();
2314 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2315 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2316 1.1 christos iopkt.comm.tstamp = grnt;
2317 1.1 christos iopkt.requested = reqt;
2318 1.1 christos if (ferror (stream) == 0)
2319 1.1 christos {
2320 1.1 christos iopkt.iotype = WRITE_TRACE;
2321 1.1 christos iopkt.nbyte = ret * size;
2322 1.1 christos }
2323 1.1 christos else
2324 1.1 christos {
2325 1.1 christos iopkt.iotype = WRITE_TRACE_ERROR;
2326 1.1 christos iopkt.nbyte = 0;
2327 1.1 christos }
2328 1.1 christos iopkt.fd = fileno (stream);
2329 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2330 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2331 1.1 christos POP_REENTRANCE (guard);
2332 1.1 christos return ret;
2333 1.1 christos }
2334 1.1 christos
2335 1.1 christos /*------------------------------------------------------------- pread */
2336 1.1 christos #if ARCH(Intel) && WSIZE(32)
2337 1.1 christos // map interposed symbol versions
2338 1.1 christos static int
2339 1.1 christos __collector_pread_symver (int(real_pread) (), int fildes, void *buf, size_t nbyte, off_t offset);
2340 1.1 christos
2341 1.1 christos SYMVER_ATTRIBUTE (__collector_pread_2_2, pread@@GLIBC_2.2)
2342 1.1 christos int
2343 1.1 christos __collector_pread_2_2 (int fildes, void *buf, size_t nbyte, off_t offset)
2344 1.1 christos {
2345 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_pread_2_2@%p(fildes=%d, buf=%p, nbyte=%lld, offset=%lld)\n",
2346 1.1 christos CALL_REAL (pread_2_2), fildes, buf, (long long) nbyte, (long long) offset);
2347 1.1 christos if (NULL_PTR (pread))
2348 1.1 christos init_io_intf ();
2349 1.1 christos return __collector_pread_symver (CALL_REAL (pread_2_2), fildes, buf, nbyte, offset);
2350 1.1 christos }
2351 1.1 christos
2352 1.1 christos SYMVER_ATTRIBUTE (__collector_pread_2_1, pread@GLIBC_2.1)
2353 1.1 christos int
2354 1.1 christos __collector_pread_2_1 (int fildes, void *buf, size_t nbyte, off_t offset)
2355 1.1 christos {
2356 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_pread_2_1@%p(fildes=%d, buf=%p, nbyte=%lld, offset=%lld)\n",
2357 1.1 christos CALL_REAL (pread_2_1), fildes, buf, (long long) nbyte, (long long) offset);
2358 1.1 christos if (NULL_PTR (pread))
2359 1.1 christos init_io_intf ();
2360 1.1 christos return __collector_pread_symver (CALL_REAL (pread_2_1), fildes, buf, nbyte, offset);
2361 1.1 christos }
2362 1.1 christos
2363 1.1 christos static int
2364 1.1 christos __collector_pread_symver (int(real_pread) (), int fildes, void *buf, size_t nbyte, off_t offset)
2365 1.1 christos {
2366 1.1 christos #else /* ^ARCH(Intel) && WSIZE(32) */
2367 1.1 christos
2368 1.1 christos ssize_t
2369 1.1 christos pread (int fildes, void *buf, size_t nbyte, off_t offset)
2370 1.1 christos {
2371 1.1 christos #endif
2372 1.1 christos int *guard;
2373 1.1 christos ssize_t ret;
2374 1.1 christos IOTrace_packet iopkt;
2375 1.1 christos if (NULL_PTR (pread))
2376 1.1 christos init_io_intf ();
2377 1.1 christos if (CHCK_REENTRANCE (guard))
2378 1.1 christos {
2379 1.1 christos #if ARCH(Intel) && WSIZE(32)
2380 1.1 christos return (real_pread) (fildes, buf, nbyte, offset);
2381 1.1 christos #else
2382 1.1 christos return CALL_REAL (pread)(fildes, buf, nbyte, offset);
2383 1.1 christos #endif
2384 1.1 christos }
2385 1.1 christos PUSH_REENTRANCE (guard);
2386 1.1 christos hrtime_t reqt = gethrtime ();
2387 1.1 christos #if ARCH(Intel) && WSIZE(32)
2388 1.1 christos ret = (real_pread) (fildes, buf, nbyte, offset);
2389 1.1 christos #else
2390 1.1 christos ret = CALL_REAL (pread)(fildes, buf, nbyte, offset);
2391 1.1 christos #endif
2392 1.1 christos if (RECHCK_REENTRANCE (guard))
2393 1.1 christos {
2394 1.1 christos POP_REENTRANCE (guard);
2395 1.1 christos return ret;
2396 1.1 christos }
2397 1.1 christos hrtime_t grnt = gethrtime ();
2398 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2399 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2400 1.1 christos iopkt.comm.tstamp = grnt;
2401 1.1 christos iopkt.requested = reqt;
2402 1.1 christos if (ret >= 0)
2403 1.1 christos iopkt.iotype = READ_TRACE;
2404 1.1 christos else
2405 1.1 christos iopkt.iotype = READ_TRACE_ERROR;
2406 1.1 christos iopkt.fd = fildes;
2407 1.1 christos iopkt.nbyte = ret;
2408 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2409 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2410 1.1 christos POP_REENTRANCE (guard);
2411 1.1 christos return ret;
2412 1.1 christos }
2413 1.1 christos
2414 1.1 christos /*------------------------------------------------------------- pwrite */
2415 1.1 christos #if ARCH(Intel) && WSIZE(32)
2416 1.1 christos // map interposed symbol versions
2417 1.1 christos static int
2418 1.1 christos __collector_pwrite_symver (int(real_pwrite) (), int fildes, const void *buf, size_t nbyte, off_t offset);
2419 1.1 christos
2420 1.1 christos SYMVER_ATTRIBUTE (__collector_pwrite_2_2, pwrite@@GLIBC_2.2)
2421 1.1 christos int
2422 1.1 christos __collector_pwrite_2_2 (int fildes, const void *buf, size_t nbyte, off_t offset)
2423 1.1 christos {
2424 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_pwrite_2_2@%p(fildes=%d, buf=%p, nbyte=%lld, offset=%lld)\n",
2425 1.1 christos CALL_REAL (pwrite_2_2), fildes, buf, (long long) nbyte, (long long) offset);
2426 1.1 christos if (NULL_PTR (pwrite))
2427 1.1 christos init_io_intf ();
2428 1.1 christos return __collector_pwrite_symver (CALL_REAL (pwrite_2_2), fildes, buf, nbyte, offset);
2429 1.1 christos }
2430 1.1 christos
2431 1.1 christos SYMVER_ATTRIBUTE (__collector_pwrite_2_1, pwrite@GLIBC_2.1)
2432 1.1 christos int
2433 1.1 christos __collector_pwrite_2_1 (int fildes, const void *buf, size_t nbyte, off_t offset)
2434 1.1 christos {
2435 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_pwrite_2_1@%p(fildes=%d, buf=%p, nbyte=%lld, offset=%lld)\n",
2436 1.1 christos CALL_REAL (pwrite_2_1), fildes, buf, (long long) nbyte, (long long) offset);
2437 1.1 christos if (NULL_PTR (pwrite))
2438 1.1 christos init_io_intf ();
2439 1.1 christos return __collector_pwrite_symver (CALL_REAL (pwrite_2_1), fildes, buf, nbyte, offset);
2440 1.1 christos }
2441 1.1 christos
2442 1.1 christos static int
2443 1.1 christos __collector_pwrite_symver (int(real_pwrite) (), int fildes, const void *buf, size_t nbyte, off_t offset)
2444 1.1 christos {
2445 1.1 christos #else /* ^ARCH(Intel) && WSIZE(32) */
2446 1.1 christos
2447 1.1 christos ssize_t
2448 1.1 christos pwrite (int fildes, const void *buf, size_t nbyte, off_t offset)
2449 1.1 christos {
2450 1.1 christos #endif /* ^ARCH(Intel) && WSIZE(32) */
2451 1.1 christos int *guard;
2452 1.1 christos ssize_t ret;
2453 1.1 christos IOTrace_packet iopkt;
2454 1.1 christos if (NULL_PTR (pwrite))
2455 1.1 christos init_io_intf ();
2456 1.1 christos if (CHCK_REENTRANCE (guard))
2457 1.1 christos {
2458 1.1 christos #if ARCH(Intel) && WSIZE(32)
2459 1.1 christos return (real_pwrite) (fildes, buf, nbyte, offset);
2460 1.1 christos #else
2461 1.1 christos return CALL_REAL (pwrite)(fildes, buf, nbyte, offset);
2462 1.1 christos #endif
2463 1.1 christos }
2464 1.1 christos PUSH_REENTRANCE (guard);
2465 1.1 christos hrtime_t reqt = gethrtime ();
2466 1.1 christos #if ARCH(Intel) && WSIZE(32)
2467 1.1 christos ret = (real_pwrite) (fildes, buf, nbyte, offset);
2468 1.1 christos #else
2469 1.1 christos ret = CALL_REAL (pwrite)(fildes, buf, nbyte, offset);
2470 1.1 christos #endif
2471 1.1 christos if (RECHCK_REENTRANCE (guard))
2472 1.1 christos {
2473 1.1 christos POP_REENTRANCE (guard);
2474 1.1 christos return ret;
2475 1.1 christos }
2476 1.1 christos hrtime_t grnt = gethrtime ();
2477 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2478 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2479 1.1 christos iopkt.comm.tstamp = grnt;
2480 1.1 christos iopkt.requested = reqt;
2481 1.1 christos if (ret >= 0)
2482 1.1 christos iopkt.iotype = WRITE_TRACE;
2483 1.1 christos else
2484 1.1 christos iopkt.iotype = WRITE_TRACE_ERROR;
2485 1.1 christos iopkt.fd = fildes;
2486 1.1 christos iopkt.nbyte = ret;
2487 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2488 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2489 1.1 christos POP_REENTRANCE (guard);
2490 1.1 christos return ret;
2491 1.1 christos }
2492 1.1 christos
2493 1.1 christos /*------------------------------------------------------------- pwrite64 */
2494 1.1 christos #if ARCH(Intel) && WSIZE(32)
2495 1.1 christos // map interposed symbol versions
2496 1.1 christos static int
2497 1.1 christos __collector_pwrite64_symver (int(real_pwrite64) (), int fildes, const void *buf, size_t nbyte, off64_t offset);
2498 1.1 christos
2499 1.1 christos SYMVER_ATTRIBUTE (__collector_pwrite64_2_2, pwrite64@@GLIBC_2.2)
2500 1.1 christos int
2501 1.1 christos __collector_pwrite64_2_2 (int fildes, const void *buf, size_t nbyte, off64_t offset)
2502 1.1 christos {
2503 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_pwrite64_2_2@%p(fildes=%d, buf=%p, nbyte=%lld, offset=%lld)\n",
2504 1.1 christos CALL_REAL (pwrite64_2_2), fildes, buf, (long long) nbyte, (long long) offset);
2505 1.1 christos if (NULL_PTR (pwrite64))
2506 1.1 christos init_io_intf ();
2507 1.1 christos return __collector_pwrite64_symver (CALL_REAL (pwrite64_2_2), fildes, buf, nbyte, offset);
2508 1.1 christos }
2509 1.1 christos
2510 1.1 christos SYMVER_ATTRIBUTE (__collector_pwrite64_2_1, pwrite64@GLIBC_2.1)
2511 1.1 christos int
2512 1.1 christos __collector_pwrite64_2_1 (int fildes, const void *buf, size_t nbyte, off64_t offset)
2513 1.1 christos {
2514 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_pwrite64_2_1@%p(fildes=%d, buf=%p, nbyte=%lld, offset=%lld)\n",
2515 1.1 christos CALL_REAL (pwrite64_2_1), fildes, buf, (long long) nbyte, (long long) offset);
2516 1.1 christos if (NULL_PTR (pwrite64))
2517 1.1 christos init_io_intf ();
2518 1.1 christos return __collector_pwrite64_symver (CALL_REAL (pwrite64_2_1), fildes, buf, nbyte, offset);
2519 1.1 christos }
2520 1.1 christos
2521 1.1 christos static int
2522 1.1 christos __collector_pwrite64_symver (int(real_pwrite64) (), int fildes, const void *buf, size_t nbyte, off64_t offset)
2523 1.1 christos {
2524 1.1 christos #else /* ^ARCH(Intel) && WSIZE(32) */
2525 1.1 christos
2526 1.1 christos ssize_t
2527 1.1 christos pwrite64 (int fildes, const void *buf, size_t nbyte, off64_t offset)
2528 1.1 christos {
2529 1.1 christos #endif /* ^ARCH(Intel) && WSIZE(32) */
2530 1.1 christos int *guard;
2531 1.1 christos ssize_t ret;
2532 1.1 christos IOTrace_packet iopkt;
2533 1.1 christos if (NULL_PTR (pwrite64))
2534 1.1 christos init_io_intf ();
2535 1.1 christos if (CHCK_REENTRANCE (guard))
2536 1.1 christos {
2537 1.1 christos #if ARCH(Intel) && WSIZE(32)
2538 1.1 christos return (real_pwrite64) (fildes, buf, nbyte, offset);
2539 1.1 christos #else
2540 1.1 christos return CALL_REAL (pwrite64)(fildes, buf, nbyte, offset);
2541 1.1 christos #endif
2542 1.1 christos }
2543 1.1 christos PUSH_REENTRANCE (guard);
2544 1.1 christos hrtime_t reqt = gethrtime ();
2545 1.1 christos #if ARCH(Intel) && WSIZE(32)
2546 1.1 christos ret = (real_pwrite64) (fildes, buf, nbyte, offset);
2547 1.1 christos #else
2548 1.1 christos ret = CALL_REAL (pwrite64)(fildes, buf, nbyte, offset);
2549 1.1 christos #endif
2550 1.1 christos if (RECHCK_REENTRANCE (guard))
2551 1.1 christos {
2552 1.1 christos POP_REENTRANCE (guard);
2553 1.1 christos return ret;
2554 1.1 christos }
2555 1.1 christos hrtime_t grnt = gethrtime ();
2556 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2557 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2558 1.1 christos iopkt.comm.tstamp = grnt;
2559 1.1 christos iopkt.requested = reqt;
2560 1.1 christos if (ret >= 0)
2561 1.1 christos iopkt.iotype = WRITE_TRACE;
2562 1.1 christos else
2563 1.1 christos iopkt.iotype = WRITE_TRACE_ERROR;
2564 1.1 christos iopkt.fd = fildes;
2565 1.1 christos iopkt.nbyte = ret;
2566 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2567 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2568 1.1 christos POP_REENTRANCE (guard);
2569 1.1 christos return ret;
2570 1.1 christos }
2571 1.1 christos
2572 1.1 christos /*------------------------------------------------------------- fgets */
2573 1.1 christos char*
2574 1.1 christos fgets (char *s, int n, FILE *stream)
2575 1.1 christos {
2576 1.1 christos int *guard;
2577 1.1 christos char *ptr;
2578 1.1 christos IOTrace_packet iopkt;
2579 1.1 christos if (NULL_PTR (fgets))
2580 1.1 christos init_io_intf ();
2581 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
2582 1.1 christos return CALL_REAL (fgets)(s, n, stream);
2583 1.1 christos PUSH_REENTRANCE (guard);
2584 1.1 christos hrtime_t reqt = gethrtime ();
2585 1.1 christos ptr = CALL_REAL (fgets)(s, n, stream);
2586 1.1 christos if (RECHCK_REENTRANCE (guard))
2587 1.1 christos {
2588 1.1 christos POP_REENTRANCE (guard);
2589 1.1 christos return ptr;
2590 1.1 christos }
2591 1.1 christos int error = errno;
2592 1.1 christos hrtime_t grnt = gethrtime ();
2593 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2594 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2595 1.1 christos iopkt.comm.tstamp = grnt;
2596 1.1 christos iopkt.requested = reqt;
2597 1.1 christos if (ptr != NULL)
2598 1.1 christos {
2599 1.1 christos iopkt.iotype = READ_TRACE;
2600 1.1 christos iopkt.nbyte = collector_strlen (ptr);
2601 1.1 christos }
2602 1.1 christos else if (ptr == NULL && error != EAGAIN && error != EBADF && error != EINTR &&
2603 1.1 christos error != EIO && error != EOVERFLOW && error != ENOMEM && error != ENXIO)
2604 1.1 christos {
2605 1.1 christos iopkt.iotype = READ_TRACE;
2606 1.1 christos iopkt.nbyte = 0;
2607 1.1 christos }
2608 1.1 christos else
2609 1.1 christos iopkt.iotype = READ_TRACE_ERROR;
2610 1.1 christos iopkt.fd = fileno (stream);
2611 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2612 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2613 1.1 christos POP_REENTRANCE (guard);
2614 1.1 christos return ptr;
2615 1.1 christos }
2616 1.1 christos
2617 1.1 christos /*------------------------------------------------------------- fputs */
2618 1.1 christos int
2619 1.1 christos fputs (const char *s, FILE *stream)
2620 1.1 christos {
2621 1.1 christos int *guard;
2622 1.1 christos int ret;
2623 1.1 christos IOTrace_packet iopkt;
2624 1.1 christos if (NULL_PTR (fputs))
2625 1.1 christos init_io_intf ();
2626 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
2627 1.1 christos return CALL_REAL (fputs)(s, stream);
2628 1.1 christos PUSH_REENTRANCE (guard);
2629 1.1 christos hrtime_t reqt = gethrtime ();
2630 1.1 christos ret = CALL_REAL (fputs)(s, stream);
2631 1.1 christos if (RECHCK_REENTRANCE (guard))
2632 1.1 christos {
2633 1.1 christos POP_REENTRANCE (guard);
2634 1.1 christos return ret;
2635 1.1 christos }
2636 1.1 christos hrtime_t grnt = gethrtime ();
2637 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2638 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2639 1.1 christos iopkt.comm.tstamp = grnt;
2640 1.1 christos iopkt.requested = reqt;
2641 1.1 christos if (ret != EOF)
2642 1.1 christos {
2643 1.1 christos iopkt.iotype = WRITE_TRACE;
2644 1.1 christos iopkt.nbyte = ret;
2645 1.1 christos }
2646 1.1 christos else
2647 1.1 christos {
2648 1.1 christos iopkt.iotype = WRITE_TRACE_ERROR;
2649 1.1 christos iopkt.nbyte = 0;
2650 1.1 christos }
2651 1.1 christos iopkt.fd = fileno (stream);
2652 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2653 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2654 1.1 christos POP_REENTRANCE (guard);
2655 1.1 christos return ret;
2656 1.1 christos }
2657 1.1 christos
2658 1.1 christos /*------------------------------------------------------------- fputc */
2659 1.1 christos int
2660 1.1 christos fputc (int c, FILE *stream)
2661 1.1 christos {
2662 1.1 christos int *guard;
2663 1.1 christos int ret;
2664 1.1 christos IOTrace_packet iopkt;
2665 1.1 christos if (NULL_PTR (fputc))
2666 1.1 christos init_io_intf ();
2667 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
2668 1.1 christos return CALL_REAL (fputc)(c, stream);
2669 1.1 christos PUSH_REENTRANCE (guard);
2670 1.1 christos hrtime_t reqt = gethrtime ();
2671 1.1 christos ret = CALL_REAL (fputc)(c, stream);
2672 1.1 christos if (RECHCK_REENTRANCE (guard))
2673 1.1 christos {
2674 1.1 christos POP_REENTRANCE (guard);
2675 1.1 christos return ret;
2676 1.1 christos }
2677 1.1 christos hrtime_t grnt = gethrtime ();
2678 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2679 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2680 1.1 christos iopkt.comm.tstamp = grnt;
2681 1.1 christos iopkt.requested = reqt;
2682 1.1 christos if (ret != EOF)
2683 1.1 christos {
2684 1.1 christos iopkt.iotype = WRITE_TRACE;
2685 1.1 christos iopkt.nbyte = ret;
2686 1.1 christos }
2687 1.1 christos else
2688 1.1 christos {
2689 1.1 christos iopkt.iotype = WRITE_TRACE_ERROR;
2690 1.1 christos iopkt.nbyte = 0;
2691 1.1 christos }
2692 1.1 christos iopkt.fd = fileno (stream);
2693 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2694 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2695 1.1 christos POP_REENTRANCE (guard);
2696 1.1 christos return ret;
2697 1.1 christos }
2698 1.1 christos
2699 1.1 christos /*------------------------------------------------------------- fprintf */
2700 1.1 christos int
2701 1.1 christos fprintf (FILE *stream, const char *format, ...)
2702 1.1 christos {
2703 1.1 christos int *guard;
2704 1.1 christos int ret;
2705 1.1 christos IOTrace_packet iopkt;
2706 1.1 christos va_list ap;
2707 1.1 christos va_start (ap, format);
2708 1.1 christos if (NULL_PTR (fprintf))
2709 1.1 christos init_io_intf ();
2710 1.1 christos if (NULL_PTR (vfprintf))
2711 1.1 christos init_io_intf ();
2712 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
2713 1.1 christos return CALL_REAL (vfprintf)(stream, format, ap);
2714 1.1 christos PUSH_REENTRANCE (guard);
2715 1.1 christos hrtime_t reqt = gethrtime ();
2716 1.1 christos ret = CALL_REAL (vfprintf)(stream, format, ap);
2717 1.1 christos if (RECHCK_REENTRANCE (guard))
2718 1.1 christos {
2719 1.1 christos POP_REENTRANCE (guard);
2720 1.1 christos return ret;
2721 1.1 christos }
2722 1.1 christos hrtime_t grnt = gethrtime ();
2723 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2724 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2725 1.1 christos iopkt.comm.tstamp = grnt;
2726 1.1 christos iopkt.requested = reqt;
2727 1.1 christos if (ret >= 0)
2728 1.1 christos iopkt.iotype = WRITE_TRACE;
2729 1.1 christos else
2730 1.1 christos iopkt.iotype = WRITE_TRACE_ERROR;
2731 1.1 christos iopkt.fd = fileno (stream);
2732 1.1 christos iopkt.nbyte = ret;
2733 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2734 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2735 1.1 christos POP_REENTRANCE (guard);
2736 1.1 christos return ret;
2737 1.1 christos }
2738 1.1 christos
2739 1.1 christos /*------------------------------------------------------------- vfprintf */
2740 1.1 christos int
2741 1.1 christos vfprintf (FILE *stream, const char *format, va_list ap)
2742 1.1 christos {
2743 1.1 christos int *guard;
2744 1.1 christos int ret;
2745 1.1 christos IOTrace_packet iopkt;
2746 1.1 christos if (NULL_PTR (vfprintf))
2747 1.1 christos init_io_intf ();
2748 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
2749 1.1 christos return CALL_REAL (vfprintf)(stream, format, ap);
2750 1.1 christos PUSH_REENTRANCE (guard);
2751 1.1 christos hrtime_t reqt = gethrtime ();
2752 1.1 christos ret = CALL_REAL (vfprintf)(stream, format, ap);
2753 1.1 christos if (RECHCK_REENTRANCE (guard))
2754 1.1 christos {
2755 1.1 christos POP_REENTRANCE (guard);
2756 1.1 christos return ret;
2757 1.1 christos }
2758 1.1 christos hrtime_t grnt = gethrtime ();
2759 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
2760 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
2761 1.1 christos iopkt.comm.tstamp = grnt;
2762 1.1 christos iopkt.requested = reqt;
2763 1.1 christos if (ret >= 0)
2764 1.1 christos iopkt.iotype = WRITE_TRACE;
2765 1.1 christos else
2766 1.1 christos iopkt.iotype = WRITE_TRACE_ERROR;
2767 1.1 christos iopkt.fd = fileno (stream);
2768 1.1 christos iopkt.nbyte = ret;
2769 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2770 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2771 1.1 christos POP_REENTRANCE (guard);
2772 1.1 christos return ret;
2773 1.1 christos }
2774 1.1 christos
2775 1.1 christos /*------------------------------------------------------------- lseek */
2776 1.1 christos off_t
2777 1.1 christos lseek (int fildes, off_t offset, int whence)
2778 1.1 christos {
2779 1.1 christos int *guard;
2780 1.1 christos off_t ret;
2781 1.1 christos IOTrace_packet iopkt;
2782 1.1 christos if (NULL_PTR (lseek))
2783 1.1 christos init_io_intf ();
2784 1.1 christos if (CHCK_REENTRANCE (guard))
2785 1.1 christos return CALL_REAL (lseek)(fildes, offset, whence);
2786 1.1 christos PUSH_REENTRANCE (guard);
2787 1.1 christos hrtime_t reqt = gethrtime ();
2788 1.1 christos ret = CALL_REAL (lseek)(fildes, offset, whence);
2789 1.1 christos if (RECHCK_REENTRANCE (guard))
2790 1.1 christos {
2791 1.1 christos POP_REENTRANCE (guard);
2792 1.1 christos return ret;
2793 1.1 christos }
2794 1.1 christos hrtime_t grnt = gethrtime ();
2795 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
2796 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
2797 1.1 christos iopkt.comm.tstamp = grnt;
2798 1.1 christos iopkt.requested = reqt;
2799 1.1 christos if (ret != -1)
2800 1.1 christos iopkt.iotype = OTHERIO_TRACE;
2801 1.1 christos else
2802 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
2803 1.1 christos iopkt.fd = fildes;
2804 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2805 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2806 1.1 christos POP_REENTRANCE (guard);
2807 1.1 christos return ret;
2808 1.1 christos }
2809 1.1 christos
2810 1.1 christos /*------------------------------------------------------------- llseek */
2811 1.1 christos offset_t
2812 1.1 christos llseek (int fildes, offset_t offset, int whence)
2813 1.1 christos {
2814 1.1 christos int *guard;
2815 1.1 christos offset_t ret;
2816 1.1 christos IOTrace_packet iopkt;
2817 1.1 christos if (NULL_PTR (llseek))
2818 1.1 christos init_io_intf ();
2819 1.1 christos if (CHCK_REENTRANCE (guard))
2820 1.1 christos return CALL_REAL (llseek)(fildes, offset, whence);
2821 1.1 christos PUSH_REENTRANCE (guard);
2822 1.1 christos hrtime_t reqt = gethrtime ();
2823 1.1 christos ret = CALL_REAL (llseek)(fildes, offset, whence);
2824 1.1 christos if (RECHCK_REENTRANCE (guard))
2825 1.1 christos {
2826 1.1 christos POP_REENTRANCE (guard);
2827 1.1 christos return ret;
2828 1.1 christos }
2829 1.1 christos hrtime_t grnt = gethrtime ();
2830 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
2831 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
2832 1.1 christos iopkt.comm.tstamp = grnt;
2833 1.1 christos iopkt.requested = reqt;
2834 1.1 christos if (ret != -1)
2835 1.1 christos iopkt.iotype = OTHERIO_TRACE;
2836 1.1 christos else
2837 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
2838 1.1 christos iopkt.fd = fildes;
2839 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2840 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
2841 1.1 christos POP_REENTRANCE (guard);
2842 1.1 christos return ret;
2843 1.1 christos }
2844 1.1 christos
2845 1.1 christos /*------------------------------------------------------------- chmod */
2846 1.1 christos int
2847 1.1 christos chmod (const char *path, mode_t mode)
2848 1.1 christos {
2849 1.1 christos int *guard;
2850 1.1 christos int ret;
2851 1.1 christos void *packet;
2852 1.1 christos IOTrace_packet *iopkt;
2853 1.1 christos size_t sz;
2854 1.1 christos unsigned pktSize;
2855 1.1 christos if (NULL_PTR (chmod))
2856 1.1 christos init_io_intf ();
2857 1.1 christos if (CHCK_REENTRANCE (guard) || path == NULL)
2858 1.1 christos return CALL_REAL (chmod)(path, mode);
2859 1.1 christos PUSH_REENTRANCE (guard);
2860 1.1 christos hrtime_t reqt = gethrtime ();
2861 1.1 christos ret = CALL_REAL (chmod)(path, mode);
2862 1.1 christos if (RECHCK_REENTRANCE (guard))
2863 1.1 christos {
2864 1.1 christos POP_REENTRANCE (guard);
2865 1.1 christos return ret;
2866 1.1 christos }
2867 1.1 christos hrtime_t grnt = gethrtime ();
2868 1.1 christos sz = collector_strlen (path);
2869 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
2870 1.1 christos pktSize = collector_align_pktsize (pktSize);
2871 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
2872 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
2873 1.1 christos if (packet != NULL)
2874 1.1 christos {
2875 1.1 christos iopkt = (IOTrace_packet *) packet;
2876 1.1 christos collector_memset (iopkt, 0, pktSize);
2877 1.1 christos iopkt->comm.tsize = pktSize;
2878 1.1 christos iopkt->comm.tstamp = grnt;
2879 1.1 christos iopkt->requested = reqt;
2880 1.1 christos if (ret != -1)
2881 1.1 christos iopkt->iotype = OTHERIO_TRACE;
2882 1.1 christos else
2883 1.1 christos iopkt->iotype = OTHERIO_TRACE_ERROR;
2884 1.1 christos collector_strncpy (&(iopkt->fname), path, sz);
2885 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2886 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
2887 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
2888 1.1 christos }
2889 1.1 christos else
2890 1.1 christos {
2891 1.1 christos Tprintf (0, "iotrace: ERROR: chmod cannot allocate memory\n");
2892 1.1 christos return 0;
2893 1.1 christos }
2894 1.1 christos POP_REENTRANCE (guard);
2895 1.1 christos return ret;
2896 1.1 christos }
2897 1.1 christos
2898 1.1 christos /*------------------------------------------------------------- access */
2899 1.1 christos int
2900 1.1 christos access (const char *path, int amode)
2901 1.1 christos {
2902 1.1 christos int *guard;
2903 1.1 christos int ret;
2904 1.1 christos void *packet;
2905 1.1 christos IOTrace_packet *iopkt;
2906 1.1 christos size_t sz;
2907 1.1 christos unsigned pktSize;
2908 1.1 christos if (NULL_PTR (access))
2909 1.1 christos init_io_intf ();
2910 1.1 christos if (CHCK_REENTRANCE (guard) || path == NULL)
2911 1.1 christos return CALL_REAL (access)(path, amode);
2912 1.1 christos PUSH_REENTRANCE (guard);
2913 1.1 christos hrtime_t reqt = gethrtime ();
2914 1.1 christos ret = CALL_REAL (access)(path, amode);
2915 1.1 christos if (RECHCK_REENTRANCE (guard))
2916 1.1 christos {
2917 1.1 christos POP_REENTRANCE (guard);
2918 1.1 christos return ret;
2919 1.1 christos }
2920 1.1 christos hrtime_t grnt = gethrtime ();
2921 1.1 christos sz = collector_strlen (path);
2922 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
2923 1.1 christos pktSize = collector_align_pktsize (pktSize);
2924 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
2925 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
2926 1.1 christos if (packet != NULL)
2927 1.1 christos {
2928 1.1 christos iopkt = (IOTrace_packet *) packet;
2929 1.1 christos collector_memset (iopkt, 0, pktSize);
2930 1.1 christos iopkt->comm.tsize = pktSize;
2931 1.1 christos iopkt->comm.tstamp = grnt;
2932 1.1 christos iopkt->requested = reqt;
2933 1.1 christos if (ret != -1)
2934 1.1 christos iopkt->iotype = OTHERIO_TRACE;
2935 1.1 christos else
2936 1.1 christos iopkt->iotype = OTHERIO_TRACE_ERROR;
2937 1.1 christos collector_strncpy (&(iopkt->fname), path, sz);
2938 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2939 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
2940 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
2941 1.1 christos }
2942 1.1 christos else
2943 1.1 christos {
2944 1.1 christos Tprintf (0, "iotrace: ERROR: access cannot allocate memory\n");
2945 1.1 christos return 0;
2946 1.1 christos }
2947 1.1 christos POP_REENTRANCE (guard);
2948 1.1 christos return ret;
2949 1.1 christos }
2950 1.1 christos
2951 1.1 christos /*------------------------------------------------------------- rename */
2952 1.1 christos int
2953 1.1 christos rename (const char *old, const char *new)
2954 1.1 christos {
2955 1.1 christos int *guard;
2956 1.1 christos int ret;
2957 1.1 christos void *packet;
2958 1.1 christos IOTrace_packet *iopkt;
2959 1.1 christos size_t sz;
2960 1.1 christos unsigned pktSize;
2961 1.1 christos if (NULL_PTR (rename))
2962 1.1 christos init_io_intf ();
2963 1.1 christos if (CHCK_REENTRANCE (guard) || new == NULL)
2964 1.1 christos return CALL_REAL (rename)(old, new);
2965 1.1 christos PUSH_REENTRANCE (guard);
2966 1.1 christos hrtime_t reqt = gethrtime ();
2967 1.1 christos ret = CALL_REAL (rename)(old, new);
2968 1.1 christos if (RECHCK_REENTRANCE (guard))
2969 1.1 christos {
2970 1.1 christos POP_REENTRANCE (guard);
2971 1.1 christos return ret;
2972 1.1 christos }
2973 1.1 christos hrtime_t grnt = gethrtime ();
2974 1.1 christos sz = collector_strlen (new);
2975 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
2976 1.1 christos pktSize = collector_align_pktsize (pktSize);
2977 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
2978 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
2979 1.1 christos if (packet != NULL)
2980 1.1 christos {
2981 1.1 christos iopkt = (IOTrace_packet *) packet;
2982 1.1 christos collector_memset (iopkt, 0, pktSize);
2983 1.1 christos iopkt->comm.tsize = pktSize;
2984 1.1 christos iopkt->comm.tstamp = grnt;
2985 1.1 christos iopkt->requested = reqt;
2986 1.1 christos if (ret != -1)
2987 1.1 christos iopkt->iotype = OTHERIO_TRACE;
2988 1.1 christos else
2989 1.1 christos iopkt->iotype = OTHERIO_TRACE_ERROR;
2990 1.1 christos collector_strncpy (&(iopkt->fname), new, sz);
2991 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
2992 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
2993 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
2994 1.1 christos }
2995 1.1 christos else
2996 1.1 christos {
2997 1.1 christos Tprintf (0, "iotrace: ERROR: rename cannot allocate memory\n");
2998 1.1 christos return 0;
2999 1.1 christos }
3000 1.1 christos POP_REENTRANCE (guard);
3001 1.1 christos return ret;
3002 1.1 christos }
3003 1.1 christos
3004 1.1 christos /*------------------------------------------------------------- mkdir */
3005 1.1 christos int
3006 1.1 christos mkdir (const char *path, mode_t mode)
3007 1.1 christos {
3008 1.1 christos int *guard;
3009 1.1 christos int ret;
3010 1.1 christos void *packet;
3011 1.1 christos IOTrace_packet *iopkt;
3012 1.1 christos size_t sz;
3013 1.1 christos unsigned pktSize;
3014 1.1 christos if (NULL_PTR (mkdir))
3015 1.1 christos init_io_intf ();
3016 1.1 christos if (CHCK_REENTRANCE (guard) || path == NULL)
3017 1.1 christos return CALL_REAL (mkdir)(path, mode);
3018 1.1 christos PUSH_REENTRANCE (guard);
3019 1.1 christos hrtime_t reqt = gethrtime ();
3020 1.1 christos ret = CALL_REAL (mkdir)(path, mode);
3021 1.1 christos if (RECHCK_REENTRANCE (guard))
3022 1.1 christos {
3023 1.1 christos POP_REENTRANCE (guard);
3024 1.1 christos return ret;
3025 1.1 christos }
3026 1.1 christos hrtime_t grnt = gethrtime ();
3027 1.1 christos sz = collector_strlen (path);
3028 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
3029 1.1 christos pktSize = collector_align_pktsize (pktSize);
3030 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
3031 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
3032 1.1 christos if (packet != NULL)
3033 1.1 christos {
3034 1.1 christos iopkt = (IOTrace_packet *) packet;
3035 1.1 christos collector_memset (iopkt, 0, pktSize);
3036 1.1 christos iopkt->comm.tsize = pktSize;
3037 1.1 christos iopkt->comm.tstamp = grnt;
3038 1.1 christos iopkt->requested = reqt;
3039 1.1 christos if (ret != -1)
3040 1.1 christos iopkt->iotype = OTHERIO_TRACE;
3041 1.1 christos else
3042 1.1 christos iopkt->iotype = OTHERIO_TRACE_ERROR;
3043 1.1 christos collector_strncpy (&(iopkt->fname), path, sz);
3044 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3045 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
3046 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
3047 1.1 christos }
3048 1.1 christos else
3049 1.1 christos {
3050 1.1 christos Tprintf (0, "iotrace: ERROR: mkdir cannot allocate memory\n");
3051 1.1 christos return 0;
3052 1.1 christos }
3053 1.1 christos POP_REENTRANCE (guard);
3054 1.1 christos return ret;
3055 1.1 christos }
3056 1.1 christos
3057 1.1 christos /*------------------------------------------------------------- getdents */
3058 1.1 christos int
3059 1.1 christos getdents (int fildes, struct dirent *buf, size_t nbyte)
3060 1.1 christos {
3061 1.1 christos int *guard;
3062 1.1 christos int ret;
3063 1.1 christos IOTrace_packet iopkt;
3064 1.1 christos if (NULL_PTR (getdents))
3065 1.1 christos init_io_intf ();
3066 1.1 christos if (CHCK_REENTRANCE (guard))
3067 1.1 christos return CALL_REAL (getdents)(fildes, buf, nbyte);
3068 1.1 christos PUSH_REENTRANCE (guard);
3069 1.1 christos hrtime_t reqt = gethrtime ();
3070 1.1 christos ret = CALL_REAL (getdents)(fildes, buf, nbyte);
3071 1.1 christos if (RECHCK_REENTRANCE (guard))
3072 1.1 christos {
3073 1.1 christos POP_REENTRANCE (guard);
3074 1.1 christos return ret;
3075 1.1 christos }
3076 1.1 christos hrtime_t grnt = gethrtime ();
3077 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3078 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3079 1.1 christos iopkt.comm.tstamp = grnt;
3080 1.1 christos iopkt.requested = reqt;
3081 1.1 christos if (ret != -1)
3082 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3083 1.1 christos else
3084 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3085 1.1 christos iopkt.fd = fildes;
3086 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3087 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3088 1.1 christos POP_REENTRANCE (guard);
3089 1.1 christos return ret;
3090 1.1 christos }
3091 1.1 christos
3092 1.1 christos /*------------------------------------------------------------- unlink */
3093 1.1 christos int
3094 1.1 christos unlink (const char *path)
3095 1.1 christos {
3096 1.1 christos int *guard;
3097 1.1 christos int ret;
3098 1.1 christos void *packet;
3099 1.1 christos IOTrace_packet *iopkt;
3100 1.1 christos size_t sz;
3101 1.1 christos unsigned pktSize;
3102 1.1 christos if (NULL_PTR (unlink))
3103 1.1 christos init_io_intf ();
3104 1.1 christos if (CHCK_REENTRANCE (guard) || path == NULL)
3105 1.1 christos return CALL_REAL (unlink)(path);
3106 1.1 christos PUSH_REENTRANCE (guard);
3107 1.1 christos hrtime_t reqt = gethrtime ();
3108 1.1 christos ret = CALL_REAL (unlink)(path);
3109 1.1 christos if (RECHCK_REENTRANCE (guard))
3110 1.1 christos {
3111 1.1 christos POP_REENTRANCE (guard);
3112 1.1 christos return ret;
3113 1.1 christos }
3114 1.1 christos hrtime_t grnt = gethrtime ();
3115 1.1 christos sz = collector_strlen (path);
3116 1.1 christos pktSize = sizeof (IOTrace_packet) + sz;
3117 1.1 christos pktSize = collector_align_pktsize (pktSize);
3118 1.1 christos Tprintf (DBG_LT1, "iotrace allocating %u from io_heap\n", pktSize);
3119 1.1 christos packet = collector_interface->allocCSize (io_heap, pktSize, 1);
3120 1.1 christos if (packet != NULL)
3121 1.1 christos {
3122 1.1 christos iopkt = (IOTrace_packet *) packet;
3123 1.1 christos collector_memset (iopkt, 0, pktSize);
3124 1.1 christos iopkt->comm.tsize = pktSize;
3125 1.1 christos iopkt->comm.tstamp = grnt;
3126 1.1 christos iopkt->requested = reqt;
3127 1.1 christos if (ret != -1)
3128 1.1 christos iopkt->iotype = OTHERIO_TRACE;
3129 1.1 christos else
3130 1.1 christos iopkt->iotype = OTHERIO_TRACE_ERROR;
3131 1.1 christos collector_strncpy (&(iopkt->fname), path, sz);
3132 1.1 christos iopkt->comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt->comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3133 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) iopkt);
3134 1.1 christos collector_interface->freeCSize (io_heap, packet, pktSize);
3135 1.1 christos }
3136 1.1 christos else
3137 1.1 christos {
3138 1.1 christos Tprintf (0, "iotrace: ERROR: unlink cannot allocate memory\n");
3139 1.1 christos return 0;
3140 1.1 christos }
3141 1.1 christos POP_REENTRANCE (guard);
3142 1.1 christos return ret;
3143 1.1 christos }
3144 1.1 christos
3145 1.1 christos /*------------------------------------------------------------- fseek */
3146 1.1 christos int
3147 1.1 christos fseek (FILE *stream, long offset, int whence)
3148 1.1 christos {
3149 1.1 christos int *guard;
3150 1.1 christos int ret;
3151 1.1 christos IOTrace_packet iopkt;
3152 1.1 christos if (NULL_PTR (fseek))
3153 1.1 christos init_io_intf ();
3154 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
3155 1.1 christos return CALL_REAL (fseek)(stream, offset, whence);
3156 1.1 christos PUSH_REENTRANCE (guard);
3157 1.1 christos hrtime_t reqt = gethrtime ();
3158 1.1 christos ret = CALL_REAL (fseek)(stream, offset, whence);
3159 1.1 christos if (RECHCK_REENTRANCE (guard))
3160 1.1 christos {
3161 1.1 christos POP_REENTRANCE (guard);
3162 1.1 christos return ret;
3163 1.1 christos }
3164 1.1 christos hrtime_t grnt = gethrtime ();
3165 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3166 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3167 1.1 christos iopkt.comm.tstamp = grnt;
3168 1.1 christos iopkt.requested = reqt;
3169 1.1 christos if (ret != -1)
3170 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3171 1.1 christos else
3172 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3173 1.1 christos iopkt.fd = fileno (stream);
3174 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3175 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3176 1.1 christos POP_REENTRANCE (guard);
3177 1.1 christos return ret;
3178 1.1 christos }
3179 1.1 christos
3180 1.1 christos /*------------------------------------------------------------- rewind */
3181 1.1 christos void
3182 1.1 christos rewind (FILE *stream)
3183 1.1 christos {
3184 1.1 christos int *guard;
3185 1.1 christos IOTrace_packet iopkt;
3186 1.1 christos if (NULL_PTR (rewind))
3187 1.1 christos init_io_intf ();
3188 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
3189 1.1 christos {
3190 1.1 christos CALL_REAL (rewind)(stream);
3191 1.1 christos return;
3192 1.1 christos }
3193 1.1 christos PUSH_REENTRANCE (guard);
3194 1.1 christos hrtime_t reqt = gethrtime ();
3195 1.1 christos CALL_REAL (rewind)(stream);
3196 1.1 christos if (RECHCK_REENTRANCE (guard))
3197 1.1 christos {
3198 1.1 christos POP_REENTRANCE (guard);
3199 1.1 christos return;
3200 1.1 christos }
3201 1.1 christos hrtime_t grnt = gethrtime ();
3202 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3203 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3204 1.1 christos iopkt.comm.tstamp = grnt;
3205 1.1 christos iopkt.requested = reqt;
3206 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3207 1.1 christos iopkt.fd = fileno (stream);
3208 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3209 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3210 1.1 christos POP_REENTRANCE (guard);
3211 1.1 christos }
3212 1.1 christos
3213 1.1 christos /*------------------------------------------------------------- ftell */
3214 1.1 christos long
3215 1.1 christos ftell (FILE *stream)
3216 1.1 christos {
3217 1.1 christos int *guard;
3218 1.1 christos long ret;
3219 1.1 christos IOTrace_packet iopkt;
3220 1.1 christos if (NULL_PTR (ftell))
3221 1.1 christos init_io_intf ();
3222 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
3223 1.1 christos return CALL_REAL (ftell)(stream);
3224 1.1 christos PUSH_REENTRANCE (guard);
3225 1.1 christos hrtime_t reqt = gethrtime ();
3226 1.1 christos ret = CALL_REAL (ftell)(stream);
3227 1.1 christos if (RECHCK_REENTRANCE (guard))
3228 1.1 christos {
3229 1.1 christos POP_REENTRANCE (guard);
3230 1.1 christos return ret;
3231 1.1 christos }
3232 1.1 christos hrtime_t grnt = gethrtime ();
3233 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3234 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3235 1.1 christos iopkt.comm.tstamp = grnt;
3236 1.1 christos iopkt.requested = reqt;
3237 1.1 christos if (ret != -1)
3238 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3239 1.1 christos else
3240 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3241 1.1 christos iopkt.fd = fileno (stream);
3242 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3243 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3244 1.1 christos POP_REENTRANCE (guard);
3245 1.1 christos return ret;
3246 1.1 christos }
3247 1.1 christos
3248 1.1 christos /*------------------------------------------------------------- fgetpos */
3249 1.1 christos // map interposed symbol versions
3250 1.1 christos #if ARCH(Intel) && WSIZE(32)
3251 1.1 christos static int
3252 1.1 christos __collector_fgetpos_symver (int(real_fgetpos) (), FILE *stream, fpos_t *pos);
3253 1.1 christos
3254 1.1 christos SYMVER_ATTRIBUTE (__collector_fgetpos_2_2, fgetpos@@GLIBC_2.2)
3255 1.1 christos int
3256 1.1 christos __collector_fgetpos_2_2 (FILE *stream, fpos_t *pos)
3257 1.1 christos {
3258 1.1 christos if (NULL_PTR (fgetpos))
3259 1.1 christos init_io_intf ();
3260 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fgetpos_2_2@%p\n", CALL_REAL (fgetpos_2_2));
3261 1.1 christos return __collector_fgetpos_symver (CALL_REAL (fgetpos_2_2), stream, pos);
3262 1.1 christos }
3263 1.1 christos
3264 1.1 christos SYMVER_ATTRIBUTE (__collector_fgetpos_2_0, fgetpos@GLIBC_2.0)
3265 1.1 christos int
3266 1.1 christos __collector_fgetpos_2_0 (FILE *stream, fpos_t *pos)
3267 1.1 christos {
3268 1.1 christos if (NULL_PTR (fgetpos))
3269 1.1 christos init_io_intf ();
3270 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fgetpos_2_0@%p\n", CALL_REAL (fgetpos_2_0));
3271 1.1 christos return __collector_fgetpos_symver (CALL_REAL (fgetpos_2_0), stream, pos);
3272 1.1 christos }
3273 1.1 christos #endif
3274 1.1 christos
3275 1.1 christos #if ARCH(Intel) && WSIZE(32)
3276 1.1 christos
3277 1.1 christos static int
3278 1.1 christos __collector_fgetpos_symver (int(real_fgetpos) (), FILE *stream, fpos_t *pos)
3279 1.1 christos {
3280 1.1 christos #else
3281 1.1 christos int
3282 1.1 christos fgetpos (FILE *stream, fpos_t *pos)
3283 1.1 christos {
3284 1.1 christos #endif
3285 1.1 christos int *guard;
3286 1.1 christos int ret;
3287 1.1 christos IOTrace_packet iopkt;
3288 1.1 christos if (NULL_PTR (fgetpos))
3289 1.1 christos init_io_intf ();
3290 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
3291 1.1 christos {
3292 1.1 christos #if ARCH(Intel) && WSIZE(32)
3293 1.1 christos return (real_fgetpos) (stream, pos);
3294 1.1 christos #else
3295 1.1 christos return CALL_REAL (fgetpos)(stream, pos);
3296 1.1 christos #endif
3297 1.1 christos }
3298 1.1 christos PUSH_REENTRANCE (guard);
3299 1.1 christos hrtime_t reqt = gethrtime ();
3300 1.1 christos #if ARCH(Intel) && WSIZE(32)
3301 1.1 christos ret = (real_fgetpos) (stream, pos);
3302 1.1 christos #else
3303 1.1 christos ret = CALL_REAL (fgetpos)(stream, pos);
3304 1.1 christos #endif
3305 1.1 christos if (RECHCK_REENTRANCE (guard))
3306 1.1 christos {
3307 1.1 christos POP_REENTRANCE (guard);
3308 1.1 christos return ret;
3309 1.1 christos }
3310 1.1 christos hrtime_t grnt = gethrtime ();
3311 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3312 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3313 1.1 christos iopkt.comm.tstamp = grnt;
3314 1.1 christos iopkt.requested = reqt;
3315 1.1 christos if (ret == 0)
3316 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3317 1.1 christos else
3318 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3319 1.1 christos iopkt.fd = fileno (stream);
3320 1.1 christos
3321 1.1 christos #if ARCH(Intel) && WSIZE(32)
3322 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
3323 1.1 christos #else
3324 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3325 1.1 christos #endif
3326 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3327 1.1 christos POP_REENTRANCE (guard);
3328 1.1 christos return ret;
3329 1.1 christos }
3330 1.1 christos
3331 1.1 christos #if WSIZE(32)
3332 1.1 christos /*------------------------------------------------------------- fgetpos64 */
3333 1.1 christos #if ARCH(Intel)
3334 1.1 christos // map interposed symbol versions
3335 1.1 christos
3336 1.1 christos static int
3337 1.1 christos __collector_fgetpos64_symver (int(real_fgetpos64) (), FILE *stream, fpos64_t *pos);
3338 1.1 christos
3339 1.1 christos SYMVER_ATTRIBUTE (__collector_fgetpos64_2_2, fgetpos64@@GLIBC_2.2)
3340 1.1 christos int
3341 1.1 christos __collector_fgetpos64_2_2 (FILE *stream, fpos64_t *pos)
3342 1.1 christos {
3343 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fgetpos64_2_2@%p(stream=%p, pos=%p)\n",
3344 1.1 christos CALL_REAL (fgetpos64_2_2), stream, pos);
3345 1.1 christos if (NULL_PTR (fgetpos64))
3346 1.1 christos init_io_intf ();
3347 1.1 christos return __collector_fgetpos64_symver (CALL_REAL (fgetpos64_2_2), stream, pos);
3348 1.1 christos }
3349 1.1 christos
3350 1.1 christos SYMVER_ATTRIBUTE (__collector_fgetpos64_2_1, fgetpos64@GLIBC_2.1)
3351 1.1 christos int
3352 1.1 christos __collector_fgetpos64_2_1 (FILE *stream, fpos64_t *pos)
3353 1.1 christos {
3354 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fgetpos64_2_1@%p(stream=%p, pos=%p)\n",
3355 1.1 christos CALL_REAL (fgetpos64_2_1), stream, pos);
3356 1.1 christos if (NULL_PTR (fgetpos64))
3357 1.1 christos init_io_intf ();
3358 1.1 christos return __collector_fgetpos64_symver (CALL_REAL (fgetpos64_2_1), stream, pos);
3359 1.1 christos }
3360 1.1 christos
3361 1.1 christos static int
3362 1.1 christos __collector_fgetpos64_symver (int(real_fgetpos64) (), FILE *stream, fpos64_t *pos)
3363 1.1 christos {
3364 1.1 christos #else
3365 1.1 christos int
3366 1.1 christos fgetpos64 (FILE *stream, fpos64_t *pos)
3367 1.1 christos {
3368 1.1 christos #endif
3369 1.1 christos int *guard;
3370 1.1 christos int ret;
3371 1.1 christos IOTrace_packet iopkt;
3372 1.1 christos if (NULL_PTR (fgetpos64))
3373 1.1 christos init_io_intf ();
3374 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
3375 1.1 christos {
3376 1.1 christos #if ARCH(Intel)
3377 1.1 christos return (real_fgetpos64) (stream, pos);
3378 1.1 christos #else
3379 1.1 christos return CALL_REAL (fgetpos64)(stream, pos);
3380 1.1 christos #endif
3381 1.1 christos }
3382 1.1 christos PUSH_REENTRANCE (guard);
3383 1.1 christos hrtime_t reqt = gethrtime ();
3384 1.1 christos #if ARCH(Intel)
3385 1.1 christos ret = (real_fgetpos64) (stream, pos);
3386 1.1 christos #else
3387 1.1 christos ret = CALL_REAL (fgetpos64)(stream, pos);
3388 1.1 christos #endif
3389 1.1 christos if (RECHCK_REENTRANCE (guard))
3390 1.1 christos {
3391 1.1 christos POP_REENTRANCE (guard);
3392 1.1 christos return ret;
3393 1.1 christos }
3394 1.1 christos hrtime_t grnt = gethrtime ();
3395 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3396 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3397 1.1 christos iopkt.comm.tstamp = grnt;
3398 1.1 christos iopkt.requested = reqt;
3399 1.1 christos if (ret == 0)
3400 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3401 1.1 christos else
3402 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3403 1.1 christos iopkt.fd = fileno (stream);
3404 1.1 christos #if ARCH(Intel)
3405 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
3406 1.1 christos #else
3407 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3408 1.1 christos #endif
3409 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3410 1.1 christos POP_REENTRANCE (guard);
3411 1.1 christos return ret;
3412 1.1 christos }
3413 1.1 christos #endif
3414 1.1 christos
3415 1.1 christos /*------------------------------------------------------------- fsetpos */
3416 1.1 christos // map interposed symbol versions
3417 1.1 christos #if ARCH(Intel) && WSIZE(32)
3418 1.1 christos static int
3419 1.1 christos __collector_fsetpos_symver (int(real_fsetpos) (), FILE *stream, const fpos_t *pos);
3420 1.1 christos
3421 1.1 christos SYMVER_ATTRIBUTE (__collector_fsetpos_2_2, fsetpos@@GLIBC_2.2)
3422 1.1 christos int
3423 1.1 christos __collector_fsetpos_2_2 (FILE *stream, const fpos_t *pos)
3424 1.1 christos {
3425 1.1 christos if (NULL_PTR (fsetpos))
3426 1.1 christos init_io_intf ();
3427 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fsetpos_2_2@%p\n", CALL_REAL (fsetpos_2_2));
3428 1.1 christos return __collector_fsetpos_symver (CALL_REAL (fsetpos_2_2), stream, pos);
3429 1.1 christos }
3430 1.1 christos
3431 1.1 christos SYMVER_ATTRIBUTE (__collector_fsetpos_2_0, fsetpos@GLIBC_2.0)
3432 1.1 christos int
3433 1.1 christos __collector_fsetpos_2_0 (FILE *stream, const fpos_t *pos)
3434 1.1 christos {
3435 1.1 christos if (NULL_PTR (fsetpos))
3436 1.1 christos init_io_intf ();
3437 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fsetpos_2_0@%p\n", CALL_REAL (fsetpos_2_0));
3438 1.1 christos return __collector_fsetpos_symver (CALL_REAL (fsetpos_2_0), stream, pos);
3439 1.1 christos }
3440 1.1 christos #endif
3441 1.1 christos
3442 1.1 christos #if ARCH(Intel) && WSIZE(32)
3443 1.1 christos
3444 1.1 christos static int
3445 1.1 christos __collector_fsetpos_symver (int(real_fsetpos) (), FILE *stream, const fpos_t *pos)
3446 1.1 christos {
3447 1.1 christos #else
3448 1.1 christos int
3449 1.1 christos fsetpos (FILE *stream, const fpos_t *pos)
3450 1.1 christos {
3451 1.1 christos #endif
3452 1.1 christos int *guard;
3453 1.1 christos int ret;
3454 1.1 christos IOTrace_packet iopkt;
3455 1.1 christos if (NULL_PTR (fsetpos))
3456 1.1 christos init_io_intf ();
3457 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
3458 1.1 christos {
3459 1.1 christos #if ARCH(Intel) && WSIZE(32)
3460 1.1 christos return (real_fsetpos) (stream, pos);
3461 1.1 christos #else
3462 1.1 christos return CALL_REAL (fsetpos)(stream, pos);
3463 1.1 christos #endif
3464 1.1 christos }
3465 1.1 christos PUSH_REENTRANCE (guard);
3466 1.1 christos hrtime_t reqt = gethrtime ();
3467 1.1 christos #if ARCH(Intel) && WSIZE(32)
3468 1.1 christos ret = (real_fsetpos) (stream, pos);
3469 1.1 christos #else
3470 1.1 christos ret = CALL_REAL (fsetpos)(stream, pos);
3471 1.1 christos #endif
3472 1.1 christos if (RECHCK_REENTRANCE (guard))
3473 1.1 christos {
3474 1.1 christos POP_REENTRANCE (guard);
3475 1.1 christos return ret;
3476 1.1 christos }
3477 1.1 christos hrtime_t grnt = gethrtime ();
3478 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3479 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3480 1.1 christos iopkt.comm.tstamp = grnt;
3481 1.1 christos iopkt.requested = reqt;
3482 1.1 christos if (ret == 0)
3483 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3484 1.1 christos else
3485 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3486 1.1 christos iopkt.fd = fileno (stream);
3487 1.1 christos #if ARCH(Intel) && WSIZE(32)
3488 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
3489 1.1 christos #else
3490 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3491 1.1 christos #endif
3492 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3493 1.1 christos POP_REENTRANCE (guard);
3494 1.1 christos return ret;
3495 1.1 christos }
3496 1.1 christos
3497 1.1 christos #if WSIZE(32)
3498 1.1 christos /*------------------------------------------------------------- fsetpos64 */
3499 1.1 christos #if ARCH(Intel)
3500 1.1 christos // map interposed symbol versions
3501 1.1 christos static int
3502 1.1 christos __collector_fsetpos64_symver (int(real_fsetpos64) (), FILE *stream, const fpos64_t *pos);
3503 1.1 christos
3504 1.1 christos SYMVER_ATTRIBUTE (__collector_fsetpos64_2_2, fsetpos64@@GLIBC_2.2)
3505 1.1 christos int
3506 1.1 christos __collector_fsetpos64_2_2 (FILE *stream, const fpos64_t *pos)
3507 1.1 christos {
3508 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fsetpos64_2_2@%p(stream=%p, pos=%p)\n",
3509 1.1 christos CALL_REAL (fsetpos64_2_2), stream, pos);
3510 1.1 christos if (NULL_PTR (fsetpos64))
3511 1.1 christos init_io_intf ();
3512 1.1 christos return __collector_fsetpos64_symver (CALL_REAL (fsetpos64_2_2), stream, pos);
3513 1.1 christos }
3514 1.1 christos
3515 1.1 christos SYMVER_ATTRIBUTE (__collector_fsetpos64_2_1, fsetpos64@GLIBC_2.1)
3516 1.1 christos int
3517 1.1 christos __collector_fsetpos64_2_1 (FILE *stream, const fpos64_t *pos)
3518 1.1 christos {
3519 1.1 christos TprintfT (DBG_LTT, "iotrace: __collector_fsetpos64_2_1@%p(stream=%p, pos=%p)\n",
3520 1.1 christos CALL_REAL (fsetpos64_2_1), stream, pos);
3521 1.1 christos if (NULL_PTR (fsetpos64))
3522 1.1 christos init_io_intf ();
3523 1.1 christos return __collector_fsetpos64_symver (CALL_REAL (fsetpos64_2_1), stream, pos);
3524 1.1 christos }
3525 1.1 christos
3526 1.1 christos static int
3527 1.1 christos __collector_fsetpos64_symver (int(real_fsetpos64) (), FILE *stream, const fpos64_t *pos)
3528 1.1 christos {
3529 1.1 christos #else
3530 1.1 christos int
3531 1.1 christos fsetpos64 (FILE *stream, const fpos64_t *pos)
3532 1.1 christos {
3533 1.1 christos #endif
3534 1.1 christos int *guard;
3535 1.1 christos int ret;
3536 1.1 christos IOTrace_packet iopkt;
3537 1.1 christos if (NULL_PTR (fsetpos64))
3538 1.1 christos init_io_intf ();
3539 1.1 christos if (CHCK_REENTRANCE (guard) || stream == NULL)
3540 1.1 christos {
3541 1.1 christos #if ARCH(Intel) && WSIZE(32)
3542 1.1 christos return (real_fsetpos64) (stream, pos);
3543 1.1 christos #else
3544 1.1 christos return CALL_REAL (fsetpos64)(stream, pos);
3545 1.1 christos #endif
3546 1.1 christos }
3547 1.1 christos PUSH_REENTRANCE (guard);
3548 1.1 christos hrtime_t reqt = gethrtime ();
3549 1.1 christos #if ARCH(Intel) && WSIZE(32)
3550 1.1 christos ret = (real_fsetpos64) (stream, pos);
3551 1.1 christos #else
3552 1.1 christos ret = CALL_REAL (fsetpos64)(stream, pos);
3553 1.1 christos #endif
3554 1.1 christos if (RECHCK_REENTRANCE (guard))
3555 1.1 christos {
3556 1.1 christos POP_REENTRANCE (guard);
3557 1.1 christos return ret;
3558 1.1 christos }
3559 1.1 christos hrtime_t grnt = gethrtime ();
3560 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3561 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3562 1.1 christos iopkt.comm.tstamp = grnt;
3563 1.1 christos iopkt.requested = reqt;
3564 1.1 christos if (ret == 0)
3565 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3566 1.1 christos else
3567 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3568 1.1 christos iopkt.fd = fileno (stream);
3569 1.1 christos #if ARCH(Intel)
3570 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK_ARG, &iopkt);
3571 1.1 christos #else
3572 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3573 1.1 christos #endif
3574 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3575 1.1 christos POP_REENTRANCE (guard);
3576 1.1 christos return ret;
3577 1.1 christos }
3578 1.1 christos #endif
3579 1.1 christos
3580 1.1 christos /*------------------------------------------------------------- fsync */
3581 1.1 christos int
3582 1.1 christos fsync (int fildes)
3583 1.1 christos {
3584 1.1 christos int *guard;
3585 1.1 christos int ret;
3586 1.1 christos IOTrace_packet iopkt;
3587 1.1 christos if (NULL_PTR (fsync))
3588 1.1 christos init_io_intf ();
3589 1.1 christos if (CHCK_REENTRANCE (guard))
3590 1.1 christos return CALL_REAL (fsync)(fildes);
3591 1.1 christos PUSH_REENTRANCE (guard);
3592 1.1 christos hrtime_t reqt = gethrtime ();
3593 1.1 christos ret = CALL_REAL (fsync)(fildes);
3594 1.1 christos if (RECHCK_REENTRANCE (guard))
3595 1.1 christos {
3596 1.1 christos POP_REENTRANCE (guard);
3597 1.1 christos return ret;
3598 1.1 christos }
3599 1.1 christos hrtime_t grnt = gethrtime ();
3600 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3601 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3602 1.1 christos iopkt.comm.tstamp = grnt;
3603 1.1 christos iopkt.requested = reqt;
3604 1.1 christos if (ret == 0)
3605 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3606 1.1 christos else
3607 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3608 1.1 christos iopkt.fd = fildes;
3609 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3610 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3611 1.1 christos POP_REENTRANCE (guard);
3612 1.1 christos return ret;
3613 1.1 christos }
3614 1.1 christos
3615 1.1 christos /*------------------------------------------------------------- readdir */
3616 1.1 christos struct dirent*
3617 1.1 christos readdir (DIR *dirp)
3618 1.1 christos {
3619 1.1 christos int *guard;
3620 1.1 christos struct dirent *ptr;
3621 1.1 christos IOTrace_packet iopkt;
3622 1.1 christos if (NULL_PTR (readdir))
3623 1.1 christos init_io_intf ();
3624 1.1 christos if (CHCK_REENTRANCE (guard))
3625 1.1 christos return CALL_REAL (readdir)(dirp);
3626 1.1 christos PUSH_REENTRANCE (guard);
3627 1.1 christos hrtime_t reqt = gethrtime ();
3628 1.1 christos ptr = CALL_REAL (readdir)(dirp);
3629 1.1 christos if (RECHCK_REENTRANCE (guard))
3630 1.1 christos {
3631 1.1 christos POP_REENTRANCE (guard);
3632 1.1 christos return ptr;
3633 1.1 christos }
3634 1.1 christos hrtime_t grnt = gethrtime ();
3635 1.1 christos collector_memset (&iopkt, 0, sizeof ( IOTrace_packet));
3636 1.1 christos iopkt.comm.tsize = sizeof ( IOTrace_packet);
3637 1.1 christos iopkt.comm.tstamp = grnt;
3638 1.1 christos iopkt.requested = reqt;
3639 1.1 christos if (ptr != NULL)
3640 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3641 1.1 christos else
3642 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3643 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3644 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3645 1.1 christos POP_REENTRANCE (guard);
3646 1.1 christos return ptr;
3647 1.1 christos }
3648 1.1 christos
3649 1.1 christos /*------------------------------------------------------------- flock */
3650 1.1 christos int
3651 1.1 christos flock (int fd, int operation)
3652 1.1 christos {
3653 1.1 christos int *guard;
3654 1.1 christos int ret;
3655 1.1 christos IOTrace_packet iopkt;
3656 1.1 christos if (NULL_PTR (flock))
3657 1.1 christos init_io_intf ();
3658 1.1 christos if (CHCK_REENTRANCE (guard))
3659 1.1 christos return CALL_REAL (flock)(fd, operation);
3660 1.1 christos PUSH_REENTRANCE (guard);
3661 1.1 christos hrtime_t reqt = gethrtime ();
3662 1.1 christos ret = CALL_REAL (flock)(fd, operation);
3663 1.1 christos if (RECHCK_REENTRANCE (guard))
3664 1.1 christos {
3665 1.1 christos POP_REENTRANCE (guard);
3666 1.1 christos return ret;
3667 1.1 christos }
3668 1.1 christos hrtime_t grnt = gethrtime ();
3669 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3670 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3671 1.1 christos iopkt.comm.tstamp = grnt;
3672 1.1 christos iopkt.requested = reqt;
3673 1.1 christos if (ret == 0)
3674 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3675 1.1 christos else
3676 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3677 1.1 christos iopkt.fd = fd;
3678 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3679 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3680 1.1 christos POP_REENTRANCE (guard);
3681 1.1 christos return ret;
3682 1.1 christos }
3683 1.1 christos
3684 1.1 christos /*------------------------------------------------------------- lockf */
3685 1.1 christos int
3686 1.1 christos lockf (int fildes, int function, off_t size)
3687 1.1 christos {
3688 1.1 christos int *guard;
3689 1.1 christos int ret;
3690 1.1 christos IOTrace_packet iopkt;
3691 1.1 christos if (NULL_PTR (lockf))
3692 1.1 christos init_io_intf ();
3693 1.1 christos if (CHCK_REENTRANCE (guard))
3694 1.1 christos return CALL_REAL (lockf)(fildes, function, size);
3695 1.1 christos PUSH_REENTRANCE (guard);
3696 1.1 christos hrtime_t reqt = gethrtime ();
3697 1.1 christos ret = CALL_REAL (lockf)(fildes, function, size);
3698 1.1 christos if (RECHCK_REENTRANCE (guard))
3699 1.1 christos {
3700 1.1 christos POP_REENTRANCE (guard);
3701 1.1 christos return ret;
3702 1.1 christos }
3703 1.1 christos hrtime_t grnt = gethrtime ();
3704 1.1 christos collector_memset (&iopkt, 0, sizeof (IOTrace_packet));
3705 1.1 christos iopkt.comm.tsize = sizeof (IOTrace_packet);
3706 1.1 christos iopkt.comm.tstamp = grnt;
3707 1.1 christos iopkt.requested = reqt;
3708 1.1 christos if (ret == 0)
3709 1.1 christos iopkt.iotype = OTHERIO_TRACE;
3710 1.1 christos else
3711 1.1 christos iopkt.iotype = OTHERIO_TRACE_ERROR;
3712 1.1 christos iopkt.fd = fildes;
3713 1.1 christos iopkt.comm.frinfo = collector_interface->getFrameInfo (io_hndl, iopkt.comm.tstamp, FRINFO_FROM_STACK, &iopkt);
3714 1.1 christos collector_interface->writeDataRecord (io_hndl, (Common_packet*) & iopkt);
3715 1.1 christos POP_REENTRANCE (guard);
3716 1.1 christos return ret;
3717 1.1 christos }
3718