From a8f93f0cdb340a61c7a2854dc74028364658dc0e Mon Sep 17 00:00:00 2001
From: mchristi <mchristi@redhat.com>
Date: Fri, 13 Oct 2006 18:18:19 +0000
Subject: [PATCH] fix docs bugzilla and similar target name bug

---
 ...initiator-utils-check-targetname-len.patch | 13 +++
 iscsi-initiator-utils-read-disc-db.patch      | 39 ++++++++
 iscsi-initiator-utils-update-doc.patch        | 99 +++++++++++++++++++
 iscsi-initiator-utils.spec                    | 13 ++-
 4 files changed, 163 insertions(+), 1 deletion(-)
 create mode 100644 iscsi-initiator-utils-check-targetname-len.patch
 create mode 100644 iscsi-initiator-utils-read-disc-db.patch
 create mode 100644 iscsi-initiator-utils-update-doc.patch

diff --git a/iscsi-initiator-utils-check-targetname-len.patch b/iscsi-initiator-utils-check-targetname-len.patch
new file mode 100644
index 0000000..3912b10
--- /dev/null
+++ b/iscsi-initiator-utils-check-targetname-len.patch
@@ -0,0 +1,13 @@
+--- open-iscsi-6.2.0.695/usr/initiator.c	2006-10-13 13:06:54.000000000 -0500
++++ open-iscsi-6.2.0.695.work/usr/initiator.c	2006-10-13 13:12:12.000000000 -0500
+@@ -1533,6 +1533,10 @@ static int match_session(void *data, cha
+ 	if (!p)
+ 		return 0;
+ 
++	if (strlen(rec->name) != strlen(targetname) ||
++	    strlen(rec->conn[0].address) != strlen(address))
++		return 0;
++
+ 	if (!strcmp(rec->transport_name, p->name) &&
+ 	    !strncmp(rec->name, targetname, strlen(rec->name)) &&
+ 	    !strncmp(rec->conn[0].address, address,
diff --git a/iscsi-initiator-utils-read-disc-db.patch b/iscsi-initiator-utils-read-disc-db.patch
new file mode 100644
index 0000000..e33835e
--- /dev/null
+++ b/iscsi-initiator-utils-read-disc-db.patch
@@ -0,0 +1,39 @@
+diff -aurp open-iscsi-6.2.0.695/usr/idbm.c open-iscsi-6.2.0.695.work/usr/idbm.c
+--- open-iscsi-6.2.0.695/usr/idbm.c	2006-10-13 13:06:54.000000000 -0500
++++ open-iscsi-6.2.0.695.work/usr/idbm.c	2006-10-13 13:07:14.000000000 -0500
+@@ -978,15 +978,14 @@ idbm_new_discovery(idbm_t *db, char *ip,
+ 	discovery_rec_t *drec;
+ 	node_rec_t *nrec;
+ 
+-	/* sync default configuration */
+-	idbm_sync_config(db, 1);
+-
+ 	/* allocate new discovery record and initialize with defaults */
+ 	drec = malloc(sizeof(discovery_rec_t));
+ 	if (!drec) {
+ 		log_error("out of memory on discovery record allocation");
+ 		return NULL;
+ 	}
++	drec->type = type;
++
+ 	if (drec->type == DISCOVERY_TYPE_SENDTARGETS) {
+ 		memcpy(drec, &db->drec_st, sizeof(discovery_rec_t));
+ 	} else if (drec->type == DISCOVERY_TYPE_SLP) {
+@@ -1005,7 +1004,6 @@ idbm_new_discovery(idbm_t *db, char *ip,
+ 	memcpy(nrec, &db->nrec, sizeof(node_rec_t));
+ 
+ 	/* update discovery record */
+-	drec->type = type;
+ 	if (drec->type == DISCOVERY_TYPE_SENDTARGETS) {
+ 		strncpy(drec->u.sendtargets.address, ip, NI_MAXHOST);
+ 		drec->u.sendtargets.port = port;
+@@ -1155,6 +1153,9 @@ idbm_delete_node(idbm_t *db, node_rec_t 
+ void
+ idbm_sendtargets_defaults(idbm_t *db, struct iscsi_sendtargets_config *cfg)
+ {
++	/* sync default configuration */
++	idbm_sync_config(db, 1);
++
+ 	memcpy(cfg, &db->drec_st.u.sendtargets,
+ 	       sizeof(struct iscsi_sendtargets_config));
+ }
diff --git a/iscsi-initiator-utils-update-doc.patch b/iscsi-initiator-utils-update-doc.patch
new file mode 100644
index 0000000..a37621f
--- /dev/null
+++ b/iscsi-initiator-utils-update-doc.patch
@@ -0,0 +1,99 @@
+diff -aurp open-iscsi-6.2.0.695/doc/iscsid.8 open-iscsi-6.2.0.695.man/doc/iscsid.8
+--- open-iscsi-6.2.0.695/doc/iscsid.8	2006-04-27 13:36:24.000000000 -0500
++++ open-iscsi-6.2.0.695.man/doc/iscsid.8	2006-10-13 12:56:25.000000000 -0500
+@@ -15,11 +15,11 @@ iSCSI database.
+ .TP
+ .BI [-c|--config=]\fIconfig\-file\fP
+ Read configuration from \fIconfig\-file\fR rather than the default
+-\fI/etc/iscsid.conf\fR file.
++\fI/etc/iscsi/iscsid.conf\fR file.
+ .TP
+ .BI [-i|--initiatorname=]\fIiname\-file\fP
+ Read initiator name from \fIiname\-file\fR rather than the default
+-\fI/etc/initiatorname.iscsi\fR file.
++\fI/etc/iscsi/initiatorname.iscsi\fR file.
+ .TP
+ .BI [-f|--foreground]
+ run
+@@ -47,14 +47,14 @@ display version and exit.
+ 
+ .SH FILES
+ .TP
+-/etc/iscsid.conf
++/etc/iscsi/iscsid.conf
+ The configuration file read by
+ .B iscsid
+ and
+ .B iscsiadm
+ on startup.
+ .TP
+-/etc/initiatorname.iscsi
++/etc/iscsi/initiatorname.iscsi
+ The file containing the iSCSI initiatorname
+ and initiatoralias read by
+ .B iscsid
+@@ -62,7 +62,7 @@ and
+ .B iscsiadm
+ on startup.
+ .TP
+-/var/db/iscsi/*.db
++/var/lib/iscsi/nodes
+ Open-iSCSI persistent configuration database
+ 
+ .SH "SEE ALSO"
+diff -aurp open-iscsi-6.2.0.695/README open-iscsi-6.2.0.695.man/README
+--- open-iscsi-6.2.0.695/README	2006-08-23 15:36:44.000000000 -0500
++++ open-iscsi-6.2.0.695.man/README	2006-10-13 12:58:04.000000000 -0500
+@@ -123,7 +123,7 @@ For help, run:
+ 
+ Usage: iscsid [OPTION]
+ 
+-  -c, --config=[path]     Execute in the config file (/etc/iscsid.conf).
++  -c, --config=[path]     Execute in the config file (/etc/iscsi/iscsid.conf).
+   -f, --foreground        run iscsid in the foreground
+   -d, --debug debuglevel  print debugging information
+   -u, --uid=uid           run as uid, default is current user
+@@ -141,10 +141,10 @@ available on all Linux installations.
+ 
+ The database contains two tables:
+ 
+-- Discovery table (discovery.db);
+-- Node table (node.db).
++- Discovery (/var/lib/iscsi/send_targets)
++- Node table (/var/lib/iscsi/nodes)
+ 
+-The regular place for iSCSI database files: /var/db/iscsi/*.db
++The regular place for iSCSI database files: /var/lib/iscsi
+ 
+ The iscsiadm utility is a command-line tool to manage (update, delete,
+ insert, query) the persistent database.
+@@ -250,7 +250,7 @@ Usage: iscsiadm [OPTION]
+ 6. Configuration
+ ================
+ 
+-The default configuration file is /etc/iscsid.conf. This file contains
++The default configuration file is /etc/iscsi/iscsid.conf. This file contains
+ only configuration that could be overwritten by iSCSI Discovery,
+ or manualy updated via iscsiadm utility. Its OK if this file does not
+ exist in which case compiled-in default configuration will take place
+@@ -333,9 +333,9 @@ and port of the portal of a discovered o
+ Once iscsi is up, you can perform discovery to targets using:
+ iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260
+ 
+-While discovery targets are kept in the discovery.db, they are
++While discovery targets are kept in the discovery db, they are
+ usefull only for re-discovery. The discovered targets (a.k.a. nodes)
+-are stored as records in the xxx.db.
++are stored as records in the /var/lib/iscsi/nodes
+ 
+ The discovered targets are not logged into yet. Rather than logging
+ into the discovered nodes (making LUs from those nodes available as
+@@ -350,7 +350,7 @@ node discovered in the discovery above:
+ 	iscsiadm -m node -T targetname -p ip:port --op update -n node.conn[0].startup -v automatic
+ 
+ Or to set the "node.conn[0].statup" attribute to "startup" as default for
+-all sessions add the following to the /etc/iscsid.conf:
++all sessions add the following to the /etc/iscsi/iscsid.conf:
+ 
+ 	node.conn[0].startup = automatic
+ 
diff --git a/iscsi-initiator-utils.spec b/iscsi-initiator-utils.spec
index fdb22b0..14df304 100644
--- a/iscsi-initiator-utils.spec
+++ b/iscsi-initiator-utils.spec
@@ -1,7 +1,7 @@
 Summary: iSCSI daemon and utility programs
 Name: iscsi-initiator-utils
 Version: 6.2.0.695
-Release: 0.6
+Release: 0.7
 Source0: http://people.redhat.com/mchristi/iscsi/FC6/open-iscsi/rpm/open-iscsi-6.2.0.695.tar.bz2
 Source1: iscsi.init
 Patch0: open-iscsi-5.0.5.595-update-initscripts-and-docs.patch
@@ -10,6 +10,9 @@ Patch2: iscsi-initiator-utils-fix-session-mixup-on-restart.patch
 Patch3: iscsi-initiator-utils-use-var-for-pid.patch
 Patch4: iscsi-initiator-utils-use-var-for-lock.patch
 Patch5: iscsi-initiator-utils-use-var-for-config.patch
+Patch6: iscsi-initiator-utils-update-doc.patch
+Patch7: iscsi-initiator-utils-read-disc-db.patch
+Patch8: iscsi-initiator-utils-check-targetname-len.patch
 
 Group: System Environment/Daemons
 License: GPL
@@ -33,6 +36,9 @@ Protocol networks.
 %patch3 -p1 -b .use-var-for-pid
 %patch4 -p1 -b .use-var-for-lock
 %patch5 -p1 -b .use-var-for-config
+%patch6 -p1 -b .update-doc.patch
+%patch7 -p1 -b .read-disc-db.patch
+%patch8 -p1 -b .check-targetname-len.patch
 
 %build
 make OPTFLAGS="%{optflags}" -C usr
@@ -85,6 +91,11 @@ fi
 %{_mandir}/*/*
 
 %changelog
+* Fri Oct 13 2006 Mike Christie <mchristie@redhat.com> - 6.2.0.695-0.7
+- BZ 210470 update man pages for file moves
+- Fix targetname strcmp
+- read default config before doing discovery
+
 * Thu Oct 5 2006 Mike Christie <mchristie@redhat.com> - 6.2.0.695-0.6
 - BZ 209523 make sure the network is not going to get shutdown so
 iscsi devices (include iscsi root and dm/md over iscsi) get syncd.