c2d5d2
From be8702e609fdfd417547f758cb88956066b63023 Mon Sep 17 00:00:00 2001
0e55d5
From: Chris Leech <cleech@redhat.com>
0e55d5
Date: Mon, 19 Nov 2012 16:38:45 -0800
0e55d5
Subject: use var for config
0e55d5
0e55d5
---
0e55d5
 README         | 33 ++++++++++++++++-----------------
0e55d5
 doc/iscsiadm.8 |  8 ++++----
0e55d5
 usr/idbm.c     |  6 +++---
c2d5d2
 usr/idbm.h     | 13 +++++++------
0e55d5
 usr/iface.h    |  4 +++-
c2d5d2
 5 files changed, 33 insertions(+), 31 deletions(-)
0e55d5
0e55d5
diff --git a/README b/README
c2d5d2
index 90e2074..9cc62ca 100644
0e55d5
--- a/README
0e55d5
+++ b/README
0e55d5
@@ -156,8 +156,7 @@ Usage: iscsid [OPTION]
0e55d5
 
0e55d5
 Open-iSCSI persistent configuration is stored in a number of
0e55d5
 directories under a configuration root directory, using a flat-file
0e55d5
-format. This configuration root directory is /etc/iscsi by default,
0e55d5
-but may also commonly be in /var/lib/iscsi.
0e55d5
+format. This configuration root directory is /var/lib/iscsi by default.
0e55d5
 
0e55d5
 Configuration is contained in directories for:
0e55d5
 
c2d5d2
@@ -467,7 +466,7 @@ a scsi_host per HBA port).
5a3872
 To manage both types of initiator stacks, iscsiadm uses the interface (iface)
5a3872
 structure. For each HBA port or for software iscsi for each network
5a3872
 device (ethX) or NIC, that you wish to bind sessions to you must create
5a3872
-a iface config /etc/iscsi/ifaces.
5a3872
+a iface config /var/lib/iscsi/ifaces.
5a3872
 
Mike Christie 3949e1
 Prep:
5ebdd5
 
c2d5d2
@@ -501,29 +500,29 @@ Running:
5ebdd5
 iface0 qla4xxx,00:c0:dd:08:63:e8,20.15.0.7,default,iqn.2005-06.com.redhat:madmax
5ebdd5
 iface1 qla4xxx,00:c0:dd:08:63:ea,20.15.0.9,default,iqn.2005-06.com.redhat:madmax
5a3872
 
5a3872
-Will report iface configurations that are setup in /etc/iscsi/ifaces.
5a3872
+Will report iface configurations that are setup in /var/lib/iscsi/ifaces.
5a3872
 The format is:
5a3872
 
5ebdd5
 iface_name transport_name,hwaddress,ipaddress,net_ifacename,initiatorname
5a3872
 
5a3872
 For software iscsi, you can create the iface configs by hand, but it is
5a3872
 reccomended that you use iscsiadm's iface mode. There is a iface.example in
5a3872
-/etc/iscsi/ifaces which can be used as a template for the daring.
5a3872
+/var/lib/iscsi/ifaces which can be used as a template for the daring.
5a3872
 
5a3872
 For each network object you wish to bind a session to you must create
5a3872
-a seperate iface config in /etc/iscsi/ifaces and each iface config file
5a3872
+a seperate iface config in /var/lib/iscsi/ifaces and each iface config file
5a3872
 must have a unique name which is less than or equal to 64 characters.
5a3872
 
5a3872
 Example:
5a3872
 
5a3872
 If you have NIC1 with MAC address 00:0F:1F:92:6B:BF and NIC2 with
5a3872
 MAC address 00:C0:DD:08:63:E7 and you wanted to do software iscsi over
5a3872
-TCP/IP. Then in /etc/iscsi/ifaces/iface0 you would enter:
5a3872
+TCP/IP. Then in /var/lib/iscsi/ifaces/iface0 you would enter:
5a3872
 
5a3872
 iface.transport_name = tcp
5a3872
 iface.hwaddress = 00:0F:1F:92:6B:BF
5a3872
 
5a3872
-and in /etc/iscsi/ifaces/iface1 you would enter:
5a3872
+and in /var/lib/iscsi/ifaces/iface1 you would enter:
5a3872
 
5a3872
 iface.transport_name = tcp
5a3872
 iface.hwaddress = 00:C0:DD:08:63:E7
c2d5d2
@@ -573,7 +572,7 @@ cxgb3i.00:07:43:05:97:07 cxgb3i,00:07:43:05:97:07,<empty>,<empty>,<empty>
Mike Christie 3949e1
 qla4xxx.00:0e:1e:04:8b:2e qla4xxx,00:0e:1e:04:8b:2e,<empty>,<empty>,<empty>
5ebdd5
 
5ebdd5
 
5ebdd5
-Will report iface configurations that are setup in /etc/iscsi/ifaces.
5ebdd5
+Will report iface configurations that are setup in /var/lib/iscsi/ifaces.
5ebdd5
 The format is:
5a3872
 
5ebdd5
 iface_name transport_name,hwaddress,ipaddress,net_ifacename,initiatorname
c2d5d2
@@ -659,7 +658,7 @@ need a seperate network connection to the target for discovery purposes.
5ebdd5
 *This will be fixed in the next version of open-iscsi*
5ebdd5
 
5ebdd5
 For compatibility reasons, when you run iscsiadm to do discovery, it
5ebdd5
-will check for interfaces in /etc/iscsi/iscsi/ifaces that are using
5ebdd5
+will check for interfaces in /var/lib/iscsi/ifaces that are using
5ebdd5
 tcp for the iface.transport and it will bind the portals that are discovered
5ebdd5
 so that they will be logged in through those ifaces. This behavior can also
5ebdd5
 be overriden by passing in the interfaces you want to use. For the case
c2d5d2
@@ -677,7 +676,7 @@ we do not bind a session to a iface, then you can use the special iface
5a3872
 
1c8eda
 iscsiadm -m discoverydb -t st -p ip:port -I default --discover -P 1
5a3872
 
5a3872
-And if you did not define any interfaces in /etc/iscsi/ifaces and do
5a3872
+And if you did not define any interfaces in /var/lib/iscsi/ifaces and do
5a3872
 not pass anything into iscsiadm, running iscsiadm will do the default
5a3872
 behavior, where we allow the network subsystem to decide which
5a3872
 device to use.
c2d5d2
@@ -719,7 +718,7 @@ To now log into targets it is the same as with sofware iscsi. See section
1c8eda
 
1c8eda
 	    ./iscsiadm -m discoverydb -t st -p 192.168.1.1:3260 --discover
1c8eda
 
1c8eda
-	This will search /etc/iscsi/send_targets for a record with the
1c8eda
+	This will search /var/lib/iscsi/send_targets for a record with the
1c8eda
 	ID [portal = 192.168.1.1:3260 and type = sendtargets. If found it
1c8eda
 	will perform discovery using the settings stored in the record.
1c8eda
 	If a record does not exist, it will be created using the iscsid.conf
c2d5d2
@@ -728,7 +727,7 @@ To now log into targets it is the same as with sofware iscsi. See section
Mike Christie 3949e1
 	The argument to -p may also be a hostname instead of an address.
Mike Christie 3949e1
 	    ./iscsiadm -m discoverydb -t st -p smoehost --discover
1c8eda
 
1c8eda
-	For the ifaces, iscsiadm will first search /etc/iscsi/ifaces for
1c8eda
+	For the ifaces, iscsiadm will first search /var/lib/iscsi/ifaces for
1c8eda
 	interfaces using software iscsi. If any are found then nodes found
1c8eda
 	during discovery will be setup so that they can logged in through
1c8eda
 	those interfaces. To specify a specific iface, pass the
c2d5d2
@@ -784,7 +783,7 @@ To now log into targets it is the same as with sofware iscsi. See section
5ebdd5
 	This command will perform discovery, but not manipulate the node DB.
5a3872
 
a4c8b3
   - SendTargets iSCSI Discovery with a specific interface. If you
5a3872
-	wish to only use a subset of the interfaces in /etc/iscsi/ifaces
5a3872
+	wish to only use a subset of the interfaces in /var/lib/iscsi/ifaces
5a3872
 	then you can pass them in during discovery:
5a3872
 
1c8eda
 	     ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \
c2d5d2
@@ -1145,8 +1144,8 @@ where targetname is the name of the target and ip_address:port is the address
a4c8b3
 and port of the portal. tpgt, is the portal group tag of
a4c8b3
 the portal, and is not used in iscsiadm commands except for static
a4c8b3
 record creation. And iface name is the name of the iscsi interface
a4c8b3
-defined in /etc/iscsi/ifaces. If no interface was defined in
a4c8b3
-/etc/iscsi/ifaces or passed in, the default behavior is used.
a4c8b3
+defined in /var/lib/iscsi/ifaces. If no interface was defined in
a4c8b3
+/var/lib/iscsi/ifaces or passed in, the default behavior is used.
a4c8b3
 Default here is iscsi_tcp/tcp to be used over which ever NIC the
a4c8b3
 network layer decides is best.
a4c8b3
 
c2d5d2
@@ -1261,7 +1260,7 @@ If set, iscsid will perform discovery to the address every
1c8eda
 discovery.isns.discoveryd_poll_inval or
1c8eda
 discovery.sendtargets.discoveryd_poll_inval seconds,
1c8eda
 and it will log into any portals found from the discovery source using
1c8eda
-the ifaces in /etc/iscsi/ifaces.
1c8eda
+the ifaces in /var/lib/iscsi/ifaces.
1c8eda
 
1c8eda
 Note that for iSNS the poll_interval does not have to be set. If not set,
1c8eda
 iscsid will only perform rediscovery when it gets a SCN from the server.
0e55d5
diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8
c2d5d2
index 6b15fcd..30811bd 100644
0e55d5
--- a/doc/iscsiadm.8
0e55d5
+++ b/doc/iscsiadm.8
c2d5d2
@@ -101,7 +101,7 @@ This option is only valid for ping submode.
0e55d5
 .TP
0e55d5
 \fB\-I\fR, \fB\-\-interface=\fI[iface]\fR
0e55d5
 The interface argument specifies the iSCSI interface to use for the operation.
0e55d5
-iSCSI interfaces (iface) are defined in /etc/iscsi/ifaces. For hardware
0e55d5
+iSCSI interfaces (iface) are defined in /var/lib/iscsi/ifaces. For hardware
0e55d5
 iSCSI (qla4xxx) the iface config must have the hardware address
0e55d5
 (iface.hwaddress = port's MAC address)
0e55d5
 and the driver/transport_name (iface.transport_name). The iface's name is
c2d5d2
@@ -178,7 +178,7 @@ If no other options are specified: for \fIdiscoverydb\fR and \fInode\fR, all
0e55d5
 of their respective records are displayed; for \fIsession\fR, all active
0e55d5
 sessions and connections are displayed; for \fIfw\fR, all boot firmware
0e55d5
 values are displayed; for \fIhost\fR, all iSCSI hosts are displayed; and
0e55d5
-for \fIiface\fR, all ifaces setup in /etc/iscsi/ifaces are displayed.
0e55d5
+for \fIiface\fR, all ifaces setup in /var/lib/iscsi/ifaces are displayed.
0e55d5
 
0e55d5
 .TP
0e55d5
 \fB\-n\fR, \fB\-\-name=\fIname\fR
c2d5d2
@@ -562,10 +562,10 @@ The configuration file read by \fBiscsid\fR and \fBiscsiadm\fR on startup.
0e55d5
 The file containing the iSCSI InitiatorName and InitiatorAlias read by
0e55d5
 \fBiscsid\fR and \fBiscsiadm\fR on startup.
0e55d5
 .TP
0e55d5
-/etc/iscsi/nodes/
0e55d5
+/var/lib/iscsi/nodes/
0e55d5
 This directory contains the nodes with their targets.
0e55d5
 .TP
0e55d5
-/etc/iscsi/send_targets
0e55d5
+/var/lib/iscsi/send_targets
0e55d5
 This directory contains the portals.
0e55d5
 
0e55d5
 .SH "SEE ALSO"
0e55d5
diff --git a/usr/idbm.c b/usr/idbm.c
c2d5d2
index 634e547..4bb9810 100644
0e55d5
--- a/usr/idbm.c
0e55d5
+++ b/usr/idbm.c
c2d5d2
@@ -2721,9 +2721,9 @@ free_info:
a4c8b3
 int idbm_init(idbm_get_config_file_fn *fn)
a4c8b3
 {
d3d856
 	/* make sure root db dir is there */
d3d856
-	if (access(ISCSI_CONFIG_ROOT, F_OK) != 0) {
d3d856
-		if (mkdir(ISCSI_CONFIG_ROOT, 0660) != 0) {
d3d856
-			log_error("Could not make %s %d\n", ISCSI_CONFIG_ROOT,
d3d856
+	if (access(ISCSIVAR, F_OK) != 0) {
d3d856
+		if (mkdir(ISCSIVAR, 0660) != 0) {
d3d856
+			log_error("Could not make %s %d\n", ISCSIVAR,
d3d856
 				   errno);
a4c8b3
 			return errno;
mchristi a7062b
 		}
0e55d5
diff --git a/usr/idbm.h b/usr/idbm.h
c2d5d2
index 5e4038d..1e9b132 100644
0e55d5
--- a/usr/idbm.h
0e55d5
+++ b/usr/idbm.h
c2d5d2
@@ -29,12 +29,13 @@
0e55d5
 #include "list.h"
c2d5d2
 #include "flashnode.h"
mchristi a7062b
 
d3d856
-#define NODE_CONFIG_DIR		ISCSI_CONFIG_ROOT"nodes"
d3d856
-#define SLP_CONFIG_DIR		ISCSI_CONFIG_ROOT"slp"
d3d856
-#define ISNS_CONFIG_DIR		ISCSI_CONFIG_ROOT"isns"
d3d856
-#define STATIC_CONFIG_DIR	ISCSI_CONFIG_ROOT"static"
5ebdd5
-#define FW_CONFIG_DIR		ISCSI_CONFIG_ROOT"fw"
d3d856
-#define ST_CONFIG_DIR		ISCSI_CONFIG_ROOT"send_targets"
241a29
+#define ISCSIVAR		"/var/lib/iscsi/"
d3d856
+#define NODE_CONFIG_DIR		ISCSIVAR"nodes"
d3d856
+#define SLP_CONFIG_DIR		ISCSIVAR"slp"
d3d856
+#define ISNS_CONFIG_DIR		ISCSIVAR"isns"
d3d856
+#define STATIC_CONFIG_DIR	ISCSIVAR"static"
5ebdd5
+#define FW_CONFIG_DIR		ISCSIVAR"fw"
c2d5d2
+#define ST_CONFIG_DIR		ISCSIVAR"send_targets"
d3d856
 #define ST_CONFIG_NAME		"st_config"
1c8eda
 #define ISNS_CONFIG_NAME	"isns_config"
mchristi a7062b
 
0e55d5
diff --git a/usr/iface.h b/usr/iface.h
0e55d5
index 01f7074..f396918 100644
0e55d5
--- a/usr/iface.h
0e55d5
+++ b/usr/iface.h
5ebdd5
@@ -20,7 +20,9 @@
a4c8b3
 #ifndef ISCSI_IFACE_H
a4c8b3
 #define ISCSI_IFACE_H
a4c8b3
 
a4c8b3
-#define IFACE_CONFIG_DIR	ISCSI_CONFIG_ROOT"ifaces"
5ebdd5
+#include "idbm.h"
5ebdd5
+
5ebdd5
+#define IFACE_CONFIG_DIR	ISCSIVAR"ifaces"
a4c8b3
 
a4c8b3
 struct iface_rec;
a4c8b3
 struct list_head;
0e55d5
-- 
c2d5d2
1.8.1.4
0e55d5