From 868be911f90ea6c90096cf5697ab78cca9e6ac8f Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Sun, 15 Feb 2009 15:16:47 +0200 Subject: [PATCH] osd-target: FreeBSD compatibility * osd-target/Makefile: sqlite3 is expected at /usr/local/{include,lib}/ * osd-target/Makefile: Add tgt/usr/bsd first in include path to override some system headers and missing Linux headers. * osd-target/osd.c: Include linux/fs.h that has some Linux specific definitions used by osd-target code. * osd-target/osd.c: under BSD define sync_file_range(). (os.h/c can not be used because it causes link problems, not worth it for now) Signed-off-by: Boaz Harrosh --- osd-target/Makefile | 15 +++++++++++---- osd-target/osd.c | 10 ++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/osd-target/Makefile b/osd-target/Makefile index da67ee8..b48f905 100644 --- a/osd-target/Makefile +++ b/osd-target/Makefile @@ -10,7 +10,7 @@ DEP := .depend OBJ := $(SRC:.c=.o) TESTDIR := ./tests/ UTILDIR := ../osd-util/ -STGTDIR := ../stgt/ +STGTDIR := ../tgt/ INITDIR := ../osd-initiator/ OSDTARGETLIB := libosdtgt.a @@ -19,7 +19,14 @@ UTILLIB := ../osd-util/libosdutil.a IB_HW_OF_LIBS= -L/usr/local/openib-iser/lib -LIBS := -lm -lcrypto -lsqlite3 -laio -lavahi-core -lavahi-common \ +UNAME= $(shell uname) +ifeq (FreeBSD,$(UNAME)) +LIBS += -L/usr/local/lib/ +CFLAGS += -I/usr/local/include -I$(STGTDIR)/usr/bsd -I$(STGTDIR)/usr +CFLAGS += -D__MAKE_BSD_BUILD__ +endif + +LIBS += -lm -lcrypto -lsqlite3 -laio -lavahi-core -lavahi-common \ $(IB_HW_OF_LIBS) -libverbs -lrdmacm -include ../Makedefs @@ -32,7 +39,7 @@ COPTS += -fPIC -foptimize-sibling-calls -D_GNU_SOURCE CWARN := -Wall -W -Wpointer-arith -Wwrite-strings -Wcast-align -Wcast-qual \ -Wbad-function-cast -Wundef -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -CFLAGS := $(COPTS) $(CWARN) -I.. -Wno-unused -I../osd-util +CFLAGS += $(COPTS) $(CWARN) -I.. -Wno-unused -I../osd-util ifeq ($(PVFS_OSD_INTEGRATED),1) CFLAGS += -DPVFS_OSD_INTEGRATED @@ -69,7 +76,7 @@ $(STGTLIB): STGT $(UTILLIB): UTIL make -C $(UTILDIR) -%.o: %.c +%.o: %.c Makefile $(CC) $(CFLAGS) -c $< -o $@ osd-schema.c: osd.schema diff --git a/osd-target/osd.c b/osd-target/osd.c index 08f242f..ea0debb 100644 --- a/osd-target/osd.c +++ b/osd-target/osd.c @@ -27,6 +27,8 @@ #include #include +#include + #include "osd.h" #include "osd-util/osd-defs.h" #include "target-sense.h" @@ -39,6 +41,14 @@ #include "osd-util/osd-sense.h" #include "list-entry.h" +#ifdef __MAKE_BSD_BUILD__ +static int os_sync_file_range(int fd, __off64_t offset, __off64_t bytes, + unsigned int flags) +{ + return fsync(fd); +} +#endif + struct incits_page_id { const char root_dir_page[40]; const char root_info_page[40];