[stgt] [PATCH 1/2] add signalfd support

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Thu Sep 17 10:25:44 CEST 2009


On Thu, 17 Sep 2009 15:49:05 +1000
ronnie sahlberg <ronniesahlberg at gmail.com> wrote:

> This builds and runs on rhel5.2 but not on rhel5.4.
> 
> rhel5.4 has __NR_signalfd defined
> asm-x86_64/unistd.h:#define __NR_signalfd               282
> asm-x86_64/unistd.h:__SYSCALL(__NR_signalfd, sys_ni_syscall)
> 
> but it does not have
> [root at rh54n2 usr]# make ISCSI=1
> cc -c -DISCSI -D_GNU_SOURCE -I. -g -O2 -Wall -Wstrict-prototypes -fPIC
> -DTGT_VERSION=\"0.9.8-git-2cf48f1\" iscsi/conn.c -o iscsi/conn.o
> In file included from iscsi/conn.c:29:
> ./util.h:122:28: error: linux/signalfd.h: No such file or directory

Does this work?

I'm pretty sure that there are better ways (I'm a novice at such
tricks). So let me know if anyone knows a better way.


diff --git a/usr/Makefile b/usr/Makefile
index fac476c..c8ccdfb 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -4,6 +4,10 @@ EXTRAVERSION = $(if $(shell git show-ref 2>/dev/null),-git-$(shell git show-ref
 mandir = /usr/share/man
 docdir = /usr/share/doc/tgt
 
+ifneq ($(shell test -e /usr/include/linux/signalfd.h && echo 1),)
+CFLAGS += -DUSE_SIGNALFD
+endif
+
 ifneq ($(IBMVIO),)
 CFLAGS += -DIBMVIO -DUSE_KERNEL
 TGTD_OBJS += $(addprefix ibmvio/, ibmvio.o)
diff --git a/usr/bs.c b/usr/bs.c
index e7cfb05..d0fcce4 100644
--- a/usr/bs.c
+++ b/usr/bs.c
@@ -31,7 +31,6 @@
 #include <sys/types.h>
 #include <sys/epoll.h>
 #include <linux/types.h>
-#include <linux/signalfd.h>
 
 #include "list.h"
 #include "tgtd.h"
diff --git a/usr/util.h b/usr/util.h
index acec418..a7446a3 100644
--- a/usr/util.h
+++ b/usr/util.h
@@ -8,6 +8,7 @@
 #include <signal.h>
 #include <syscall.h>
 #include <unistd.h>
+#include <linux/types.h>
 
 #include "be_byteshift.h"
 
@@ -117,7 +118,9 @@ static inline int __sync_file_range(int fd, __off64_t offset, __off64_t bytes)
 #define __sync_file_range(fd, offset, bytes) fsync(fd)
 #endif
 
-#if defined(__NR_signalfd)
+#if defined(__NR_signalfd) && defined(USE_SIGNALFD)
+#include <linux/signalfd.h>
+
 static inline int __signalfd(int fd, const sigset_t *mask, int flags)
 {
 	int fd2, ret;
@@ -141,7 +144,9 @@ static inline int __signalfd(int fd, const sigset_t *mask, int flags)
 	return fd2;
 }
 #else
-#define __signalfd() (-1)
+#define __signalfd(fd, mask, flags) (-1)
+struct signalfd_siginfo {
+};
 #endif
 
 #endif
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list