261a1a1
From f7c6a7381a38ca59fd7a9a64e5f54cf5c16995ad Mon Sep 17 00:00:00 2001
0e55d5b
From: Chris Leech <cleech@redhat.com>
0e55d5b
Date: Mon, 19 Nov 2012 16:38:45 -0800
261a1a1
Subject: [PATCH 1/1] use var for config
0e55d5b
0e55d5b
---
0e55d5b
 README         | 33 ++++++++++++++++-----------------
0e55d5b
 doc/iscsiadm.8 |  8 ++++----
bda814b
 doc/iscsid.8   |  2 +-
0e55d5b
 usr/idbm.c     |  6 +++---
c2d5d21
 usr/idbm.h     | 13 +++++++------
e8d2112
 usr/iface.h    |  3 ++-
bda814b
 6 files changed, 33 insertions(+), 32 deletions(-)
0e55d5b
0e55d5b
diff --git a/README b/README
261a1a1
index b62a14e..1875e3d 100644
0e55d5b
--- a/README
0e55d5b
+++ b/README
e8d2112
@@ -172,8 +172,7 @@ Usage: iscsid [OPTION]
0e55d5b
 
0e55d5b
 Open-iSCSI persistent configuration is stored in a number of
0e55d5b
 directories under a configuration root directory, using a flat-file
0e55d5b
-format. This configuration root directory is /etc/iscsi by default,
0e55d5b
-but may also commonly be in /var/lib/iscsi.
0e55d5b
+format. This configuration root directory is /var/lib/iscsi by default.
0e55d5b
 
0e55d5b
 Configuration is contained in directories for:
0e55d5b
 
261a1a1
@@ -573,7 +572,7 @@ a scsi_host per HBA port).
5a3872e
 To manage both types of initiator stacks, iscsiadm uses the interface (iface)
5a3872e
 structure. For each HBA port or for software iscsi for each network
5a3872e
 device (ethX) or NIC, that you wish to bind sessions to you must create
5a3872e
-a iface config /etc/iscsi/ifaces.
5a3872e
+a iface config /var/lib/iscsi/ifaces.
5a3872e
 
e8d2112
 Prep
e8d2112
 ----
261a1a1
@@ -606,7 +605,7 @@ Running
e8d2112
 The command
e8d2112
 	iscsiadm -m iface
5ebdd59
 
e8d2112
-will report iface configurations that are setup in /etc/iscsi/ifaces:
e8d2112
+will report iface configurations that are setup in /var/lib/iscsi/ifaces:
5a3872e
 
e8d2112
 	iface0 qla4xxx,00:c0:dd:08:63:e8,20.15.0.7,default,iqn.2005-06.com.redhat:madmax
e8d2112
 	iface1 qla4xxx,00:c0:dd:08:63:ea,20.15.0.9,default,iqn.2005-06.com.redhat:madmax
261a1a1
@@ -616,10 +615,10 @@ The format is:
5a3872e
 
5a3872e
 For software iscsi, you can create the iface configs by hand, but it is
7c06f46
 recommended that you use iscsiadm's iface mode. There is an iface.example in
5a3872e
-/etc/iscsi/ifaces which can be used as a template for the daring.
5a3872e
+/var/lib/iscsi/ifaces which can be used as a template for the daring.
5a3872e
 
e8d2112
 For each network object you wish to bind a session to, you must create
7c06f46
-a separate iface config in /etc/iscsi/ifaces and each iface config file
7c06f46
+a separate iface config in /var/lib/iscsi/ifaces and each iface config file
5a3872e
 must have a unique name which is less than or equal to 64 characters.
5a3872e
 
e8d2112
 Example
261a1a1
@@ -627,12 +626,12 @@ Example
5a3872e
 
5a3872e
 If you have NIC1 with MAC address 00:0F:1F:92:6B:BF and NIC2 with
e8d2112
 MAC address 00:C0:DD:08:63:E7, and you wanted to do software iscsi over
e8d2112
-TCP/IP, then in /etc/iscsi/ifaces/iface0 you would enter:
e8d2112
+TCP/IP, then in /var/lib/iscsi/ifaces/iface0 you would enter:
5a3872e
 
e8d2112
 	iface.transport_name = tcp
e8d2112
 	iface.hwaddress = 00:0F:1F:92:6B:BF
5a3872e
 
5a3872e
-and in /etc/iscsi/ifaces/iface1 you would enter:
5a3872e
+and in /var/lib/iscsi/ifaces/iface1 you would enter:
5a3872e
 
e8d2112
 	iface.transport_name = tcp
e8d2112
 	iface.hwaddress = 00:C0:DD:08:63:E7
261a1a1
@@ -674,7 +673,7 @@ port. The iface name will be of the form:
e8d2112
 Running the following command:
e8d2112
 	iscsiadm -m iface
5ebdd59
 
e8d2112
-will report iface configurations that are setup in /etc/iscsi/ifaces:
e8d2112
+will report iface configurations that are setup in /var/lib/iscsi/ifaces:
5a3872e
 
e8d2112
 	default tcp,<empty>,<empty>,<empty>,<empty>
e8d2112
 	iser iser,<empty>,<empty>,<empty>,<empty>
261a1a1
@@ -754,7 +753,7 @@ need a separate network connection to the target for discovery purposes.
5ebdd59
 *This will be fixed in the next version of open-iscsi*
5ebdd59
 
5ebdd59
 For compatibility reasons, when you run iscsiadm to do discovery, it
5ebdd59
-will check for interfaces in /etc/iscsi/iscsi/ifaces that are using
e8d2112
+will check for interfaces in /var/lib/iscsi/iscsi/ifaces that are using
e8d2112
 tcp for the iface.transport, and it will bind the portals that are discovered
5ebdd59
 so that they will be logged in through those ifaces. This behavior can also
e8d2112
 be overridden by passing in the interfaces you want to use. For the case
261a1a1
@@ -769,7 +768,7 @@ If you had defined interfaces but wanted the old behavior, where we do not
e8d2112
 bind a session to an iface, then you can use the special iface "default":
e8d2112
 	iscsiadm -m discoverydb -t st -p ip:port -I default --discover -P 1
5a3872e
 
5a3872e
-And if you did not define any interfaces in /etc/iscsi/ifaces and do
5a3872e
+And if you did not define any interfaces in /var/lib/iscsi/ifaces and do
5a3872e
 not pass anything into iscsiadm, running iscsiadm will do the default
e8d2112
 behavior, allowing the network subsystem to decide which device to use.
1c8eda8
 
261a1a1
@@ -805,7 +804,7 @@ Discovery mode
e8d2112
 		ID [192.168.1.1:3260]:
e8d2112
 	iscsiadm -m discoverydb -t st -p 192.168.1.1:3260 --discover
1c8eda8
 
1c8eda8
-	This will search /etc/iscsi/send_targets for a record with the
1c8eda8
+	This will search /var/lib/iscsi/send_targets for a record with the
1c8eda8
 	ID [portal = 192.168.1.1:3260 and type = sendtargets. If found it
1c8eda8
 	will perform discovery using the settings stored in the record.
1c8eda8
 	If a record does not exist, it will be created using the iscsid.conf
261a1a1
@@ -814,7 +813,7 @@ Discovery mode
e8d2112
 	The argument to -p may also be a hostname instead of an address:
e8d2112
 		iscsiadm -m discoverydb -t st -p somehost --discover
1c8eda8
 
1c8eda8
-	For the ifaces, iscsiadm will first search /etc/iscsi/ifaces for
1c8eda8
+	For the ifaces, iscsiadm will first search /var/lib/iscsi/ifaces for
1c8eda8
 	interfaces using software iscsi. If any are found then nodes found
1c8eda8
 	during discovery will be setup so that they can logged in through
1c8eda8
 	those interfaces. To specify a specific iface, pass the
261a1a1
@@ -865,7 +864,7 @@ Discovery mode
5a3872e
 
e8d2112
 - SendTargets iSCSI Discovery with a specific interface.
e8d2112
 		If you wish to only use a subset of the interfaces in
e8d2112
-		/etc/iscsi/ifaces, then you can pass them in during discovery:
e8d2112
+		/var/lib/iscsi/ifaces, then you can pass them in during discovery:
e8d2112
 	iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \
e8d2112
 		--interface=iface0 --interface=iface1 --discover
5a3872e
 
261a1a1
@@ -1232,8 +1231,8 @@ where targetname is the name of the target and ip_address:port is the address
e8d2112
 and port of the portal. tpgt is the Target Portal Group Tag of
a4c8b30
 the portal, and is not used in iscsiadm commands except for static
e8d2112
 record creation. ifacename is the name of the iscsi interface
a4c8b30
-defined in /etc/iscsi/ifaces. If no interface was defined in
a4c8b30
-/etc/iscsi/ifaces or passed in, the default behavior is used.
a4c8b30
+defined in /var/lib/iscsi/ifaces. If no interface was defined in
a4c8b30
+/var/lib/iscsi/ifaces or passed in, the default behavior is used.
e8d2112
 Default here is iscsi_tcp/tcp to be used over whichever NIC the
a4c8b30
 network layer decides is best.
a4c8b30
 
261a1a1
@@ -1353,7 +1352,7 @@ If set, iscsid will perform discovery to the address every
1c8eda8
 discovery.isns.discoveryd_poll_inval or
1c8eda8
 discovery.sendtargets.discoveryd_poll_inval seconds,
1c8eda8
 and it will log into any portals found from the discovery source using
1c8eda8
-the ifaces in /etc/iscsi/ifaces.
1c8eda8
+the ifaces in /var/lib/iscsi/ifaces.
1c8eda8
 
1c8eda8
 Note that for iSNS the poll_interval does not have to be set. If not set,
1c8eda8
 iscsid will only perform rediscovery when it gets a SCN from the server.
0e55d5b
diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8
261a1a1
index 3729a72..9f84a81 100644
0e55d5b
--- a/doc/iscsiadm.8
0e55d5b
+++ b/doc/iscsiadm.8
261a1a1
@@ -228,7 +228,7 @@ This option is only valid for ping submode.
0e55d5b
 .TP
0e55d5b
 \fB\-I\fR, \fB\-\-interface=\fI[iface]\fR
0e55d5b
 The interface argument specifies the iSCSI interface to use for the operation.
0e55d5b
-iSCSI interfaces (iface) are defined in /etc/iscsi/ifaces. For hardware
0e55d5b
+iSCSI interfaces (iface) are defined in /var/lib/iscsi/ifaces. For hardware
0e55d5b
 iSCSI (qla4xxx) the iface config must have the hardware address
0e55d5b
 (iface.hwaddress = port's MAC address)
0e55d5b
 and the driver/transport_name (iface.transport_name). The iface's name is
261a1a1
@@ -318,7 +318,7 @@ If no other options are specified: for \fIdiscovery\fR, \fIdiscoverydb\fR and
b34de1d
 \fInode\fR, all of their respective records are displayed; for \fIsession\fR,
b34de1d
 all active sessions and connections are displayed; for \fIfw\fR, all boot
b34de1d
 firmware values are displayed; for \fIhost\fR, all iSCSI hosts are displayed;
b34de1d
-and for \fIiface\fR, all ifaces setup in /etc/iscsi/ifaces are displayed.
b34de1d
+and for \fIiface\fR, all ifaces setup in /var/lib/iscsi/ifaces are displayed.
0e55d5b
 .TP
0e55d5b
 \fB\-n\fR, \fB\-\-name=\fIname\fR
bda814b
 In node mode, specify a field \fIname\fR in a record. In flashnode submode
261a1a1
@@ -681,10 +681,10 @@ The configuration file read by \fBiscsid\fR and \fBiscsiadm\fR on startup.
0e55d5b
 The file containing the iSCSI InitiatorName and InitiatorAlias read by
0e55d5b
 \fBiscsid\fR and \fBiscsiadm\fR on startup.
0e55d5b
 .TP
0e55d5b
-/etc/iscsi/nodes/
0e55d5b
+/var/lib/iscsi/nodes/
0e55d5b
 This directory contains the nodes with their targets.
0e55d5b
 .TP
0e55d5b
-/etc/iscsi/send_targets
0e55d5b
+/var/lib/iscsi/send_targets
0e55d5b
 This directory contains the portals.
bda814b
 .SH "SEE ALSO"
bda814b
 .BR iscsid (8)
bda814b
diff --git a/doc/iscsid.8 b/doc/iscsid.8
261a1a1
index db996b4..eaa9c3b 100644
bda814b
--- a/doc/iscsid.8
bda814b
+++ b/doc/iscsid.8
261a1a1
@@ -70,7 +70,7 @@ and
bda814b
 .B iscsiadm
bda814b
 on startup.
bda814b
 .TP
bda814b
-/etc/iscsi/nodes
bda814b
+/var/lib/iscsi/nodes
bda814b
 Open-iSCSI persistent configuration database
0e55d5b
 
0e55d5b
 .SH "SEE ALSO"
0e55d5b
diff --git a/usr/idbm.c b/usr/idbm.c
261a1a1
index 7c63c04..779d052 100644
0e55d5b
--- a/usr/idbm.c
0e55d5b
+++ b/usr/idbm.c
261a1a1
@@ -3104,9 +3104,9 @@ free_info:
a4c8b30
 int idbm_init(idbm_get_config_file_fn *fn)
a4c8b30
 {
d3d8564
 	/* make sure root db dir is there */
d3d8564
-	if (access(ISCSI_CONFIG_ROOT, F_OK) != 0) {
261a1a1
-		if (mkdir(ISCSI_CONFIG_ROOT, 0770) != 0) {
929689a
-			log_error("Could not make %s %d", ISCSI_CONFIG_ROOT,
d3d8564
+	if (access(ISCSIVAR, F_OK) != 0) {
261a1a1
+		if (mkdir(ISCSIVAR, 0770) != 0) {
929689a
+			log_error("Could not make %s %d", ISCSIVAR,
d3d8564
 				   errno);
a4c8b30
 			return errno;
mchristi a7062b5
 		}
0e55d5b
diff --git a/usr/idbm.h b/usr/idbm.h
261a1a1
index 7496f1d..db3048b 100644
0e55d5b
--- a/usr/idbm.h
0e55d5b
+++ b/usr/idbm.h
bda814b
@@ -30,12 +30,13 @@
0e55d5b
 #include "list.h"
c2d5d21
 #include "flashnode.h"
mchristi a7062b5
 
d3d8564
-#define NODE_CONFIG_DIR		ISCSI_CONFIG_ROOT"nodes"
d3d8564
-#define SLP_CONFIG_DIR		ISCSI_CONFIG_ROOT"slp"
d3d8564
-#define ISNS_CONFIG_DIR		ISCSI_CONFIG_ROOT"isns"
d3d8564
-#define STATIC_CONFIG_DIR	ISCSI_CONFIG_ROOT"static"
5ebdd59
-#define FW_CONFIG_DIR		ISCSI_CONFIG_ROOT"fw"
d3d8564
-#define ST_CONFIG_DIR		ISCSI_CONFIG_ROOT"send_targets"
241a29f
+#define ISCSIVAR		"/var/lib/iscsi/"
d3d8564
+#define NODE_CONFIG_DIR		ISCSIVAR"nodes"
d3d8564
+#define SLP_CONFIG_DIR		ISCSIVAR"slp"
d3d8564
+#define ISNS_CONFIG_DIR		ISCSIVAR"isns"
d3d8564
+#define STATIC_CONFIG_DIR	ISCSIVAR"static"
5ebdd59
+#define FW_CONFIG_DIR		ISCSIVAR"fw"
c2d5d21
+#define ST_CONFIG_DIR		ISCSIVAR"send_targets"
d3d8564
 #define ST_CONFIG_NAME		"st_config"
1c8eda8
 #define ISNS_CONFIG_NAME	"isns_config"
mchristi a7062b5
 
0e55d5b
diff --git a/usr/iface.h b/usr/iface.h
bda814b
index 6c06f7f..c8b9de9 100644
0e55d5b
--- a/usr/iface.h
0e55d5b
+++ b/usr/iface.h
e8d2112
@@ -21,8 +21,9 @@
a4c8b30
 #define ISCSI_IFACE_H
a4c8b30
 
e8d2112
 #include <libopeniscsiusr/libopeniscsiusr.h>
5ebdd59
+#include "idbm.h"
e8d2112
 
e8d2112
-#define IFACE_CONFIG_DIR	ISCSI_CONFIG_ROOT"ifaces"
5ebdd59
+#define IFACE_CONFIG_DIR	ISCSIVAR"ifaces"
a4c8b30
 
a4c8b30
 struct iface_rec;
a4c8b30
 struct list_head;
0e55d5b
-- 
261a1a1
2.26.3
0e55d5b