[PATCH] init.c: Expose f_out and f_err to loaded libraries via dlsym()
authorJoel Becker <joel.becker@oracle.com>
Thu, 1 Mar 2007 07:24:39 +0000 (08:24 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 1 Mar 2007 07:24:39 +0000 (08:24 +0100)
Loaded ioengines would like to use the logging functions but can't, as
they can't see f_out and f_err.  Create get_f_{out,err}() so that
the libraries can dlsym() them.  Compile fio with -rdynamic so dlopen()
works.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Makefile
fio.h
init.c

index 3a51af3417ee4e20652e86baee646e0a06db8ec7..6af29a34b0d120f5bba49aaadef6bc086ebbb786 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 CC     = gcc -W
 DEBUGFLAGS = -D_FORTIFY_SOURCE=2
 OPTFLAGS= -O2 -g
 CC     = gcc -W
 DEBUGFLAGS = -D_FORTIFY_SOURCE=2
 OPTFLAGS= -O2 -g
-CFLAGS = -Wwrite-strings -Wall -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(DEBUGFLAGS)
+CFLAGS = -Wwrite-strings -Wall -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(DEBUGFLAGS) -rdynamic
 PROGS  = fio
 SCRIPTS = fio_generate_plots
 OBJS = gettime.o fio.o ioengines.o init.o stat.o log.o time.o md5.o crc32.o \
 PROGS  = fio
 SCRIPTS = fio_generate_plots
 OBJS = gettime.o fio.o ioengines.o init.o stat.o log.o time.o md5.o crc32.o \
diff --git a/fio.h b/fio.h
index 6d0c9e31f36164db8062bfa6d2a2ab74ab1e65ce..4eabfbcb162f8f298389bb631759670414dc56ce 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -715,6 +715,9 @@ static inline void fio_sem_up(volatile int *sem)
                fprintf(stderr, ##args);        \
        } while (0)
 
                fprintf(stderr, ##args);        \
        } while (0)
 
+FILE *get_f_out(void);
+FILE *get_f_err(void);
+
 struct ioengine_ops {
        struct list_head list;
        char name[16];
 struct ioengine_ops {
        struct list_head list;
        char name[16];
diff --git a/init.c b/init.c
index 624814ade9eae5ba55dcf493d2914005cb7e0222..c6837c9f91d3bea0db10d7a8a4a106bcf9268deb 100644 (file)
--- a/init.c
+++ b/init.c
@@ -608,6 +608,16 @@ FILE *f_err = NULL;
 static int write_lat_log = 0;
 int write_bw_log = 0;
 
 static int write_lat_log = 0;
 int write_bw_log = 0;
 
+FILE *get_f_out()
+{
+       return f_out;
+}
+
+FILE *get_f_err()
+{
+       return f_err;
+}
+
 /*
  * Return a free job structure.
  */
 /*
  * Return a free job structure.
  */