From 9728ce37ea4348d4bdb2eefbaafee75ad651758c Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Thu, 1 Mar 2007 08:24:39 +0100 Subject: [PATCH] [PATCH] init.c: Expose f_out and f_err to loaded libraries via dlsym() 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 Signed-off-by: Jens Axboe --- Makefile | 2 +- fio.h | 3 +++ init.c | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3a51af34..6af29a34 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ 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 \ diff --git a/fio.h b/fio.h index 6d0c9e31..4eabfbcb 100644 --- a/fio.h +++ b/fio.h @@ -715,6 +715,9 @@ static inline void fio_sem_up(volatile int *sem) 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]; diff --git a/init.c b/init.c index 624814ad..c6837c9f 100644 --- 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; +FILE *get_f_out() +{ + return f_out; +} + +FILE *get_f_err() +{ + return f_err; +} + /* * Return a free job structure. */ -- 2.25.1