summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorLee Duncan <lduncan@suse.com>2022-03-25 07:54:18 -0700
committerLee Duncan <lduncan@suse.com>2022-03-25 07:54:18 -0700
commit9a2d2f2cf391c707a98204d488c3cb3e58cdab00 (patch)
treeb96c83ff4479e16f9032dcabf4435270f2ca6a9d /usr
parent89df67cd154d43c9b8361880fbd0d94175ff65a1 (diff)
downloadopen-iscsi-9a2d2f2cf391c707a98204d488c3cb3e58cdab00.tar.gz
Make DB and ISCSIHOME directories configurable.
This commit adds two new top-level build options: one for the "home" directory for open-iscsi called "HOMEDIR", and one for the "database" directory, called "DBROOT". One can now override the defaults of "/etc/iscsi" for either or both of these directories on the make command line. The README and man pages are updated with details about these new options. Some Makefile cleanup/repair was done as well. Installation of the initiatorname.iscsi file, was moved out of the top-level Makefile into the etc subdirectory, and installation of man ages moved from the top-level Makefile to the doc subdirectory. Also, this fixes some issues from commit fd14dd8316b1 ("Clean p Makefile build system."), which incorrectly changed the DESTDIR ariable in the Makefiles. This current commit also fixes the top-level variable names for moving DBROOT and HOMEDIR.
Diffstat (limited to 'usr')
-rw-r--r--usr/Makefile16
-rw-r--r--usr/idbm.c8
-rw-r--r--usr/idbm.h13
-rw-r--r--usr/iface.c4
-rw-r--r--usr/iface.h2
-rw-r--r--usr/initiator.h8
-rw-r--r--usr/iscsid_req.c2
7 files changed, 32 insertions, 21 deletions
diff --git a/usr/Makefile b/usr/Makefile
index e7ba803..04e0bbb 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -7,7 +7,8 @@ endif
INSTALL = install
DESTDR ?=
-SBINDIR ?= $(DESTDIR)/sbin
+SBINDIR ?= /sbin
+etcdir = /etc
OSNAME=$(shell uname -s)
@@ -37,6 +38,9 @@ IPC_OBJ=ioctl.o
endif
endif
+DBROOT ?= $(etcdir)/iscsi
+HOMEDIR ?= $(etcdir)/iscsi
+
PKG_CONFIG = /usr/bin/pkg-config
CFLAGS ?= -O2 -g
@@ -51,9 +55,11 @@ LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd)
else
CFLAGS += -DNO_SYSTEMD
endif
+CFLAGS += -DISCSI_DB_ROOT=\"$(DBROOT)\"
+CFLAGS += -DISCSI_CONFIG_ROOT=\"$(HOMEDIR)\"
PROGRAMS = iscsid iscsiadm iscsistart
-PROGRAMS_DEST = $(addprefix $(SBINDIR)/,$(PROGRAMS))
+PROGRAMS_DEST = $(addprefix $(DESTDIR)$(SBINDIR)/,$(PROGRAMS))
# libc compat files
SYSDEPS_SRCS = $(sort $(wildcard ../utils/sysdeps/*.o))
@@ -85,12 +91,12 @@ iscsistart: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \
iscsistart.o statics.o
$(CC) $(CFLAGS) $^ -o $@ -lcrypto -lrt $(LDFLAGS) $(ISCSI_LIB)
-install: $(SBINDIR) $(PROGRAMS_DEST)
+install: $(DESTDIR)$(SBINDIR) $(PROGRAMS_DEST)
-$(SBINDIR):
+$(DESTDIR)$(SBINDIR):
[ -d $@ ] || $(INSTALL) -d $@
-$(PROGRAMS_DEST): $(SBINDIR)/%: %
+$(PROGRAMS_DEST): $(DESTDIR)$(SBINDIR)/%: %
$(INSTALL) -m 755 $? $@
clean:
diff --git a/usr/idbm.c b/usr/idbm.c
index c232b7b..921dcad 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -1835,7 +1835,7 @@ int idbm_print_all_discovery(int info_level)
* @port: rec's port
*
* This will run fn over all recs with the {targetname,tpgt,ip,port}
- * id. It does not iterate over the ifaces setup in /etc/iscsi/ifaces.
+ * id. It does not iterate over the ifaces setup in the iface DB directory.
*
* fn should return -1 if it skipped the rec, an ISCSI_ERR error code if
* the operation failed or 0 if fn was run successfully.
@@ -3031,9 +3031,9 @@ free_info:
int idbm_init(idbm_get_config_file_fn *fn)
{
/* make sure root db dir is there */
- if (access(ISCSI_CONFIG_ROOT, F_OK) != 0) {
- if (mkdir(ISCSI_CONFIG_ROOT, 0770) != 0) {
- log_error("Could not make %s %d", ISCSI_CONFIG_ROOT,
+ if (access(ISCSI_DB_ROOT, F_OK) != 0) {
+ if (mkdir(ISCSI_DB_ROOT, 0770) != 0) {
+ log_error("Could not make %s %d", ISCSI_DB_ROOT,
errno);
return errno;
}
diff --git a/usr/idbm.h b/usr/idbm.h
index 7496f1d..0fde800 100644
--- a/usr/idbm.h
+++ b/usr/idbm.h
@@ -30,12 +30,13 @@
#include "list.h"
#include "flashnode.h"
-#define NODE_CONFIG_DIR ISCSI_CONFIG_ROOT"nodes"
-#define SLP_CONFIG_DIR ISCSI_CONFIG_ROOT"slp"
-#define ISNS_CONFIG_DIR ISCSI_CONFIG_ROOT"isns"
-#define STATIC_CONFIG_DIR ISCSI_CONFIG_ROOT"static"
-#define FW_CONFIG_DIR ISCSI_CONFIG_ROOT"fw"
-#define ST_CONFIG_DIR ISCSI_CONFIG_ROOT"send_targets"
+#define NODE_CONFIG_DIR ISCSI_DB_ROOT"/nodes"
+#define SLP_CONFIG_DIR ISCSI_DB_ROOT"/slp"
+#define ISNS_CONFIG_DIR ISCSI_DB_ROOT"/isns"
+#define STATIC_CONFIG_DIR ISCSI_DB_ROOT"/static"
+#define FW_CONFIG_DIR ISCSI_DB_ROOT"/fw"
+#define ST_CONFIG_DIR ISCSI_DB_ROOT"/send_targets"
+
#define ST_CONFIG_NAME "st_config"
#define ISNS_CONFIG_NAME "isns_config"
diff --git a/usr/iface.c b/usr/iface.c
index 9db73c3..8b15b7d 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -93,8 +93,8 @@ static void iface_init(struct iface_rec *iface)
}
/*
- * default is to use tcp through whatever the network layer
- * selects for us with the /etc/iscsi/initiatorname.iscsi iname.
+ * Default is to use tcp through whatever the network layer
+ * selects for us with the initiatorname.iscsi iname.
*/
void iface_setup_defaults(struct iface_rec *iface)
{
diff --git a/usr/iface.h b/usr/iface.h
index 095772e..7e1e6a2 100644
--- a/usr/iface.h
+++ b/usr/iface.h
@@ -22,7 +22,7 @@
#include <libopeniscsiusr/libopeniscsiusr.h>
-#define IFACE_CONFIG_DIR ISCSI_CONFIG_ROOT"ifaces"
+#define IFACE_CONFIG_DIR ISCSI_DB_ROOT"/ifaces"
struct iface_rec;
struct list_head;
diff --git a/usr/initiator.h b/usr/initiator.h
index a4e01a2..0222797 100644
--- a/usr/initiator.h
+++ b/usr/initiator.h
@@ -34,15 +34,19 @@
#include "list.h"
#include "log.h"
+#ifndef ISCSI_CONFIG_ROOT
#define ISCSI_CONFIG_ROOT "/etc/iscsi/"
+#endif
-#define CONFIG_FILE ISCSI_CONFIG_ROOT"iscsid.conf"
-#define INITIATOR_NAME_FILE ISCSI_CONFIG_ROOT"initiatorname.iscsi"
+#define CONFIG_FILE ISCSI_CONFIG_ROOT"/iscsid.conf"
+#define INITIATOR_NAME_FILE ISCSI_CONFIG_ROOT"/initiatorname.iscsi"
#define PID_FILE "/run/iscsid.pid"
+
#ifndef LOCK_DIR
#define LOCK_DIR "/run/lock/iscsi"
#endif
+
#define LOCK_FILE LOCK_DIR"/lock"
#define LOCK_WRITE_FILE LOCK_DIR"/lock.write"
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
index f0882b5..fbcba41 100644
--- a/usr/iscsid_req.c
+++ b/usr/iscsid_req.c
@@ -46,7 +46,7 @@ static void iscsid_startup(void)
if (!startup_cmd) {
log_error("iscsid is not running. Could not start it up "
"automatically using the startup command in the "
- "/etc/iscsi/iscsid.conf iscsid.startup setting. "
+ "iscsid.conf iscsid.startup setting. "
"Please check that the file exists or that your "
"init scripts have started iscsid.");
return;