blob: 08248d35848458f7a32307e66999d022ce588c4a [file] [log] [blame]
Brad Bishopc1d34332019-09-09 14:56:00 -04001From 365efb2fd3062065af4b6eb3dc1661b96557dae8 Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Wed, 21 Aug 2019 16:37:53 +0800
4Subject: [PATCH] Make iscsid systemd usage optional
5
6Upstream-Status: Backport[https://github.com/open-iscsi/open-iscsi
7/commit/f71581bd641dc26d330cb8b97e5ec272dd08f811]
8
9Signed-off-by: Changqing Li <changqing.li@windriver.com>
10---
11 Makefile | 5 +++++
12 usr/Makefile | 2 ++
13 usr/iscsid.c | 6 ++++++
14 3 files changed, 13 insertions(+)
15
16diff --git a/Makefile b/Makefile
17index c533e9d..1ef0921 100644
18--- a/Makefile
19+++ b/Makefile
20@@ -39,6 +39,11 @@ ifneq (,$(CFLAGS))
21 export CFLAGS
22 endif
23
24+# export systemd disablement if set
25+ifneq ($(NO_SYSTEMD),)
26+export NO_SYSTEMD
27+endif
28+
29 # Random comments:
30 # using '$(MAKE)' instead of just 'make' allows make to run in parallel
31 # over multiple makefile.
32diff --git a/usr/Makefile b/usr/Makefile
33index f9445ad..0203127 100644
34--- a/usr/Makefile
35+++ b/usr/Makefile
36@@ -41,7 +41,9 @@ CFLAGS += $(WARNFLAGS) -I../include -I. -D_GNU_SOURCE \
37 CFLAGS += $(shell $(PKG_CONFIG) --cflags libkmod)
38 ISCSI_LIB = -L$(TOPDIR)/libopeniscsiusr -lopeniscsiusr
39 LDFLAGS += $(shell $(PKG_CONFIG) --libs libkmod)
40+ifneq ($(NO_SYSTEMD),)
41 LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd)
42+endif
43 PROGRAMS = iscsid iscsiadm iscsistart
44
45 # libc compat files
46diff --git a/usr/iscsid.c b/usr/iscsid.c
47index 0c98440..164325e 100644
48--- a/usr/iscsid.c
49+++ b/usr/iscsid.c
50@@ -34,7 +34,9 @@
51 #include <sys/wait.h>
52 #include <sys/types.h>
53 #include <sys/stat.h>
54+#ifndef NO_SYSTEMD
55 #include <systemd/sd-daemon.h>
56+#endif
57
58 #include "iscsid.h"
59 #include "mgmt_ipc.h"
60@@ -339,6 +341,7 @@ static void missing_iname_warn(char *initiatorname_file)
61 /* called right before we enter the event loop */
62 static void set_state_to_ready(void)
63 {
64+#ifndef NO_SYSTEMD
65 if (sessions_to_recover)
66 sd_notify(0, "READY=1\n"
67 "RELOADING=1\n"
68@@ -346,14 +349,17 @@ static void set_state_to_ready(void)
69 else
70 sd_notify(0, "READY=1\n"
71 "STATUS=Ready to process requests\n");
72+#endif
73 }
74
75 /* called when recovery process has been reaped */
76 static void set_state_done_reloading(void)
77 {
78+#ifndef NO_SYSTEMD
79 sessions_to_recover = 0;
80 sd_notifyf(0, "READY=1\n"
81 "STATUS=Ready to process requests\n");
82+#endif
83 }
84
85 int main(int argc, char *argv[])
86--
872.7.4
88